|
@@ -4,10 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.constant.AppConstant;
|
|
|
import com.fdkankan.common.constant.CameraConstant;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
-import com.fdkankan.common.util.Base64Converter;
|
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
|
import com.fdkankan.common.util.RandomUtil;
|
|
|
import com.fdkankan.common.util.SecurityUtil;
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
@@ -16,7 +16,6 @@ import com.fdkankan.ucenter.entity.CameraDetail;
|
|
|
import com.fdkankan.ucenter.entity.User;
|
|
|
import com.fdkankan.ucenter.service.*;
|
|
|
import com.fdkankan.ucenter.vo.request.AppLoginParam;
|
|
|
-import com.fdkankan.ucenter.vo.request.AppSceneParam;
|
|
|
import com.fdkankan.ucenter.vo.request.LoginParam;
|
|
|
import com.fdkankan.ucenter.vo.response.LoginVo;
|
|
|
import com.fdkankan.ucenter.vo.response.UserVo;
|
|
@@ -61,7 +60,7 @@ public class AppService {
|
|
|
if(!user.getPassword().equals(passwordCode)){
|
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3014, LoginConstant.FAILURE_MSG_3014);
|
|
|
}
|
|
|
- String token = this.redisLogin(user.getUserName(), 21800L);
|
|
|
+ String token = this.redisLogin(user.getUserName(), JSONObject.toJSONString(user),21800L);
|
|
|
LoginVo loginVo = commonLogin(user, param, token);
|
|
|
loginVo.getUser().setPassword(param.getPassword());
|
|
|
return loginVo;
|
|
@@ -91,10 +90,14 @@ public class AppService {
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
- public String redisLogin(String userName,Long time){
|
|
|
+ public String redisLogin(String userName,String value,Long time){
|
|
|
String token = JwtUtil.createJWT(-1,userName,"app");
|
|
|
String redisKey = RedisKeyUtil.PREFIX_CACHE_CAMERA+ userName;
|
|
|
redisUtil.set(redisKey, token,time);
|
|
|
+
|
|
|
+ //设置官网token
|
|
|
+ String redisKey2 = String.format(RedisKey.TOKEN_V3 , token );
|
|
|
+ redisUtil.set(redisKey2, value,time);
|
|
|
return token;
|
|
|
}
|
|
|
|
|
@@ -107,7 +110,7 @@ public class AppService {
|
|
|
redisUtil.set(param.getUuid(),param.getAppUserName(),60 * 5);
|
|
|
}
|
|
|
|
|
|
- private void commonCheckCamera(AppLoginParam param){
|
|
|
+ private Long commonCheckCamera(AppLoginParam param){
|
|
|
Camera camera = cameraService.getBySnCodeAndPassword(param.getAppUserName(),param.getAppPassword());
|
|
|
if(camera == null){
|
|
|
throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
@@ -116,14 +119,20 @@ public class AppService {
|
|
|
if (detail == null ){
|
|
|
throw new BusinessException(AppConstant.FAILURE_CODE_4012, AppConstant.FAILURE_MSG_4012);
|
|
|
}
|
|
|
+ return detail.getUserId();
|
|
|
}
|
|
|
|
|
|
public JSONObject login2(AppLoginParam param) {
|
|
|
if(StringUtils.isEmpty(param.getAppUserName()) || StringUtils.isEmpty(param.getAppPassword())){
|
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
|
|
|
}
|
|
|
- commonCheckCamera(param);
|
|
|
- String token = redisLogin(param.getAppUserName(), 604800L);
|
|
|
+ Long userId = commonCheckCamera(param);
|
|
|
+ String redisValue = "";
|
|
|
+ if(userId!= null){
|
|
|
+ User user = userService.getById(userId);
|
|
|
+ redisValue = JSONObject.toJSONString(user);
|
|
|
+ }
|
|
|
+ String token = redisLogin(param.getAppUserName(),redisValue, 604800L);
|
|
|
JSONObject obj = new JSONObject();
|
|
|
obj.put("token", token);
|
|
|
return obj;
|
|
@@ -139,7 +148,7 @@ public class AppService {
|
|
|
if(user == null){
|
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
|
|
|
}
|
|
|
- String token = redisLogin(param.getPhoneNum(), 21600L);
|
|
|
+ String token = redisLogin(param.getPhoneNum(), JSONObject.toJSONString(user),21600L);
|
|
|
return commonLogin(user,param,token);
|
|
|
}
|
|
|
|