From 0337633ce18dd22d8cb8b5f08e4316758f61fce4 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Mon, 27 Jan 2025 21:21:00 +0800 Subject: [PATCH] pwd --- .../customer/dto/CustChangePasswordDTO.java | 32 +++++++ .../customer/dto/CustForgetPasswordDTO.java | 25 ++++++ .../customer/service/CustInfoService.java | 13 +++ .../service/impl/CustInfoServiceImpl.java | 83 +++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustChangePasswordDTO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustForgetPasswordDTO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustInfoService.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustChangePasswordDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustChangePasswordDTO.java new file mode 100644 index 00000000..e50d8bb2 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustChangePasswordDTO.java @@ -0,0 +1,32 @@ +package net.xnzn.core.customer.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@ApiModel("小程序使用修改密码") +@Data +public class CustChangePasswordDTO implements Serializable { + @ApiModelProperty("人员id") + private @NotNull( + message = "人员id不能为空" +) Long custId; + + @ApiModelProperty("旧密码") + private @NotNull( + message = "旧密码不能为空" +) String oldPassword; + + @ApiModelProperty("新密码") + private @NotNull( + message = "新密码不能为空" +) String newPassword; + + @ApiModelProperty("openid") + private String openid; + + @ApiModelProperty("源类型 1-钉钉 2-微信 3-小程序") + private Integer sourceType; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustForgetPasswordDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustForgetPasswordDTO.java new file mode 100644 index 00000000..b68afb7a --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/dto/CustForgetPasswordDTO.java @@ -0,0 +1,25 @@ +package net.xnzn.core.customer.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@ApiModel("小程序使用修改密码") +@Data +public class CustForgetPasswordDTO implements Serializable { + @ApiModelProperty("新密码") + private @NotNull( + message = "新密码不能为空" +) String newPassword; + + @ApiModelProperty("mobile") + private @NotBlank( + message = "手机号不能为空" +) String mobile; + + @ApiModelProperty("验证码") + private String code; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustInfoService.java new file mode 100644 index 00000000..bf9584be --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustInfoService.java @@ -0,0 +1,13 @@ +package net.xnzn.core.customer.service; + +import net.xnzn.core.customer.dto.CustChangePasswordDTO; +import net.xnzn.core.customer.dto.CustForgetPasswordDTO; + +public interface CustInfoService { + + void custChangePassword(CustChangePasswordDTO content); + + void custForgetPassword(CustForgetPasswordDTO content); + + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java new file mode 100644 index 00000000..be3a13af --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java @@ -0,0 +1,83 @@ +//package net.xnzn.core.customer.service.impl; +// +//import cn.hutool.core.util.ObjectUtil; +//import net.xnzn.core.customer.dto.CustChangePasswordDTO; +//import net.xnzn.core.customer.dto.CustForgetPasswordDTO; +//import net.xnzn.core.customer.service.*; +//import net.xnzn.domain.CustInfo; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.context.annotation.Lazy; +//import org.springframework.core.task.AsyncTaskExecutor; +//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +//import org.springframework.stereotype.Service; +//import java.util.*; +// +//@Service +//public class CustInfoServiceImpl implements CustInfoService { +// private static final Logger log = LoggerFactory.getLogger(CustInfoServiceImpl.class); +// @Autowired +// @Lazy +// private AesEncryptUtil aesEncryptUtil; +// @Autowired +// @Lazy +// private SmsCodeApi smsCodeApi; +// @Autowired +// @Lazy +// private CustCasualApi custCasualApi; +// +// @Value("${customer.h5-login-default-pwd}") +// private String h5LoginPwd; +// +// public void custChangePassword(CustChangePasswordDTO content) { +// CustInfo custInfo = (CustInfo)this.getOne((Wrapper)((LambdaQueryWrapper)(new LambdaQueryWrapper()).eq(CustInfo::getCustId, content.getCustId())).eq(CustInfo::getCustState, PersonalStatusEnum.NORMAL.getKey())); +// if (ObjectUtil.isNull(custInfo)) { +// log.error("小程序修改密码错误:人员不存在:" + String.valueOf(custInfo)); +// throw new LeException(RetCodeEnum.PAY_PERSONAL_NO_EXIT, I18n.getMessage("customer.customer.inExists", new Object[0])); +// } else { +// String oldPassword = content.getOldPassword(); +// String newPassword = content.getNewPassword(); +// if (Objects.equals(oldPassword, newPassword)) { +// log.error("小程序修改密码错误:两次密码不能一致"); +// throw new LeException(I18n.getMessage("customer.password.change.same", new Object[0])); +// } else { +// BCryptPasswordEncoder bCrypt = new BCryptPasswordEncoder(); +// if (!bCrypt.matches(oldPassword, custInfo.getPwd())) { +// log.error("小程序修改密码错误:原密码不正确"); +// throw new LeException(I18n.getMessage("customer.password.ord.error", new Object[0])); +// } else { +// String password = bCrypt.encode(newPassword); +// custInfo.setPwd(password); +// this.updateById(custInfo); +// this.custCasualApi.updateLoginState(content.getCustId(), content.getOpenid()); +// } +// } +// } +// } +// +// public void custForgetPassword(CustForgetPasswordDTO content) { +// content.setMobile(this.aesEncryptUtil.aesDecode(content.getMobile())); +// content.setNewPassword(this.aesEncryptUtil.aesDecode(content.getNewPassword())); +// SmsCodeVerifyDTO smsCodeVerifyDTO = new SmsCodeVerifyDTO(); +// smsCodeVerifyDTO.setTelephoneNumber(content.getMobile()); +// smsCodeVerifyDTO.setCode(content.getCode()); +// if (!this.smsCodeApi.verifySmsCode(smsCodeVerifyDTO)) { +// throw new LeException(I18n.getMessage("notice_verify_sms_code_exception", new Object[0])); +// } else { +// CustInfo custInfo = (CustInfo)this.getOne((Wrapper)((LambdaQueryWrapper)(new LambdaQueryWrapper()).eq(CustInfo::getMobile, SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()))).eq(CustInfo::getCustState, PersonalStatusEnum.NORMAL.getKey())); +// if (ObjectUtil.isNull(custInfo)) { +// log.error("修改密码错误:人员不存在:" + String.valueOf(custInfo)); +// throw new LeException(RetCodeEnum.PAY_PERSONAL_NO_EXIT, I18n.getMessage("customer.customer.inExists", new Object[0])); +// } else { +// String newPassword = content.getNewPassword(); +// BCryptPasswordEncoder bCrypt = new BCryptPasswordEncoder(); +// String password = bCrypt.encode(newPassword); +// custInfo.setPwd(password); +// this.updateById(custInfo); +// } +// } +// } +// +//}