提交 133b8a35 作者: zhenjie

登录字段添加

上级 3c361661
......@@ -21,6 +21,7 @@ public class LoginSuccessDTO implements Serializable {
private String token;
private Integer userAccountId;
private String accountNo;
private Integer portType;
private String uid;
private String phoneNum;
private String userName;
......
......@@ -30,4 +30,8 @@ public class AppUserSucVO implements Serializable {
private String nickName;
@ApiModelProperty(value = "sessionKey")
private String sessionKey;
@ApiModelProperty(value = "端口:0后台管理账号 ; 100云享飞-客户端;")
private Integer portType;
@ApiModelProperty(value = "端口:0后台管理账号 ; 100云享飞-客户端;")
private Integer authStatus;
}
......@@ -9,6 +9,7 @@ public interface JwtConstant {
public final static String SUBJECT = "mmc_iuav888";
public final static String ISSUER = "mmc_uav";
public final static long EXPIRATION = 1 * 24 * 60 * 60 * 1000L;
public final static long TEMP_EXPIRATION = 10 * 60 * 1000L;
public final static String TOKEN_TYPE = "TOKEN_TYPE";
public final static String M_TOKEN = "M_TOKEN"; //后台管理用户token
public final static String IUAV_TOKEN = "IUAV_TOKEN"; //小程序token
......
......@@ -16,7 +16,7 @@ public enum ResultEnum implements BaseErrorInfoInterface{
LOGIN_ACCOUNT_NOT_EXIT_ERROR("5005", "账号不存在"),
LOGIN_PASSWORD_ERROR("5006", "密码错误"),
LOGIN_ACCOUNT_STATUS_ERROR("5008", "外部访问"),
LOGIN_ACCOUNT_STATUS_ERROR("5008", "未登录"),
//微信相关
PASSWORD_INCONSISTENT("5026", "新密码与确认密码不一致,请确认一致"),
......
......@@ -34,6 +34,7 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor {
String requestURI = request.getRequestURI();
String remoteHost = request.getRemoteHost();
System.out.println("remoteHost: " + remoteHost);
System.out.println("getServerName: " + request.getServerName());
// //根据uri确认是否要拦截
// if (!shouldFilter(requestURI)){
// return true;
......@@ -41,17 +42,13 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor {
// String token = request.getHeader("token");
// String tokenJson = stringRedisTemplate.opsForValue().get(token);
//
// if (request.getServerName().equals("iuav.mmcuav.cn")){
// if (StringUtils.isBlank(tokenJson)){
// exceptionProcess(response);
// return false;
// }
// LoginSuccessDTO loginSuccessDTO = JSONObject.parseObject(tokenJson, LoginSuccessDTO.class);
// if (loginSuccessDTO != null){
// request.setAttribute("userAccountId", loginSuccessDTO.getUserAccountId());
// return true;
// }
return true;
}
......
......@@ -10,6 +10,8 @@ import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.auth.PwdUtil;
import com.mmc.iuav.user.constant.WxConstant;
import com.mmc.iuav.user.dao.CompanyAuthDao;
import com.mmc.iuav.user.entity.CompanyAuthDO;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.enums.UserAccountStatus;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
......@@ -48,6 +50,9 @@ public class AuthServiceImpl implements AuthService {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private CompanyAuthDao companyAuthDao;
@Override
public ResultBody appletLogin(WxLoginVO wxLoginVO) {
String unionId;
......@@ -89,6 +94,7 @@ public class AuthServiceImpl implements AuthService {
//数据库查询用户信息
UserAccountVO userAccountVO = userAccountService.getUserAccountInfoByUnionId(unionId);
String uid;
Integer companyAuthStatus = 0;
if (userAccountVO == null) {
UserAccountDO userAccountDO = new UserAccountDO();
userAccountDO.setUnionId(unionId);
......@@ -102,6 +108,10 @@ public class AuthServiceImpl implements AuthService {
userAccountVO = userAccountDO.buildUserAccountVO();
}else {
uid = userAccountVO.getUid();
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountVO.getId());
if (companyAuthDO != null) {
companyAuthStatus = companyAuthDO.getAuthStatus();
}
}
Map<String, Object> map = new HashMap<String, Object>();
map.put(JwtConstant.USER_ACCOUNT_ID, userAccountVO.getId());
......@@ -110,14 +120,14 @@ public class AuthServiceImpl implements AuthService {
String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).userAccountId(userAccountVO.getId()).accountNo(userAccountVO.getAccountNo()).uid(uid)
.userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).build();
.userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).portType(100).build();
stringRedisTemplate.opsForValue().set(
token, JSONObject.toJSONString(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
return ResultBody.success(AppUserSucVO.builder().token(token).uid(userAccountVO.getUid()).phoneNum(userAccountVO.getPhoneNum())
.nickName(userAccountVO.getNickName()).userAccountId(userAccountVO.getId()).sessionKey(sessionKey).build());
.nickName(userAccountVO.getNickName()).userAccountId(userAccountVO.getId()).sessionKey(sessionKey).portType(100).authStatus(companyAuthStatus).build());
}
@Override
......@@ -147,12 +157,12 @@ public class AuthServiceImpl implements AuthService {
map.put(JwtConstant.TOKEN_TYPE, JwtConstant.M_TOKEN);
String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).userAccountId(user.getId()).accountNo(user.getAccountNo()).uid(user.getUid())
.userName(user.getUserName()).nickName(user.getNickName()).phoneNum(user.getPhoneNum()).build();
.userName(user.getUserName()).nickName(user.getNickName()).phoneNum(user.getPhoneNum()).portType(100).build();
stringRedisTemplate.opsForValue().set(
token, JSONObject.toJSONString(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
return ResultBody.success(LoginSuccessDTO.builder().token(token).userAccountId(user.getId()).accountNo(user.getAccountNo()).build());
return ResultBody.success(LoginSuccessDTO.builder().token(token).userAccountId(user.getId()).accountNo(user.getAccountNo()).portType(100).build());
}
@Override
......@@ -162,15 +172,20 @@ public class AuthServiceImpl implements AuthService {
Map<String, Object> map = new HashMap<String, Object>();
map.put(JwtConstant.USER_ACCOUNT_ID, userAccountVO.getId());
map.put(JwtConstant.TOKEN_TYPE, JwtConstant.IUAV_TOKEN);
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountVO.getId());
Integer companyAuthStatus = 0;
if (companyAuthDO != null) {
companyAuthStatus = companyAuthDO.getAuthStatus();
}
String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).userAccountId(userAccountVO.getId()).accountNo(userAccountVO.getAccountNo()).uid(userAccountVO.getUid())
.userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).build();
.userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).portType(100).build();
stringRedisTemplate.opsForValue().set(
token, JSONObject.toJSONString(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
return ResultBody.success(AppUserSucVO.builder().token(token).uid(userAccountVO.getUid()).phoneNum(userAccountVO.getPhoneNum())
.nickName(userAccountVO.getNickName()).userAccountId(userAccountVO.getId()).build());
.nickName(userAccountVO.getNickName()).userAccountId(userAccountVO.getId()).portType(100).authStatus(companyAuthStatus).build());
}
return ResultBody.error(ResultEnum.APPLET_LOGIN_ERROR);
}
......@@ -179,7 +194,7 @@ public class AuthServiceImpl implements AuthService {
public ResultBody tempConfirmLogin(LoginSuccessDTO loginSuccessDTO, String randomLoginCode) {
stringRedisTemplate.opsForValue().set(
randomLoginCode, JSONObject.toJSONString(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
JwtConstant.TEMP_EXPIRATION, TimeUnit.MILLISECONDS);
return ResultBody.success();
}
......
......@@ -12,3 +12,4 @@ data-filter:
- /userapp/cooperation/listTag
- /userapp/temp-auth/getLoginInfo
- /userapp/wx/getAppletQRCode
- /userapp/wx/wxSendMessage
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论