1.增加重置密码接口

master
panqihua 1 year ago
parent a43b6b8ca0
commit 9f7007896f
  1. 5
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/store/account/PlatformStoreAccountController.java
  2. 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  3. 2
      ttsbg-framework/src/main/java/com/ruoyi/framework/service/ISmsService.java
  4. 7
      ttsbg-framework/src/main/java/com/ruoyi/framework/service/impl/SmsServiceImpl.java
  5. 12
      ttsbg-framework/src/main/resources/mapper/PlatformSmsMapper.xml
  6. 2
      ttsbg-store/src/main/java/com/ruoyi/store/service/IStoreAccountService.java
  7. 29
      ttsbg-store/src/main/java/com/ruoyi/store/service/impl/StoreAccountServiceImpl.java

@ -47,6 +47,11 @@ public class PlatformStoreAccountController extends BaseController {
return ajax;
}
@PostMapping("resetpwd")
public AjaxResult resetpwd(@RequestBody StoreAccountVo account) {
return success(platformStoreAccountService.resetpwd(account));
}
/**
* 查询店家账号列表
*/

@ -120,7 +120,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
//平台短信发送
.antMatchers("/platform/public/sms/send").permitAll()
//店家注册登录
.antMatchers("/platform/store/account/register", "/platform/store/account/login").permitAll()
.antMatchers("/platform/store/account/register", "/platform/store/account/login", "/platform/store/account/resetpwd").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()

@ -68,5 +68,5 @@ public interface ISmsService {
*/
public String send(String mobile, Integer integer);
public boolean existsSms(String mobile, String code);
public Sms querySms(String mobile, String code);
}

@ -95,20 +95,19 @@ public class SmsServiceImpl implements ISmsService {
* @return
*/
@Override
public boolean existsSms(String mobile, String code) {
public Sms querySms(String mobile, String code) {
LambdaQueryWrapper<Sms> wrapper = new LambdaQueryWrapper<>();
Date d = new Date();
wrapper.select(Sms::getId).eq(Sms::getMobile, mobile).le(Sms::getSendtime, d).ge(Sms::getDeadtime, d);
if (code != null) {
wrapper.eq(Sms::getCode, code);
}
Sms sms = smsMapper.selectOne(wrapper);
return sms != null;
return smsMapper.selectOne(wrapper);
}
@Override
public String send(String mobile, Integer smsTime) {
if (existsSms(mobile, null)) {
if (querySms(mobile, null) != null) {
return "短信发送过于频繁";
} else {
String code = RandomStringUtils.randomNumeric(6);

@ -19,7 +19,7 @@
from platform_sms
</sql>
<select id="selectPlatformSmsList" parameterType="Sms" resultMap="PlatformSmsResult">
<select id="selectSmsList" parameterType="Sms" resultMap="PlatformSmsResult">
<include refid="selectPlatformSmsVo"/>
<where>
<if test="mobile != null and mobile != ''">and mobile = #{mobile}</if>
@ -30,12 +30,12 @@
</where>
</select>
<select id="selectPlatformSmsById" parameterType="Long" resultMap="PlatformSmsResult">
<select id="selectSmsById" parameterType="Long" resultMap="PlatformSmsResult">
<include refid="selectPlatformSmsVo"/>
where id = #{id}
</select>
<insert id="insertPlatformSms" parameterType="Sms">
<insert id="insertSms" parameterType="Sms">
insert into platform_sms
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
@ -57,7 +57,7 @@
</trim>
</insert>
<update id="updatePlatformSms" parameterType="Sms">
<update id="updateSms" parameterType="Sms">
update platform_sms
<trim prefix="SET" suffixOverrides=",">
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
@ -70,13 +70,13 @@
where id = #{id}
</update>
<delete id="deletePlatformSmsById" parameterType="Long">
<delete id="deleteSmsById" parameterType="Long">
delete
from platform_sms
where id = #{id}
</delete>
<delete id="deletePlatformSmsByIds" parameterType="String">
<delete id="deleteSmsByIds" parameterType="String">
delete from platform_sms where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}

@ -70,4 +70,6 @@ public interface IStoreAccountService {
* @return
*/
public StoreAccount selectAccountByMobile(String mobile);
String resetpwd(StoreAccountVo account);
}

@ -2,6 +2,7 @@ package com.ruoyi.store.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.domain.Sms;
import com.ruoyi.framework.service.ISmsService;
import com.ruoyi.store.domain.StoreAccount;
import com.ruoyi.store.domain.vo.StoreAccountVo;
@ -25,7 +26,7 @@ public class StoreAccountServiceImpl implements IStoreAccountService {
private StoreAccountMapper storeAccountMapper;
@Autowired
private ISmsService SmsService;
private ISmsService smsService;
/**
* 查询店家账号
@ -103,7 +104,10 @@ public class StoreAccountServiceImpl implements IStoreAccountService {
@Override
public String register(StoreAccountVo account) {
//检查验证码是否有效
if (SmsService.existsSms(account.getMobile(), account.getVerificationCode())) {
Sms sms = smsService.querySms(account.getMobile(), account.getVerificationCode());
if (sms != null) {
sms.setDeadtime(new Date());
smsService.updateSms(sms);
if (selectAccountByMobile(account.getMobile()) != null) {
return "手机号已注册";
} else {
@ -121,7 +125,26 @@ public class StoreAccountServiceImpl implements IStoreAccountService {
}
}
} else {
return "无效验证码";
return "手机号或验证码错误";
}
}
@Override
public String resetpwd(StoreAccountVo account) {
//检查验证码是否有效
Sms sms = smsService.querySms(account.getMobile(), account.getVerificationCode());
if (sms != null) {
sms.setDeadtime(new Date());
smsService.updateSms(sms);
StoreAccount storeAccount = selectAccountByMobile(account.getMobile());
storeAccount.setPassword(SecurityUtils.encryptPassword(account.getPassword()));
if (storeAccountMapper.updateById(storeAccount) > 0) {
return "密码重置成功";
} else {
return "密码重置失败";
}
} else {
return "手机号或验证码错误";
}
}
}

Loading…
Cancel
Save