Commit a7e0e9ff by 东州 翁 Committed by chenzg

企业中心在修改密码接口添加了修改原密码的方法,更正验证码code的类型

parent c2444e7c
...@@ -61,8 +61,6 @@ public class LoginController { ...@@ -61,8 +61,6 @@ public class LoginController {
@Autowired @Autowired
private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper; private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper;
// @Autowired // @Autowired
// private DataSourceTransactionManager transactionManager; // private DataSourceTransactionManager transactionManager;
...@@ -126,7 +124,7 @@ public class LoginController { ...@@ -126,7 +124,7 @@ public class LoginController {
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<String> authentication(@RequestBody EntRegisterDto entRegisterDto) { public Result<String> authentication(@RequestBody EntRegisterDto entRegisterDto) {
String phone = entRegisterDto.getPhone(); String phone = entRegisterDto.getPhone();
Integer code = entRegisterDto.getCode(); String code = entRegisterDto.getCode();
// String codeRedis = (String) redisTemplate.get(phone); // String codeRedis = (String) redisTemplate.get(phone);
String codeRedis = (String) session.getAttribute(phone); String codeRedis = (String) session.getAttribute(phone);
...@@ -142,33 +140,32 @@ public class LoginController { ...@@ -142,33 +140,32 @@ public class LoginController {
* @param qyzxEmpLogin * @param qyzxEmpLogin
* @return * @return
* @throws IOException * @throws IOException
*/ *//*
@PostMapping(value = "/test") * @PostMapping(value = "/test")
@ApiOperation(value = "3.测试", httpMethod = "POST", notes = "接口发布说明") *
@ApiOperationSupport(order = 3) * @ApiOperation(value = "3.测试", httpMethod = "POST", notes = "接口发布说明")
public void test(HttpServletRequest request, HttpServletResponse res) throws IOException { *
* @ApiOperationSupport(order = 3) public void test(HttpServletRequest request,
res.setHeader("content-type","text/html;charset=UTF-8"); * HttpServletResponse res) throws IOException {
res.setHeader("selfHeader","selfHeaderValue"); *
// res.addHeader("response_code", "123"); * res.setHeader("content-type","text/html;charset=UTF-8");
// res.setContentType("application/octet-stream"); * res.setHeader("selfHeader","selfHeaderValue"); //
// res.addHeader("Content-Length", "0"); * res.addHeader("response_code", "123"); //
* res.setContentType("application/octet-stream"); //
res.addHeader("response_code", "100"); * res.addHeader("Content-Length", "0");
res.addHeader("trans_id", ""); *
res.addHeader("cmd_code", "NO com"); * res.addHeader("response_code", "100"); res.addHeader("trans_id", "");
* res.addHeader("cmd_code", "NO com");
res.setContentType("application/octet-stream"); *
res.addHeader("Content-Length", "0"); * res.setContentType("application/octet-stream");
* res.addHeader("Content-Length", "0");
res.flushBuffer(); *
// response.addHeader("response_code", "ERROR_INVALID_LIB_NAME"); * res.flushBuffer(); // response.addHeader("response_code",
// response.setContentType("application/octet-stream"); * "ERROR_INVALID_LIB_NAME"); //
// response.addHeader("Content-Length", "0"); * response.setContentType("application/octet-stream"); //
// response.flushBuffer(); * response.addHeader("Content-Length", "0"); // response.flushBuffer();
System.out.println(111); * System.out.println(111); }
} */
/** /**
* 修改密码 * 修改密码
...@@ -179,28 +176,55 @@ public class LoginController { ...@@ -179,28 +176,55 @@ public class LoginController {
@PostMapping(value = "/updatepassword") @PostMapping(value = "/updatepassword")
@ApiOperation(value = "4.修改密码", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "4.修改密码", httpMethod = "POST", notes = "接口发布说明")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public Result<String> updatepassword(@RequestBody EntRegisterDto entRegisterDto){ public Result<String> updatepassword(@RequestBody EntRegisterDto entRegisterDto) {
String phone = entRegisterDto.getPhone(); String phone = entRegisterDto.getPhone();
String pw = entRegisterDto.getPw(); String pw = entRegisterDto.getPw();
Integer code = entRegisterDto.getCode(); String code = entRegisterDto.getCode();
//String codeRedis =redisTemplate.get(phone).toString(); if (entRegisterDto.getPwUpdateType() != 2) {
String codeRedis = (String)session.getAttribute(phone);
// String codeRedis =redisTemplate.get(phone).toString();
if (code == null || !code.toString().equals(codeRedis)) { String codeRedis = (String) session.getAttribute(phone);
return ResultUtil.error("验证码不符"); if (code == null) {
} return ResultUtil.error("请填写验证码");
QyzxEmpLogin qyzxEmpLogin1 = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper) }
.eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one(); if ( !code.toString().equals(codeRedis)) {
if (qyzxEmpLogin1 != null) { return ResultUtil.error("验证码不符");
}
QyzxEmpLogin qyzxEmpLogin = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper)
.eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one();
if (qyzxEmpLogin != null) {
qyzxEmpLogin1.setPhone(phone); qyzxEmpLogin.setPhone(phone);
qyzxEmpLogin1.setPw(Md5.md5( pw)); qyzxEmpLogin.setPw(Md5.md5(pw));
qyzxEmpLogin1.updateById(); qyzxEmpLogin.updateById();
return ResultUtil.success("修改密码成功"); return ResultUtil.success("修改密码成功");
}else {
return ResultUtil.error("修改密码失败,查找不到该人员!");
}
}else {
if (code == null) {
return ResultUtil.error("请填写原密码");
}
if (pw.trim() == code.trim()) {
return ResultUtil.error("新密码与原密码相同!请更改重试");
}
QyzxEmpLogin qyzxEmpLogin = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper)
.eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one();
if (qyzxEmpLogin != null) {
if (qyzxEmpLogin.getPw() == Md5.md5(pw)) {
qyzxEmpLogin.setPhone(phone);
qyzxEmpLogin.setPw(Md5.md5(pw));
qyzxEmpLogin.updateById();
return ResultUtil.success("修改密码成功");
}else {
return ResultUtil.error("原密码有误!请核对重试");
}
}
return ResultUtil.error("修改密码失败,查找不到该人员!");
} }
return ResultUtil.error("修改密码失败"); //return ResultUtil.error("修改密码失败");
} }
/** /**
...@@ -218,9 +242,9 @@ public class LoginController { ...@@ -218,9 +242,9 @@ public class LoginController {
*/ */
Integer empNum = userBean.getEmpNum(); Integer empNum = userBean.getEmpNum();
String phone = entRegisterDto.getPhone(); String phone = entRegisterDto.getPhone();
Integer code = entRegisterDto.getCode(); String code = entRegisterDto.getCode();
//String codeRedis = redisTemplate.get(phone).toString(); // String codeRedis = redisTemplate.get(phone).toString();
String codeRedis = (String)session.getAttribute(phone); String codeRedis = (String) session.getAttribute(phone);
if (code == null || !code.toString().equals(codeRedis)) { if (code == null || !code.toString().equals(codeRedis)) {
return ResultUtil.error("验证码不符/失效"); return ResultUtil.error("验证码不符/失效");
...@@ -229,7 +253,7 @@ public class LoginController { ...@@ -229,7 +253,7 @@ public class LoginController {
if (qyzxEmpLogin1 != null) { if (qyzxEmpLogin1 != null) {
qyzxEmpLogin1.setPhone(phone); qyzxEmpLogin1.setPhone(phone);
qyzxEmpLogin1.setPw(Md5.md5( "123456"));// 密码初始化 qyzxEmpLogin1.setPw(Md5.md5("123456"));// 密码初始化
qyzxEmpLogin1.updateById(); qyzxEmpLogin1.updateById();
return ResultUtil.success("修改手机号/用户名成功"); return ResultUtil.success("修改手机号/用户名成功");
...@@ -245,7 +269,7 @@ public class LoginController { ...@@ -245,7 +269,7 @@ public class LoginController {
*/ */
@PostMapping(value = "/register") @PostMapping(value = "/register")
@ApiOperation(value = "注册企业", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "注册企业", httpMethod = "POST", notes = "接口发布说明")
public Result<String> register(@RequestBody EntRegisterDto entRegisterDto){ public Result<String> register(@RequestBody EntRegisterDto entRegisterDto) {
// 事务回滚 // 事务回滚
/* /*
* DefaultTransactionDefinition def = new DefaultTransactionDefinition(); * DefaultTransactionDefinition def = new DefaultTransactionDefinition();
...@@ -287,10 +311,9 @@ public class LoginController { ...@@ -287,10 +311,9 @@ public class LoginController {
if (login == null) { if (login == null) {
// 员工信息 // 员工信息
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(phone).pw(Md5.md5( pw)) QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(phone).pw(Md5.md5(pw))
.sts(CommonEnum.U_STS_ON.getType()) .sts(CommonEnum.U_STS_ON.getType()).orgId(qyzxEntInfoM.getId()).regTime(DateUtil.date())
.orgId(qyzxEntInfoM.getId()).regTime(DateUtil.date()).endTime(DateUtil.nextMonth()) .endTime(DateUtil.nextMonth()).build();
.build();
boolean b2 = qyzxEmpLogin.insert(); boolean b2 = qyzxEmpLogin.insert();
if (!b2) { if (!b2) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
...@@ -331,28 +354,29 @@ public class LoginController { ...@@ -331,28 +354,29 @@ public class LoginController {
*/ */
@PostMapping(value = "/code") @PostMapping(value = "/code")
@ApiOperation(value = "验证码登录", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "验证码登录", httpMethod = "POST", notes = "接口发布说明")
public Result<QyzxEmpLogin> codelogin(@RequestBody EntRegisterDto entRegisterDto,HttpServletRequest request){ public Result<QyzxEmpLogin> codelogin(@RequestBody EntRegisterDto entRegisterDto, HttpServletRequest request) {
Integer code = entRegisterDto.getCode(); String code = entRegisterDto.getCode();
String phone = entRegisterDto.getPhone(); String phone = entRegisterDto.getPhone();
//Object codeRedis = redisTemplate.get(phone); // Object codeRedis = redisTemplate.get(phone);
String codeRedis = (String)session.getAttribute(phone); String codeRedis = (String) session.getAttribute(phone);
if (codeRedis == null || !code.toString().equals(codeRedis.toString())) if (codeRedis == null || !code.toString().equals(codeRedis.toString()))
return ResultUtil.error("验证码不符"); return ResultUtil.error("验证码不符");
QyzxEmpLogin qyzxEmpLogin1 = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper) QyzxEmpLogin qyzxEmpLogin1 = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper)
.eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one(); .eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one();
return loginhan(qyzxEmpLogin1,request); return loginhan(qyzxEmpLogin1, request);
} }
@Autowired @Autowired
ZzglBmgwMMapper zzglBmgwMMapper; ZzglBmgwMMapper zzglBmgwMMapper;
private Result<QyzxEmpLogin> loginhan(QyzxEmpLogin qyzxEmpLogin1,HttpServletRequest request) { private Result<QyzxEmpLogin> loginhan(QyzxEmpLogin qyzxEmpLogin1, HttpServletRequest request) {
if (qyzxEmpLogin1 == null) return ResultUtil.error("帐号不存在!"); if (qyzxEmpLogin1 == null)
return ResultUtil.error("帐号不存在!");
String ip; String ip;
try { try {
ip = UserIp.getIpAddr(request); ip = UserIp.getIpAddr(request);
...@@ -361,23 +385,25 @@ public class LoginController { ...@@ -361,23 +385,25 @@ public class LoginController {
e.printStackTrace(); e.printStackTrace();
} }
List<QysDto> qys = qyzxEmpLoginMapper.getQys(qyzxEmpLogin1.getId()); List<QysDto> qys = qyzxEmpLoginMapper.getQys(qyzxEmpLogin1.getId());
if(qys.size()==0) return ResultUtil.error("没有任何公司可以查看!"); if (qys.size() == 0)
return ResultUtil.error("没有任何公司可以查看!");
qyzxEmpLogin1.setQys(qys); qyzxEmpLogin1.setQys(qys);
QysDto ctrl =qys.get(0); QysDto ctrl = qys.get(0);
if(qyzxEmpLogin1.getOrgId()!=null){ if (qyzxEmpLogin1.getOrgId() != null) {
Stream<QysDto> s = qys.stream().filter(item -> item.getStatus()==1 && qyzxEmpLogin1.getOrgId().equals(item.getId())); Stream<QysDto> s = qys.stream()
if (s != null){ .filter(item -> item.getStatus() == 1 && qyzxEmpLogin1.getOrgId().equals(item.getId()));
ctrl=s.findFirst().get(); if (s != null) {
ctrl = s.findFirst().get();
} }
} }
if (ctrl.getStatus() == null||ctrl.getStatus().equals(0)){ if (ctrl.getStatus() == null || ctrl.getStatus().equals(0)) {
return ResultUtil.error("帐号被禁用"); return ResultUtil.error("帐号被禁用");
} }
qyzxEmpLogin1.setOrgId(ctrl.getId()); qyzxEmpLogin1.setOrgId(ctrl.getId());
@SuppressWarnings("unused") @SuppressWarnings("unused")
String phone = qyzxEmpLogin1.getPhone(); String phone = qyzxEmpLogin1.getPhone();
if ( CommonEnum.U_TYPE_ADMIN.getType().equals(ctrl.getUserType()) if (CommonEnum.U_TYPE_ADMIN.getType().equals(ctrl.getUserType())
|| CommonEnum.U_TYPE_C_ADMIN.getType().equals(ctrl.getUserType())) { || CommonEnum.U_TYPE_C_ADMIN.getType().equals(ctrl.getUserType())) {
} else { } else {
// 获取权限 // 获取权限
ArrayList<Integer> list = new ArrayList<Integer>(); ArrayList<Integer> list = new ArrayList<Integer>();
...@@ -389,7 +415,7 @@ public class LoginController { ...@@ -389,7 +415,7 @@ public class LoginController {
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
LambdaQueryWrapper<ZzglAuth> wp = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ZzglAuth> wp = new LambdaQueryWrapper<>();
wp.select(ZzglAuth::getMenuId).eq(ZzglAuth::getOrgCode, qyzxEmpLogin1.getOrgId()) wp.select(ZzglAuth::getMenuId).eq(ZzglAuth::getOrgCode, qyzxEmpLogin1.getOrgId())
.and(i -> i.in(ZzglAuth::getBmgwId, list.toArray())); .and(i -> i.in(ZzglAuth::getBmgwId, list.toArray()));
List<ZzglAuth> zas = ZzglAuth.builder().build().selectList(wp); List<ZzglAuth> zas = ZzglAuth.builder().build().selectList(wp);
List<String> menus = new ArrayList<>(); List<String> menus = new ArrayList<>();
zas.stream().forEach(o -> menus.add(o.getMenuId())); zas.stream().forEach(o -> menus.add(o.getMenuId()));
...@@ -398,7 +424,7 @@ public class LoginController { ...@@ -398,7 +424,7 @@ public class LoginController {
} }
// 可操作企业 // 可操作企业
//需要更新最后一次登陆信息 // 需要更新最后一次登陆信息
// 用户信息缓存 // 用户信息缓存
session.setAttribute("ui", qyzxEmpLogin1); session.setAttribute("ui", qyzxEmpLogin1);
// redisTemplate.set("loginUser:" + phone, session.getId()); // redisTemplate.set("loginUser:" + phone, session.getId());
...@@ -415,7 +441,7 @@ public class LoginController { ...@@ -415,7 +441,7 @@ public class LoginController {
*/ */
@PostMapping(value = "/password") @PostMapping(value = "/password")
@ApiOperation(value = "密码登录", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "密码登录", httpMethod = "POST", notes = "接口发布说明")
public Result<QyzxEmpLogin> passwordlogin(@RequestBody EntRegisterDto entRegisterDto,HttpServletRequest request){ public Result<QyzxEmpLogin> passwordlogin(@RequestBody EntRegisterDto entRegisterDto, HttpServletRequest request) {
String phone = entRegisterDto.getPhone(); String phone = entRegisterDto.getPhone();
String pw = entRegisterDto.getPw(); String pw = entRegisterDto.getPw();
...@@ -423,10 +449,10 @@ public class LoginController { ...@@ -423,10 +449,10 @@ public class LoginController {
QyzxEmpLogin qyzxEmpLogin1 = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper) QyzxEmpLogin qyzxEmpLogin1 = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper)
.eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one(); .eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one();
if (qyzxEmpLogin1 != null) { if (qyzxEmpLogin1 != null) {
if (StrUtil.hasBlank(pw) || !qyzxEmpLogin1.getPw().equals(Md5.md5( pw))) if (StrUtil.hasBlank(pw) || !qyzxEmpLogin1.getPw().equals(Md5.md5(pw)))
return ResultUtil.error("帐号密码错误"); return ResultUtil.error("帐号密码错误");
return loginhan(qyzxEmpLogin1,request); return loginhan(qyzxEmpLogin1, request);
} else { } else {
return ResultUtil.error("帐号不存在-错误"); return ResultUtil.error("帐号不存在-错误");
} }
......
...@@ -32,12 +32,15 @@ public class EntRegisterDto implements Serializable { ...@@ -32,12 +32,15 @@ public class EntRegisterDto implements Serializable {
private String sendDate; private String sendDate;
@ApiModelProperty(value = "验证码 ", example = "666666") @ApiModelProperty(value = "验证码 ", example = "666666")
private Integer code; private String code;
@ApiModelProperty(value = "1.验证码 2.消息推送 3通知提醒 ", example = "1") @ApiModelProperty(value = "1.验证码 2.消息推送 3通知提醒 ", example = "1")
private Integer messageType; private Integer messageType;
@ApiModelProperty(value = "短信模板:1.身份验证验证码 2.登录确认验证码 3.登录异常验证码 4.用户注册验证码 5.修改密码验证码 6.信息变更验证码 ", example = "1") @ApiModelProperty(value = "短信模板:1.身份验证验证码 2.登录确认验证码 3.登录异常验证码 4.用户注册验证码 5.修改密码验证码 6.信息变更验证码 ", example = "1")
private Integer tc; private Integer tc;
@ApiModelProperty(value = "1.验证码修改密码 2.原密码修改密码 ", example = "1")
private Integer pwUpdateType;
} }
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