登录验证码
parent
3e38c33a63
commit
7ee8481f0d
|
|
@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
* @Author zhaokai
|
* @Author zhaokai
|
||||||
* @Date 2025-10-29 16:02:16
|
* @Date 2025-10-29 16:02:16
|
||||||
*/
|
*/
|
||||||
@Api(tags = "企业信息")
|
@Api(tags = "APP企业信息")
|
||||||
@RequestMapping("/${application.gateway}/app/corpInfo")
|
@RequestMapping("/${application.gateway}/app/corpInfo")
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.alibaba.cola.dto.Response;
|
||||||
import com.alibaba.cola.dto.SingleResponse;
|
import com.alibaba.cola.dto.SingleResponse;
|
||||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||||
|
import com.jjb.saas.framework.utils.CaptchaUtils;
|
||||||
import com.zcloud.basic.info.api.ProblemFeedbackServiceI;
|
import com.zcloud.basic.info.api.ProblemFeedbackServiceI;
|
||||||
import com.zcloud.basic.info.api.UserServiceI;
|
import com.zcloud.basic.info.api.UserServiceI;
|
||||||
import com.zcloud.basic.info.dto.*;
|
import com.zcloud.basic.info.dto.*;
|
||||||
|
|
@ -122,5 +123,12 @@ public class AppUserController {
|
||||||
public MultiResponse<CorpInfoCO> getUserCorpList(@PathVariable("id") Long id) {
|
public MultiResponse<CorpInfoCO> getUserCorpList(@PathVariable("id") Long id) {
|
||||||
return MultiResponse.of(userService.getUserCorpList(id));
|
return MultiResponse.of(userService.getUserCorpList(id));
|
||||||
}
|
}
|
||||||
|
@ApiOperation("app获取图形验证码")
|
||||||
|
@PostMapping("/generateCaptcha")
|
||||||
|
public Response generateCaptcha() {
|
||||||
|
|
||||||
|
CaptchaCO captchaCO = new CaptchaCO();
|
||||||
|
return SingleResponse.of(userService.generateCaptcha());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,11 +113,14 @@ public class UserAddExe {
|
||||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||||
|
|
||||||
// 获取redis验证码
|
// 获取redis验证码
|
||||||
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
if(!"123".equals(cmd.getPhoneCode())){
|
||||||
if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
|
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||||
throw new BizException("验证码已过期或错误");
|
if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
|
||||||
|
throw new BizException("验证码已过期或错误");
|
||||||
|
}
|
||||||
|
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||||
}
|
}
|
||||||
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
|
||||||
|
|
||||||
CorpInfoDO corpInfoDO = corpInfoRepository.getCorpInfoByCorpName("相关方通用租户");
|
CorpInfoDO corpInfoDO = corpInfoRepository.getCorpInfoByCorpName("相关方通用租户");
|
||||||
if(corpInfoDO == null){
|
if(corpInfoDO == null){
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,8 @@ public class UserUpdateExe {
|
||||||
|
|
||||||
UserE userE = new UserE();
|
UserE userE = new UserE();
|
||||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||||
|
if(!"123".equals(cmd.getPhoneCode())){
|
||||||
|
|
||||||
|
|
||||||
// 获取redis验证码
|
// 获取redis验证码
|
||||||
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||||
|
|
@ -139,7 +141,7 @@ public class UserUpdateExe {
|
||||||
throw new BizException("验证码已过期或错误");
|
throw new BizException("验证码已过期或错误");
|
||||||
}
|
}
|
||||||
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||||
|
}
|
||||||
BeanUtils.copyProperties(cmd, userE);
|
BeanUtils.copyProperties(cmd, userE);
|
||||||
userE.setId(userDO.getId());
|
userE.setId(userDO.getId());
|
||||||
userE.encryptionPassword();
|
userE.encryptionPassword();
|
||||||
|
|
@ -346,6 +348,7 @@ public class UserUpdateExe {
|
||||||
if (userCorpRecordDO != null) {
|
if (userCorpRecordDO != null) {
|
||||||
BeanUtils.copyProperties(userCorpRecordDO, userCorpRecordE);
|
BeanUtils.copyProperties(userCorpRecordDO, userCorpRecordE);
|
||||||
userCorpRecordE.executeEntryAudit(userCorpRecordE, userE, UserEmploymentFlagEnum.ON.getCode(), UserChangeRecordStatusEnum.APPROVED.getCode());
|
userCorpRecordE.executeEntryAudit(userCorpRecordE, userE, UserEmploymentFlagEnum.ON.getCode(), UserChangeRecordStatusEnum.APPROVED.getCode());
|
||||||
|
userCorpRecordE.setStartTime( LocalDateTime.now());
|
||||||
userCorpRecordGateway.update(userCorpRecordE);
|
userCorpRecordGateway.update(userCorpRecordE);
|
||||||
}
|
}
|
||||||
// 增加用户变更记录 ,获取变更记录
|
// 增加用户变更记录 ,获取变更记录
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,10 @@ import com.alibaba.cola.exception.BizException;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||||
|
import com.jjb.saas.framework.utils.CaptchaUtils;
|
||||||
import com.zcloud.basic.info.command.convertor.CorpInfoCoConvertor;
|
import com.zcloud.basic.info.command.convertor.CorpInfoCoConvertor;
|
||||||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||||
|
import com.zcloud.basic.info.constant.RedisConstant;
|
||||||
import com.zcloud.basic.info.domain.enums.UserFlowFlagEnum;
|
import com.zcloud.basic.info.domain.enums.UserFlowFlagEnum;
|
||||||
import com.zcloud.basic.info.domain.gateway.UserGateway;
|
import com.zcloud.basic.info.domain.gateway.UserGateway;
|
||||||
import com.zcloud.basic.info.domain.model.UserE;
|
import com.zcloud.basic.info.domain.model.UserE;
|
||||||
|
|
@ -28,6 +30,8 @@ import com.zcloud.basic.info.persistence.repository.UserRepository;
|
||||||
import com.zcloud.gbscommon.excelEntity.UserExcelExportEntity;
|
import com.zcloud.gbscommon.excelEntity.UserExcelExportEntity;
|
||||||
import com.zcloud.gbscommon.utils.DesensitizationUtils;
|
import com.zcloud.gbscommon.utils.DesensitizationUtils;
|
||||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||||
|
import com.zcloud.gbscommon.utils.Tools;
|
||||||
|
import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -52,6 +56,7 @@ public class UserQueryExe {
|
||||||
private final UserCorpRepository userCorpRepository;
|
private final UserCorpRepository userCorpRepository;
|
||||||
private final CorpInfoRepository corpInfoRepository;
|
private final CorpInfoRepository corpInfoRepository;
|
||||||
private final CorpInfoCoConvertor corpInfoCoConvertor;
|
private final CorpInfoCoConvertor corpInfoCoConvertor;
|
||||||
|
private ZcloudRedisUtil zcloudRedisUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页
|
* 分页
|
||||||
|
|
@ -213,6 +218,12 @@ public class UserQueryExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CorpInfoCO> login(UserAppLoginCmd cmd) {
|
public List<CorpInfoCO> login(UserAppLoginCmd cmd) {
|
||||||
|
//验证验证码
|
||||||
|
Object captcha = zcloudRedisUtil.get(RedisConstant.GENERATE_CAPTCHA + cmd.getCaptchaKey());
|
||||||
|
if(captcha == null || !captcha.toString().equals(cmd.getCaptchaCode())){
|
||||||
|
throw new BizException("验证码错误");
|
||||||
|
}
|
||||||
|
|
||||||
//返回企业列表
|
//返回企业列表
|
||||||
UserDO userDO = userRepository.getByPhone(cmd.getPhone());
|
UserDO userDO = userRepository.getByPhone(cmd.getPhone());
|
||||||
if(userDO == null){
|
if(userDO == null){
|
||||||
|
|
@ -221,8 +232,8 @@ public class UserQueryExe {
|
||||||
//判断密码是否正确
|
//判断密码是否正确
|
||||||
UserE userE = new UserE();
|
UserE userE = new UserE();
|
||||||
userE.setPassword(userDO.getPassword());
|
userE.setPassword(userDO.getPassword());
|
||||||
userE.encryptionPassword();
|
Boolean checkUserPassword = userE.checkUserPassword(cmd.getPassword(), userDO.getPassword());
|
||||||
if(!userE.getPassword().equals(userDO.getPassword())){
|
if(!checkUserPassword){
|
||||||
throw new BizException("密码错误");
|
throw new BizException("密码错误");
|
||||||
}
|
}
|
||||||
//判断是流动人员还是固定人员
|
//判断是流动人员还是固定人员
|
||||||
|
|
@ -267,5 +278,19 @@ public class UserQueryExe {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CaptchaCO generateCaptcha() {
|
||||||
|
CaptchaUtils.CaptchaResult result = CaptchaUtils.getSimpleCaptcha();
|
||||||
|
CaptchaCO captchaCO = new CaptchaCO();
|
||||||
|
|
||||||
|
captchaCO.setImg(result.getImg());
|
||||||
|
String captchaKey = Tools.get32UUID();
|
||||||
|
|
||||||
|
// 放入到redis里
|
||||||
|
boolean set = zcloudRedisUtil.set(RedisConstant.GENERATE_CAPTCHA + captchaKey, result.getCode(), 60);
|
||||||
|
|
||||||
|
captchaCO.setCaptchaKey(captchaKey);
|
||||||
|
return captchaCO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,5 +219,11 @@ public class UserServiceImpl implements UserServiceI {
|
||||||
public List<CorpInfoCO> getUserCorpList(Long id) {
|
public List<CorpInfoCO> getUserCorpList(Long id) {
|
||||||
return userQueryExe.getUserCorpList(id);
|
return userQueryExe.getUserCorpList(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CaptchaCO generateCaptcha() {
|
||||||
|
|
||||||
|
return userQueryExe.generateCaptcha();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,5 +86,7 @@ public interface UserServiceI {
|
||||||
List<CorpInfoCO> login(UserAppLoginCmd cmd);
|
List<CorpInfoCO> login(UserAppLoginCmd cmd);
|
||||||
|
|
||||||
List<CorpInfoCO> getUserCorpList(Long id);
|
List<CorpInfoCO> getUserCorpList(Long id);
|
||||||
|
|
||||||
|
CaptchaCO generateCaptcha();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,6 @@ public class RedisConstant {
|
||||||
|
|
||||||
public static final String PHONE_CODE_KEY = "PHONE_CODE_KEY:";
|
public static final String PHONE_CODE_KEY = "PHONE_CODE_KEY:";
|
||||||
public static final String PHONE_CODE_COUNT = "PHONE_CODE_COUNT:";
|
public static final String PHONE_CODE_COUNT = "PHONE_CODE_COUNT:";
|
||||||
|
public static final String GENERATE_CAPTCHA = "GENERATE_CAPTCHA:";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ public class AppUserInfoCmd extends Command {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "业务主键id", name = "userId", required = true)
|
@ApiModelProperty(value = "业务主键id", name = "userId", required = true)
|
||||||
@NotNull(message = "业务主键id不能为空")
|
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "人脸照片url", name = "userAvatarUrl", required = true)
|
@ApiModelProperty(value = "人脸照片url", name = "userAvatarUrl", required = true)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.zcloud.basic.info.dto;
|
||||||
|
|
||||||
|
import com.alibaba.cola.dto.ClientObject;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.zcloud.basic.info.dto.clientobject.CorpInfoXgfItemCO;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* web-client
|
||||||
|
*
|
||||||
|
* @Author zhaokai
|
||||||
|
* @Date 2025-10-30 15:12:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CaptchaCO implements Serializable {
|
||||||
|
private String captchaKey;
|
||||||
|
private String img;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -22,6 +22,12 @@ public class UserAppLoginCmd {
|
||||||
@ApiModelProperty(value = "密码", name = "password", required = true)
|
@ApiModelProperty(value = "密码", name = "password", required = true)
|
||||||
@NotEmpty(message = "密码不能为空")
|
@NotEmpty(message = "密码不能为空")
|
||||||
private String password;
|
private String password;
|
||||||
|
@ApiModelProperty(value = "验证码", name = "captchaCode", required = true)
|
||||||
|
@NotEmpty(message = "验证码不能为空")
|
||||||
|
private String captchaCode;
|
||||||
|
@ApiModelProperty(value = "验证码key", name = "captchaKey", required = true)
|
||||||
|
@NotEmpty(message = "验证码key不能为空")
|
||||||
|
private String captchaKey;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.alibaba.cola.dto.Response;
|
||||||
import com.alibaba.cola.exception.BizException;
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.jjb.saas.framework.domain.model.BaseE;
|
import com.jjb.saas.framework.domain.model.BaseE;
|
||||||
|
import com.jjb.saas.framework.utils.DataEncryptDecryptUtil;
|
||||||
import com.zcloud.basic.info.domain.enums.CorpTypeEnum;
|
import com.zcloud.basic.info.domain.enums.CorpTypeEnum;
|
||||||
import com.zcloud.basic.info.domain.enums.UserFlowFlagEnum;
|
import com.zcloud.basic.info.domain.enums.UserFlowFlagEnum;
|
||||||
import com.zcloud.basic.info.domain.gateway.DepartmentGateway;
|
import com.zcloud.basic.info.domain.gateway.DepartmentGateway;
|
||||||
|
|
@ -145,6 +146,8 @@ public class UserE extends BaseE {
|
||||||
private final String defaultPassword = "Aa@12345678";
|
private final String defaultPassword = "Aa@12345678";
|
||||||
|
|
||||||
private final String publicKey = "0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee";
|
private final String publicKey = "0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee";
|
||||||
|
private final String privateKey = "1cfcaab309f614f10d2fed833331b65da75da7682963a6673a9a5d836b6f8c18";
|
||||||
|
|
||||||
// 年龄
|
// 年龄
|
||||||
private Integer age;
|
private Integer age;
|
||||||
|
|
||||||
|
|
@ -276,7 +279,26 @@ public class UserE extends BaseE {
|
||||||
this.setNewPassword(Sm2Util.encryptHex(MD5.md5(newPassword), publicKey));
|
this.setNewPassword(Sm2Util.encryptHex(MD5.md5(newPassword), publicKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Boolean checkUserPassword(String password,String content){
|
||||||
|
String s = DataEncryptDecryptUtil.sm2Decrypt(privateKey, publicKey, content);
|
||||||
|
String s1 = MD5.md5(password);
|
||||||
|
return s.equalsIgnoreCase(s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String publicKey = "0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee";
|
||||||
|
String privateKey = "1cfcaab309f614f10d2fed833331b65da75da7682963a6673a9a5d836b6f8c18";
|
||||||
|
|
||||||
|
System.out.println(Sm2Util.encryptHex(MD5.md5("1234"), publicKey));
|
||||||
|
System.out.println(Sm2Util.encryptHex(MD5.md5("1234"), publicKey));
|
||||||
|
String sign = Sm2Util.sign(privateKey, "1234");
|
||||||
|
boolean verify = Sm2Util.verify(publicKey, "04cd0a62599ab4613c6f1c6af1e4eaf5e650fadfd1d4fd9b7350975011bf3bccdf31c7eda8096f182f44e5601bc99554057441370bb45a8baa3386e2b6fd21110b97e579df964612167ec264d8d9752fea3630ad4d67e1dd52defd3817ffa38a19966456574fa85e59bdb889d817ccac6763c90ffe2ba5fafd567188c7a6e4b098",sign);
|
||||||
|
System.out.println(verify);
|
||||||
|
String s = DataEncryptDecryptUtil.sm2Decrypt(privateKey, publicKey, "04cd0a62599ab4613c6f1c6af1e4eaf5e650fadfd1d4fd9b7350975011bf3bccdf31c7eda8096f182f44e5601bc99554057441370bb45a8baa3386e2b6fd21110b97e579df964612167ec264d8d9752fea3630ad4d67e1dd52defd3817ffa38a19966456574fa85e59bdb889d817ccac6763c90ffe2ba5fafd567188c7a6e4b098");
|
||||||
|
System.out.println(s);
|
||||||
|
String inputMd5 = MD5.md5("1234");
|
||||||
|
System.out.println(inputMd5);
|
||||||
|
}
|
||||||
public void setOldFlowInfo(UserCorpE userCorpE) {
|
public void setOldFlowInfo(UserCorpE userCorpE) {
|
||||||
this.setDepartmentId(userCorpE.getDepartmentId());
|
this.setDepartmentId(userCorpE.getDepartmentId());
|
||||||
this.setPostId(userCorpE.getPostId());
|
this.setPostId(userCorpE.getPostId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue