Browse Source

移动端-pc添加用户后,移动端登录

master
dimengzhe 3 years ago
parent
commit
4beb371961
  1. 16
      anrui-portal/anrui-portal-biz/src/main/java/com/yxt/anrui/portal/biz/sysstaffinfo/SysStaffinfoService.java
  2. 25
      anrui-portal/anrui-portal-biz/src/main/java/com/yxt/anrui/portal/biz/sysuser/app/AppSysUserRest.java

16
anrui-portal/anrui-portal-biz/src/main/java/com/yxt/anrui/portal/biz/sysstaffinfo/SysStaffinfoService.java

@ -4,14 +4,10 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.anrui.portal.api.sysorganization.AppContactSysOrganizationVo; import com.yxt.anrui.portal.api.sysorganization.AppContactSysOrganizationVo;
import com.yxt.anrui.portal.api.sysorganization.SysOrganization;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo;
import com.yxt.anrui.portal.api.syspost.SysPost;
import com.yxt.anrui.portal.api.sysstaffinfo.*; import com.yxt.anrui.portal.api.sysstaffinfo.*;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg; import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgDetailsVo; import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgDetailsVo;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgDto; import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgDto;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgVo;
import com.yxt.anrui.portal.api.sysstaffpost.SysStaffPost; import com.yxt.anrui.portal.api.sysstaffpost.SysStaffPost;
import com.yxt.anrui.portal.api.sysstaffpost.SysStaffPostDetailsVo; import com.yxt.anrui.portal.api.sysstaffpost.SysStaffPostDetailsVo;
import com.yxt.anrui.portal.api.sysstaffpost.SysStaffPostDto; import com.yxt.anrui.portal.api.sysstaffpost.SysStaffPostDto;
@ -23,6 +19,7 @@ import com.yxt.anrui.portal.biz.sysstaffpost.SysStaffPostService;
import com.yxt.anrui.portal.biz.sysuser.SysUserService; import com.yxt.anrui.portal.biz.sysuser.SysUserService;
import com.yxt.common.base.config.component.FileUploadComponent; import com.yxt.common.base.config.component.FileUploadComponent;
import com.yxt.common.base.service.MybatisBaseService; import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.Encodes;
import com.yxt.common.base.utils.PagerUtil; import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.PinYinUtils; import com.yxt.common.base.utils.PinYinUtils;
import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.query.PagerQuery;
@ -186,7 +183,8 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
} }
//查询员工的手机号是否重复 //查询员工的手机号是否重复
SysStaffinfo sysStaffinfo1 = baseMapper.selectByMobile(dto.getMobile()); SysStaffinfo sysStaffinfo1 = baseMapper.selectByMobile(dto.getMobile());
if (sysStaffinfo1 != null) { SysUser sysUser1 = sysUserService.selectByMobile(dto.getMobile());
if (sysStaffinfo1 != null || sysUser1 != null) {
return rb.setMsg("已存在手机号为" + dto.getMobile() + "的员工"); return rb.setMsg("已存在手机号为" + dto.getMobile() + "的员工");
} }
//查询是否存在该身份证号的员工 //查询是否存在该身份证号的员工
@ -280,6 +278,7 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
} }
sysStaffOrgDto.fillEntity(sysStaffOrg); sysStaffOrgDto.fillEntity(sysStaffOrg);
sysStaffOrg.setStaffSid(sysStaffinfo3.getSid()); sysStaffOrg.setStaffSid(sysStaffinfo3.getSid());
sysStaffOrg.setManageType("3");
sysStaffOrgService.save(sysStaffOrg); sysStaffOrgService.save(sysStaffOrg);
//增加员工的关联的岗位信息 //增加员工的关联的岗位信息
SysStaffPost sysStaffPost = new SysStaffPost(); SysStaffPost sysStaffPost = new SysStaffPost();
@ -293,6 +292,10 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
sysUser.setStaffSid(sysStaffinfo3.getSid()); sysUser.setStaffSid(sysStaffinfo3.getSid());
sysUser.setUserName(jobNumber); sysUser.setUserName(jobNumber);
sysUser.setMobile(sysStaffinfo3.getMobile()); sysUser.setMobile(sysStaffinfo3.getMobile());
sysUser.setUserType(1);
String password = sysStaffinfo3.getMobile().substring(5, 11);
String md5 = Encodes.md5(password);
sysUser.setPassword(md5);
boolean isSave = sysUserService.save(sysUser); boolean isSave = sysUserService.save(sysUser);
sysStaffPostDto.fillEntity(sysStaffPost); sysStaffPostDto.fillEntity(sysStaffPost);
sysStaffPost.setStaffSid(sysStaffinfo3.getSid()); sysStaffPost.setStaffSid(sysStaffinfo3.getSid());
@ -348,7 +351,8 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
} }
//查询员工的手机号是否重复 //查询员工的手机号是否重复
SysStaffinfo sysStaffinfo2 = baseMapper.selectByMobileAndSid(dto.getMobile(), sid); SysStaffinfo sysStaffinfo2 = baseMapper.selectByMobileAndSid(dto.getMobile(), sid);
if (sysStaffinfo2 != null) { SysUser sysUser = sysUserService.selectByMobile(dto.getMobile());
if (sysStaffinfo2 != null || sysUser != null) {
return rb.setMsg("已存在手机号为" + dto.getMobile() + "的员工"); return rb.setMsg("已存在手机号为" + dto.getMobile() + "的员工");
} }
//查询是否存在该身份证号的员工 //查询是否存在该身份证号的员工

25
anrui-portal/anrui-portal-biz/src/main/java/com/yxt/anrui/portal/biz/sysuser/app/AppSysUserRest.java

@ -66,6 +66,7 @@ public class AppSysUserRest implements AppSysUserFeign {
122根据传参设备appId查询到绑定的账号与用户传递的账号一致验证登录信息 122根据传参设备appId查询到绑定的账号与用户传递的账号一致验证登录信息
1验证登录信息成功后返回用户信息验证不成功返回错误信息验证码密码错误 1验证登录信息成功后返回用户信息验证不成功返回错误信息验证码密码错误
*/ */
ResultBean<SysUserVo> rb = ResultBean.fireFail();
String userName = userQuery.getUserName(); String userName = userQuery.getUserName();
String password = userQuery.getPassword(); String password = userQuery.getPassword();
String appId = userQuery.getAppId(); String appId = userQuery.getAppId();
@ -84,7 +85,12 @@ public class AppSysUserRest implements AppSysUserFeign {
SysUser sysUser = sysUserService.selectByAppId(appId); SysUser sysUser = sysUserService.selectByAppId(appId);
if (null == sysUser) { // 未查询到绑定的账号 if (null == sysUser) { // 未查询到绑定的账号
sysUser = sysUserService.selectByUserNameApp(userName); sysUser = sysUserService.selectByUserNameApp(userName);
if (null == sysUser) return new ResultBean<SysUserVo>().fail().setMsg("账号不存在"); if (sysUser == null) {
sysUser = sysUserService.selectByMobile(userName);
if (sysUser == null) {
return rb.setMsg("账号不存在");
}
}
String appIdVal = sysUser.getAppId(); String appIdVal = sysUser.getAppId();
if (StringUtils.isBlank(appIdVal)) { // 设备值为空 if (StringUtils.isBlank(appIdVal)) { // 设备值为空
if (type.equals("1")) { if (type.equals("1")) {
@ -92,7 +98,6 @@ public class AppSysUserRest implements AppSysUserFeign {
if (md5.equals(sysUser.getPassword())) { if (md5.equals(sysUser.getPassword())) {
sysUserService.updateAppId(sysUser.getSid(), appId); sysUserService.updateAppId(sysUser.getSid(), appId);
SysUserVo sysUserVo = sysUserService.selectUser(sysUser); SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
// SysUserVo sysUserVo = sysUserService.selectUserOne(sysUser);
insertLoginLog(sysUser); insertLoginLog(sysUser);
return new ResultBean<SysUserVo>().success().setData(sysUserVo); return new ResultBean<SysUserVo>().success().setData(sysUserVo);
} else { } else {
@ -100,7 +105,8 @@ public class AppSysUserRest implements AppSysUserFeign {
} }
} else { } else {
String codeFromRedis = redisUtil.get("loginCode" + userName); String codeFromRedis = redisUtil.get("loginCode" + userName);
if(StringUtils.isBlank(codeFromRedis)) return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送"); if (StringUtils.isBlank(codeFromRedis))
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送");
if (verifyCode.equals(codeFromRedis.substring(0, 4))) { if (verifyCode.equals(codeFromRedis.substring(0, 4))) {
sysUserService.updateAppId(sysUser.getSid(), appId); sysUserService.updateAppId(sysUser.getSid(), appId);
SysUserVo sysUserVo = sysUserService.selectUser(sysUser); SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
@ -116,12 +122,11 @@ public class AppSysUserRest implements AppSysUserFeign {
return new ResultBean<SysUserVo>().fail().setMsg("当前账号已被其它设备绑定(错误码:" + res + ")"); return new ResultBean<SysUserVo>().fail().setMsg("当前账号已被其它设备绑定(错误码:" + res + ")");
} }
} else { // 查询到绑定的账号 } else { // 查询到绑定的账号
if(userName.equals(sysUser.getUserName())){ // 设备appId一致,验证用户名 if (userName.equals(sysUser.getUserName()) || userName.equals(sysUser.getMobile())) { // 设备appId一致,验证用户名
if (type.equals("1")) { if (type.equals("1")) {
String md5 = Encodes.md5(password); String md5 = Encodes.md5(password);
if (md5.equals(sysUser.getPassword())) { if (md5.equals(sysUser.getPassword())) {
SysUserVo sysUserVo = sysUserService.selectUser(sysUser); SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
// SysUserVo sysUserVo = sysUserService.selectUserOne(sysUser);
insertLoginLog(sysUser); insertLoginLog(sysUser);
return new ResultBean<SysUserVo>().success().setData(sysUserVo); return new ResultBean<SysUserVo>().success().setData(sysUserVo);
} else { } else {
@ -129,7 +134,8 @@ public class AppSysUserRest implements AppSysUserFeign {
} }
} else { } else {
String codeFromRedis = redisUtil.get("loginCode" + userName); String codeFromRedis = redisUtil.get("loginCode" + userName);
if(StringUtils.isBlank(codeFromRedis)) return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送"); if (StringUtils.isBlank(codeFromRedis))
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送");
if (verifyCode.equals(codeFromRedis.substring(0, 4))) { if (verifyCode.equals(codeFromRedis.substring(0, 4))) {
SysUserVo sysUserVo = sysUserService.selectUser(sysUser); SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
redisUtil.remove("loginCode" + userName); redisUtil.remove("loginCode" + userName);
@ -148,6 +154,7 @@ public class AppSysUserRest implements AppSysUserFeign {
/** /**
* 插入登录日志 * 插入登录日志
*
* @param user * @param user
*/ */
private void insertLoginLog(SysUser user) { private void insertLoginLog(SysUser user) {
@ -163,6 +170,7 @@ public class AppSysUserRest implements AppSysUserFeign {
/** /**
* 手机发送短信验证码 * 手机发送短信验证码
*
* @param mobile * @param mobile
* @param type 1登录2修改密码3找回密码 * @param type 1登录2修改密码3找回密码
* @param appId 绑定手机的appid * @param appId 绑定手机的appid
@ -214,6 +222,7 @@ public class AppSysUserRest implements AppSysUserFeign {
/** /**
* 插入错误的信息 * 插入错误的信息
*
* @param operChar * @param operChar
* @param operArg * @param operArg
* @param remark * @param remark
@ -279,7 +288,8 @@ public class AppSysUserRest implements AppSysUserFeign {
@Override @Override
public ResultBean resetPwdApp(String mobile, String newPwd, HttpServletRequest httpServletRequest) { public ResultBean resetPwdApp(String mobile, String newPwd, HttpServletRequest httpServletRequest) {
String token = httpServletRequest.getHeader("token"); String token = httpServletRequest.getHeader("token");
if (StringUtils.isBlank(mobile) || !RegexUtil.isMobile(mobile)) return new ResultBean().fail().setMsg("请输入正确的手机号"); if (StringUtils.isBlank(mobile) || !RegexUtil.isMobile(mobile))
return new ResultBean().fail().setMsg("请输入正确的手机号");
if (StringUtils.isBlank(newPwd)) return new ResultBean().fail().setMsg("请输入密码"); if (StringUtils.isBlank(newPwd)) return new ResultBean().fail().setMsg("请输入密码");
return sysUserService.resetPwdApp(mobile, newPwd, token); return sysUserService.resetPwdApp(mobile, newPwd, token);
} }
@ -302,6 +312,7 @@ public class AppSysUserRest implements AppSysUserFeign {
/** /**
* 手机端根据token获取userSid * 手机端根据token获取userSid
*
* @return * @return
*/ */
@Override @Override

Loading…
Cancel
Save