Compare commits

..

2 Commits

Author SHA1 Message Date
kuang.yife 38b7a8f3ad 忘记密码 2024-03-13 17:51:52 +08:00
kuang.yife 7020853604 微信小程序登陆 2024-03-13 16:17:55 +08:00
6 changed files with 41 additions and 3 deletions

View File

@ -66,4 +66,16 @@ public class PlayletUserAppController {
} }
} }
@ResponseBody
@PostMapping(value = "/updatePasswordByCode")
@ApiOperation(value = "验证码修改密码", httpMethod = "POST")
public Result<String> updatePasswordByCode(@RequestBody PlayUserReq playUserReq){
try {
playletUserAppService.updatePasswordByCode(playUserReq);
return Result.success();
}catch (Exception e){
return Result.error(e.getMessage());
}
}
} }

View File

@ -32,4 +32,9 @@ public interface PlayletUserAppService {
*/ */
void updatePlayletUser(PlayletUser playletUser); void updatePlayletUser(PlayletUser playletUser);
/**
* @param playUserReq 用户资料
*/
void updatePasswordByCode(PlayUserReq playUserReq) throws Exception;
} }

View File

@ -67,4 +67,24 @@ public class PlayletUserAppServiceImpl implements PlayletUserAppService {
public void updatePlayletUser(PlayletUser playletUser) { public void updatePlayletUser(PlayletUser playletUser) {
iPlayletUserService.updateById(playletUser); iPlayletUserService.updateById(playletUser);
} }
@Override
public void updatePasswordByCode(PlayUserReq playUserReq) throws Exception{
String alreadyCode = stringRedisTemplate.opsForValue().get(RedisConstants.SMS_CODE_PREFIX + playUserReq.getPhone());
if(StringUtils.isEmpty(alreadyCode)){
throw new Exception("验证码已过期!");
}
if(!alreadyCode.equals(playUserReq.getCode())){
throw new Exception("短信验证码错误!");
}
PlayletUser user = iPlayletUserService.lambdaQuery()
.eq(PlayletUser::getPhone, playUserReq.getPhone()).one();
if(user == null){
throw new Exception("用户尚未注册!");
}else {
user.setPassword(playUserReq.getPassword());
iPlayletUserService.updateById(user);
}
}
} }

View File

@ -32,7 +32,7 @@ public class WxServiceImpl implements WxService {
@Override @Override
public String getOpenidByCode(String code) { public String getOpenidByCode(String code) {
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="+ wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&code=" + code + "&grant_type=authorization_code"; String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+ wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + code + "&grant_type=authorization_code";
log.info("调用微信获取openId,入参url:{}", url); log.info("调用微信获取openId,入参url:{}", url);
String result = HttpUtils.sendGet(url); String result = HttpUtils.sendGet(url);
log.info("调用微信获取openId,响应内容:{}", result); log.info("调用微信获取openId,响应内容:{}", result);

View File

@ -161,8 +161,8 @@ swagger:
#小程序配置 #小程序配置
wx: wx:
appId: 'wx60fa92c432e05ed1' appId: 'wx0e233b84fa447fb4'
secret: '8ff8ab065446e2ad552e88a37780d8fe' secret: '9d8a99595d25cfc852f3644dafd06e98'
#阿里云OSS配置 #阿里云OSS配置
aliyun: aliyun:

View File

@ -46,6 +46,7 @@ public class BaseEntity implements Serializable
/** 请求参数 */ /** 请求参数 */
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private Map<String, Object> params; private Map<String, Object> params;
public Map<String, Object> getParams() public Map<String, Object> getParams()