Commit 1580105d authored by hanfeng's avatar hanfeng

Merge branch 'master-customer-management' into dev

parents d6b36b08 b33c1d66
package com.github.wxiaoqi.security.admin.biz;
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.AppStaffUserVo;
......@@ -56,9 +57,9 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
if (appStaffUser.getPhone()!=null){
criteria.andEqualTo("phone",appStaffUser.getPhone());
AppStaffUser staffUser = mapper.selectOneByExample(example);
if (staffUser!=null) {
List<AppStaffUser> appStaffUsers = mapper.selectByExample(example);
if (CollectionUtil.isNotEmpty(appStaffUsers)) {
AppStaffUser staffUser = appStaffUsers.get(0);
AppStaffUserVo appStaffUserVo = new AppStaffUserVo();
BeanUtils.copyProperties(staffUser,appStaffUserVo);
Integer suId = staffUser.getSuId();
......@@ -66,7 +67,6 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
appStaffUserVo.setEmployeeName(userInfoById.getRealname());
appStaffUserVo.setEmployeePhone(userInfoById.getUsername());
return appStaffUserVo;
}
}
......@@ -74,4 +74,13 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
}
public boolean select(AppStaffUser appStaffUser) {
Example example=new Example(AppStaffUser.class);
example.createCriteria().andEqualTo("uName",appStaffUser.getUName())
.andEqualTo("phone",appStaffUser.getPhone())
.andEqualTo("isDel",0);
List<AppStaffUser> appStaffUsers = mapper.selectByExample(example);
return CollectionUtil.isEmpty(appStaffUsers)?true:false;
}
}
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.admin.biz.AppStaffUserBiz;
import com.github.wxiaoqi.security.admin.entity.AppStaffUser;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
......@@ -52,8 +53,12 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"不能绑定本人为客户");
}
appStaffUser.setSuId(userDTO.getUserid());
baseBiz.insertSelective(appStaffUser);
return ObjectRestResponse.succ();
if (baseBiz.select(appStaffUser)) {
baseBiz.insertSelective(appStaffUser);
return ObjectRestResponse.succ();
}
throw new BaseException("用户已存在");
}
@ApiOperation("查询一条")
......@@ -86,8 +91,11 @@ public class AppStaffUserController extends BaseController<AppStaffUserBiz, AppS
if (appStaffUser.getPhone().equals(userDTO.getUsername())) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"不能绑定本人为客户");
}
baseBiz.updateSelectiveById(appStaffUser);
return ObjectRestResponse.succ();
if (baseBiz.select(appStaffUser)) {
baseBiz.updateSelectiveById(appStaffUser);
return ObjectRestResponse.succ();
}
throw new BaseException("用户已存在");
}
}
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