|
@@ -1,19 +1,8 @@
|
|
package com.fdkankan.ucenter.controller.inner;
|
|
package com.fdkankan.ucenter.controller.inner;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
|
-import com.fdkankan.common.exception.BusinessException;
|
|
|
|
-import com.fdkankan.common.util.JwtUtil;
|
|
|
|
-import com.fdkankan.redis.constant.RedisKey;
|
|
|
|
-import com.fdkankan.redis.util.RedisUtil;
|
|
|
|
import com.fdkankan.ucenter.common.BaseController;
|
|
import com.fdkankan.ucenter.common.BaseController;
|
|
import com.fdkankan.ucenter.common.Result;
|
|
import com.fdkankan.ucenter.common.Result;
|
|
-import com.fdkankan.ucenter.entity.ScenePro;
|
|
|
|
-import com.fdkankan.ucenter.entity.User;
|
|
|
|
-import com.fdkankan.ucenter.service.ISceneProService;
|
|
|
|
-import com.fdkankan.ucenter.service.IUserService;
|
|
|
|
-import com.fdkankan.web.util.WebUtil;
|
|
|
|
|
|
+import com.fdkankan.ucenter.service.IInnerService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -28,37 +17,19 @@ import org.springframework.web.bind.annotation.RestController;
|
|
* @since 2022/8/19
|
|
* @since 2022/8/19
|
|
**/
|
|
**/
|
|
@RestController
|
|
@RestController
|
|
-@RequestMapping("/inner")
|
|
|
|
|
|
+@RequestMapping("/_inner")
|
|
public class InnerController extends BaseController {
|
|
public class InnerController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private ISceneProService sceneProService;
|
|
|
|
- @Autowired
|
|
|
|
- private IUserService userService;
|
|
|
|
- @Autowired
|
|
|
|
- private RedisUtil redisUtil;
|
|
|
|
|
|
+ private IInnerService innerService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据场景码获取token
|
|
* 根据场景码获取token
|
|
*/
|
|
*/
|
|
- @GetMapping("/createTokenByNum")
|
|
|
|
|
|
+ @GetMapping("/_token")
|
|
public Result createTokenByNum(String num) throws Exception{
|
|
public Result createTokenByNum(String num) throws Exception{
|
|
-
|
|
|
|
- String requestIp = WebUtil.getIpAddress(this.request);
|
|
|
|
- if(!"221.4.210.172".equals(requestIp)){
|
|
|
|
- throw new BusinessException(ErrorCode.HAVE_NO_RIGHT);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ScenePro sceneProEntity = sceneProService.getByNum(num);
|
|
|
|
- User user = userService.getById(sceneProEntity.getUserId());
|
|
|
|
- String token = JwtUtil.createJWT(-1, user.getUserName(), "user");
|
|
|
|
- String redisKey = String.format(RedisKey.TOKEN_V3,token);
|
|
|
|
- redisUtil.set(redisKey, JSON.toJSONString(user), RedisKey.EXPIRE_TIME_2_HOUR);
|
|
|
|
-
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
|
- object.put("token", token);
|
|
|
|
-
|
|
|
|
- return Result.success(object);
|
|
|
|
|
|
+ String customToken = request.getHeader("custom-token");
|
|
|
|
+ return innerService.createTokenByNum(num, customToken);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|