main
parent
fce07eaa2d
commit
25a0ee197e
|
|
@ -11,12 +11,10 @@ import com.mdd.common.core.AjaxResult;
|
|||
import com.mdd.common.entity.AppUser;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.enums.NoticeEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.AppUserMapper;
|
||||
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.plugin.notice.NoticeCheck;
|
||||
import com.mdd.common.plugin.wechat.WxMnpDriver;
|
||||
import com.mdd.common.util.*;
|
||||
import com.mdd.front.cache.ScanLoginCache;
|
||||
|
|
@ -108,7 +106,7 @@ public class LoginServiceImpl implements ILoginService {
|
|||
Assert.isFalse(!pwd.equals(user.getPassword()), "账号或密码错误!");
|
||||
Assert.isFalse(!user.getIsDisable().equals(0), "账号已被禁用!");
|
||||
|
||||
return this.__loginToken(user.getId(), user.getMobile(), user.getIsNew(), terminal);
|
||||
return this.__loginToken(user.getId(), user.getMobile(), terminal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -122,22 +120,22 @@ public class LoginServiceImpl implements ILoginService {
|
|||
@Override
|
||||
public LoginTokenVo mobileLogin(String mobile, String code, Integer terminal) {
|
||||
// 校验验证码
|
||||
int sceneCode = NoticeEnum.LOGIN_CODE.getCode();
|
||||
if (!NoticeCheck.verify(sceneCode, code)) {
|
||||
Object sceneCode = RedisUtils.get("app_code_" + mobile);
|
||||
|
||||
if (sceneCode == null || !sceneCode.equals(code)) {
|
||||
throw new OperateException("验证码错误!");
|
||||
}
|
||||
|
||||
// 查询手机号
|
||||
User user = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,username,mobile,is_disable,is_new")
|
||||
AppUser user = appUserMapper.selectOne(new QueryWrapper<AppUser>()
|
||||
.select("id,username,mobile")
|
||||
.eq("mobile", mobile)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(user, "账号不存在!");
|
||||
Assert.isFalse(user.getIsDisable() != 0, "账号已禁用!");
|
||||
|
||||
return this.__loginToken(user.getId(), user.getMobile(), user.getIsNew(), terminal);
|
||||
return this.__loginToken(user.getId(), user.getMobile(), terminal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -395,7 +393,7 @@ public class LoginServiceImpl implements ILoginService {
|
|||
userAuthMapper.updateById(auth);
|
||||
}
|
||||
|
||||
return this.__loginToken(user.getId(), user.getMobile(), user.getIsNew(), terminal);
|
||||
return this.__loginToken(user.getId(), user.getMobile(), terminal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -407,22 +405,16 @@ public class LoginServiceImpl implements ILoginService {
|
|||
* @param terminal 终端
|
||||
* @return LoginTokenVo
|
||||
*/
|
||||
private LoginTokenVo __loginToken(Integer userId, String mobile, Integer isNew, Integer terminal) {
|
||||
private LoginTokenVo __loginToken(Integer userId, String mobile, Integer terminal) {
|
||||
// 实现账号登录
|
||||
StpUtil.login(userId, String.valueOf(terminal));
|
||||
|
||||
// 更新登录信息
|
||||
User user = new User();
|
||||
user.setLastLoginIp(IpUtils.getHostIp());
|
||||
user.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||
userMapper.update(user, new QueryWrapper<User>().eq("id", userId));
|
||||
|
||||
RedisUtils.del("app_code_" + mobile);
|
||||
// 返回登录信息
|
||||
LoginTokenVo vo = new LoginTokenVo();
|
||||
vo.setId(userId);
|
||||
vo.setIsBindMobile(!StringUtils.isEmpty(mobile));
|
||||
vo.setMobile(mobile);
|
||||
vo.setToken(StpUtil.getTokenValue());
|
||||
vo.setIsNew(isNew);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@ public class LoginTokenVo implements Serializable {
|
|||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "绑定手机")
|
||||
private Boolean isBindMobile;
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "登录令牌")
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty(value = "是否为新用户")
|
||||
private Integer isNew;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue