This commit is contained in:
sxu 2025-02-01 10:19:16 +08:00
parent d8c982d47d
commit 7c30de203f
2 changed files with 48 additions and 8 deletions

View File

@ -0,0 +1,42 @@
package net.xnzn.core.customer.controller;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.xnzn.core.customer.dto.CustChangePasswordDTO;
import net.xnzn.core.customer.dto.CustForgetPasswordDTO;
import net.xnzn.core.customer.service.CustInfoService;
import net.xnzn.utils.AesEncryptUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/dept")
@Slf4j
public class CustInfoController extends BaseController {
@Autowired
CustInfoService custInfoService;
@ApiOperation("小程序修改密码")
@PostMapping({"/change/password"})
public AjaxResult changePassword(@Validated @RequestBody CustChangePasswordDTO content) {
this.custInfoService.custChangePassword(content);
return success();
}
@ApiOperation("忘记密码")
@PostMapping({"/forget/password"})
public AjaxResult forgetPassword(@Validated @RequestBody CustForgetPasswordDTO content) {
content.setMobile(AesEncryptUtil.aesDecode(content.getMobile()));
content.setNewPassword(AesEncryptUtil.aesDecode(content.getNewPassword()));
this.custInfoService.custForgetPassword(content);
return success();
}
}

View File

@ -1,8 +1,6 @@
package net.xnzn.core.customer.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bonus.common.core.exception.ServiceException;
import net.xnzn.constant.RetCodeEnum;
import net.xnzn.core.customer.api.CustCasualApi;
@ -28,9 +26,9 @@ 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 AesEncryptUtil aesEncryptUtil;
@Autowired
@Lazy
private SmsCodeApi smsCodeApi;
@ -72,8 +70,8 @@ public class CustInfoServiceImpl implements CustInfoService {
}
public void custForgetPassword(CustForgetPasswordDTO content) {
content.setMobile(this.aesEncryptUtil.aesDecode(content.getMobile()));
content.setNewPassword(this.aesEncryptUtil.aesDecode(content.getNewPassword()));
content.setMobile(AesEncryptUtil.aesDecode(content.getMobile()));
content.setNewPassword(AesEncryptUtil.aesDecode(content.getNewPassword()));
SmsCodeVerifyDTO smsCodeVerifyDTO = new SmsCodeVerifyDTO();
smsCodeVerifyDTO.setTelephoneNumber(content.getMobile());
smsCodeVerifyDTO.setCode(content.getCode());
@ -84,7 +82,7 @@ public class CustInfoServiceImpl implements CustInfoService {
custInfoQuery.setMobile(SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()));
CustInfo custInfo = custInfoMapper.selectOne(custInfoQuery);
if (ObjectUtil.isNull(custInfo)) {
log.error("修改密码错误:人员不存在:" + String.valueOf(custInfo));
log.error("修改密码错误:人员不存在:" + custInfo);
throw new ServiceException("修改密码错误:人员不存在", RetCodeEnum.PAY_PERSONAL_NO_EXIT.getKey());
} else {
String newPassword = content.getNewPassword();