Commit 88a20d89 authored by hanfeng's avatar hanfeng

Merge branch 'master-customer-management'

# Conflicts:
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserDetailBiz.java
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
parents 316ed6fb f6425a20
...@@ -29,7 +29,10 @@ public class AppUserLogRemarkDTO { ...@@ -29,7 +29,10 @@ public class AppUserLogRemarkDTO {
*/ */
private Integer levelId; private Integer levelId;
/**
* 照片url多张已","分割
*/
private String photos;
} }
package com.github.wxiaoqi.security.admin.entity; package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import tk.mybatis.mapper.annotation.KeySql; import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect; import tk.mybatis.mapper.code.IdentityDialect;
...@@ -22,9 +24,15 @@ public class AppStaffUser { ...@@ -22,9 +24,15 @@ public class AppStaffUser {
@Column(name = "su_id") @Column(name = "su_id")
@ApiModelProperty("员工app账号id") @ApiModelProperty("员工app账号id")
private Integer suId; private Integer suId;
@Column(name = "su_phone")
@ApiModelProperty("员工手机号")
private String suPhone;
@Column(name = "u_name") @Column(name = "u_name")
@ApiModelProperty("客户姓名") @ApiModelProperty("客户姓名")
private String uName; private String uName;
@Column(name = "u_id")
@ApiModelProperty("客户id")
private Integer uid;
@ApiModelProperty("客户手机") @ApiModelProperty("客户手机")
private String phone; private String phone;
@ApiModelProperty("客户公司") @ApiModelProperty("客户公司")
...@@ -40,4 +48,5 @@ public class AppStaffUser { ...@@ -40,4 +48,5 @@ public class AppStaffUser {
@Column(name = "is_del") @Column(name = "is_del")
@ApiModelProperty("状态:0-未删除 1-已删除") @ApiModelProperty("状态:0-未删除 1-已删除")
private Integer isDel; private Integer isDel;
private Integer status;
} }
package com.github.wxiaoqi.security.admin.entity;
import lombok.Data;
/**
* @Auther: Administrator
* @Date: 2019/12/17 15:35
* @Description:
*/
@Data
public class AppStaffUserDTO {
/**
* 员工id
*/
private Integer suId;
/**
* 员工手机号
*/
private String suPhone;
/**
* 客户id
*/
private Integer uid;
/**
* 下级客户姓名
*/
private String uName;
/**
* 下级客户手机号
*/
private String phone;
/**
* 下级身份
*/
private Integer positionId;
}
...@@ -11,6 +11,7 @@ import javax.persistence.GeneratedValue; ...@@ -11,6 +11,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* APP员工客户日志备注表 * APP员工客户日志备注表
...@@ -38,4 +39,12 @@ public class AppUserLogRemark { ...@@ -38,4 +39,12 @@ public class AppUserLogRemark {
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date time; private Date time;
/**
* 照片url地址","分割
*/
private String photos;
/**
* 照片url地址
*/
private List<String> photoList;
} }
package com.github.wxiaoqi.security.admin.entity;
import lombok.Data;
/**
* 修改后的用户信息
* @author Administrator
* @Auther: Administrator
* @Date: 2019/12/17 18:24
* @Description:
*/
@Data
public class ModifiedUsers {
private Integer userid;
private String phone;
private String name;
private Integer positionId;
}
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.druid.sql.visitor.functions.If;
import com.github.wxiaoqi.security.admin.entity.AppStaffUser; import com.github.wxiaoqi.security.admin.entity.AppStaffUser;
import com.github.wxiaoqi.security.admin.entity.AppStaffUserDTO;
import com.github.wxiaoqi.security.admin.entity.AppStaffUserVo; import com.github.wxiaoqi.security.admin.entity.AppStaffUserVo;
import com.github.wxiaoqi.security.admin.entity.ModifiedUsers;
import com.github.wxiaoqi.security.admin.mapper.AppStaffUserMapper; import com.github.wxiaoqi.security.admin.mapper.AppStaffUserMapper;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.im.utils.StringUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -20,17 +24,15 @@ import java.util.List; ...@@ -20,17 +24,15 @@ import java.util.List;
* @author Administrator * @author Administrator
*/ */
@Service @Service
@RequiredArgsConstructor(onConstructor_={@Autowired}) @RequiredArgsConstructor(onConstructor_ = {@Autowired})
@Slf4j
public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> { public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
private final AppUserLoginBiz appUserLoginBiz;
private final AppUserDetailBiz appUserDetailBiz; private final AppUserDetailBiz appUserDetailBiz;
private final Integer POSITION_ID=4;
public List<AppStaffUser> getAll(Integer id) { public List<AppStaffUser> getAll(Integer id, String username) {
Example example = new Example(AppStaffUser.class); return mapper.selectByBysuIdOrUsername(id,username);
example.createCriteria().andEqualTo("suId",id).andEqualTo("isDel",0);
example.orderBy("crtTime").desc();
return selectByExample(example);
} }
@Override @Override
...@@ -40,7 +42,6 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> { ...@@ -40,7 +42,6 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
} }
@Override @Override
public int updateSelectiveByIdRe(AppStaffUser appStaffUser) { public int updateSelectiveByIdRe(AppStaffUser appStaffUser) {
appStaffUser.setUpdTime(new Date()); appStaffUser.setUpdTime(new Date());
...@@ -48,46 +49,98 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> { ...@@ -48,46 +49,98 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
} }
public AppStaffUser findOne(AppStaffUser appStaffUser) { public AppStaffUser findOne(AppStaffUser appStaffUser) {
Example example= new Example(AppStaffUser.class); Example example = new Example(AppStaffUser.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isDel",0); criteria.andEqualTo("isDel", 0);
if (appStaffUser.getId()!=null) { if (appStaffUser.getId() != null) {
criteria.andEqualTo("id",appStaffUser.getId()); criteria.andEqualTo("id", appStaffUser.getId());
return mapper.selectOneByExample(example); }
if (appStaffUser.getPhone() != null) {
criteria.andEqualTo("phone", appStaffUser.getPhone());
} }
if (appStaffUser.getPhone()!=null){
criteria.andEqualTo("phone",appStaffUser.getPhone());
List<AppStaffUser> appStaffUsers = mapper.selectByExample(example); List<AppStaffUser> appStaffUsers = mapper.selectByExample(example);
if (CollectionUtil.isNotEmpty(appStaffUsers)) { if (CollectionUtil.isNotEmpty(appStaffUsers)) {
AppStaffUser staffUser = appStaffUsers.get(0); AppStaffUser staffUser = appStaffUsers.get(0);
AppStaffUserVo appStaffUserVo = new AppStaffUserVo(); AppStaffUserVo appStaffUserVo = new AppStaffUserVo();
BeanUtils.copyProperties(staffUser,appStaffUserVo); BeanUtils.copyProperties(staffUser, appStaffUserVo);
Integer suId = staffUser.getSuId(); Integer suId = staffUser.getSuId();
AppUserVo userInfoById = appUserDetailBiz.getUserInfoById(suId); //上级员工信息
appStaffUserVo.setEmployeeName(userInfoById.getRealname()); if (suId!=null||suId!=0||appStaffUser.getPhone()!=null){
appStaffUserVo.setEmployeePhone(userInfoById.getUsername()); AppUserVo spuser = appUserDetailBiz.getUserInfoById(suId);
return appStaffUserVo; appStaffUserVo.setEmployeeName(spuser.getRealname());
appStaffUserVo.setEmployeePhone(spuser.getUsername());
} }
//客户信息
Integer uid = staffUser.getUid();
if (uid!=null||uid!=0){
AppUserVo user = appUserDetailBiz.getUserInfoById(uid);
appStaffUserVo.setUName(StringUtil.isEmpty(user.getRealname())?user.getNickname():user.getRealname());
appStaffUserVo.setPhone(user.getUsername());
} }
return appStaffUserVo;
}
return null; return null;
} }
public boolean select(AppStaffUser appStaffUser) { public boolean select(AppStaffUser appStaffUser) {
Example example=new Example(AppStaffUser.class); Example example = new Example(AppStaffUser.class);
example.createCriteria().andEqualTo("uName",appStaffUser.getUName()) Example.Criteria criteria = example.createCriteria();
.andEqualTo("phone",appStaffUser.getPhone()) criteria.andEqualTo("phone", appStaffUser.getPhone())
.andEqualTo("isDel",0); .andEqualTo("isDel", 0);
List<AppStaffUser> appStaffUsers = mapper.selectByExample(example); List<AppStaffUser> appStaffUsers = mapper.selectByExample(example);
return CollectionUtil.isEmpty(appStaffUsers)?true:false; return CollectionUtil.isEmpty(appStaffUsers) ? true : false;
} }
public void update(AppStaffUser staffUser, Integer userid) { public void update(AppStaffUser staffUser, Integer userid) {
Example example = new Example(AppStaffUser.class); Example example = new Example(AppStaffUser.class);
example.createCriteria().andEqualTo("id",staffUser.getId()).andEqualTo("suId",userid); example.createCriteria().andEqualTo("id", staffUser.getId()).andEqualTo("suId", userid);
mapper.updateByExampleSelective(staffUser,example); mapper.updateByExampleSelective(staffUser, example);
} }
public void updateByPhone(AppStaffUser staffUser) {
Example example = new Example(AppStaffUser.class);
example.createCriteria().andEqualTo("phone",staffUser.getPhone());
mapper.updateByExampleSelective(staffUser, example);
}
/**
* 添加用户关系
* @param staffUserDTO
*/
public void addAppStaffUser(AppStaffUserDTO staffUserDTO){
log.info("staffUserDTO={}",staffUserDTO);
AppUserVo superAppUserVo= appUserDetailBiz.getUserInfoById(staffUserDTO.getSuId());
AppUserVo userInfoById = appUserDetailBiz.getUser(staffUserDTO.getUid());
log.info("userInfoById={}",userInfoById);
AppStaffUser appStaffUser = new AppStaffUser();
appStaffUser.setSuId(superAppUserVo.getUserid());
appStaffUser.setSuPhone(superAppUserVo.getUsername());
appStaffUser.setUid(staffUserDTO.getUid());
appStaffUser.setUName(StringUtil.isEmpty(userInfoById.getRealname()) ? userInfoById.getNickname() : userInfoById.getRealname());
appStaffUser.setPhone(userInfoById.getUsername());
appStaffUser.setStatus(1);
if (select(appStaffUser)) {
insertSelective(appStaffUser);
}else {
updateByPhone(appStaffUser);
}
}
/**
* 修改客户关系,根据修改后的用户信息
* @param modifiedUsers
*/
public void updateByModifiedUsers(ModifiedUsers modifiedUsers){
if (POSITION_ID.equals(modifiedUsers.getPositionId())) {
mapper.updateByPositionId(modifiedUsers);
}else {
mapper.update(modifiedUsers);
}
}
} }
...@@ -202,4 +202,9 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail ...@@ -202,4 +202,9 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
org.springframework.beans.BeanUtils.copyProperties(appUserDetail,appUserVo); org.springframework.beans.BeanUtils.copyProperties(appUserDetail,appUserVo);
return appUserVo; return appUserVo;
} }
public AppUserVo getUser(Integer userId) {
return mapper.getUser(userId);
}
} }
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.collection.CollectionUtil;
import com.github.wxiaoqi.security.admin.dto.AppUserLogRemarkDTO; import com.github.wxiaoqi.security.admin.dto.AppUserLogRemarkDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogRemark; import com.github.wxiaoqi.security.admin.entity.AppUserLogRemark;
import com.github.wxiaoqi.security.admin.mapper.AppUserLogRemarkMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserLogRemarkMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -14,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -14,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Transactional @Transactional
@Service @Service
...@@ -44,9 +48,17 @@ public class AppUserLogRemarkBiz extends BaseBiz<AppUserLogRemarkMapper, AppUser ...@@ -44,9 +48,17 @@ public class AppUserLogRemarkBiz extends BaseBiz<AppUserLogRemarkMapper, AppUser
Example example = new Example(AppUserLogRemark.class); Example example = new Example(AppUserLogRemark.class);
example.createCriteria().andEqualTo("levelId", levelId); example.createCriteria().andEqualTo("levelId", levelId);
example.orderBy("time").desc(); example.orderBy("time").desc().orderBy("crtTime").desc();
List<AppUserLogRemark> list = selectByExample(example); List<AppUserLogRemark> list = selectByExample(example);
if (CollectionUtil.isNotEmpty(list)) {
list.parallelStream().peek(e -> {
if (!Objects.isNull(e)) {
e.setPhotoList(Lists.newArrayList(e.getPhotos().split(",")));
}
}).count();
}
return list; return list;
} }
......
...@@ -57,6 +57,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -57,6 +57,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
@Autowired @Autowired
private AppUserPositionTempBiz positionTempBiz; private AppUserPositionTempBiz positionTempBiz;
@Autowired
private AppStaffUserBiz staffUserBiz;
/** /**
* 关系绑定 * 关系绑定
* 规则A->B (B无有效上线+无有效下线) * 规则A->B (B无有效上线+无有效下线)
...@@ -64,9 +67,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -64,9 +67,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
* @param userId * @param userId
* @param parentId * @param parentId
*/ */
public void bindRelation(Integer userId, Integer parentId, Integer type) { public void bindRelation(Integer userId,Integer parentId,Integer type){
if (userId.equals(parentId)) { try {
log.info("----userId===" + userId + "----parentId====" + parentId + "----自己不能成为自己的上线"); if (userId.equals(parentId)){
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
return; return;
} }
...@@ -75,42 +79,52 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -75,42 +79,52 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在"); log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在");
return; return;
}*/ }*/
AppUserVo appUserVo = userDetailBiz.getUserInfoById(parentId); AppUserVo appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo == null) { if (appUserVo==null){
log.info("----userId===" + userId + "----parentId====" + parentId + "----该上线用户不存在"); log.info("----userId==="+userId+"----parentId===="+parentId+"----该上线用户不存在");
return; return;
} }
AppUserRelation relation = getMyBiz().getRelationByUserId(parentId); AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time = System.currentTimeMillis(); Long time=System.currentTimeMillis();
if (relation == null) { if(relation==null){
relation = new AppUserRelation(); relation=new AppUserRelation();
relation.setUserId(parentId); relation.setUserId(parentId);
relation.setBindType(type); relation.setBindType(type);
insertSelective(relation); insertSelective(relation);
} }
Long bindTime = time - validTime; Long bindTime=time-validTime;
//判断用户是否有有效的下线 //判断用户是否有有效的下线
if (getCountByParentId(userId, bindTime) == 0L) { if (getCountByParentId(userId,bindTime)==0L){
relation = getMyBiz().getRelationByUserId(userId); relation=getMyBiz().getRelationByUserId(userId);
if (relation == null) { if(relation==null){
relation = new AppUserRelation(); relation=new AppUserRelation();
relation.setUserId(userId); relation.setUserId(userId);
relation.setParentId(parentId); relation.setParentId(parentId);
relation.setBindType(type); relation.setBindType(type);
relation.setBindTime(time); relation.setBindTime(time);
insertSelective(relation); insertSelective(relation);
} else { }else {
//判断用户是否有有效的上线 //判断用户是否有有效的上线
log.info("----userId===" + userId + "----bindTime====" + bindTime + "----relation.getBindTime()===" + relation.getBindTime()); log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime());
if (relation.getParentId() == null || relation.getParentId() == 0 || (relation.getIsForever() != 1 && validTime > 0 && relation.getBindTime() < bindTime)) { if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&validTime>0&&relation.getBindTime()<bindTime)){
relation.setParentId(parentId); relation.setParentId(parentId);
relation.setBindType(type); relation.setBindType(type);
relation.setBindTime(time); relation.setBindTime(time);
getMyBiz().updRelation(relation); getMyBiz().updRelation(relation);
} }
} }
if (relation != null){
AppStaffUserDTO staffUserDTO=new AppStaffUserDTO();
staffUserDTO.setSuId(relation.getParentId());
staffUserDTO.setUid(relation.getUserId());
staffUserBiz.addAppStaffUser(staffUserDTO);
} }
} }
}catch (Exception e){
log.info("网络异常===" + e.getMessage());
}
}
//首页关系绑定 //首页关系绑定
public ObjectRestResponse appBindRelation(Integer userId, String code) { public ObjectRestResponse appBindRelation(Integer userId, String code) {
...@@ -215,8 +229,8 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -215,8 +229,8 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
relationTemp.setIsValid(0); relationTemp.setIsValid(0);
relationTemp.setType(1); relationTemp.setType(1);
relationTemp.setIsDel(0); relationTemp.setIsDel(0);
relationTemp = relationTempBiz.selectOne(relationTemp); relationTemp=relationTempBiz.selectOne(relationTemp);
if (relationTemp == null) { if(relationTemp==null){
return; return;
} }
Integer parentId = relationTemp.getUserId(); Integer parentId = relationTemp.getUserId();
......
package com.github.wxiaoqi.security.admin.mapper; package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppStaffUser; import com.github.wxiaoqi.security.admin.entity.AppStaffUser;
import com.github.wxiaoqi.security.admin.entity.ModifiedUsers;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import javax.persistence.Id;
import java.util.List;
/** /**
* @author Administrator * @author Administrator
*/ */
public interface AppStaffUserMapper extends Mapper<AppStaffUser> { public interface AppStaffUserMapper extends Mapper<AppStaffUser> {
List<AppStaffUser> selectByBysuIdOrUsername(@Param("id") Integer id,@Param("username") String username);
void updateByPositionId(ModifiedUsers modifiedUsers);
void update(ModifiedUsers modifiedUsers);
} }
...@@ -33,4 +33,6 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> { ...@@ -33,4 +33,6 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> {
List<AppUserVo> getUserByUserIdList(@Param("userIds") List<Integer> userIds); List<AppUserVo> getUserByUserIdList(@Param("userIds") List<Integer> userIds);
List<UserStaffBo> findAllStaffsByCompanyIdAndPostionId(StaffStatisticsFindDTO staffStatisticsFindDTO); List<UserStaffBo> findAllStaffsByCompanyIdAndPostionId(StaffStatisticsFindDTO staffStatisticsFindDTO);
AppUserVo getUser(Integer userId);
} }
\ No newline at end of file
package com.github.wxiaoqi.security.admin.rest; package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.AppStaffUserBiz; import com.github.wxiaoqi.security.admin.biz.AppStaffUserBiz;
import com.github.wxiaoqi.security.admin.biz.AppUserDetailBiz;
import com.github.wxiaoqi.security.admin.biz.AppUserLoginBiz;
import com.github.wxiaoqi.security.admin.entity.AppStaffUser; import com.github.wxiaoqi.security.admin.entity.AppStaffUser;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
...@@ -30,8 +34,10 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS ...@@ -30,8 +34,10 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS
private final UserAuthConfig authConfig; private final UserAuthConfig authConfig;
private final HttpServletRequest request; private final HttpServletRequest request;
private final PublicController publicController; private final PublicController publicController;
private final String POSITION_NAME="员工"; private final Integer POSITION_ID=4;
private final UserAuthUtil userAuthUtil; private final UserAuthUtil userAuthUtil;
private final AppUserLoginBiz appUserLoginBiz;
private final AppUserDetailBiz appUserDetailBiz;
/** /**
* 获取该用户所用的客户 * 获取该用户所用的客户
...@@ -41,8 +47,8 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS ...@@ -41,8 +47,8 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS
@GetMapping("/getAll") @GetMapping("/getAll")
public ObjectRestResponse<List<AppStaffUser>> getAll() throws Exception { public ObjectRestResponse<List<AppStaffUser>> getAll() throws Exception {
AppUserDTO userDTO = (AppUserDTO) publicController.userDetailByToken(authConfig.getToken(request)).getData(); AppUserDTO userDTO = (AppUserDTO) publicController.userDetailByToken(authConfig.getToken(request)).getData();
if (POSITION_NAME.equals(userDTO.getPositionName())) { if (POSITION_ID.equals(userDTO.getPositionId())) {
return ObjectRestResponse.succ(baseBiz.getAll(userDTO.getUserid())) ; return ObjectRestResponse.succ(baseBiz.getAll(userDTO.getUserid(),userDTO.getUsername())) ;
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
...@@ -52,8 +58,17 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS ...@@ -52,8 +58,17 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS
@PostMapping(value = "") @PostMapping(value = "")
public ObjectRestResponse<AppStaffUser> add(@RequestBody AppStaffUser appStaffUser) throws Exception { public ObjectRestResponse<AppStaffUser> add(@RequestBody AppStaffUser appStaffUser) throws Exception {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(authConfig.getToken(request)); IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(authConfig.getToken(request));
if (appStaffUser.getPhone().equals(infoFromToken.getUniqueName())) { Integer positionId = null;
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"不能绑定本人为客户"); try {
positionId = appUserDetailBiz.getUserInfoById(
appUserLoginBiz.getUserByUsername(appStaffUser.getPhone()).getId()
).getPositionId();
} catch (Exception e) {
e.printStackTrace();
}
if (POSITION_ID.equals(positionId)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"绑定错误");
} }
appStaffUser.setSuId(Integer.valueOf(infoFromToken.getId())); appStaffUser.setSuId(Integer.valueOf(infoFromToken.getId()));
if (baseBiz.select(appStaffUser)) { if (baseBiz.select(appStaffUser)) {
...@@ -92,15 +107,20 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS ...@@ -92,15 +107,20 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS
@ResponseBody @ResponseBody
public ObjectRestResponse update(@RequestBody AppStaffUser appStaffUser) throws Exception { public ObjectRestResponse update(@RequestBody AppStaffUser appStaffUser) throws Exception {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(authConfig.getToken(request)); IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(authConfig.getToken(request));
if (appStaffUser.getPhone().equals(infoFromToken.getUniqueName())) { Integer positionId = null;
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"不能绑定本人为客户"); try {
positionId = appUserDetailBiz.getUserInfoById(
appUserLoginBiz.getUserByUsername(appStaffUser.getPhone()).getId()
).getPositionId();
} catch (Exception e) {
e.printStackTrace();
}
if (appStaffUser.getPhone().equals(infoFromToken.getUniqueName())||POSITION_ID.equals(positionId)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"绑定错误");
} }
appStaffUser.setSuId(Integer.valueOf(infoFromToken.getId())); appStaffUser.setSuId(Integer.valueOf(infoFromToken.getId()));
if (baseBiz.select(appStaffUser)) {
baseBiz.updateSelectiveById(appStaffUser); baseBiz.updateSelectiveById(appStaffUser);
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"客户已存在");
}
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.github.wxiaoqi.security.admin.mapper.AppStaffUserMapper">
<select id="selectByBysuIdOrUsername" resultType="com.github.wxiaoqi.security.admin.entity.AppStaffUser">
SELECT
s.id,
s.su_id,
s.u_id,
s.company,
s.remarks,
s.crt_time,
s.upd_time,
s.is_del,
s.`status`,
(CASE
WHEN ld.realname IS NOT NULL THEN
ld.realname
WHEN ld.nickname IS NOT NULL THEN
ld.nickname
ELSE
s.u_name
END
) AS u_name,
(
CASE
WHEN ld.username IS NOT NULL THEN
ld.username
ELSE
s.phone
END
) AS phone
FROM
app_staff_user s
LEFT JOIN (
SELECT
l.id,
l.username,
d.nickname,
d.realname
FROM
app_user_login l
LEFT JOIN app_user_detail d ON l.id = d.userid
) ld ON s.u_id = ld.id
WHERE is_del = 0 and (su_id=#{id} or su_phone=#{username})
</select>
<update id="updateByPositionId" parameterType="com.github.wxiaoqi.security.admin.entity.ModifiedUsers">
update app_staff_user set su_phone=#{phone} where su_id=#{userid}
</update>
<update id="update" parameterType="com.github.wxiaoqi.security.admin.entity.ModifiedUsers">
update app_staff_user set u_name=#{name}, phone= #{phone} where u_id=#{userid}
</update>
</mapper>
\ No newline at end of file
...@@ -322,4 +322,10 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id= ...@@ -322,4 +322,10 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=
) as `sell` on sell.user_id=saff.userId ) as `sell` on sell.user_id=saff.userId
order by sell.sellAmount desc order by sell.sellAmount desc
</select> </select>
<select id="getUser" resultMap="AppUserVoMap">
select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.* from app_user_login l
left join app_user_detail d
on d.userid = l.id
where l.id = #{userId} limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment