123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package com.fdkankan.ucenter.controller.inner;
- import com.fdkankan.common.constant.ErrorCode;
- import com.fdkankan.common.exception.BusinessException;
- import com.fdkankan.sign.SignUtils;
- import com.fdkankan.ucenter.annotation.VerifySign;
- import com.fdkankan.ucenter.common.BaseController;
- import com.fdkankan.ucenter.common.Result;
- import com.fdkankan.ucenter.common.constants.ResultCode;
- import com.fdkankan.ucenter.constant.LoginConstant;
- import com.fdkankan.ucenter.entity.AppSecret;
- import com.fdkankan.ucenter.entity.User;
- import com.fdkankan.ucenter.service.IAppSecretService;
- import com.fdkankan.ucenter.service.IInnerService;
- import com.fdkankan.ucenter.service.IUserService;
- import com.fdkankan.ucenter.service.impl.LoginService;
- import com.fdkankan.ucenter.vo.request.SceneParam;
- import org.apache.commons.lang3.ObjectUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.*;
- /**
- * <p>
- * 内部接口控制器
- * </p>
- *
- * @author dengsixing
- * @since 2022/8/19
- **/
- @RestController
- @RequestMapping("/ucenter/_inner")
- public class InnerController extends BaseController {
- @Autowired
- private IInnerService innerService;
- @Autowired
- IUserService userService;
- @Autowired
- LoginService loginService;
- @Autowired
- IAppSecretService appSecretService;
- /**
- * 根据场景码获取token
- */
- @GetMapping("/_token")
- @VerifySign
- public Result createTokenByNum(String num){
- return innerService.createTokenByNum(num);
- }
- /**
- * 查询场景资源路径
- */
- @GetMapping("/querySceneDataSource")
- @VerifySign
- public String querySceneDataSource(String num){
- return innerService.querySceneDataSource(num);
- }
- /**
- * 查询场景资源路径
- */
- @GetMapping("/querySceneNum")
- @VerifySign
- public Result querySceneNum(String path){
- if(ObjectUtils.isEmpty(path)){
- return Result.failure("请输入路径");
- }
- return innerService.querySceneNum(path);
- }
- /**
- * 查询场景资源路径
- */
- @GetMapping("/getAllSceneDbInfo")
- @VerifySign
- public Result getAllSceneDbInfo(String num){
- if(ObjectUtils.isEmpty(num)){
- return Result.failure("请输入场景码");
- }
- return innerService.querySceneNum(num);
- }
- /**
- * 查询场景资源路径
- */
- @GetMapping("/downloadCapture")
- @VerifySign
- public Result downloadCapture(String num){
- if(ObjectUtils.isEmpty(num)){
- return Result.failure("请输入场景号");
- }
- return innerService.downloadCapture(num);
- }
- /**
- * 根据场景码获取场景码版本 深时使用
- */
- @GetMapping("/_getSceneNumVersion")
- @VerifySign
- public Result getSceneNumVersion(@RequestParam(required = false) String num){
- if(StringUtils.isBlank(num)){
- throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
- }
- return Result.success(innerService.getSceneInfo(num));
- }
- @GetMapping(value = "/getSnCode/{snCode}")
- @VerifySign
- public Result getSnCode( @PathVariable String snCode) {
- if(StringUtils.isBlank(snCode)){
- throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
- }
- return Result.success(innerService.getCameraDetail(snCode));
- }
- @GetMapping("/getTokenByUserName/{userName}")
- @VerifySign
- public Result getTokenByUserName(@PathVariable String userName){
- User user = userService.getByUserName(userName);
- if(user == null){
- throw new BusinessException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
- }
- return Result.success(loginService.login(user));
- }
- @PostMapping(value = "/getSceneBySnCode")
- @VerifySign
- public Result getSceneSnCode( @RequestBody SceneParam param) {
- if(StringUtils.isBlank(param.getSnCode())){
- throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
- }
- return Result.success(innerService.getSceneBySnCode(param));
- }
- @Value("${ucenter.sign.appid}")
- public String sssappId;
- @GetMapping(value = "/pdsfsdfsrvateddsfeky/{appId}")
- public Result getPrivateKey(@PathVariable String appId){
- AppSecret appSecret = appSecretService.getByAppId(sssappId);
- if(appSecret == null){
- throw new com.fdkankan.ucenter.exception.BusinessException(ResultCode.SIGN_ERROR);
- }
- if(!SignUtils.checkSign(getSign(),appId,appSecret.getPrivateKey())){
- throw new com.fdkankan.ucenter.exception.BusinessException(ResultCode.SIGN_ERROR);
- }
- return Result.success(appSecretService.getByAppId(appId));
- }
- }
|