|
@@ -1,5 +1,7 @@
|
|
|
package com.zhiqiyun.open.mvc.controller;
|
|
package com.zhiqiyun.open.mvc.controller;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
@@ -11,14 +13,18 @@ import com.zhiqiyun.open.annotation.Permission;
|
|
|
import com.zhiqiyun.open.core.enmus.YN;
|
|
import com.zhiqiyun.open.core.enmus.YN;
|
|
|
import com.zhiqiyun.open.core.models.app.ApiRequestLog;
|
|
import com.zhiqiyun.open.core.models.app.ApiRequestLog;
|
|
|
import com.zhiqiyun.open.core.models.app.AppKeyInfo;
|
|
import com.zhiqiyun.open.core.models.app.AppKeyInfo;
|
|
|
|
|
+import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
import com.zhiqiyun.open.core.service.ApiRequestLogService;
|
|
import com.zhiqiyun.open.core.service.ApiRequestLogService;
|
|
|
import com.zhiqiyun.open.core.service.AppKeyInfoService;
|
|
import com.zhiqiyun.open.core.service.AppKeyInfoService;
|
|
|
|
|
+import com.zhiqiyun.open.core.service.OauthService;
|
|
|
import com.zhiqiyun.open.core.service.SequenceService;
|
|
import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
|
import com.zhiqiyun.open.mvc.params.QueryApiRequestLogParams;
|
|
import com.zhiqiyun.open.mvc.params.QueryApiRequestLogParams;
|
|
|
import com.zhiqiyun.open.mvc.params.QueryAppKeyInfoParams;
|
|
import com.zhiqiyun.open.mvc.params.QueryAppKeyInfoParams;
|
|
|
import com.zhiqiyun.open.mvc.params.SaveAppKeyInfoParam;
|
|
import com.zhiqiyun.open.mvc.params.SaveAppKeyInfoParam;
|
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
|
|
|
+import com.zhiqiyun.open.utils.ServletContext;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -27,12 +33,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/appKey")
|
|
@RequestMapping("/appKey")
|
|
|
public class AppKeyInfoController {
|
|
public class AppKeyInfoController {
|
|
@@ -49,11 +55,20 @@ public class AppKeyInfoController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RouterService routerService;
|
|
private RouterService routerService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private OauthService oauthService;
|
|
|
|
|
+
|
|
|
@Permission(value = "app.key.find", tags = "查询AppKey")
|
|
@Permission(value = "app.key.find", tags = "查询AppKey")
|
|
|
@PostMapping("/findPage")
|
|
@PostMapping("/findPage")
|
|
|
public Result findPage(@RequestBody QueryAppKeyInfoParams params) {
|
|
public Result findPage(@RequestBody QueryAppKeyInfoParams params) {
|
|
|
-
|
|
|
|
|
QueryWrapper<AppKeyInfo> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<AppKeyInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ String accessToken = ServletContext.getAccessToken();
|
|
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(accessToken);
|
|
|
|
|
+ log.info("当前用户信息:{}", JSONObject.toJSONString(oauthInfo));
|
|
|
|
|
+ if (StrUtil.isNotBlank(oauthInfo.getOpenKey())) {
|
|
|
|
|
+ queryWrapper.in("id", Arrays.stream(oauthInfo.getOpenKey().split(","))
|
|
|
|
|
+ .map(Long::parseLong).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
if (params.getId() != null) {
|
|
if (params.getId() != null) {
|
|
|
queryWrapper.eq("id", params.getId());
|
|
queryWrapper.eq("id", params.getId());
|
|
|
}
|
|
}
|
|
@@ -63,12 +78,9 @@ public class AppKeyInfoController {
|
|
|
if (StringUtils.isNotBlank(params.getRemark())) {
|
|
if (StringUtils.isNotBlank(params.getRemark())) {
|
|
|
queryWrapper.like("remark", params.getRemark());
|
|
queryWrapper.like("remark", params.getRemark());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
Page<AppKeyInfo> page = params.getPage();
|
|
Page<AppKeyInfo> page = params.getPage();
|
|
|
page.addOrder(OrderItem.desc("created_time"));
|
|
page.addOrder(OrderItem.desc("created_time"));
|
|
|
-
|
|
|
|
|
Page<AppKeyInfo> resultData = this.appKeyInfoService.page(page, queryWrapper);
|
|
Page<AppKeyInfo> resultData = this.appKeyInfoService.page(page, queryWrapper);
|
|
|
-
|
|
|
|
|
return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
}
|
|
}
|
|
|
|
|
|