|
@@ -10,7 +10,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
+import com.zhongzheng.common.core.domain.AjaxResult;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
+import com.zhongzheng.common.enums.UserStatus;
|
|
|
+import com.zhongzheng.common.exception.BaseException;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.*;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
@@ -65,7 +68,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Autowired
|
|
|
private CollectNoteMapper collectNoteMapper;
|
|
|
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private WxTokenService wxTokenService;
|
|
|
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
@@ -386,7 +390,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
if(bo.getPwd()==null){
|
|
|
throw new CustomException("密码不能为空");
|
|
|
}
|
|
|
- String key = Constants.REGISTER + bo.getTel();
|
|
|
+ String key = Constants.REGISTER_SMS + bo.getTel();
|
|
|
String code = redisCache.getCacheObject(key);
|
|
|
if(code==null){
|
|
|
throw new CustomException("验证码错误");
|
|
@@ -421,6 +425,86 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean forgetUser(UserAppForgetBo bo) {
|
|
|
+ if(bo.getTel()==null){
|
|
|
+ throw new CustomException("手机号不能为空");
|
|
|
+ }
|
|
|
+ if(bo.getPwd()==null){
|
|
|
+ throw new CustomException("密码不能为空");
|
|
|
+ }
|
|
|
+ String key = Constants.FORGET_SMS + bo.getTel();
|
|
|
+ String code = redisCache.getCacheObject(key);
|
|
|
+ if(code==null){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ if(!code.equals(bo.getCode())){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ User user = getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getTelphone,bo.getTel()).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("该手机号未注册");
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
|
+ user.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return userService.updateById(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String,Object> smsLogin(UserAppSmsLoginBo bo) {
|
|
|
+ if(bo.getTel()==null){
|
|
|
+ throw new CustomException("手机号不能为空");
|
|
|
+ }
|
|
|
+ String key = Constants.LOGIN_SMS + bo.getTel();
|
|
|
+ String code = redisCache.getCacheObject(key);
|
|
|
+ if(code==null){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ if(!code.equals(bo.getCode())){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ User user = getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getTelphone,bo.getTel()).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("该手机号未注册");
|
|
|
+ }
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
+ loginUser.setUser(user);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put(Constants.TOKEN,wxTokenService.createToken(loginUser));
|
|
|
+ map.put("user_account",user.getUserAccount());
|
|
|
+ map.put("full_info",Validator.isEmpty(user.getIdCard())?false:true); //是否完善身份信息
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> accountLogin(UserAppAccountLoginBo bo) {
|
|
|
+ if(Validator.isEmpty(bo.getAccount())){
|
|
|
+ throw new CustomException("账号不能为空");
|
|
|
+ }
|
|
|
+ User user = getOne(new LambdaQueryWrapper<User>().eq(User::getTelphone,bo.getAccount())
|
|
|
+ .or().eq(User::getIdCard, bo.getAccount()));
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("该账号不存在");
|
|
|
+ }
|
|
|
+ else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
|
|
+ {
|
|
|
+ throw new BaseException("对不起,您的账号:已停用");
|
|
|
+ }
|
|
|
+ if (!SecurityUtils.matchesPassword(bo.getPwd(),user.getPassword() ))
|
|
|
+ {
|
|
|
+ throw new BaseException("密码错误");
|
|
|
+ }
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
+ loginUser.setUser(user);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put(Constants.TOKEN,wxTokenService.createToken(loginUser));
|
|
|
+ map.put("user_account",user.getUserAccount());
|
|
|
+ map.put("full_info",Validator.isEmpty(user.getIdCard())?false:true); //是否完善身份信息
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前月第一天
|
|
|
* @param month
|