Compare commits
300 Commits
master
...
dev_monito
| Author | SHA1 | Date |
|---|---|---|
|
|
4c63f2f369 | |
|
|
a4412b8d70 | |
|
|
2320982887 | |
|
|
a56cd53feb | |
|
|
74f9063e4a | |
|
|
bc0aed63c9 | |
|
|
20b7e93bfb | |
|
|
9e637de0c5 | |
|
|
e21dd46aaa | |
|
|
d2a7a74ef6 | |
|
|
4485d8b5a2 | |
|
|
d9a5821cc5 | |
|
|
f91685320b | |
|
|
fc420f7b8e | |
|
|
d4dac70695 | |
|
|
8670953e8a | |
|
|
7ea1f7fde5 | |
|
|
ee48cf7547 | |
|
|
823adf4853 | |
|
|
7e3be6366f | |
|
|
4264a4f1ad | |
|
|
815b500947 | |
|
|
986c522f7c | |
|
|
68b958208c | |
|
|
2d142a428f | |
|
|
ea9d0ff37c | |
|
|
3133fdce15 | |
|
|
c10f49d209 | |
|
|
9e49f23a70 | |
|
|
1fc41ead3b | |
|
|
1155e4a4b8 | |
|
|
3b13534717 | |
|
|
5ed80f2769 | |
|
|
bd153dec44 | |
|
|
8601e91125 | |
|
|
7e29c5b8de | |
|
|
998dad05e7 | |
|
|
f3ba40e400 | |
|
|
be61b61b85 | |
|
|
c54c31d711 | |
|
|
5508a34a51 | |
|
|
c939148c75 | |
|
|
0eaf82e3c7 | |
|
|
4c62b8c1f5 | |
|
|
e74cbd5d8a | |
|
|
c52e178f4d | |
|
|
69d627f8e5 | |
|
|
4ccda26fd5 | |
|
|
7f07d226da | |
|
|
7a28e98b5d | |
|
|
7dd24d43bc | |
|
|
10fe8855d5 | |
|
|
65a5089ddc | |
|
|
ebab84d04b | |
|
|
ee7f36bb8f | |
|
|
0450126d84 | |
|
|
419548cb52 | |
|
|
c433080296 | |
|
|
850a477d17 | |
|
|
95b35d1847 | |
|
|
9394e9f9a0 | |
|
|
14bdda20a1 | |
|
|
cb5cc6e3b4 | |
|
|
93aca87a0b | |
|
|
9300a8f092 | |
|
|
4ff20b445b | |
|
|
9d110b608d | |
|
|
561363ea1b | |
|
|
2116f7cadd | |
|
|
afc7c9f20a | |
|
|
3fdfee7bd5 | |
|
|
4513ae20d6 | |
|
|
4ada9fc829 | |
|
|
2eb21023e4 | |
|
|
f46b3c40b3 | |
|
|
e8bdc8fc92 | |
|
|
3a0f0d84c5 | |
|
|
569eaa14ff | |
|
|
3fad2b311f | |
|
|
10323b94f1 | |
|
|
33e77ed05b | |
|
|
7c785d4743 | |
|
|
c890870e09 | |
|
|
07a70f12ce | |
|
|
5daaa3d54a | |
|
|
e87484b1e1 | |
|
|
02791388bd | |
|
|
5d14d5e56a | |
|
|
e3ddab5ceb | |
|
|
587a2707a7 | |
|
|
992c17b4c8 | |
|
|
0aa96e853a | |
|
|
34ab56eb8a | |
|
|
bdbd2da88d | |
|
|
30f8ce8184 | |
|
|
7fbfbdaf8d | |
|
|
93ed7838e6 | |
|
|
68988926b9 | |
|
|
5485d39894 | |
|
|
2516ba038e | |
|
|
bb9b4f05da | |
|
|
4bbf3c91e2 | |
|
|
00bde1ad9a | |
|
|
092d566de4 | |
|
|
27c5e64e1a | |
|
|
71f4e4bc8f | |
|
|
8c8e13a5e1 | |
|
|
82c74b9184 | |
|
|
290fc64c88 | |
|
|
b0aede3f93 | |
|
|
902f961469 | |
|
|
e904d854f6 | |
|
|
3dbdef7ab8 | |
|
|
072e85de82 | |
|
|
8f48c1030a | |
|
|
9380081443 | |
|
|
0646a3b773 | |
|
|
43e75440d5 | |
|
|
0ca345d200 | |
|
|
83c1457c50 | |
|
|
3f208de48a | |
|
|
bce79534bd | |
|
|
f402ec1748 | |
|
|
7de259d088 | |
|
|
1c9bc630d8 | |
|
|
c13748d494 | |
|
|
69e789d856 | |
|
|
02f215c2e4 | |
|
|
d1076e48d5 | |
|
|
b25411e35c | |
|
|
1f3d65fd39 | |
|
|
3f155f2270 | |
|
|
ee77bdb8a1 | |
|
|
631f6752a6 | |
|
|
39a8dde543 | |
|
|
0f0a639bf4 | |
|
|
cf2c5cffa3 | |
|
|
b89c235df3 | |
|
|
2d5d43b37e | |
|
|
32b58df5d1 | |
|
|
555ef0fc80 | |
|
|
46cbaccf64 | |
|
|
ebf1dc53cf | |
|
|
e6dadf2ccd | |
|
|
71cf4fb6fc | |
|
|
eed4b9d9eb | |
|
|
cad9ea1247 | |
|
|
02e369849d | |
|
|
f7e9d9350e | |
|
|
356b85fd35 | |
|
|
19a32e2f7c | |
|
|
b2f9921664 | |
|
|
2567386baa | |
|
|
8e10fee65f | |
|
|
310b423ec9 | |
|
|
705823ec3f | |
|
|
172e0ee92e | |
|
|
726ece8af9 | |
|
|
82f180d31c | |
|
|
e91ee14d63 | |
|
|
10a1b3f5cf | |
|
|
7f22a2c6ec | |
|
|
9c76980bdc | |
|
|
a861d69061 | |
|
|
53274c3b0e | |
|
|
32ded69b77 | |
|
|
36e9d84dd8 | |
|
|
4e0d281bf7 | |
|
|
fbcbe63ad4 | |
|
|
48e0510bb3 | |
|
|
3726e4b294 | |
|
|
335d05d2c3 | |
|
|
fa4ee4526b | |
|
|
405b2e07c1 | |
|
|
c6fd9a1c9d | |
|
|
bfbaa3491d | |
|
|
c97b64f3bc | |
|
|
83c8d5fe3e | |
|
|
7cff154598 | |
|
|
d0fcf1fbce | |
|
|
3cf7ced976 | |
|
|
ddb1a06acc | |
|
|
0c94e636e1 | |
|
|
0f2d37babe | |
|
|
6e72d6f762 | |
|
|
d330e7a56d | |
|
|
29dbc84989 | |
|
|
f055d0f28e | |
|
|
20ce451a9a | |
|
|
629822dcb9 | |
|
|
e7ca96f280 | |
|
|
f9956c305e | |
|
|
d13b38e980 | |
|
|
45c84d17b6 | |
|
|
71ec75c3e5 | |
|
|
0d0b0072c3 | |
|
|
8f84d425c8 | |
|
|
1cb6c3e758 | |
|
|
17a911c54e | |
|
|
adc86b04c9 | |
|
|
cd19bd94cc | |
|
|
dc814cffff | |
|
|
92bfd2c7f2 | |
|
|
6a71629784 | |
|
|
1e016300c7 | |
|
|
fdf61667f7 | |
|
|
22f350510c | |
|
|
2566f119d3 | |
|
|
19718b6123 | |
|
|
3fa2daac28 | |
|
|
2d304cfae0 | |
|
|
1f2f48c120 | |
|
|
19e298b67a | |
|
|
f70681d783 | |
|
|
8abb5a38bd | |
|
|
9eb10143f7 | |
|
|
9865c8bad9 | |
|
|
bc92fb8419 | |
|
|
a25048faad | |
|
|
8c068c4b79 | |
|
|
735d7fd9e9 | |
|
|
705a9241b6 | |
|
|
03b7c170e4 | |
|
|
0c0f27810e | |
|
|
4fd5c1cc4d | |
|
|
65a5b5d081 | |
|
|
e97b972f31 | |
|
|
828901d322 | |
|
|
33185a1d0c | |
|
|
29b6b2bbae | |
|
|
2883029641 | |
|
|
5eed69522c | |
|
|
c5d99153b8 | |
|
|
6f4a10f1cb | |
|
|
c6f58972a6 | |
|
|
53795b1b88 | |
|
|
1f653894cd | |
|
|
5af3df62ee | |
|
|
fde9893840 | |
|
|
e44f63a4c6 | |
|
|
6d47364cca | |
|
|
128a107f8f | |
|
|
65aaa7df5b | |
|
|
b1da0ba006 | |
|
|
ad3625a823 | |
|
|
115a3cbe12 | |
|
|
c9d08ef3d5 | |
|
|
3f795fadb5 | |
|
|
672476ba53 | |
|
|
1f55a7835e | |
|
|
0b16dbf195 | |
|
|
8111f6db61 | |
|
|
ae073b68bc | |
|
|
14072b1dff | |
|
|
12eecde9c4 | |
|
|
66e1b9aca6 | |
|
|
93e56ed555 | |
|
|
13d5e7aa46 | |
|
|
dc9a537feb | |
|
|
3d5d6bfc6e | |
|
|
bac9eeda5f | |
|
|
18f89d1b8e | |
|
|
c3b5dcafba | |
|
|
a0aec9bf88 | |
|
|
a511f39a13 | |
|
|
75f828b76c | |
|
|
4b1042c25d | |
|
|
e9c41768e1 | |
|
|
15aa7016b9 | |
|
|
f96cee3f4a | |
|
|
055b26ee29 | |
|
|
368a45e8b2 | |
|
|
2c5f0518ca | |
|
|
06fbbf7208 | |
|
|
6613950ff8 | |
|
|
8184eb2401 | |
|
|
213aee5587 | |
|
|
274af358dd | |
|
|
58bf8326c5 | |
|
|
5e19e53b94 | |
|
|
2be36ca12e | |
|
|
ad405c912e | |
|
|
6ef1fafac8 | |
|
|
39d43e3d68 | |
|
|
1eefa65c32 | |
|
|
c6b4a1bd80 | |
|
|
21ba1ce6bd | |
|
|
dd870b3cd3 | |
|
|
417d440549 | |
|
|
67b2e9ce7c | |
|
|
32b83749e2 | |
|
|
010d5e5354 | |
|
|
94e0be0e71 | |
|
|
2845d19aae | |
|
|
97b1c9437c | |
|
|
b0f9e06e18 | |
|
|
f58af4b0b5 | |
|
|
78cbd4b0ee | |
|
|
fca8490bdd | |
|
|
616bf1229f |
|
|
@ -0,0 +1,26 @@
|
|||
package com.microservices.system.api;
|
||||
|
||||
import com.microservices.common.core.constant.ServiceNameConstants;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.system.api.domain.SysDictData;
|
||||
import com.microservices.system.api.factory.RemoteDictFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@FeignClient(contextId = "remoteDictDataService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteDictFallbackFactory.class)
|
||||
public interface RemoteDictDataService {
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/dict/data/type/{dictType}")
|
||||
R<List<SysDictData>> dictType(@PathVariable("dictType") String dictType);
|
||||
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件服务
|
||||
|
|
@ -34,6 +35,17 @@ public interface RemoteFileService {
|
|||
@RequestParam("hierarchy") String hierarchy,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* Base64 图片上传(HashMap 版本)
|
||||
*/
|
||||
@PostMapping(value = "/upload/base64")
|
||||
R<SysFileInfo> uploadBase64(
|
||||
@RequestBody Map<String, Object> params,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam("hierarchy") String hierarchy,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source
|
||||
);
|
||||
|
||||
/**
|
||||
* 根据文件Id列表获取文件列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ package com.microservices.system.api;
|
|||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.constant.ServiceNameConstants;
|
||||
import com.microservices.common.core.constant.TokenConstants;
|
||||
import com.microservices.system.api.factory.RemoteGatewayFallbackFactory;
|
||||
import com.microservices.system.api.model.GraphqlQueryVo;
|
||||
import feign.Response;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -28,6 +28,14 @@ public interface RemoteGatewayService {
|
|||
@PostMapping("/sentinel/auth/login")
|
||||
Response loginSentinel(@RequestParam("username") String username, @RequestParam("password") String password);
|
||||
|
||||
/**
|
||||
* 登录Rancher
|
||||
*
|
||||
* @return 响应
|
||||
*/
|
||||
@PostMapping("/rancher/v3-public/localProviders/local?action=login")
|
||||
Response loginRancher(@RequestBody JSONObject loginBody);
|
||||
|
||||
/**
|
||||
* 登录Nacos
|
||||
*
|
||||
|
|
@ -43,4 +51,45 @@ public interface RemoteGatewayService {
|
|||
*/
|
||||
@PostMapping("/portainer/api/auth")
|
||||
Response loginPortainer(@RequestBody JSONObject loginBody);
|
||||
|
||||
@GetMapping("/prometheus/api/v1/query")
|
||||
JSONObject getPrometheusQueryRes(@RequestParam("query") String query,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/prometheus/api/v1/query_range")
|
||||
JSONObject getPrometheusQueryRangeRes(@RequestParam("query") String query,
|
||||
@RequestParam("step") Long step,
|
||||
@RequestParam("start") Long start,
|
||||
@RequestParam("end") Long end,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@PostMapping("/skywalking/graphql")
|
||||
JSONObject executeSkywalkingGql(@RequestBody GraphqlQueryVo gqlBody);
|
||||
|
||||
@GetMapping("/sentinel/app/briefinfos.json")
|
||||
JSONObject getSentinelAppList(@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/nacos/v1/ns/catalog/services?pageNo=1&pageSize=999")
|
||||
JSONObject getNacosServiceList(@RequestParam("serviceNameParam") String serviceNameParam, @RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/nacos/v1/cs/configs?types=yaml&search=blur&group=&pageNo=1&pageSize=10")
|
||||
JSONObject getGatewayNacosConfigList(@RequestParam("dataId") String dataId, @RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/nacos/v1/cs/listener")
|
||||
JSONObject getNacosConfigList(@RequestParam("ip") String ip, @RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/nacos/v1/cs/configs")
|
||||
String getNacosConfigDetail(@RequestParam("dataId") String dataId, @RequestParam("group") String group, @RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@PostMapping(value = "/nacos/v1/cs/configs", consumes = {"application/x-www-form-urlencoded"})
|
||||
Response updateNacosConfig(Map<String, ?> formParams, @RequestHeader(TokenConstants.AUTHENTICATION) String userKey);
|
||||
|
||||
@PostMapping("/es/{esIndex}/_search")
|
||||
JSONObject executeElasticsearchQuery(@PathVariable("esIndex") String esIndex, @RequestBody JSONObject esBody);
|
||||
|
||||
@PostMapping("/es/{esIndex}/_doc/{docId}/_update")
|
||||
JSONObject executeElasticsearchUpdate(@PathVariable("esIndex") String esIndex,@PathVariable("docId") String docId, @RequestBody JSONObject esBody);
|
||||
|
||||
@PostMapping("/gns/notification/gitlink")
|
||||
JSONObject sendNotification(@RequestBody JSONObject body);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
package com.microservices.system.api;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.constant.Constants;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
import com.microservices.common.core.constant.ServiceNameConstants;
|
||||
import com.microservices.common.core.constant.TokenConstants;
|
||||
import com.microservices.system.api.factory.RemoteGatewayFallbackFactory;
|
||||
import com.microservices.system.api.factory.RemoteRancherFallbackFactory;
|
||||
import feign.Response;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 网关
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Component
|
||||
@FeignClient(contextId = "RemoteRancherService", value = ServiceNameConstants.GATEWAY_SERVICE, fallbackFactory = RemoteRancherFallbackFactory.class)
|
||||
public interface RemoteRancherService {
|
||||
@GetMapping("/rancher/v3/clusters/{cluster_id}/namespaces")
|
||||
Response getK8sNamespaceList(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/apps.daemonsets?exclude=metadata.managedFields")
|
||||
Response getK8sDaemonsetsList(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/apps.deployments?exclude=metadata.managedFields")
|
||||
Response getK8sDeployList(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/apps.statefulsets?exclude=metadata.managedFields")
|
||||
Response getK8sStatefulList(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/nodes?exclude=metadata.managedFields")
|
||||
Response getK8sClusterNodeList(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/{fullKind}/{namespace}/{applicationName}")
|
||||
Response getK8sApplicationDetail(@PathVariable("cluster_id") String cluster_id,
|
||||
@PathVariable("fullKind") String fullKind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/pods/{namespace}")
|
||||
Response getK8sPodListByNamespace(@PathVariable("cluster_id") String cluster_id,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/pods")
|
||||
Response getK8sPodList(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/services/{nginxApplicationId}")
|
||||
Response getK8sServiceByApplicationId(@PathVariable("cluster_id") String cluster_id,
|
||||
@PathVariable("nginxApplicationId") String nginxApplicationId,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@DeleteMapping("/rancher/v1/pods/{namespace}/{podName}")
|
||||
Response deletePod(@PathVariable("namespace") String namespace,
|
||||
@PathVariable("podName") String podName,
|
||||
@RequestBody JSONObject deletePodBody,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@PutMapping("/rancher/v1/{fullKind}/{namespace}/{applicationName}")
|
||||
Response updateK8sApplication(@PathVariable("fullKind") String fullKind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestBody JSONObject applicationDetail,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String userKey);
|
||||
|
||||
@PostMapping(value = "/rancher/v1/{fullKind}", consumes = {Constants.YAML_CONTENT_TYPE})
|
||||
Response createK8sApplication(@PathVariable("fullKind") String fullName,
|
||||
@RequestBody String yamlContent,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String userKey);
|
||||
|
||||
@PostMapping(value = "/rancher/v1/management.cattle.io.clusters/{cluster_id}?action=apply")
|
||||
Response applyK8sYaml(@PathVariable("cluster_id") String cluster_id,
|
||||
@RequestBody JSONObject yamlContent,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String userKey);
|
||||
|
||||
@GetMapping("/rancher/apis/apps/v1/namespaces/{namespace}/{kindName}/{applicationName}")
|
||||
Response getApplicationYamlFile(@PathVariable("kindName") String kindName,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@PutMapping(value = "/rancher/v1/{fullKind}/{namespace}/{applicationName}", consumes = {Constants.YAML_CONTENT_TYPE})
|
||||
Response editK8sApplication(@PathVariable("fullKind") String fullKind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestBody String yamlContent,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@DeleteMapping("/rancher/v1/{fullKind}/{namespace}/{applicationName}")
|
||||
Response deleteApplication(@PathVariable("fullKind") String fullKind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/v1/configmaps/{namespace}")
|
||||
Response getK8sConfigmapByNamespace(@PathVariable("namespace") String namespace,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/v1/secrets/{namespace}")
|
||||
Response getK8sSecretByNamespace(@PathVariable("namespace") String namespace,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/rancher/k8s/clusters/{cluster_id}/v1/services/{namespace}")
|
||||
Response getK8sServiceByNamespace(@PathVariable("cluster_id") String cluster_id,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
|
||||
@DeleteMapping("/rancher/v1/services/{serviceId}")
|
||||
Response deleteK8sService(@PathVariable("serviceId") String serviceId,@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.microservices.system.api.factory;
|
||||
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.system.api.RemoteDictDataService;
|
||||
import com.microservices.system.api.domain.SysDictData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典服务降级处理
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Component
|
||||
public class RemoteDictFallbackFactory implements FallbackFactory<RemoteDictDataService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteDictFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteDictDataService create(Throwable throwable) {
|
||||
log.error("字典服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteDictDataService() {
|
||||
@Override
|
||||
public R<List<SysDictData>> dictType(String dictType) {
|
||||
return R.fail("获取字典列表失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件服务降级处理
|
||||
|
|
@ -36,6 +37,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||
return R.fail("上传文件失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<SysFileInfo> uploadBase64(Map<String, Object> params, String type, String hierarchy, String source) {
|
||||
return R.fail("上传base64文件失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysFileInfo>> getFileList(String fileIds) {
|
||||
return R.fail("获取文件列表失败:" + throwable.getMessage());
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.microservices.system.api.factory;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.system.api.RemoteGatewayService;
|
||||
import com.microservices.system.api.model.GraphqlQueryVo;
|
||||
import feign.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -25,7 +27,12 @@ public class RemoteGatewayFallbackFactory implements FallbackFactory<RemoteGatew
|
|||
return new RemoteGatewayService() {
|
||||
|
||||
@Override
|
||||
public Response loginSentinel(String password, String username) {
|
||||
public Response loginSentinel(String username, String password) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response loginRancher(JSONObject loginBody) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +43,66 @@ public class RemoteGatewayFallbackFactory implements FallbackFactory<RemoteGatew
|
|||
|
||||
@Override
|
||||
public Response loginPortainer(JSONObject loginBody) {
|
||||
System.out.println(throwable.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getPrometheusQueryRes(String query, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getPrometheusQueryRangeRes(String query, Long step, Long start, Long end, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject executeSkywalkingGql(GraphqlQueryVo gqlBody) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getSentinelAppList(String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getNacosServiceList(String serviceNameParam, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getGatewayNacosConfigList(String dataId, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getNacosConfigList(String ip, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNacosConfigDetail(String dataId, String group, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response updateNacosConfig(Map<String, ?> formParams, String userKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject executeElasticsearchQuery(String esIndex, JSONObject esBody) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject executeElasticsearchUpdate(String esIndex, String docId, JSONObject esBody) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject sendNotification(JSONObject body) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
package com.microservices.system.api.factory;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.system.api.RemoteGatewayService;
|
||||
import com.microservices.system.api.RemoteRancherService;
|
||||
import com.microservices.system.api.utils.FeignUtils;
|
||||
import feign.FeignException;
|
||||
import feign.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户服务降级处理
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Component
|
||||
public class RemoteRancherFallbackFactory implements FallbackFactory<RemoteRancherService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteRancherFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteRancherService create(Throwable throwable) {
|
||||
log.error("Rancher服务调用失败:{}", throwable.getMessage());
|
||||
|
||||
return new RemoteRancherService() {
|
||||
@Override
|
||||
public Response getK8sNamespaceList(String cluster_id, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sDaemonsetsList(String cluster_id, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sDeployList(String cluster_id, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sStatefulList(String cluster_id, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sClusterNodeList(String cluster_id, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sApplicationDetail(String cluster_id, String fullKind, String namespace, String applicationName, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sPodListByNamespace(String cluster_id, String namespace, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sPodList(String cluster_id, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sServiceByApplicationId(String cluster_id, String nginxApplicationId, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deletePod(String namespace, String podName, JSONObject deletePodBody, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response updateK8sApplication(String fullKind, String namespace, String applicationName, JSONObject applicationDetail, String userKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response createK8sApplication(String fullName, String yamlContent, String userKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response applyK8sYaml(String cluster_id, JSONObject yamlContent, String userKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getApplicationYamlFile(String kindName, String namespace, String applicationName, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response editK8sApplication(String fullKind, String namespace, String applicationName, String yamlContent, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteApplication(String fullKind, String namespace, String applicationName, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sConfigmapByNamespace(String namespace, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sSecretByNamespace(String namespace, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getK8sServiceByNamespace(String cluster_id, String namespace, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteK8sService(String serviceId, String token) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.microservices.system.api.model;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GraphqlQueryVo {
|
||||
String operationName;
|
||||
String query;
|
||||
JSONObject variables;
|
||||
}
|
||||
|
|
@ -3,20 +3,24 @@ package com.microservices.system.api.utils;
|
|||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import feign.Response;
|
||||
|
||||
/**
|
||||
* @author otto
|
||||
*/
|
||||
public class FeignUtils {
|
||||
public static <T> T getReturnData(R<T> result){
|
||||
public static <T> T getReturnData(R<T> result) {
|
||||
if (StringUtils.isNull(result)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (R.FAIL == result.getCode())
|
||||
{
|
||||
if (R.FAIL == result.getCode()) {
|
||||
throw new ServiceException(result.getMsg());
|
||||
}
|
||||
return result.getData();
|
||||
}
|
||||
|
||||
public static Boolean isSuccess(Response response) {
|
||||
return response != null && response.status() >= 200 && response.status() < 300;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package com.microservices.system.api.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class StandardMultipartFile implements MultipartFile {
|
||||
|
||||
private final byte[] content;
|
||||
private final String name;
|
||||
private final String originalFilename;
|
||||
private final String contentType;
|
||||
|
||||
public StandardMultipartFile(byte[] content, String name, String originalFilename, String contentType) {
|
||||
this.content = content != null ? content : new byte[0];
|
||||
this.name = name;
|
||||
this.originalFilename = originalFilename;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return originalFilename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return content.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return content.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
try (FileOutputStream fos = new FileOutputStream(dest)) {
|
||||
fos.write(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,3 +6,5 @@ com.microservices.system.api.factory.RemoteCmsFallbackFactory
|
|||
com.microservices.system.api.factory.RemoteZoneFallbackFactory
|
||||
com.microservices.system.api.factory.RemotePmsFallbackFactory
|
||||
com.microservices.system.api.factory.RemoteGatewayFallbackFactory
|
||||
com.microservices.system.api.factory.RemoteRancherFallbackFactory
|
||||
com.microservices.system.api.factory.RemoteDictFallbackFactory
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9110
|
||||
port: 8080
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -213,6 +213,11 @@ public class CacheConstants {
|
|||
*/
|
||||
public final static String SENTINEL_TOKEN = "sentinel_token";
|
||||
|
||||
/**
|
||||
* Rancher Token缓存Key
|
||||
*/
|
||||
public final static String RANCHER_TOKEN = "rancher_token";
|
||||
|
||||
|
||||
/**
|
||||
* Nacos Token缓存Key
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ package com.microservices.common.core.constant;
|
|||
*
|
||||
* @author microservices
|
||||
*/
|
||||
public class Constants
|
||||
{
|
||||
public class Constants {
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
|
|
@ -125,6 +124,10 @@ public class Constants
|
|||
* JSON类型
|
||||
*/
|
||||
public static final String JSON_CONTENT_TYPE = "application/json";
|
||||
/**
|
||||
* Yaml类型
|
||||
*/
|
||||
public static final String YAML_CONTENT_TYPE = "application/yaml";
|
||||
/**
|
||||
* 文本类型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ public class SecurityConstants
|
|||
*/
|
||||
public static final String USER_KEY = "user_key";
|
||||
|
||||
/**
|
||||
* 用户Token
|
||||
*/
|
||||
public static final String TOKEN = "token";
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,9 +22,16 @@ public class TokenConstants {
|
|||
* Sentinel令牌标识
|
||||
*/
|
||||
public static final String Sentinel_Token_Key = "sentinel_dashboard_cookie";
|
||||
/**
|
||||
* Rancher令牌标识
|
||||
*/
|
||||
public static final String Rancher_Cookie_Token_Key = "R_SESS";
|
||||
/**
|
||||
* Portainer令牌标识
|
||||
*/
|
||||
public static final String Portainer_Token_Key = "portainer_api_key";
|
||||
/**
|
||||
* Sentinel令牌标识
|
||||
* Nacos令牌标识
|
||||
*/
|
||||
public static final String Nacos_Token_Key = "Accesstoken";
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.microservices.common.core.threadPool;
|
||||
|
||||
import com.microservices.common.core.constant.TokenConstants;
|
||||
import com.microservices.common.core.context.SecurityContextHolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -37,6 +38,9 @@ public class ThreadPoolExecutorWrap extends ThreadPoolExecutor {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if(contextValue != null&&contextValue.containsKey("user_key")){
|
||||
contextValue.put(TokenConstants.AUTHENTICATION, contextValue.get("user_key"));
|
||||
}
|
||||
SecurityContextHolder.setLocalMap(contextValue);
|
||||
// 用户任务逻辑
|
||||
task.run();
|
||||
|
|
|
|||
|
|
@ -13,17 +13,19 @@ import com.microservices.common.core.utils.reflect.ReflectUtils;
|
|||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
|
|
@ -1458,4 +1460,288 @@ public class ExcelUtil<T>
|
|||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
// 存储Excel中的图片(key: 行号_列号,value: MultipartFile)
|
||||
private final Map<String, MultipartFile> excelImageMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 获取解析后的Excel图片映射表(行号_列号 -> MultipartFile)
|
||||
* <p>对外返回不可修改的Map,避免外部篡改,同时让静态检查识别到该集合被查询</p>
|
||||
* @return 图片映射表
|
||||
*/
|
||||
public Map<String, MultipartFile> getExcelImageMap() {
|
||||
// 返回不可修改的Map,提升代码安全性,同时让静态检查识别到集合被读取
|
||||
return Collections.unmodifiableMap(excelImageMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析Excel中的图片并转换为MultipartFile,存入{@link #excelImageMap}
|
||||
* @param sheet Excel工作表
|
||||
* @throws IOException 解析图片失败时抛出
|
||||
*/
|
||||
private void parseExcelImages(Sheet sheet) throws IOException {
|
||||
if (wb instanceof XSSFWorkbook) {
|
||||
parseXSSFImages((XSSFSheet) sheet);
|
||||
} else if (wb instanceof HSSFWorkbook) {
|
||||
parseHSSFImages((HSSFWorkbook) wb, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析XSSF格式(xlsx)图片
|
||||
*/
|
||||
private void parseXSSFImages(XSSFSheet sheet) {
|
||||
XSSFDrawing drawing = sheet.createDrawingPatriarch();
|
||||
List<XSSFShape> shapes = drawing.getShapes();
|
||||
|
||||
for (XSSFShape shape : shapes) {
|
||||
if (shape instanceof XSSFPicture) {
|
||||
XSSFPicture picture = (XSSFPicture) shape;
|
||||
XSSFPictureData pictureData = picture.getPictureData();
|
||||
XSSFClientAnchor anchor = picture.getPreferredSize();
|
||||
|
||||
// 获取图片所在单元格位置
|
||||
int row = anchor.getRow1();
|
||||
int col = anchor.getCol1();
|
||||
String cellKey = row + "_" + col;
|
||||
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile multipartFile = bytesToMultipartFile(pictureData.getData(), "xlsx_image.png");
|
||||
excelImageMap.put(cellKey, multipartFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析HSSF格式(xls)图片
|
||||
*/
|
||||
private void parseHSSFImages(HSSFWorkbook workbook, Sheet sheet) {
|
||||
List<HSSFPictureData> pictureDataList = workbook.getAllPictures();
|
||||
|
||||
for (int i = 0; i < pictureDataList.size(); i++) {
|
||||
HSSFPictureData pictureData = pictureDataList.get(i);
|
||||
HSSFPatriarch patriarch = (HSSFPatriarch) sheet.createDrawingPatriarch();
|
||||
List<HSSFShape> shapes = patriarch.getChildren();
|
||||
|
||||
for (HSSFShape shape : shapes) {
|
||||
if (shape instanceof HSSFPicture) {
|
||||
HSSFPicture picture = (HSSFPicture) shape;
|
||||
if (picture.getPictureIndex() == i) {
|
||||
HSSFClientAnchor anchor = picture.getClientAnchor();
|
||||
int row = anchor.getRow1();
|
||||
int col = anchor.getCol1();
|
||||
String cellKey = row + "_" + col;
|
||||
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile multipartFile = bytesToMultipartFile(pictureData.getData(), "xls_image.png");
|
||||
excelImageMap.put(cellKey, multipartFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义MultipartFile实现(通用版,无外部依赖)
|
||||
*/
|
||||
public static class CustomMultipartFile implements MultipartFile {
|
||||
private final byte[] content;
|
||||
private final String filename;
|
||||
private final String contentType;
|
||||
|
||||
public CustomMultipartFile(byte[] content, String filename, String contentType) {
|
||||
this.content = content;
|
||||
this.filename = filename;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return content == null || content.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return content.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(java.io.File dest) throws IOException, IllegalStateException {
|
||||
try (java.io.OutputStream os = new java.io.FileOutputStream(dest)) {
|
||||
os.write(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节数组转换为MultipartFile(核心工具方法)
|
||||
*/
|
||||
public MultipartFile bytesToMultipartFile(byte[] bytes, String fileName) {
|
||||
try {
|
||||
String suffix = "png";
|
||||
if (fileName != null && fileName.contains(".")) {
|
||||
suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
}
|
||||
String finalFileName = UUID.randomUUID().toString() + "." + suffix;
|
||||
String contentType = "image/" + suffix;
|
||||
|
||||
return new CustomMultipartFile(bytes, finalFileName, contentType);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("转换图片为MultipartFile失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 导入包含图片的excel
|
||||
public List<T> importExcelWithImages(String sheetName, InputStream is, int titleNum) throws Exception {
|
||||
this.type = Type.IMPORT;
|
||||
this.wb = WorkbookFactory.create(is);
|
||||
List<T> list = new ArrayList<T>();
|
||||
|
||||
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
|
||||
if (sheet == null) {
|
||||
throw new IOException("文件sheet不存在");
|
||||
}
|
||||
|
||||
// 1. 解析Excel中的图片,生成imageMap(行号_列号 -> MultipartFile)
|
||||
parseExcelImages(sheet);
|
||||
|
||||
int rows = sheet.getLastRowNum();
|
||||
if (rows > 0) {
|
||||
// ========== 参考原有逻辑:构建表头列名和下标映射 ==========
|
||||
Map<String, Integer> cellMap = new HashMap<>();
|
||||
Row heard = sheet.getRow(titleNum);
|
||||
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) {
|
||||
Cell cell = heard.getCell(i);
|
||||
if (StringUtils.isNotNull(cell)) {
|
||||
String columnName = this.getCellValue(heard, i).toString().trim();
|
||||
cellMap.put(columnName, i);
|
||||
} else {
|
||||
cellMap.put(null, i);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 参考原有逻辑:构建字段映射(通过Excel注解匹配列名) ==========
|
||||
List<Object[]> fields = this.getFields();
|
||||
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>();
|
||||
for (Object[] objects : fields) {
|
||||
Excel attr = (Excel) objects[1];
|
||||
Integer column = cellMap.get(attr.name());
|
||||
if (column != null) {
|
||||
fieldsMap.put(column, objects);
|
||||
}
|
||||
}
|
||||
|
||||
// 找到「图片」列的下标(关键:和Excel模板的列名对应)
|
||||
Integer imageColumnIndex = cellMap.get("图片");
|
||||
|
||||
// ========== 遍历数据行(参考原有逻辑) ==========
|
||||
for (int i = titleNum + 1; i <= rows; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
if (isRowEmpty(row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
T entity = null;
|
||||
// 生成当前行的图片key:行号_图片列下标(i是数据行号,对应Excel的行)
|
||||
String imageCellKey = i + "_" + imageColumnIndex;
|
||||
|
||||
// ========== 参考原有逻辑:遍历字段映射赋值 ==========
|
||||
for (Map.Entry<Integer, Object[]> entry : fieldsMap.entrySet()) {
|
||||
Integer columnIndex = entry.getKey();
|
||||
Object val = this.getCellValue(row, columnIndex);
|
||||
|
||||
// 如果不存在实例则新建
|
||||
entity = (entity == null ? clazz.newInstance() : entity);
|
||||
|
||||
// 从map中得到对应列的field和Excel注解
|
||||
Field field = (Field) entry.getValue()[0];
|
||||
Excel attr = (Excel) entry.getValue()[1];
|
||||
|
||||
// ========== 关键修改:如果是「图片」列,替换值为图片key ==========
|
||||
if (imageColumnIndex != null && columnIndex.equals(imageColumnIndex)) {
|
||||
val = imageCellKey; // 将单元格原始值替换为图片key(如1_12)
|
||||
}
|
||||
|
||||
// ========== 原有类型转换逻辑(完全复用) ==========
|
||||
Class<?> fieldType = field.getType();
|
||||
if (String.class == fieldType) {
|
||||
String s = Convert.toStr(val);
|
||||
if (StringUtils.endsWith(s, ".0")) {
|
||||
val = StringUtils.substringBefore(s, ".0");
|
||||
} else {
|
||||
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
||||
if (StringUtils.isNotEmpty(dateFormat)) {
|
||||
val = parseDateToStr(dateFormat, val);
|
||||
} else {
|
||||
val = Convert.toStr(val);
|
||||
}
|
||||
}
|
||||
} else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) {
|
||||
val = Convert.toInt(val);
|
||||
} else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) {
|
||||
val = Convert.toLong(val);
|
||||
} else if (Double.TYPE == fieldType || Double.class == fieldType) {
|
||||
val = Convert.toDouble(val);
|
||||
} else if (Float.TYPE == fieldType || Float.class == fieldType) {
|
||||
val = Convert.toFloat(val);
|
||||
} else if (BigDecimal.class == fieldType) {
|
||||
val = Convert.toBigDecimal(val);
|
||||
} else if (Date.class == fieldType) {
|
||||
if (val instanceof String) {
|
||||
val = DateUtils.parseDate(val);
|
||||
} else if (val instanceof Double) {
|
||||
val = DateUtil.getJavaDate((Double) val);
|
||||
}
|
||||
} else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) {
|
||||
val = Convert.toBool(val, false);
|
||||
}
|
||||
|
||||
// ========== 原有反射赋值逻辑(完全复用) ==========
|
||||
if (StringUtils.isNotNull(fieldType)) {
|
||||
String propertyName = field.getName();
|
||||
if (StringUtils.isNotEmpty(attr.targetAttr())) {
|
||||
propertyName = field.getName() + "." + attr.targetAttr();
|
||||
} else if (StringUtils.isNotEmpty(attr.readConverterExp())) {
|
||||
val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
|
||||
} else if (!attr.handler().equals(ExcelHandlerAdapter.class)) {
|
||||
val = dataFormatHandlerAdapter(val, attr);
|
||||
}
|
||||
// 使用原有工具类反射赋值(核心:替换自定义setEntityFieldValue)
|
||||
ReflectUtils.invokeSetter(entity, propertyName, val);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
list.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class GenericsTableDataInfo<T> implements Serializable {
|
|||
/**
|
||||
* 面包屑数据
|
||||
*/
|
||||
@ApiModelProperty("面包屑数据")
|
||||
@ApiModelProperty(value = "面包屑数据",hidden = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) //为空时隐藏
|
||||
private List<Breadcrumb> breadcrumb;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
package com.microservices.common.httpClient.config;
|
||||
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -11,7 +16,13 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* HttpClient 配置类
|
||||
* 支持 HTTPS 和连接池管理,包含自动连接清理机制
|
||||
*
|
||||
* @author admin
|
||||
* @date 2017/2/6
|
||||
*/
|
||||
|
|
@ -20,74 +31,131 @@ public class HttpClientConfiguration {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpClientConfiguration.class);
|
||||
|
||||
@Value("${http.maxTotal}")
|
||||
@Value("${http.maxTotal:100}")
|
||||
private Integer maxTotal;
|
||||
|
||||
@Value("${http.defaultMaxPerRoute}")
|
||||
@Value("${http.defaultMaxPerRoute:20}")
|
||||
private Integer defaultMaxPerRoute;
|
||||
|
||||
@Value("${http.connectTimeout}")
|
||||
@Value("${http.connectTimeout:10000}")
|
||||
private Integer connectTimeout;
|
||||
|
||||
@Value("${http.connectionRequestTimeout}")
|
||||
@Value("${http.connectionRequestTimeout:5000}")
|
||||
private Integer connectionRequestTimeout;
|
||||
|
||||
@Value("${http.socketTimeout}")
|
||||
@Value("${http.socketTimeout:30000}")
|
||||
private Integer socketTimeout;
|
||||
|
||||
@Value("${http.staleConnectionCheckEnabled}")
|
||||
@Value("${http.staleConnectionCheckEnabled:true}")
|
||||
private boolean staleConnectionCheckEnabled;
|
||||
|
||||
private PoolingHttpClientConnectionManager connectionManager;
|
||||
|
||||
/**
|
||||
* 首先实例化一个连接池管理器,设置最大连接数、并发连接数
|
||||
* 创建支持 HTTPS 的连接池管理器
|
||||
* 使用自定义的 SSL 配置来避免 "peer not authenticated" 错误
|
||||
*
|
||||
* @return
|
||||
* @return PoolingHttpClientConnectionManager
|
||||
*/
|
||||
@Bean(name = "httpClientConnectionManager")
|
||||
public PoolingHttpClientConnectionManager getHttpClientConnectionManager() {
|
||||
PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager();
|
||||
//最大连接数
|
||||
httpClientConnectionManager.setMaxTotal(maxTotal);
|
||||
//并发数
|
||||
httpClientConnectionManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
|
||||
return httpClientConnectionManager;
|
||||
try {
|
||||
// 创建 SSLConnectionSocketFactory
|
||||
SSLConnectionSocketFactory sslSocketFactory = SSLContextFactory.createSSLConnectionSocketFactory();
|
||||
|
||||
// 注册 HTTP 和 HTTPS 的 SocketFactory
|
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.getSocketFactory())
|
||||
.register("https", sslSocketFactory)
|
||||
.build();
|
||||
|
||||
// 使用自定义 Registry 创建连接池管理器
|
||||
PoolingHttpClientConnectionManager manager = new PoolingHttpClientConnectionManager(registry);
|
||||
|
||||
// 设置连接池参数
|
||||
manager.setMaxTotal(maxTotal);
|
||||
manager.setDefaultMaxPerRoute(defaultMaxPerRoute);
|
||||
|
||||
// 设置连接验证间隔(非常重要!防止使用已关闭的连接)
|
||||
manager.setValidateAfterInactivity(2000);
|
||||
|
||||
this.connectionManager = manager;
|
||||
|
||||
logger.info("HttpClient连接池初始化成功 - 最大连接数: {}, 每个路由最大连接数: {}, SSL验证: 启用",
|
||||
maxTotal, defaultMaxPerRoute);
|
||||
|
||||
return manager;
|
||||
} catch (Exception e) {
|
||||
logger.error("HttpClient连接池初始化失败", e);
|
||||
throw new RuntimeException("HttpClient连接池初始化失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化连接池,设置连接池管理器。
|
||||
* 这里需要以参数形式注入上面实例化的连接池管理器
|
||||
* 创建 HttpClientBuilder
|
||||
* 配置重试机制和连接管理策略
|
||||
*
|
||||
* @param httpClientConnectionManager
|
||||
* @return
|
||||
* @param httpClientConnectionManager 连接池管理器
|
||||
* @return HttpClientBuilder
|
||||
*/
|
||||
@Bean(name = "httpClientBuilder")
|
||||
public HttpClientBuilder getHttpClientBuilder(@Qualifier("httpClientConnectionManager") PoolingHttpClientConnectionManager httpClientConnectionManager) {
|
||||
public org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(
|
||||
@Qualifier("httpClientConnectionManager") PoolingHttpClientConnectionManager httpClientConnectionManager) {
|
||||
|
||||
//HttpClientBuilder中的构造方法被protected修饰,所以这里不能直接使用new来实例化一个HttpClientBuilder,可以使用HttpClientBuilder提供的静态方法create()来获取HttpClientBuilder对象
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
httpClientBuilder.setConnectionManager(httpClientConnectionManager);
|
||||
org.apache.http.impl.client.HttpClientBuilder builder = HttpClients.custom()
|
||||
.setConnectionManager(httpClientConnectionManager)
|
||||
// 设置连接存活时间 - 防止连接被长期占用
|
||||
.setConnectionTimeToLive(60, TimeUnit.SECONDS)
|
||||
// 添加重试机制 - 针对 IO/SSL 异常
|
||||
.setRetryHandler((exception, executionCount, context) -> {
|
||||
if (executionCount > 2) {
|
||||
logger.warn("HTTP请求重试次数超过限制(2次),停止重试");
|
||||
return false;
|
||||
}
|
||||
// 可重试的异常类型
|
||||
if (exception instanceof org.apache.http.NoHttpResponseException
|
||||
|| exception instanceof javax.net.ssl.SSLHandshakeException
|
||||
|| exception instanceof java.net.SocketException
|
||||
|| exception instanceof org.apache.http.conn.HttpHostConnectException) {
|
||||
logger.warn("HTTP请求失败,正在进行第{}次重试。异常类型: {}, 消息: {}",
|
||||
executionCount, exception.getClass().getSimpleName(), exception.getMessage());
|
||||
return true;
|
||||
}
|
||||
logger.debug("HTTP请求失败,异常类型不支持重试: {}", exception.getClass().getName());
|
||||
return false;
|
||||
})
|
||||
// 禁用过期连接
|
||||
.evictIdleConnections(30, TimeUnit.SECONDS)
|
||||
// 空闲连接验证
|
||||
.setConnectionManagerShared(false);
|
||||
|
||||
return httpClientBuilder;
|
||||
logger.info("HttpClientBuilder 配置完成 - 重试机制: 启用(最多2次), 连接存活时间: 60秒");
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入连接池,用于获取httpClient
|
||||
* 创建 CloseableHttpClient 实例
|
||||
*
|
||||
* @param httpClientBuilder
|
||||
* @return
|
||||
* @param httpClientBuilder HttpClientBuilder
|
||||
* @return CloseableHttpClient
|
||||
*/
|
||||
@Bean
|
||||
public CloseableHttpClient getCloseableHttpClient(@Qualifier("httpClientBuilder") HttpClientBuilder httpClientBuilder) {
|
||||
return httpClientBuilder.build();
|
||||
public CloseableHttpClient getCloseableHttpClient(
|
||||
@Qualifier("httpClientBuilder") org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) {
|
||||
|
||||
CloseableHttpClient httpClient = httpClientBuilder.build();
|
||||
|
||||
// 启动连接池清理后台线程
|
||||
startConnectionMonitorThread();
|
||||
|
||||
logger.info("CloseableHttpClient 创建成功");
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder是RequestConfig的一个内部类
|
||||
* 通过RequestConfig的custom方法来获取到一个Builder对象
|
||||
* 设置builder的连接信息
|
||||
* 这里还可以设置proxy,cookieSpec等属性。有需要的话可以在此设置
|
||||
* 创建 RequestConfig.Builder
|
||||
*
|
||||
* @return
|
||||
* @return RequestConfig.Builder
|
||||
*/
|
||||
@Bean(name = "builder")
|
||||
public RequestConfig.Builder getBuilder() {
|
||||
|
|
@ -99,14 +167,78 @@ public class HttpClientConfiguration {
|
|||
}
|
||||
|
||||
/**
|
||||
* 使用builder构建一个RequestConfig对象
|
||||
* 创建 RequestConfig
|
||||
*
|
||||
* @param builder
|
||||
* @return
|
||||
* @param builder RequestConfig.Builder
|
||||
* @return RequestConfig
|
||||
*/
|
||||
@Bean
|
||||
public RequestConfig getRequestConfig(@Qualifier("builder") RequestConfig.Builder builder) {
|
||||
return builder.build();
|
||||
RequestConfig config = builder.build();
|
||||
logger.info("RequestConfig 配置完成 - 连接超时: {}ms, 请求超时: {}ms, Socket超时: {}ms, 陈旧连接检查: {}",
|
||||
connectTimeout, connectionRequestTimeout, socketTimeout, staleConnectionCheckEnabled);
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动连接池监控和清理线程
|
||||
* 定期清理过期和空闲连接,防止使用已关闭的连接
|
||||
*/
|
||||
private void startConnectionMonitorThread() {
|
||||
Thread monitorThread = new Thread(() -> {
|
||||
logger.info("HttpClient连接池监控线程启动");
|
||||
try {
|
||||
while (connectionManager != null) {
|
||||
try {
|
||||
// 每 10 秒清理一次
|
||||
Thread.sleep(10000);
|
||||
|
||||
if (connectionManager != null) {
|
||||
// 关闭过期连接
|
||||
connectionManager.closeExpiredConnections();
|
||||
// 关闭空闲超过 30 秒的连接
|
||||
connectionManager.closeIdleConnections(30, TimeUnit.SECONDS);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("HttpClient连接池状态 - 总连接数: {}, 路由数: {}, 最大连接数: {}, 每路由最大连接数: {}",
|
||||
connectionManager.getTotalStats().getLeased() +
|
||||
connectionManager.getTotalStats().getAvailable(),
|
||||
connectionManager.getTotalStats().getLeased(),
|
||||
connectionManager.getMaxTotal(),
|
||||
connectionManager.getDefaultMaxPerRoute());
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
logger.warn("HttpClient连接池监控线程被中断");
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
logger.error("HttpClient连接池清理过程中出现异常", e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
logger.info("HttpClient连接池监控线程停止");
|
||||
}
|
||||
});
|
||||
|
||||
monitorThread.setDaemon(true);
|
||||
monitorThread.setName("http-connection-monitor");
|
||||
monitorThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用关闭时清理资源
|
||||
*/
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
logger.info("开始清理 HttpClient 资源");
|
||||
if (connectionManager != null) {
|
||||
try {
|
||||
connectionManager.close();
|
||||
logger.info("HttpClient 连接池已关闭");
|
||||
} catch (Exception e) {
|
||||
logger.error("关闭 HttpClient 连接池时出现异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
package com.microservices.common.httpClient.config;
|
||||
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* SSL/TLS 配置工厂类
|
||||
* 用于创建支持 HTTPS 的 SSLContext 和 SocketFactory
|
||||
*
|
||||
* @author otto
|
||||
*/
|
||||
public class SSLContextFactory {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SSLContextFactory.class);
|
||||
|
||||
/**
|
||||
* 创建支持所有 TLS 版本的 SSLContext
|
||||
* 信任所有证书(仅用于内部系统调用)
|
||||
*
|
||||
* @return SSLContext 实例
|
||||
*/
|
||||
public static SSLContext createSSLContext() {
|
||||
try {
|
||||
// 使用 TLSv1.2 或更高版本
|
||||
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||
|
||||
// 创建信任所有证书的 TrustManager
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
logger.debug("SSLContext 创建成功,使用 TLSv1.2 协议");
|
||||
return sslContext;
|
||||
} catch (NoSuchAlgorithmException | KeyManagementException e) {
|
||||
logger.error("创建 SSLContext 失败", e);
|
||||
throw new RuntimeException("创建 SSLContext 失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 SSLConnectionSocketFactory
|
||||
* 跳过主机名验证(仅用于内部系统调用)
|
||||
*
|
||||
* @return SSLConnectionSocketFactory 实例
|
||||
*/
|
||||
public static SSLConnectionSocketFactory createSSLConnectionSocketFactory() {
|
||||
try {
|
||||
SSLContext sslContext = createSSLContext();
|
||||
|
||||
// 创建跳过主机名验证的 HostnameVerifier
|
||||
HostnameVerifier allowAllHosts = new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
// 记录连接的主机信息,便于调试
|
||||
logger.debug("SSL 连接主机: {}, 证书主体: {}", hostname, getCertificateSubject(session));
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getCertificateSubject(SSLSession session) {
|
||||
try {
|
||||
return session.getPeerPrincipal().toString();
|
||||
} catch (Exception e) {
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 支持的协议:TLSv1.2, TLSv1.3
|
||||
String[] supportedProtocols = new String[]{"TLSv1.2", "TLSv1.3"};
|
||||
|
||||
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
|
||||
sslContext,
|
||||
supportedProtocols,
|
||||
null, // 使用默认的密码套件
|
||||
allowAllHosts
|
||||
);
|
||||
|
||||
logger.debug("SSLConnectionSocketFactory 创建成功,支持的协议: TLSv1.2, TLSv1.3");
|
||||
return sslSocketFactory;
|
||||
} catch (Exception e) {
|
||||
logger.error("创建 SSLConnectionSocketFactory 失败", e);
|
||||
throw new RuntimeException("创建 SSLConnectionSocketFactory 失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建用于信任所有证书的 TrustManager(用于日志记录)
|
||||
*
|
||||
* @return TrustManager 数组
|
||||
*/
|
||||
public static TrustManager[] createTrustAllManagers() {
|
||||
return new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||
logger.debug("客户端证书验证通过");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||
if (chain != null && chain.length > 0) {
|
||||
X509Certificate cert = chain[0];
|
||||
logger.debug("服务器证书验证通过 - 主体: {}, 颁发者: {}, 有效期: {} - {}",
|
||||
cert.getSubjectDN(),
|
||||
cert.getIssuerDN(),
|
||||
cert.getNotBefore(),
|
||||
cert.getNotAfter());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.microservices.common.httpClient.domain.GitLinkRequestUrl.GET_FILE_SUB_ENTRIES;
|
||||
import static com.microservices.common.httpClient.util.GitLinkRequestHelper.RequestType.GET;
|
||||
|
|
@ -79,44 +80,75 @@ public class GitLinkRequestHelper {
|
|||
HashMap<String, String> headers = prepareAuthenticationHeaders(gitLinkRequestUrl);
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
String path = gitLinkRequestUrl.getPath();
|
||||
logger.info("[{}]通过HttpClient向平台发起请求,请求方法为:{},请求网站为:{},请求路由为:{},请求载体为:{},请求头为:{}"
|
||||
logger.debug("[{}]通过HttpClient向平台发起请求,请求方法为:{},请求网站为:{},请求路由为:{},请求载体为:{},请求头为:{}"
|
||||
, requestId
|
||||
, requestType
|
||||
, gitLinkUrl
|
||||
, path
|
||||
, object
|
||||
, headers);
|
||||
JSONObject result;
|
||||
try {
|
||||
String requestURL = EscapeUtil.removeExtraSlashOfUrl(gitLinkUrl + path.replace(" ", "%20"));
|
||||
switch (requestType) {
|
||||
case POST:
|
||||
result = httpAPIService.doPost(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
case POST_FILE:
|
||||
result = httpAPIService.doPostFile(requestURL, (MultipartFile) object, headers);
|
||||
break;
|
||||
case DELETE:
|
||||
result = httpAPIService.doDelete(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
case GET:
|
||||
result = httpAPIService.doGet(requestURL, headers);
|
||||
break;
|
||||
case PUT:
|
||||
result = httpAPIService.doPut(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
case PATCH:
|
||||
result = httpAPIService.doPatch(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("不支持该请求方式:" + requestType.name());
|
||||
JSONObject result = null;
|
||||
Exception lastException = null;
|
||||
|
||||
// 业务层重试机制:针对 SSL 握手失败等偶发性错误
|
||||
int maxRetries = 2;
|
||||
for (int attempt = 1; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
String requestURL = EscapeUtil.removeExtraSlashOfUrl(gitLinkUrl + path.replace(" ", "%20"));
|
||||
switch (requestType) {
|
||||
case POST:
|
||||
result = httpAPIService.doPost(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
case POST_FILE:
|
||||
result = httpAPIService.doPostFile(requestURL, (MultipartFile) object, headers);
|
||||
break;
|
||||
case DELETE:
|
||||
result = httpAPIService.doDelete(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
case GET:
|
||||
result = httpAPIService.doGet(requestURL, headers);
|
||||
break;
|
||||
case PUT:
|
||||
result = httpAPIService.doPut(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
case PATCH:
|
||||
result = httpAPIService.doPatch(requestURL, (JSONObject) object, headers);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("不支持该请求方式:" + requestType.name());
|
||||
}
|
||||
logger.debug("[{}]请求响应为:{}"
|
||||
, requestId
|
||||
, result);
|
||||
// 请求成功,跳出重试循环
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
lastException = e;
|
||||
String errorMsg = e.getMessage();
|
||||
// 判断是否为可重试的异常类型
|
||||
boolean isRetryable = errorMsg != null && (
|
||||
errorMsg.contains("peer not authenticated") ||
|
||||
errorMsg.contains("SSLHandshakeException") ||
|
||||
errorMsg.contains("Connection reset") ||
|
||||
errorMsg.contains("NoHttpResponseException") ||
|
||||
errorMsg.contains("SocketException")
|
||||
);
|
||||
|
||||
if (isRetryable && attempt < maxRetries) {
|
||||
logger.warn("[{}]请求平台时发生可重试异常(第{}次尝试),将在100ms后重试。异常信息: {}",
|
||||
requestId, attempt, errorMsg);
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ServiceException("请求被中断");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
throw new ServiceException("请求平台出现错误:" + errorMsg);
|
||||
}
|
||||
logger.info("[{}]请求响应为:{}"
|
||||
, requestId
|
||||
, result);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("请求平台出现错误:" + e.getMessage());
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
throw new ServiceException("请求平台时,未返回内容");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@
|
|||
<artifactId>microservices-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.microservices.common.security.feign;
|
|||
import feign.RequestInterceptor;
|
||||
import feign.codec.Encoder;
|
||||
import feign.form.FormEncoder;
|
||||
import feign.form.spring.SpringFormEncoder;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
|
|
@ -33,6 +34,6 @@ public class FeignAutoConfiguration
|
|||
// 重要的是返回类型要是 Encoder 并且实现类必须是 FormEncoder 或者其子类
|
||||
@Bean
|
||||
public Encoder feignFormEncoder() {
|
||||
return new FormEncoder(new SpringEncoder(messageConverters));
|
||||
return new SpringFormEncoder(new SpringEncoder(messageConverters));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.microservices.common.security.handler;
|
||||
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
|
||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityException;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException;
|
||||
import com.alibaba.csp.sentinel.slots.system.SystemBlockException;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
public class SentinelBlockExceptionHandler implements BlockExceptionHandler {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
BlockException ex) throws Exception {
|
||||
|
||||
R<?> body;
|
||||
if (ex instanceof FlowException) { // 限流
|
||||
body = R.fail(429, "请求过于频繁,请稍后重试");
|
||||
} else if (ex instanceof DegradeException) { // 熔断
|
||||
body = R.fail(500, "服务暂时不可用,请稍后重试");
|
||||
} else if (ex instanceof ParamFlowException) { // 热点参数限流
|
||||
body = R.fail(400, "热点参数限流");
|
||||
} else if (ex instanceof AuthorityException) { // 授权规则
|
||||
body = R.fail(403, "无权限访问该资源");
|
||||
} else if (ex instanceof SystemBlockException) { // 系统规则
|
||||
body = R.fail(500, "系统规则限制,无法访问");
|
||||
} else { // 兜底
|
||||
body = R.fail(500, "服务繁忙,请稍后重试");
|
||||
}
|
||||
|
||||
response.setStatus(HttpStatus.OK.value());
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.getWriter().write(JSONObject.toJSONString(body));
|
||||
}
|
||||
}
|
||||
|
|
@ -4,3 +4,4 @@ com.microservices.common.security.service.impl.RequestCustomServiceImpl
|
|||
com.microservices.common.security.aspect.PreAuthorizeAspect
|
||||
com.microservices.common.security.aspect.InnerAuthAspect
|
||||
com.microservices.common.security.handler.GlobalExceptionHandler
|
||||
com.microservices.common.security.handler.SentinelBlockExceptionHandler
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
try {
|
||||
claims = JwtUtils.parseToken(token);
|
||||
} catch (Exception e) {
|
||||
log.error("令牌解析失败:{}", e.getMessage());
|
||||
log.error("[鉴权异常处理]令牌解析失败:{}", e.getMessage());
|
||||
return unauthorizedResponse(exchange, "令牌格式不正确!");
|
||||
}
|
||||
if (claims == null) {
|
||||
|
|
@ -139,7 +139,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
);
|
||||
redisService.setCacheObject(redisKey, feignResult);
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户【{}】身份列表时发生异常:{}", username, e.getMessage());
|
||||
log.error("[鉴权异常处理]获取用户【{}】身份列表时发生异常:{}", username, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
}
|
||||
return genCookieByToken(token);
|
||||
} catch (Exception e) {
|
||||
log.error("检查该gitlink token【{}】是否登录时发生异常:{}", token, e.getMessage());
|
||||
log.error("[鉴权异常处理]检查该token【{}】是否登录时发生异常:{}", token, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -215,11 +215,11 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
try {
|
||||
feignResult = future.get();
|
||||
} catch (Exception e) {
|
||||
log.error("异步请求获取本系统Token出错:{}", e.getMessage());
|
||||
log.error("[鉴权异常处理]异步请求获取本系统Token出错:{}", e.getMessage());
|
||||
throw new ServiceException("内部服务错误");
|
||||
}
|
||||
if (StringUtils.isNull(feignResult) || R.FAIL == feignResult.getCode()) {
|
||||
log.error("Token获取出错:{}", feignResult.getMsg());
|
||||
log.error("[鉴权异常处理]Token获取出错:{}", feignResult.getMsg());
|
||||
throw new ServiceException("内部服务错误");
|
||||
}
|
||||
if (R.SUCCESS == feignResult.getCode()) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
String lowerUrl = request.getURI().getPath().toLowerCase();
|
||||
ServerHttpResponse originalResponse = exchange.getResponse();
|
||||
DataBufferFactory bufferFactory = originalResponse.bufferFactory();
|
||||
|
||||
// 当请求为Nacos时,Nacos返回的所有非JSON响应都会被自动转换为结构化的错误信息,同时将HTTP状态码设置为200,适合用于规范化微服务架构的响应格式。
|
||||
if (lowerUrl.startsWith("/nacos")) {
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
return super.writeWith(body);
|
||||
}
|
||||
if (status == HttpStatus.FORBIDDEN) {
|
||||
log.error("nacos鉴权异常,已清理redis中nacos token");
|
||||
log.error("[网关转发异常处理]nacos鉴权异常,已清理redis中nacos token");
|
||||
// 设置新的状态码为 200
|
||||
setStatusCode(HttpStatus.OK);
|
||||
// 设置响应内容类型为 JSON
|
||||
|
|
@ -125,7 +126,7 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
}
|
||||
synchronousSink.complete();
|
||||
}).flatMap(resStr -> {
|
||||
log.error("Portainer响应处理异常,异常信息:{}", resStr);
|
||||
log.error("[网关转发异常处理]Portainer响应处理异常,异常信息:{}", resStr);
|
||||
originalResponse.setStatusCode(HttpStatus.OK);
|
||||
byte[] bytes;
|
||||
if (JSON.isValid(resStr)) {
|
||||
|
|
@ -133,7 +134,7 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
if (resJson.containsKey("message")) {
|
||||
String message = resJson.getString("message");
|
||||
if (StringUtils.isNotBlank(message) && message.contains("A valid authorisation token is missing")) {
|
||||
log.error("Portainer鉴权异常,已清理redis中Portainer token");
|
||||
log.error("[网关转发异常处理]Portainer鉴权异常,已清理redis中Portainer token");
|
||||
//token失效清除redis缓存
|
||||
redisService.deleteObject(CacheConstants.PORTAINER_TOKEN);
|
||||
bytes = JSON.toJSONBytes(AjaxResult.error(ExceptionMsgConstants.RETRY_ERROR));
|
||||
|
|
@ -160,12 +161,12 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
ServerHttpResponseDecorator decoratedResponse = new ServerHttpResponseDecorator(originalResponse) {
|
||||
@Override
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
HttpStatus status = getStatusCode() != null ? getStatusCode() : HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
HttpStatus status = getStatusCode();
|
||||
if (!status.isError()) {
|
||||
return super.writeWith(body);
|
||||
}
|
||||
if (status == HttpStatus.UNAUTHORIZED) {
|
||||
log.error("sentinel鉴权异常,已清理redis中sentinel token");
|
||||
log.error("[网关转发异常处理]sentinel鉴权异常,已清理redis中sentinel token");
|
||||
// 设置新的状态码为 200
|
||||
setStatusCode(HttpStatus.OK);
|
||||
// 设置响应内容类型为 JSON
|
||||
|
|
@ -192,7 +193,7 @@ public class GlobalResponseFilter implements GlobalFilter, Ordered {
|
|||
}
|
||||
synchronousSink.complete();
|
||||
}).flatMap(resStr -> {
|
||||
log.error("Sentinel响应处理异常,异常信息:{}", resStr);
|
||||
log.error("[网关转发异常处理]Sentinel响应处理异常,异常信息:{}", resStr);
|
||||
byte[] bytes;
|
||||
bytes = JSON.toJSONBytes(AjaxResult.error(ExceptionMsgConstants.SYSTEM_EXEC_ERROR));
|
||||
setStatusCode(HttpStatus.OK);
|
||||
|
|
|
|||
|
|
@ -53,8 +53,14 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
public String portainerUsername;
|
||||
@Value("${thirdPartyTools.portainer.auth.password:}")
|
||||
public String portainerPassword;
|
||||
@Value("${thirdPartyTools.rancher.auth.username:}")
|
||||
public String rancherUsername;
|
||||
@Value("${thirdPartyTools.rancher.auth.password:}")
|
||||
public String rancherPassword;
|
||||
@Value("${thirdPartyTools.portainer.endpoints:}")
|
||||
public Integer portainerEndpoints;
|
||||
@Value("${thirdPartyTools.retryTimes:1}")
|
||||
public Integer retryTimes;
|
||||
ThreadPoolExecutor threadPoolExecutor = CustomExecutorFactory.threadPoolExecutor;
|
||||
@Lazy
|
||||
@Autowired
|
||||
|
|
@ -83,27 +89,81 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
if (redisService.hasKey(CacheConstants.SENTINEL_TOKEN)) {
|
||||
sentinelCookie = redisService.getCacheObject(CacheConstants.SENTINEL_TOKEN);
|
||||
} else {
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Sentinel Token
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginSentinel(sentinelUsername, sentinelPassword));
|
||||
try {
|
||||
Response response = future.get(1, TimeUnit.SECONDS);
|
||||
Map<String, Collection<String>> header = response.headers();
|
||||
if (header != null && header.containsKey("set-cookie")) {
|
||||
sentinelCookie = header.get("set-cookie").iterator().next();
|
||||
//Sentinel登录状态默认30分钟失效,将Sentinel Token缓存过期时间调整为28分钟
|
||||
redisService.setCacheObject(CacheConstants.SENTINEL_TOKEN, sentinelCookie, 28L, TimeUnit.MINUTES);
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Sentinel Token
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginSentinel(sentinelUsername, sentinelPassword));
|
||||
try {
|
||||
Response response = future.get(3, TimeUnit.SECONDS);
|
||||
Map<String, Collection<String>> header = response.headers();
|
||||
if (header != null && header.containsKey("set-cookie")) {
|
||||
sentinelCookie = header.get("set-cookie").iterator().next();
|
||||
//Sentinel登录状态默认30分钟失效,将Sentinel Token缓存过期时间调整为28分钟
|
||||
redisService.setCacheObject(CacheConstants.SENTINEL_TOKEN, sentinelCookie, 28L, TimeUnit.MINUTES);
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("[网关转发异常处理]获取Sentinel Token超时");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("[网关转发异常处理]获取Sentinel Token失败:{}", e.getMessage());
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("获取Sentinel Token超时");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("获取Sentinel Token失败:{}", e.getMessage());
|
||||
|
||||
if (StringUtils.isNotEmpty(sentinelCookie)) {
|
||||
break;
|
||||
}
|
||||
|
||||
log.warn("[网关转发异常处理]获取Sentinel Token失败,进行第{}次重试中", i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(sentinelCookie)) {
|
||||
ServletUtils.removeHeader(mutate, TokenConstants.Cookie);
|
||||
mutate.header(TokenConstants.Cookie, String.format("%s;%s;", cookie, sentinelCookie));
|
||||
} else {
|
||||
throw new ServiceException("Sentinel服务获取Token失败");
|
||||
throw new ServiceException("[网关转发异常处理]Sentinel服务获取Token失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 处理Rancher请求
|
||||
if (lowerUrl.startsWith("/rancher")) {
|
||||
String rancherToken = null;
|
||||
if (redisService.hasKey(CacheConstants.RANCHER_TOKEN)) {
|
||||
rancherToken = redisService.getCacheObject(CacheConstants.RANCHER_TOKEN);
|
||||
} else {
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
JSONObject loginRancherBody = new JSONObject();
|
||||
loginRancherBody.put("description", "api session");
|
||||
loginRancherBody.put("responseType", "cookie");
|
||||
loginRancherBody.put("username", rancherUsername);
|
||||
loginRancherBody.put("password", rancherPassword);
|
||||
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Rancher Token
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginRancher(loginRancherBody));
|
||||
try {
|
||||
Response response = future.get(3, TimeUnit.SECONDS);
|
||||
Map<String, Collection<String>> header = response.headers();
|
||||
if (header != null && header.containsKey("set-cookie")) {
|
||||
String rancherCookie = header.get("set-cookie").iterator().next();
|
||||
rancherToken = getValueByCookieKey(rancherCookie, TokenConstants.Rancher_Cookie_Token_Key);
|
||||
//Rancher登录状态默认15小时失效,将Rancher Token缓存过期时间调整为14分钟
|
||||
redisService.setCacheObject(CacheConstants.RANCHER_TOKEN, rancherToken, 14L, TimeUnit.HOURS);
|
||||
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("[网关转发异常处理]获取Rancher Token超时");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("[网关转发异常处理]获取Rancher Token失败:{}", e.getMessage());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(rancherToken)) {
|
||||
break;
|
||||
}
|
||||
|
||||
log.warn("[网关转发异常处理]获取Rancher Token失败,进行第{}次重试中", i + 1);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(rancherToken)) {
|
||||
ServletUtils.removeHeader(mutate, TokenConstants.AUTHENTICATION);
|
||||
mutate.header(TokenConstants.AUTHENTICATION, TokenConstants.PREFIX + rancherToken);
|
||||
} else {
|
||||
throw new ServiceException("[网关转发异常处理]Rancher服务获取Token失败");
|
||||
}
|
||||
}
|
||||
// 处理Nacos请求
|
||||
|
|
@ -112,38 +172,44 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
if (redisService.hasKey(CacheConstants.NACOS_TOKEN)) {
|
||||
nacosToken = redisService.getCacheObject(CacheConstants.NACOS_TOKEN);
|
||||
} else {
|
||||
Map<String, String> nacosMap = new HashMap<>();
|
||||
nacosMap.put("username", nacosUsername);
|
||||
nacosMap.put("password", nacosPassword);
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Nacos Token
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginNacos(nacosMap));
|
||||
try {
|
||||
Response res = future.get(1, TimeUnit.SECONDS);
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
|
||||
String str = writer.toString();
|
||||
if (!JSON.isValid(str)) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
Map<String, String> nacosMap = new HashMap<>();
|
||||
nacosMap.put("username", nacosUsername);
|
||||
nacosMap.put("password", nacosPassword);
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Nacos Token
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginNacos(nacosMap));
|
||||
try {
|
||||
Response res = future.get(3, TimeUnit.SECONDS);
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
|
||||
String str = writer.toString();
|
||||
if (!JSON.isValid(str)) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
}
|
||||
JSONObject resJsonObject = JSONObject.parseObject(str);
|
||||
if (resJsonObject == null) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
}
|
||||
nacosToken = resJsonObject.getString("accessToken");
|
||||
Long tokenTtl = resJsonObject.getLong("tokenTtl");
|
||||
if (nacosToken != null && tokenTtl != null) {
|
||||
redisService.setCacheObject(CacheConstants.NACOS_TOKEN, nacosToken, tokenTtl - 10, TimeUnit.SECONDS);
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("[网关转发异常处理]获取Nacos Token超时");
|
||||
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
|
||||
log.error("[网关转发异常处理]获取Nacos Token失败:{}", e.getMessage());
|
||||
}
|
||||
JSONObject resJsonObject = JSONObject.parseObject(str);
|
||||
if (resJsonObject == null) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
if (StringUtils.isNotEmpty(nacosToken)) {
|
||||
break;
|
||||
}
|
||||
nacosToken = resJsonObject.getString("accessToken");
|
||||
Long tokenTtl = resJsonObject.getLong("tokenTtl");
|
||||
if (nacosToken != null && tokenTtl != null) {
|
||||
redisService.setCacheObject(CacheConstants.NACOS_TOKEN, nacosToken, tokenTtl - 10, TimeUnit.SECONDS);
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("获取Nacos Token超时");
|
||||
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
|
||||
log.error("获取Nacos Token失败:{}", e.getMessage());
|
||||
log.warn("[网关转发异常处理]获取Nacos Token失败,进行第{}次重试中", i + 1);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(nacosToken)) {
|
||||
mutate.header(TokenConstants.Nacos_Token_Key, nacosToken);
|
||||
} else {
|
||||
throw new ServiceException("Nacos服务获取Token失败");
|
||||
throw new ServiceException("[网关转发异常处理]Nacos服务获取Token失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +229,7 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
try {
|
||||
mutate.uri(new URI(url));
|
||||
} catch (URISyntaxException e) {
|
||||
log.error("替换Portainer请求中Endpoints时发生异常:{}", e.getMessage());
|
||||
log.error("[网关转发异常处理]替换Portainer请求中Endpoints时发生异常:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -178,38 +244,44 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
if (redisService.hasKey(CacheConstants.PORTAINER_TOKEN)) {
|
||||
portainerToken = redisService.getCacheObject(CacheConstants.PORTAINER_TOKEN);
|
||||
} else {
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Portainer Token
|
||||
JSONObject loginPortainerBody = new JSONObject();
|
||||
loginPortainerBody.put("username", portainerUsername);
|
||||
loginPortainerBody.put("password", portainerPassword);
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginPortainer(loginPortainerBody));
|
||||
try {
|
||||
Response res = future.get(1, TimeUnit.SECONDS);
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
|
||||
String str = writer.toString();
|
||||
if (!JSON.isValid(str)) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
}
|
||||
JSONObject resJsonObject = JSONObject.parseObject(str);
|
||||
portainerToken = resJsonObject.getString("jwt");
|
||||
if (portainerToken == null) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
}
|
||||
String[] tokenSplit = portainerToken.split("\\.");
|
||||
String tokenBodyStr = new String(Base64.getDecoder().decode(tokenSplit[1]), StandardCharsets.UTF_8);
|
||||
JSONObject tokenBody = JSONObject.parseObject(tokenBodyStr);
|
||||
Long expiration = tokenBody.getLong("exp");
|
||||
Long now = new Date().getTime() / 1000;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
// 网关采用异步架构,所以此处需要通过异步请求获取Portainer Token
|
||||
JSONObject loginPortainerBody = new JSONObject();
|
||||
loginPortainerBody.put("username", portainerUsername);
|
||||
loginPortainerBody.put("password", portainerPassword);
|
||||
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginPortainer(loginPortainerBody));
|
||||
try {
|
||||
Response res = future.get(1, TimeUnit.SECONDS);
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
|
||||
String str = writer.toString();
|
||||
if (!JSON.isValid(str)) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
}
|
||||
JSONObject resJsonObject = JSONObject.parseObject(str);
|
||||
portainerToken = resJsonObject.getString("jwt");
|
||||
if (portainerToken == null) {
|
||||
return exceptionResponse(exchange, str, res.status());
|
||||
}
|
||||
String[] tokenSplit = portainerToken.split("\\.");
|
||||
String tokenBodyStr = new String(Base64.getDecoder().decode(tokenSplit[1]), StandardCharsets.UTF_8);
|
||||
JSONObject tokenBody = JSONObject.parseObject(tokenBodyStr);
|
||||
Long expiration = tokenBody.getLong("exp");
|
||||
Long now = new Date().getTime() / 1000;
|
||||
|
||||
long portainerTokenTtl = expiration - now;
|
||||
if (portainerTokenTtl > 20) {
|
||||
redisService.setCacheObject(CacheConstants.PORTAINER_TOKEN, portainerToken, portainerTokenTtl - 10, TimeUnit.SECONDS);
|
||||
long portainerTokenTtl = expiration - now;
|
||||
if (portainerTokenTtl > 20) {
|
||||
redisService.setCacheObject(CacheConstants.PORTAINER_TOKEN, portainerToken, portainerTokenTtl - 10, TimeUnit.SECONDS);
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("[网关转发异常处理]获取Portainer Token超时");
|
||||
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
|
||||
log.error("[网关转发异常处理]获取Portainer Token失败:{}", e.getMessage());
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
log.error("获取Portainer Token超时");
|
||||
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
|
||||
log.error("获取Portainer Token失败:{}", e.getMessage());
|
||||
if (StringUtils.isNotEmpty(portainerToken)) {
|
||||
break;
|
||||
}
|
||||
log.warn("[网关转发异常处理]获取Portainer Token失败,进行第{}次重试中", i + 1);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(portainerToken)) {
|
||||
|
|
@ -218,7 +290,7 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
mutate.header(TokenConstants.AUTHENTICATION, TokenConstants.PREFIX + portainerToken);
|
||||
mutate.header(TokenConstants.Cookie, String.format("%s;%s;", cookie, portainerToken));
|
||||
} else {
|
||||
throw new ServiceException("Portainer服务获取Token失败");
|
||||
throw new ServiceException("[网关转发异常处理]Portainer服务获取Token失败");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -226,7 +298,23 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
|
|||
|
||||
|
||||
private Mono<Void> exceptionResponse(ServerWebExchange exchange, String msg, int code) {
|
||||
log.error("[第三方工具请求处理异常]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), msg);
|
||||
log.error("[网关转发异常处理]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), msg);
|
||||
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), ExceptionMsgConstants.SYSTEM_EXEC_ERROR, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过指定Key获取Cookie中指定值
|
||||
*/
|
||||
private static String getValueByCookieKey(String cookie, String key) {
|
||||
if (cookie != null) {
|
||||
String[] cookies = StringUtils.split(cookie, ';');
|
||||
for (String cookieItem : cookies) {
|
||||
if (cookieItem.contains(key)) {
|
||||
String token = StringUtils.remove(cookieItem, key + "=");
|
||||
return StringUtils.remove(token, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ public class CmsDoc extends BaseSortEntity {
|
|||
hotCmsDocDto.setName(name);
|
||||
hotCmsDocDto.setSummary(summary);
|
||||
hotCmsDocDto.setPublishTime(publishTime);
|
||||
hotCmsDocDto.setHeadImg(headImg);
|
||||
return hotCmsDocDto;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import lombok.Data;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author otto
|
||||
|
|
@ -51,6 +52,10 @@ public class CmsDocInputDto {
|
|||
@ApiModelProperty("关键词")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "发布时间,隐藏参数,内部调用使用", hidden = true)
|
||||
private Date publishDate;
|
||||
|
||||
|
||||
public String getContent() {
|
||||
String base64decodedString;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -33,4 +33,6 @@ public class HotCmsDocDto {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty("发布时间")
|
||||
private Date publishTime;
|
||||
@ApiModelProperty(value = "文章头图")
|
||||
private String headImg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -364,6 +365,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
boolean success = insertCommonCmsDoc(cmsDoc,
|
||||
"创建文章:" + StringUtils.truncateStringAndConcatenatingSpecifiedString(cmsDoc.getName(), 100, "..."),
|
||||
cmsDocInputDto.getContent());
|
||||
innerInitPublishDate(cmsDoc,cmsDocInputDto.getPublishDate());
|
||||
return success ? cmsDoc.getId().intValue() : null;
|
||||
} else {
|
||||
//创建临时分支,创建文件,创建PR
|
||||
|
|
@ -373,11 +375,22 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
boolean success = insertCmsDocWithAudit(cmsDoc,
|
||||
"创建文章:" + StringUtils.truncateStringAndConcatenatingSpecifiedString(cmsDoc.getName(), 100, "..."),
|
||||
cmsDocInputDto.getContent());
|
||||
innerInitPublishDate(cmsDoc,cmsDocInputDto.getPublishDate());
|
||||
return success ? cmsDoc.getId().intValue() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void innerInitPublishDate(CmsDoc cmsDoc, Date publishDate) {
|
||||
if(publishDate!=null){
|
||||
cmsDoc.setCreateTime(publishDate);
|
||||
cmsDoc.setUpdateTime(publishDate);
|
||||
cmsDoc.setPublishTime(publishDate);
|
||||
cmsDocMapper.updateCmsDoc(cmsDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isCurrentUserZoneAdmin(Long deptId) {
|
||||
boolean isZoneAdmin = false;
|
||||
List<SysUserDeptRole> sysUserDeptRoleList = FeignUtils.getReturnData(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9116
|
||||
port: 8080
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -87,10 +87,18 @@
|
|||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-core</artifactId>
|
||||
|
|
@ -125,7 +133,7 @@
|
|||
<dependency>
|
||||
<groupId>com.hankcs</groupId>
|
||||
<artifactId>hanlp</artifactId>
|
||||
<version>portable-1.8.4</version>
|
||||
<version>portable-1.3.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,17 @@ import com.microservices.common.log.enums.BusinessType;
|
|||
import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.Achievements;
|
||||
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
|
||||
import com.microservices.system.api.RemoteFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 成果Controller
|
||||
*
|
||||
|
|
@ -30,13 +33,17 @@ public class AchievementsController extends BaseController {
|
|||
@Autowired
|
||||
private IAchievementsService achievementsService;
|
||||
|
||||
@Autowired
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 查询成果列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Achievements achievements) {
|
||||
public TableDataInfo list(AchQueryVo achQueryVo) {
|
||||
startPage();
|
||||
List<Achievements> list = achievementsService.selectAchievementsList(achievements);
|
||||
achQueryVo.setAllStatus(true);
|
||||
List<Achievements> list = achievementsService.getAllResult(achQueryVo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +52,8 @@ public class AchievementsController extends BaseController {
|
|||
*/
|
||||
@Log(title = "成果", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Achievements achievements) {
|
||||
List<Achievements> list = achievementsService.selectAchievementsList(achievements);
|
||||
public void export(HttpServletResponse response, AchQueryVo achQueryVo) {
|
||||
List<Achievements> list = achievementsService.selectAchievementsList(achQueryVo);
|
||||
ExcelUtil<Achievements> util = new ExcelUtil<Achievements>(Achievements.class);
|
||||
util.exportExcel(response, list, "成果数据");
|
||||
}
|
||||
|
|
@ -56,7 +63,7 @@ public class AchievementsController extends BaseController {
|
|||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(achievementsService.selectAchievementsById(id));
|
||||
return success(achievementsService.selectAchievementsById(id, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,19 +222,20 @@ public class AchievementsController extends BaseController {
|
|||
public AjaxResult getWatchFavoriteStatusById(Long id, Long userId) {
|
||||
return success(achievementsService.getWatchFavoriteStatusById(id, userId));
|
||||
}
|
||||
|
||||
@ApiOperation("根据成果ID,获取近7日成果点击数量(折线图)")
|
||||
@GetMapping("/get7AddClickById")
|
||||
public AjaxResult get7AddClickById(String id,@RequestParam(value = "clickType",required = false, defaultValue = "Achievements")
|
||||
public AjaxResult get7AddClickById(String id, @RequestParam(value = "clickType", required = false, defaultValue = "Achievements")
|
||||
String clickType) {
|
||||
return success(achievementsService.get7AddClickById(id,clickType));
|
||||
return success(achievementsService.get7AddClickById(id, clickType));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据专家id,获取近7日成果点击数量(折线图)")
|
||||
@GetMapping("/getExpert7AddClickById")
|
||||
public AjaxResult getExpert7AddClickById(String id,@RequestParam(value = "clickType",required = false, defaultValue = "Experts")
|
||||
public AjaxResult getExpert7AddClickById(String id, @RequestParam(value = "clickType", required = false, defaultValue = "Experts")
|
||||
String clickType) {
|
||||
return success(achievementsService.get7AddClickById(id,clickType));
|
||||
return success(achievementsService.get7AddClickById(id, clickType));
|
||||
}
|
||||
|
||||
@ApiOperation("根据成果ID,获取成果的相关行为数据统计(点击量、搜索量、附件下载量、收藏、关注)")
|
||||
|
|
@ -243,21 +251,24 @@ public class AchievementsController extends BaseController {
|
|||
return success(achievementsService.getAllAreas(areaName));
|
||||
}
|
||||
|
||||
@ApiOperation("根据已有数据,获取融办名称数据")
|
||||
@GetMapping("/getAllField2")
|
||||
public AjaxResult getAllField2() {
|
||||
return success(achievementsService.getAllField2());
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据领域,将成果数据进行分类")
|
||||
@GetMapping("/getAreaStatistic")
|
||||
public AjaxResult getAreaStatistic(String areaKey)
|
||||
{
|
||||
public AjaxResult getAreaStatistic(String areaKey) {
|
||||
return success(achievementsService.getAreaStatistic(areaKey));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据领域获取领域详情")
|
||||
@GetMapping("/getAreaDetail")
|
||||
public AjaxResult getAreaDetail(String areaKey,String kyxmSum,String source)
|
||||
{
|
||||
return success(achievementsService.getAreaDetail(areaKey,kyxmSum,source));
|
||||
public AjaxResult getAreaDetail(String areaKey, String kyxmSum, String source) {
|
||||
return success(achievementsService.getAreaDetail(areaKey, kyxmSum, source));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -265,46 +276,59 @@ public class AchievementsController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "获取开源项目的相关成果")
|
||||
@GetMapping("/getRelatedAch")
|
||||
public AjaxResult getRelatedAch(Long id,Long sourceId)
|
||||
{
|
||||
return success(achievementsService.getRelatedAch(id,sourceId));
|
||||
public AjaxResult getRelatedAch(Long id, Long sourceId) {
|
||||
return success(achievementsService.getRelatedAch(id, sourceId));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取开源竞赛的相关成果")
|
||||
@GetMapping("/getRelatedAchCompetition")
|
||||
public AjaxResult getRelatedAchCompetition(Long id,Long sourceId)
|
||||
{
|
||||
return success(achievementsService.getRelatedAchCompetition(id,sourceId));
|
||||
public AjaxResult getRelatedAchCompetition(Long id, Long sourceId) {
|
||||
return success(achievementsService.getRelatedAchCompetition(id, sourceId));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取创客任务的相关成果")
|
||||
@GetMapping("/getRelatedAchTask")
|
||||
public AjaxResult getRelatedAchTask(Long id,Long sourceId)
|
||||
{
|
||||
return success(achievementsService.getRelatedAchTask(id,sourceId));
|
||||
public AjaxResult getRelatedAchTask(Long id, Long sourceId) {
|
||||
return success(achievementsService.getRelatedAchTask(id, sourceId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取专家-创客任务的相关成果")
|
||||
@GetMapping("/getRelatedAchTaskOfExpert")
|
||||
public AjaxResult getRelatedAchTaskOfExpert(Long expertId)
|
||||
{
|
||||
public AjaxResult getRelatedAchTaskOfExpert(Long expertId) {
|
||||
return success(achievementsService.getRelatedAchTaskOfExpert(expertId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取专家-开源竞赛的相关成果")
|
||||
@GetMapping("/getRelatedAchCompetitionOfExpert")
|
||||
public AjaxResult getRelatedAchCompetitionOfExpert(Long expertId)
|
||||
{
|
||||
public AjaxResult getRelatedAchCompetitionOfExpert(Long expertId) {
|
||||
return success(achievementsService.getRelatedAchCompetitionOfExpert(expertId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "搜索行为数据记录")
|
||||
@GetMapping("/getSearchResult")
|
||||
public AjaxResult getSearchResult(String achName,Long userId)
|
||||
{
|
||||
return success(achievementsService.getSearchResult(achName,userId));
|
||||
public AjaxResult getSearchResult(String achName, Long userId) {
|
||||
return success(achievementsService.getSearchResult(achName, userId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "融办名称分类数据统计")
|
||||
@GetMapping("/getSource5Statistic")
|
||||
public AjaxResult getSource5Statistic(String name) {
|
||||
return success(achievementsService.getSource5Statistic(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入项目资源库数据
|
||||
*/
|
||||
@PostMapping("/importData")
|
||||
@Log(title = "项目资源库", businessType = BusinessType.INSERT)
|
||||
public AjaxResult importData(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception {
|
||||
if (file == null || file.isEmpty()) {
|
||||
return AjaxResult.error("上传文件不能为空");
|
||||
}
|
||||
return AjaxResult.success(achievementsService.batchImportAchievementsZip(file, updateSupport));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.microservices.common.core.web.domain.AjaxResult;
|
|||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.SchoolEnterpriseAchievements;
|
||||
import com.microservices.dms.achievementLibrary.service.ISchoolEnterpriseAchievementsService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -15,9 +16,11 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 校企成果Controller
|
||||
|
|
@ -90,6 +93,21 @@ public class SchoolEnterpriseAchievementsController extends BaseController
|
|||
return AjaxResult.success(schoolEnterpriseAchievementsService.insertSchoolEnterpriseAchievements(schoolEnterpriseAchievements));
|
||||
}
|
||||
|
||||
@PostMapping("/importData")
|
||||
@Log(title = "校企成果", businessType = BusinessType.INSERT)
|
||||
public AjaxResult importData(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception {
|
||||
ExcelUtil<SchoolEnterpriseAchievements> util = new ExcelUtil<>(SchoolEnterpriseAchievements.class);
|
||||
// 1. 解析Excel,获取实体列表和图片Map
|
||||
List<SchoolEnterpriseAchievements> list = util.importExcelWithImages(StringUtils.EMPTY, file.getInputStream(), 0);
|
||||
Map<String, MultipartFile> imageMap = util.getExcelImageMap();
|
||||
// 2. 调用业务层处理(传入实体列表和图片Map)
|
||||
String operName = SecurityUtils.getUsername();
|
||||
String message = schoolEnterpriseAchievementsService.batchInsertSchoolEnterpriseAchievements(list, imageMap, updateSupport, operName);
|
||||
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改校企成果
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,12 +1,25 @@
|
|||
package com.microservices.dms.achievementLibrary.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AchQueryVo {
|
||||
|
||||
private String areaQuery;//领域
|
||||
private String source;//来源
|
||||
private String achievementType;//成果类型
|
||||
private String achievementName;//名称
|
||||
private Long userId;
|
||||
private String userId;
|
||||
private String showAchievementName;
|
||||
private String rongbanName;
|
||||
private String maturityLevel; //成果成熟度
|
||||
private String sortBy; //排序字段
|
||||
private String sortOrder; //升降序
|
||||
private Boolean userSelf = false; //用户自己
|
||||
private Boolean allStatus = false; //所有状态
|
||||
|
||||
private List<String> achievementTypeList;//成果类型
|
||||
private List<String> sourceList;//成果类型
|
||||
|
||||
public String getAreaQuery() {
|
||||
return areaQuery;
|
||||
}
|
||||
|
|
@ -31,11 +44,11 @@ public class AchQueryVo {
|
|||
this.achievementName = achievementName;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
|
@ -46,4 +59,77 @@ public class AchQueryVo {
|
|||
public void setShowAchievementName(String showAchievementName) {
|
||||
this.showAchievementName = showAchievementName;
|
||||
}
|
||||
|
||||
public String getRongbanName() {
|
||||
return rongbanName;
|
||||
}
|
||||
|
||||
public void setRongbanName(String rongbanName) {
|
||||
this.rongbanName = rongbanName;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getAchievementTypeList() {
|
||||
return achievementTypeList;
|
||||
}
|
||||
|
||||
public void setAchievementTypeList(List<String> achievementTypeList) {
|
||||
this.achievementTypeList = achievementTypeList;
|
||||
}
|
||||
|
||||
public List<String> getSourceList() {
|
||||
return sourceList;
|
||||
}
|
||||
|
||||
public void setSourceList(List<String> sourceList) {
|
||||
this.sourceList = sourceList;
|
||||
}
|
||||
|
||||
public String getMaturityLevel() {
|
||||
return maturityLevel;
|
||||
}
|
||||
|
||||
public void setMaturityLevel(String maturityLevel) {
|
||||
this.maturityLevel = maturityLevel;
|
||||
}
|
||||
|
||||
public String getAchievementType() {
|
||||
return achievementType;
|
||||
}
|
||||
|
||||
public void setAchievementType(String achievementType) {
|
||||
this.achievementType = achievementType;
|
||||
}
|
||||
|
||||
public String getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
public void setSortBy(String sortBy) {
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
|
||||
public String getSortOrder() {
|
||||
return sortOrder;
|
||||
}
|
||||
|
||||
public void setSortOrder(String sortOrder) {
|
||||
this.sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
public Boolean getUserSelf() {
|
||||
return userSelf;
|
||||
}
|
||||
|
||||
public void setUserSelf(Boolean userSelf) {
|
||||
this.userSelf = userSelf;
|
||||
}
|
||||
|
||||
public Boolean getAllStatus() {
|
||||
return allStatus;
|
||||
}
|
||||
|
||||
public void setAllStatus(Boolean allStatus) {
|
||||
this.allStatus = allStatus;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.microservices.dms.achievementLibrary.domain;
|
||||
|
||||
import com.microservices.system.api.domain.SysDictData;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AchievementSourceDictVo extends SysDictData {
|
||||
private Long cnt;
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.microservices.dms.achievementLibrary.domain;
|
||||
|
||||
public class AchievementSourceStatisticVo {
|
||||
private String rongbanName;
|
||||
|
||||
private String rongbanDesc;
|
||||
//成果数
|
||||
private Long achievementSum;
|
||||
//点击量(浏览量)
|
||||
private Long clickSum;
|
||||
|
||||
public String getRongbanName() {
|
||||
return rongbanName;
|
||||
}
|
||||
|
||||
public void setRongbanName(String rongbanName) {
|
||||
this.rongbanName = rongbanName;
|
||||
}
|
||||
|
||||
public String getRongbanDesc() {
|
||||
return rongbanDesc;
|
||||
}
|
||||
|
||||
public void setRongbanDesc(String rongbanDesc) {
|
||||
this.rongbanDesc = rongbanDesc;
|
||||
}
|
||||
|
||||
public Long getAchievementSum() {
|
||||
return achievementSum;
|
||||
}
|
||||
|
||||
public void setAchievementSum(Long achievementSum) {
|
||||
this.achievementSum = achievementSum;
|
||||
}
|
||||
|
||||
public Long getClickSum() {
|
||||
return clickSum;
|
||||
}
|
||||
|
||||
public void setClickSum(Long clickSum) {
|
||||
this.clickSum = clickSum;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.microservices.dms.achievementLibrary.domain;
|
||||
|
||||
import com.microservices.system.api.domain.SysDictData;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AchievementTypeDictVo extends SysDictData {
|
||||
private Long cnt;
|
||||
}
|
||||
|
|
@ -38,33 +38,37 @@ public class Achievements extends BaseEntity {
|
|||
/**
|
||||
* 成果领域1
|
||||
*/
|
||||
@Excel(name = "成果领域1")
|
||||
// @Excel(
|
||||
// name = "成果领域",
|
||||
// readConverterExp = "1=理论研究,2=政策法规,3=医学,4=电子信息,5=通信工程,6=计算机科学,7=软件工程,9=人工智能,10=知识图谱,12=大数据,23=机器人,24=无人系统,25=创意征集,26=文献翻译,27=成果转化,28=科技协同,29=科研组织模式,30=新兴领域,31=其他,32=电子元器件,33=测试仪器,34=军事历史,35=计算机网络"
|
||||
// )
|
||||
@Excel(name = "成果领域一级")
|
||||
private String field1;
|
||||
//成果领域名称
|
||||
private String field1Name;
|
||||
|
||||
/**
|
||||
* 成果领域2
|
||||
* 成果领域二级
|
||||
*/
|
||||
@Excel(name = "成果领域2")
|
||||
@Excel(name = "成果领域二级")
|
||||
private String field2;
|
||||
|
||||
/**
|
||||
* 成果领域3
|
||||
* 融办描述
|
||||
*/
|
||||
@Excel(name = "成果领域3")
|
||||
@Excel(name = "融办描述")
|
||||
private String field3;
|
||||
|
||||
/**
|
||||
* 成果类型
|
||||
*/
|
||||
@Excel(name = "成果类型")
|
||||
@Excel(name = "成果类型", readConverterExp = "1=基础研究成果,2=技术开发成果,3=应用研究成果,4=软科学成果")
|
||||
private String achievementType;
|
||||
|
||||
/**
|
||||
* 成果来源
|
||||
*/
|
||||
@Excel(name = "成果来源")
|
||||
@Excel(name = "成果来源渠道", readConverterExp = "1=开源项目,2=创客任务,3=开放竞赛,4=校企成果,5=省市融办", defaultValue = "5")
|
||||
private String source;
|
||||
|
||||
/**
|
||||
|
|
@ -74,15 +78,15 @@ public class Achievements extends BaseEntity {
|
|||
private Long sourceId;
|
||||
|
||||
/**
|
||||
* 成果来源跳转链接
|
||||
* 成果来源URL
|
||||
*/
|
||||
@Excel(name = "成果来源跳转链接")
|
||||
@Excel(name = "成果来源URL")
|
||||
private String sourceLink;
|
||||
|
||||
/**
|
||||
* 成果标签
|
||||
*/
|
||||
@Excel(name = "成果标签")
|
||||
@Excel(name = "成果标签", readConverterExp = "1=高校,2=企业,3=其他")
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
|
|
@ -92,15 +96,15 @@ public class Achievements extends BaseEntity {
|
|||
private String summary;
|
||||
|
||||
/**
|
||||
* 发布单位
|
||||
* 成果提供方
|
||||
*/
|
||||
@Excel(name = "发布单位")
|
||||
@Excel(name = "成果提供方")
|
||||
private String publishingUnit;
|
||||
|
||||
/**
|
||||
* 成果地址
|
||||
* 单位概况
|
||||
*/
|
||||
@Excel(name = "成果地址")
|
||||
@Excel(name = "单位概况")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
|
|
@ -116,9 +120,9 @@ public class Achievements extends BaseEntity {
|
|||
private String contactPerson;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
* 联系方式
|
||||
*/
|
||||
@Excel(name = "联系电话")
|
||||
@Excel(name = "联系方式")
|
||||
private String contactNumber;
|
||||
|
||||
/**
|
||||
|
|
@ -140,9 +144,9 @@ public class Achievements extends BaseEntity {
|
|||
private String status;
|
||||
|
||||
/**
|
||||
* 成果详情
|
||||
* 成果简介
|
||||
*/
|
||||
@Excel(name = "成果详情")
|
||||
@Excel(name = "成果简介")
|
||||
private String details;
|
||||
|
||||
/**
|
||||
|
|
@ -167,7 +171,7 @@ public class Achievements extends BaseEntity {
|
|||
/**
|
||||
* 成果图片
|
||||
*/
|
||||
@Excel(name = "成果图片")
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
/**
|
||||
|
|
@ -176,20 +180,32 @@ public class Achievements extends BaseEntity {
|
|||
@Excel(name = "成果附件")
|
||||
private String attachments;
|
||||
|
||||
//成果小类
|
||||
@Excel(name = "成果图片视频")
|
||||
private String ext1;
|
||||
//成果状态
|
||||
|
||||
@Excel(name = "应用图片视频")
|
||||
private String ext2;
|
||||
//成果团队名称
|
||||
|
||||
@Excel(name = "应用场景")
|
||||
private String ext3;
|
||||
|
||||
private String ext4;
|
||||
private String ext5;
|
||||
|
||||
@Excel(name = "成果载体")
|
||||
private String storageType;
|
||||
@Excel(name = "成果成熟度")
|
||||
private String maturityLevel;
|
||||
@Excel(name = "推介范围")
|
||||
private String recommendScope;
|
||||
|
||||
private Long clickSum;
|
||||
private Long watcherSum;
|
||||
private Long favoriteSum;
|
||||
private Long dockSum;
|
||||
private String filedDesc;
|
||||
private Float hotRank;
|
||||
private Long attachmentCount;
|
||||
private int attachmentCount;
|
||||
private Integer isExpertAudit;
|
||||
private String userImg;
|
||||
private String userNickName;
|
||||
|
|
@ -221,6 +237,22 @@ public class Achievements extends BaseEntity {
|
|||
this.ext3 = ext3;
|
||||
}
|
||||
|
||||
public String getExt4() {
|
||||
return ext4;
|
||||
}
|
||||
|
||||
public void setExt4(String ext4) {
|
||||
this.ext4 = ext4;
|
||||
}
|
||||
|
||||
public String getExt5() {
|
||||
return ext5;
|
||||
}
|
||||
|
||||
public void setExt5(String ext5) {
|
||||
this.ext5 = ext5;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDockingUserInfo() {
|
||||
return dockingUserInfo;
|
||||
}
|
||||
|
|
@ -325,11 +357,11 @@ public class Achievements extends BaseEntity {
|
|||
this.isExpertAudit = isExpertAudit;
|
||||
}
|
||||
|
||||
public Long getAttachmentCount() {
|
||||
public int getAttachmentCount() {
|
||||
return attachmentCount;
|
||||
}
|
||||
|
||||
public void setAttachmentCount(Long attachmentCount) {
|
||||
public void setAttachmentCount(int attachmentCount) {
|
||||
this.attachmentCount = attachmentCount;
|
||||
}
|
||||
|
||||
|
|
@ -551,4 +583,27 @@ public class Achievements extends BaseEntity {
|
|||
return attachments;
|
||||
}
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setStorageType(String storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
|
||||
public String getMaturityLevel() {
|
||||
return maturityLevel;
|
||||
}
|
||||
|
||||
public void setMaturityLevel(String maturityLevel) {
|
||||
this.maturityLevel = maturityLevel;
|
||||
}
|
||||
|
||||
public String getRecommendScope() {
|
||||
return recommendScope;
|
||||
}
|
||||
|
||||
public void setRecommendScope(String recommendScope) {
|
||||
this.recommendScope = recommendScope;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
|
|||
/**
|
||||
* 成果领域1
|
||||
*/
|
||||
@Excel(name = "成果领域1")
|
||||
@Excel(
|
||||
name = "成果领域",
|
||||
readConverterExp = "1=理论研究,2=政策法规,3=医学,4=电子信息,5=通信工程,6=计算机科学,7=软件工程,9=人工智能,10=知识图谱,12=大数据,23=机器人,24=无人系统,25=创意征集,26=文献翻译,27=成果转化,28=科技协同,29=科研组织模式,30=新兴领域,31=其他,32=电子元器件,33=测试仪器,34=军事历史,35=计算机网络"
|
||||
)
|
||||
private String field1;
|
||||
|
||||
/**
|
||||
|
|
@ -50,7 +53,7 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
|
|||
/**
|
||||
* 成果类型
|
||||
*/
|
||||
@Excel(name = "成果类型")
|
||||
@Excel(name = "成果类型", readConverterExp = "1=理论成果,2=技术成果,3=应用成果,4=软科学成果,5=文化艺术成果,6=社会服务成果,7=交叉领域成果")
|
||||
private String achievementType;
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +77,10 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
|
|||
/**
|
||||
* 成果标签
|
||||
*/
|
||||
@Excel(name = "成果标签")
|
||||
@Excel(
|
||||
name = "成果标签",
|
||||
readConverterExp = "1=高校,2=企业,3=其他"
|
||||
)
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
|
|
@ -159,7 +165,7 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
|
|||
/**
|
||||
* 成果图片
|
||||
*/
|
||||
@Excel(name = "成果图片")
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
/**
|
||||
|
|
@ -169,10 +175,18 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
|
|||
private String attachments;
|
||||
private Integer achievementStatus;
|
||||
//成果小类型
|
||||
@Excel(
|
||||
name = "成果小类型",
|
||||
readConverterExp = "7=学术论文,8=学术专著,9=理论模型,10=发明专利,11=技术标准,12=软件系统,13=技术原型,14=产品设备,15=解决方案,16=示范工程,17=政策建议,18=咨询报告,19=行业标准,20=管理办法,21=文学作品,22=艺术作品,23=公益项目,24=社会调查报告,25=教育培训成果,26=理论模型+产品设备,27=学术论文+技术原型"
|
||||
)
|
||||
private String achievementLittleType;
|
||||
//成果状态
|
||||
@Excel(
|
||||
name = "成果状态",
|
||||
readConverterExp = "1=已有阶段性成果,2=已有成熟成果,3=已公开发表,4=已对外发布,5=已开展应用,6=已形成商业化产品"
|
||||
)
|
||||
private String achievementCurStatus;
|
||||
//团队名称
|
||||
@Excel(name = "成果团队名称")
|
||||
private String teamName;
|
||||
|
||||
private List<AchievementTeam> teamList;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ import com.microservices.common.datasource.annotation.Master;
|
|||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.dms.achievementLibrary.domain.*;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.AchievementSourceStatisticVo;
|
||||
import com.microservices.dms.common.vo.NameCountVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
|
||||
/**
|
||||
* 成果Mapper接口
|
||||
|
|
@ -30,6 +31,7 @@ public interface AchievementsMapper {
|
|||
* @return 成果
|
||||
*/
|
||||
public Achievements selectAchievementsById(Long id);
|
||||
public Achievements selectAchievementsByAchievementName(String achievementName);
|
||||
|
||||
/**
|
||||
* 查询成果列表
|
||||
|
|
@ -82,6 +84,7 @@ public interface AchievementsMapper {
|
|||
List<KeyValueVo> getTjByAreas();
|
||||
|
||||
List<Achievements> selectAchievementsByParam(AchQueryVo achQueryVo);
|
||||
List<Achievements> selectAchievementsByParamNew(AchQueryVo achQueryVo);
|
||||
|
||||
Long getAchievementClickSum(@Param("id") Long id);
|
||||
|
||||
|
|
@ -165,10 +168,18 @@ public interface AchievementsMapper {
|
|||
List<KeyValVo<String, Long>> getExperts(@Param("s") Date s, @Param("e") Date e);
|
||||
|
||||
List<KeyValueVo> getAllAreas(@Param("areaName") String areaName);
|
||||
List<KeyValueVo> getAllField2();
|
||||
|
||||
void updateRelationAchievements(@Param("source") String source,@Param("sourceId") Long sourceId);
|
||||
|
||||
List<Map<String, Object>> getDockingUserInfoList(@Param("id") Long id);
|
||||
|
||||
String getField1RemarkByParam(@Param("source")String source,@Param("areaKey") String areaKey);
|
||||
|
||||
AchievementSourceStatisticVo getSource5Statistic(@Param("name") String name);
|
||||
AchievementSourceStatisticVo getSource5Field2(@Param("name") String name);
|
||||
|
||||
List<NameCountVo> groupByAchievementsType();
|
||||
List<NameCountVo> groupByAchievementsSource();
|
||||
int isGitlinkAdminUser(@Param("gitlinkUserId") Long gitlinkUserId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import java.util.Map;
|
|||
|
||||
import com.microservices.dms.achievementLibrary.domain.*;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.AchievementSourceStatisticVo;
|
||||
import com.microservices.dms.common.vo.NameCountVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 成果Service接口
|
||||
|
|
@ -22,15 +25,15 @@ public interface IAchievementsService {
|
|||
* @param id 成果主键
|
||||
* @return 成果
|
||||
*/
|
||||
public Achievements selectAchievementsById(Long id);
|
||||
public Achievements selectAchievementsById(Long id, Boolean isOpenView);
|
||||
|
||||
/**
|
||||
* 查询成果列表
|
||||
*
|
||||
* @param achievements 成果
|
||||
* @param achQueryVo 成果
|
||||
* @return 成果集合
|
||||
*/
|
||||
public List<Achievements> selectAchievementsList(Achievements achievements);
|
||||
public List<Achievements> selectAchievementsList(AchQueryVo achQueryVo);
|
||||
|
||||
/**
|
||||
* 新增成果
|
||||
|
|
@ -106,6 +109,8 @@ public interface IAchievementsService {
|
|||
|
||||
int getSearchResult(String achName, Long userId);
|
||||
|
||||
AchievementSourceStatisticVo getSource5Statistic(String name);
|
||||
|
||||
List<KeyValueVo> getProjectAreasByName(String areaName);
|
||||
|
||||
List<String> getExpertAreasByName(String areaName);
|
||||
|
|
@ -123,5 +128,13 @@ public interface IAchievementsService {
|
|||
List<KeyValVo<String, Long>> get7DayAddExport(AchQueryVo achQueryVo);
|
||||
|
||||
List<KeyValueVo> getAllAreas(String areaName);
|
||||
List<KeyValueVo> getAllField2();
|
||||
|
||||
Map<String, Object> batchInsertAchievements(List<Achievements> list, boolean updateSupport, String operName);
|
||||
|
||||
String batchImportAchievementsZip(MultipartFile file, boolean updateSupport);
|
||||
|
||||
List<AchievementTypeDictVo> achievementsTypeStatistic();
|
||||
|
||||
List<AchievementSourceDictVo> achievementsSourceStatistic();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.microservices.dms.achievementLibrary.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.microservices.dms.achievementLibrary.domain.SchoolEnterpriseAchievements;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 校企成果Service接口
|
||||
|
|
@ -64,4 +67,6 @@ public interface ISchoolEnterpriseAchievementsService
|
|||
List<SchoolEnterpriseAchievements> listFront(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
|
||||
|
||||
boolean getCheckSchoolAchName(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
|
||||
|
||||
String batchInsertSchoolEnterpriseAchievements(List<SchoolEnterpriseAchievements> list, Map<String, MultipartFile> imageMap, boolean updateSupport, String operName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,57 @@
|
|||
package com.microservices.dms.achievementLibrary.service.impl;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.httpClient.service.HttpAPIService;
|
||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.*;
|
||||
import com.microservices.dms.achievementLibrary.mapper.SchoolEnterpriseAchievementsMapper;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementImageVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.AchievementSourceStatisticVo;
|
||||
import com.microservices.dms.behaviorImage.service.IBehaviorImageService;
|
||||
import com.microservices.dms.resourceLibrary.domain.Clicker;
|
||||
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.Searcher;
|
||||
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
|
||||
import com.microservices.dms.common.vo.AchievementSysFileVo;
|
||||
import com.microservices.dms.common.vo.NameCountVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.*;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import com.microservices.dms.resourceLibrary.mapper.CompetitionResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper;
|
||||
import com.microservices.dms.utils.CustomMultipartFile;
|
||||
import com.microservices.dms.utils.DateUtil;
|
||||
import com.microservices.dms.utils.FileMultipartFile;
|
||||
import com.microservices.system.api.RemoteDictDataService;
|
||||
import com.microservices.system.api.RemoteFileService;
|
||||
import com.microservices.system.api.domain.SysDictData;
|
||||
import com.microservices.system.api.domain.SysFile;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.K;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
|
||||
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.activation.FileTypeMap;
|
||||
|
||||
import static com.microservices.dms.constant.BlockChainFunConstants.QUERY_REPO;
|
||||
import static com.microservices.dms.utils.UrlUtil.getUrlPath;
|
||||
|
||||
/**
|
||||
|
|
@ -46,6 +63,9 @@ import static com.microservices.dms.utils.UrlUtil.getUrlPath;
|
|||
@Service
|
||||
@Slf4j
|
||||
public class AchievementsServiceImpl implements IAchievementsService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AchievementsServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AchievementsMapper achievementsMapper;
|
||||
|
||||
|
|
@ -59,6 +79,12 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
@Autowired
|
||||
private IBehaviorImageService behaviorImageService;
|
||||
|
||||
@Autowired
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
@Autowired
|
||||
private RemoteDictDataService remoteDictDataService;
|
||||
|
||||
@Value("${makerSpaceUrl}")
|
||||
public String makerSpaceUrl;
|
||||
|
||||
|
|
@ -75,7 +101,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
* @return 成果
|
||||
*/
|
||||
@Override
|
||||
public Achievements selectAchievementsById(Long id) {
|
||||
public Achievements selectAchievementsById(Long id, Boolean isOpenView) {
|
||||
Achievements a = achievementsMapper.selectAchievementsById(id);
|
||||
if (StringUtils.isNotNull(a)) {
|
||||
String gender = a.getGender();
|
||||
|
|
@ -86,16 +112,20 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
img = "images/avatars/User/boy.jpg";
|
||||
}
|
||||
a.setUserImg(img);
|
||||
if (StringUtils.isNotEmpty(a.getField1())) {
|
||||
if (StringUtils.isNotEmpty(a.getField1()) && !a.getSource().equals("5")) {
|
||||
String field1Name = achievementsMapper.getField1NameByParam(a.getSource(), a.getId());
|
||||
if (StringUtils.isNotNull(field1Name)) {
|
||||
a.setField1Name(field1Name);
|
||||
}
|
||||
}
|
||||
a.setUserImg(img);
|
||||
|
||||
a.setImages(buildFileInfoByIdents(a.getImages(), a.getSource()));
|
||||
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
|
||||
a.setImages( a.getImages() == null ? null : a.getImages().replace("/api/file/common/downloadByIdentifier/", "/api/file/open/downloadByIdentifier/"));
|
||||
if (isOpenView){
|
||||
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
|
||||
}
|
||||
//拼接对接的用户信息
|
||||
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfoList(a.getId());
|
||||
a.setDockingUserInfo(dockingUserInfo);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
|
@ -103,36 +133,12 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
/**
|
||||
* 查询成果列表
|
||||
*
|
||||
* @param achievements 成果
|
||||
* @param achQueryVo 成果
|
||||
* @return 成果
|
||||
*/
|
||||
@Override
|
||||
public List<Achievements> selectAchievementsList(Achievements achievements) {
|
||||
List<Achievements> list = achievementsMapper.selectAchievementsList(achievements);
|
||||
for (Achievements a : list) {
|
||||
String gender = a.getGender();
|
||||
String img = "";
|
||||
if (StringUtils.isNotEmpty(gender) && gender.equals("1")) {
|
||||
img = "images/avatars/User/girl.jpg";
|
||||
} else if (StringUtils.isNotEmpty(gender) && gender.equals("0")) {
|
||||
img = "images/avatars/User/boy.jpg";
|
||||
}
|
||||
a.setUserImg(img);
|
||||
//根据id获取领域名称
|
||||
if (StringUtils.isNotEmpty(a.getField1())) {
|
||||
String field1Name = achievementsMapper.getField1NameByParam(a.getSource(), a.getId());
|
||||
if (StringUtils.isNotNull(field1Name)) {
|
||||
a.setField1Name(field1Name);
|
||||
}
|
||||
}
|
||||
a.setImages(buildFileInfoByIdents(a.getImages(), a.getSource()));
|
||||
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
|
||||
|
||||
//拼接对接的用户信息
|
||||
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfoList(a.getId());
|
||||
a.setDockingUserInfo(dockingUserInfo);
|
||||
}
|
||||
return list;
|
||||
public List<Achievements> selectAchievementsList(AchQueryVo achQueryVo) {
|
||||
return getAllResult(achQueryVo);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -196,7 +202,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
Achievements achievements = achievementsMapper.selectAchievementsById(id);
|
||||
if(achievements != null){
|
||||
String source = achievements.getSource();
|
||||
if(StringUtils.isNotEmpty(source)) {
|
||||
if(StringUtils.isNotEmpty(source) && !source.equals("5")) {
|
||||
achievementsMapper.updateRelationAchievements(source,achievements.getSourceId());
|
||||
}
|
||||
}
|
||||
|
|
@ -211,20 +217,10 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
|
||||
List<Map<String, String>> list = JSON.parseObject(aStr, new TypeReference<List<Map<String, String>>>() {
|
||||
});
|
||||
|
||||
if (Objects.equals(source, "1") || Objects.equals(source, "3")) {
|
||||
concatUrl(list, gitLinkUrl);
|
||||
}
|
||||
|
||||
if (Objects.equals(source, "2")) {
|
||||
concatUrl(list, makerSpaceUrl);
|
||||
}
|
||||
|
||||
if (Objects.equals(source, "4")) {
|
||||
concatUrl(list, gatewayUrl);
|
||||
}
|
||||
|
||||
return JSON.toJSONString(list);
|
||||
List<Map<String, String>> filterList = list.stream()
|
||||
.filter(item -> !item.getOrDefault("name","").contains("入驻承诺书"))
|
||||
.collect(Collectors.toList());
|
||||
return JSON.toJSONString(filterList);
|
||||
}
|
||||
|
||||
private void concatUrl(List<Map<String, String>> list, String url) {
|
||||
|
|
@ -254,26 +250,28 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
@Override
|
||||
public List<Achievements> getAllResult(AchQueryVo achQueryVo) {
|
||||
//根据查询条件获取所有的成果数据
|
||||
List<Achievements> list = achievementsMapper.selectAchievementsByParam(achQueryVo);
|
||||
logger.info("getAllResult USERID======={},user={}", SecurityUtils.getGitlinkUserId(),SecurityUtils.getUsername());
|
||||
if (achQueryVo.getUserSelf() && SecurityUtils.getGitlinkUserId() != null) {
|
||||
achQueryVo.setUserId(SecurityUtils.getGitlinkUserId().toString());
|
||||
achQueryVo.setAllStatus(true);
|
||||
}
|
||||
List<Achievements> list = achievementsMapper.selectAchievementsByParamNew(achQueryVo);
|
||||
//遍历成果数据,获取对应成果的点击数
|
||||
for (Achievements a : list) {
|
||||
String gender = a.getGender();
|
||||
String img = "";
|
||||
String img = "images/avatars/User/boy.jpg";
|
||||
if (StringUtils.isNotEmpty(gender) && gender.equals("1")) {
|
||||
img = "images/avatars/User/girl.jpg";
|
||||
} else if (StringUtils.isNotEmpty(gender) && gender.equals("0")) {
|
||||
img = "images/avatars/User/boy.jpg";
|
||||
}
|
||||
a.setUserImg(img);
|
||||
//根据id获取领域名称
|
||||
if (StringUtils.isEmpty(achQueryVo.getSource()) && StringUtils.isNotEmpty(a.getField1())) {
|
||||
String field1Name = achievementsMapper.getField1NameByParam(a.getSource(), a.getId());
|
||||
if (StringUtils.isNotNull(field1Name)) {
|
||||
a.setField1Name(field1Name);
|
||||
}
|
||||
}
|
||||
Long clickSum = achievementsMapper.getAchievementClickSum(a.getId());
|
||||
a.setClickSum(clickSum);
|
||||
a.setImages( a.getImages() == null ? null : a.getImages().replace("/api/file/common/downloadByIdentifier/", "/api/file/open/downloadByIdentifier/"));
|
||||
//拼接对接的用户信息
|
||||
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfoList(a.getId());
|
||||
a.setDockingUserInfo(dockingUserInfo);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
@ -513,17 +511,19 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
@Override
|
||||
public List<AchRelatedResult> getRelatedAchCompetition(Long id, Long sourceId) {
|
||||
List<AchRelatedResult> relatedResultList = new ArrayList<>();
|
||||
//想根据开源项目id,获取对应的年度信息
|
||||
List<Long> allSourceId = achievementsMapper.getAllSourceIdCompetition(id, sourceId);
|
||||
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
|
||||
if (StringUtils.isNotNull(allYear)) {
|
||||
//遍历年度信息,获取年度成果数据
|
||||
for (String paramYear : allYear) {
|
||||
AchRelatedResult relatedResult = new AchRelatedResult();
|
||||
relatedResult.setYear(paramYear);
|
||||
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
|
||||
relatedResult.setAchRelatedVoList(tmpList);
|
||||
relatedResultList.add(relatedResult);
|
||||
if (sourceId !=null){
|
||||
//想根据开源项目id,获取对应的年度信息
|
||||
List<Long> allSourceId = achievementsMapper.getAllSourceIdCompetition(id, sourceId);
|
||||
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
|
||||
if (StringUtils.isNotNull(allYear)) {
|
||||
//遍历年度信息,获取年度成果数据
|
||||
for (String paramYear : allYear) {
|
||||
AchRelatedResult relatedResult = new AchRelatedResult();
|
||||
relatedResult.setYear(paramYear);
|
||||
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
|
||||
relatedResult.setAchRelatedVoList(tmpList);
|
||||
relatedResultList.add(relatedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
return relatedResultList;
|
||||
|
|
@ -532,17 +532,19 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
@Override
|
||||
public List<AchRelatedResult> getRelatedAchTask(Long id, Long sourceId) {
|
||||
List<AchRelatedResult> relatedResultList = new ArrayList<>();
|
||||
//想根据开源项目id,获取对应的年度信息
|
||||
List<Long> allSourceId = achievementsMapper.getAllSourceIdTask(id, sourceId);
|
||||
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
|
||||
if (StringUtils.isNotNull(allYear)) {
|
||||
//遍历年度信息,获取年度成果数据
|
||||
for (String paramYear : allYear) {
|
||||
AchRelatedResult relatedResult = new AchRelatedResult();
|
||||
relatedResult.setYear(paramYear);
|
||||
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
|
||||
relatedResult.setAchRelatedVoList(tmpList);
|
||||
relatedResultList.add(relatedResult);
|
||||
if (sourceId !=null){
|
||||
//想根据开源项目id,获取对应的年度信息
|
||||
List<Long> allSourceId = achievementsMapper.getAllSourceIdTask(id, sourceId);
|
||||
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
|
||||
if (StringUtils.isNotNull(allYear)) {
|
||||
//遍历年度信息,获取年度成果数据
|
||||
for (String paramYear : allYear) {
|
||||
AchRelatedResult relatedResult = new AchRelatedResult();
|
||||
relatedResult.setYear(paramYear);
|
||||
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
|
||||
relatedResult.setAchRelatedVoList(tmpList);
|
||||
relatedResultList.add(relatedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
return relatedResultList;
|
||||
|
|
@ -587,6 +589,15 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AchievementSourceStatisticVo getSource5Statistic(String name) {
|
||||
AchievementSourceStatisticVo ronbanVo = achievementsMapper.getSource5Field2(name);
|
||||
AchievementSourceStatisticVo statisticVo = achievementsMapper.getSource5Statistic(name);
|
||||
ronbanVo.setClickSum(statisticVo.getClickSum());
|
||||
ronbanVo.setAchievementSum(statisticVo.getAchievementSum());
|
||||
return ronbanVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyValueVo> getProjectAreasByName(String areaName) {
|
||||
return achievementsMapper.getProjectAreasByName(areaName);
|
||||
|
|
@ -629,4 +640,409 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return resultVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyValueVo> getAllField2() {
|
||||
List<KeyValueVo> resultVal = achievementsMapper.getAllField2();
|
||||
return resultVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AchievementTypeDictVo> achievementsTypeStatistic() {
|
||||
List<NameCountVo> nameCountVos = achievementsMapper.groupByAchievementsType();
|
||||
R<List<SysDictData>> feignResult = remoteDictDataService.dictType("dms_achievement_type");
|
||||
return Optional.ofNullable(feignResult.getData()).orElse(Collections.emptyList())
|
||||
.stream().map(sysDictData -> {
|
||||
AchievementTypeDictVo dictVo = new AchievementTypeDictVo();
|
||||
BeanUtils.copyProperties(sysDictData, dictVo);
|
||||
dictVo.setCnt(nameCountVos.isEmpty() ? 0 : nameCountVos.stream().filter(dict -> sysDictData.getDictValue().equals(dict.getName()))
|
||||
.mapToLong(NameCountVo::getCnt).sum());
|
||||
return dictVo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AchievementSourceDictVo> achievementsSourceStatistic() {
|
||||
List<NameCountVo> nameCountVos = achievementsMapper.groupByAchievementsSource();
|
||||
R<List<SysDictData>> feignResult = remoteDictDataService.dictType("dms_achievement_source");
|
||||
return Optional.ofNullable(feignResult.getData()).orElse(Collections.emptyList())
|
||||
.stream().map(sysDictData -> {
|
||||
AchievementSourceDictVo dictVo = new AchievementSourceDictVo();
|
||||
BeanUtils.copyProperties(sysDictData, dictVo);
|
||||
dictVo.setCnt(nameCountVos.isEmpty() ? 0 : nameCountVos.stream().filter(dict -> dict.getName().equals(sysDictData.getDictValue()))
|
||||
.mapToLong(NameCountVo::getCnt).sum());
|
||||
return dictVo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> batchInsertAchievements(List<Achievements> list, boolean updateSupport, String operName) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
throw new RuntimeException("导入项目资源数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
List<Achievements> successList = new ArrayList<>();
|
||||
|
||||
for (Achievements achievements : list) {
|
||||
try {
|
||||
// 查重:根据项目名称查询
|
||||
Achievements exist = achievementsMapper.selectAchievementsByAchievementName(achievements.getAchievementName());
|
||||
Long gitlinkUserId=SecurityUtils.getGitlinkUserId();
|
||||
Boolean gitlinkUserAdmin=achievementsMapper.isGitlinkAdminUser(gitlinkUserId) == 1;
|
||||
achievements.setStatus(gitlinkUserAdmin ? "1" : "0");
|
||||
achievements.setOwnerId(gitlinkUserId.toString());
|
||||
if (null == exist) {
|
||||
achievements.setCreateBy(operName);
|
||||
achievements.setCreateTime(new Date());
|
||||
achievements.setUpdateBy(operName);
|
||||
achievements.setUpdateTime(new Date());
|
||||
achievementsMapper.insertAchievements(achievements);
|
||||
successNum++;
|
||||
successList.add(achievements);
|
||||
successMsg.append("<br/>").append(successNum).append("、成果 ").append(achievements.getAchievementName()).append(" 导入成功");
|
||||
} else {
|
||||
if (updateSupport && exist.getOwnerId() != null && exist.getOwnerId().equals(gitlinkUserId.toString())) {
|
||||
achievements.setId(exist.getId());
|
||||
achievements.setCreateBy(exist.getCreateBy());
|
||||
achievements.setCreateTime(exist.getCreateTime());
|
||||
achievements.setUpdateBy(operName);
|
||||
achievements.setUpdateTime(new Date());
|
||||
achievementsMapper.updateAchievements(achievements);
|
||||
successNum++;
|
||||
successList.add(achievements);
|
||||
successMsg.append("<br/>").append(successNum).append("、成果 ").append(achievements.getAchievementName()).append(" 更新成功");
|
||||
} else if (!updateSupport && exist.getOwnerId() != null && exist.getOwnerId().equals(gitlinkUserId.toString())) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、成果 ").append(achievements.getAchievementName()).append(" 已存在(未开启成果重名时覆盖更新)");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、成果 ").append(achievements.getAchievementName()).append(" 其他用户已使用");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、项目 " + achievements.getAchievementName() + " 导入失败:";
|
||||
failureMsg.append(msg).append(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 组装最终提示信息
|
||||
StringBuilder finalMsg = new StringBuilder();
|
||||
if (successNum > 0) {
|
||||
finalMsg.append("共 ").append(successNum).append(" 条数据导入/更新成功:").append(successMsg);
|
||||
finalMsg.append("<br/>***压缩包共读取到 ").append(successList.stream().mapToInt(Achievements::getAttachmentCount).sum()).append(" 个文件");
|
||||
}
|
||||
if (failureNum > 0) {
|
||||
finalMsg.append("<br/>共 ").append(failureNum).append(" 条数据导入失败:").append(failureMsg);
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("successNum", successNum);
|
||||
result.put("failureNum", failureNum);
|
||||
result.put("message", finalMsg);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String batchImportAchievementsZip(MultipartFile file, boolean updateSupport) {
|
||||
// 尝试多种编码
|
||||
Charset[] charsets = {
|
||||
StandardCharsets.UTF_8,
|
||||
Charset.forName("GBK"),
|
||||
Charset.forName("GB2312"),
|
||||
Charset.forName("ISO-8859-1")
|
||||
};
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<Achievements> excelDataList = new ArrayList<>();
|
||||
Map<String, AchievementSysFileVo> mp4ImagesExt1 = new HashMap<>();
|
||||
Map<String, AchievementSysFileVo> mp4ImagesExt2 = new HashMap<>();
|
||||
Map<String, AchievementSysFileVo> attachmentMap = new HashMap<>();
|
||||
Map<String, AchievementSysFileVo> coveImages = new HashMap<>();
|
||||
|
||||
for (Charset charset : charsets) {
|
||||
ZipInputStream zipInputStream = null;
|
||||
try {
|
||||
zipInputStream = new ZipInputStream(file.getInputStream(), charset);
|
||||
ZipEntry entry;
|
||||
while ((entry = zipInputStream.getNextEntry()) != null) {
|
||||
String entryName = entry.getName();
|
||||
|
||||
// 跳过目录条目
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 统一路径分隔符(处理Windows和Unix)
|
||||
String normalizedPath = entryName.replace('\\', '/');
|
||||
String fileName = getFileName(normalizedPath);
|
||||
String parentPath = getParentPath(normalizedPath);
|
||||
|
||||
// 1. 处理 Excel 文件
|
||||
if (!entryName.endsWith("附件") && (entryName.endsWith(".xlsx") || entryName.endsWith(".xls"))) {
|
||||
byte[] content = readZipEntryContent(zipInputStream);
|
||||
try (InputStream excelStream = new ByteArrayInputStream(content)) {
|
||||
ExcelUtil<Achievements> util = new ExcelUtil<>(Achievements.class);
|
||||
List<Achievements> dataList = util.importExcel(excelStream);
|
||||
excelDataList.addAll(dataList);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// 2. 处理 MP4 - 大文件建议保存到临时文件
|
||||
|
||||
else if (parentPath.endsWith("成果图片视频") && entryName.endsWith(".mp4")) {
|
||||
File tempFile = saveToTempFile(zipInputStream, fileName);
|
||||
String contentType = "video/mp4";
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile videoFile = new FileMultipartFile(tempFile, fileName, contentType);
|
||||
// 上传视频...
|
||||
R<SysFile> fileResult = remoteFileService.upload(videoFile, "dms", "import", SecurityConstants.INNER);
|
||||
if (R.SUCCESS == fileResult.getCode()) {
|
||||
SysFile sysFile = fileResult.getData();
|
||||
AchievementSysFileVo transferVo = new AchievementSysFileVo();
|
||||
BeanUtils.copyProperties(sysFile, transferVo);
|
||||
transferVo.setK(videoFile.getOriginalFilename());
|
||||
transferVo.setV(sysFile.getUrl());
|
||||
mp4ImagesExt1.put(fileName, transferVo);
|
||||
}
|
||||
// 清理临时文件
|
||||
tempFile.delete();
|
||||
} else if (parentPath.endsWith("应用图片视频") && entryName.endsWith(".mp4")) {
|
||||
File tempFile = saveToTempFile(zipInputStream, fileName);
|
||||
String contentType = "video/mp4";
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile videoFile = new FileMultipartFile(tempFile, fileName, contentType);
|
||||
// 上传视频...
|
||||
R<SysFile> fileResult = remoteFileService.upload(videoFile, "dms", "import", SecurityConstants.INNER);
|
||||
if (R.SUCCESS == fileResult.getCode()) {
|
||||
SysFile sysFile = fileResult.getData();
|
||||
AchievementSysFileVo transferVo = new AchievementSysFileVo();
|
||||
BeanUtils.copyProperties(sysFile, transferVo);
|
||||
transferVo.setName(videoFile.getOriginalFilename());
|
||||
transferVo.setK(videoFile.getOriginalFilename());
|
||||
transferVo.setV(sysFile.getUrl());
|
||||
mp4ImagesExt2.put(fileName, transferVo);
|
||||
}
|
||||
// 清理临时文件
|
||||
tempFile.delete();
|
||||
}
|
||||
|
||||
// 3. 处理图片文件
|
||||
else if (parentPath.endsWith("成果图片视频") && isImageFile(fileName)) {
|
||||
byte[] content = readZipEntryContent(zipInputStream);
|
||||
String suffix = "png";
|
||||
if (entryName != null && entryName.contains(".")) {
|
||||
suffix = entryName.substring(entryName.lastIndexOf(".") + 1);
|
||||
}
|
||||
String contentType = "image/" + suffix;
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile imageFile = new CustomMultipartFile(content, fileName, contentType);
|
||||
R<SysFile> fileResult = remoteFileService.upload(imageFile, "dms-open", "import", SecurityConstants.INNER);
|
||||
if (R.SUCCESS == fileResult.getCode()) {
|
||||
SysFile sysFile = fileResult.getData();
|
||||
AchievementSysFileVo transferVo = new AchievementSysFileVo();
|
||||
BeanUtils.copyProperties(sysFile, transferVo);
|
||||
transferVo.setName(imageFile.getOriginalFilename());
|
||||
transferVo.setK(imageFile.getOriginalFilename());
|
||||
transferVo.setV(sysFile.getUrl());
|
||||
mp4ImagesExt1.put(fileName, transferVo);
|
||||
}
|
||||
}
|
||||
// 3. 处理图片文件
|
||||
else if (parentPath.endsWith("应用图片视频") && isImageFile(fileName)) {
|
||||
byte[] content = readZipEntryContent(zipInputStream);
|
||||
String suffix = "png";
|
||||
if (entryName != null && entryName.contains(".")) {
|
||||
suffix = entryName.substring(entryName.lastIndexOf(".") + 1);
|
||||
}
|
||||
String contentType = "image/" + suffix;
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile imageFile = new CustomMultipartFile(content, fileName, contentType);
|
||||
R<SysFile> fileResult = remoteFileService.upload(imageFile, "dms-open", "import", SecurityConstants.INNER);
|
||||
if (R.SUCCESS == fileResult.getCode()) {
|
||||
SysFile sysFile = fileResult.getData();
|
||||
AchievementSysFileVo transferVo = new AchievementSysFileVo();
|
||||
BeanUtils.copyProperties(sysFile, transferVo);
|
||||
transferVo.setName(imageFile.getOriginalFilename());
|
||||
transferVo.setK(imageFile.getOriginalFilename());
|
||||
transferVo.setV(sysFile.getUrl());
|
||||
mp4ImagesExt2.put(fileName, transferVo);
|
||||
}
|
||||
}
|
||||
else if (parentPath.endsWith("附件")) {
|
||||
File tempFile = saveToTempFile(zipInputStream, fileName);
|
||||
String contentType = FileTypeMap.getDefaultFileTypeMap().getContentType(fileName);
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile attachmentFile = new FileMultipartFile(tempFile, fileName, contentType);
|
||||
// 上传视频...
|
||||
R<SysFile> fileResult = remoteFileService.upload(attachmentFile, "dms-open", "import", SecurityConstants.INNER);
|
||||
if (R.SUCCESS == fileResult.getCode()) {
|
||||
SysFile sysFile = fileResult.getData();
|
||||
AchievementSysFileVo transferVo = new AchievementSysFileVo();
|
||||
BeanUtils.copyProperties(sysFile, transferVo);
|
||||
transferVo.setName(attachmentFile.getOriginalFilename());
|
||||
transferVo.setK(attachmentFile.getOriginalFilename());
|
||||
transferVo.setV(sysFile.getUrl());
|
||||
attachmentMap.put(fileName, transferVo);
|
||||
}
|
||||
// 清理临时文件
|
||||
tempFile.delete();
|
||||
}// 3. 处理图片文件
|
||||
else if (parentPath.endsWith("封面图") && isImageFile(fileName)) {
|
||||
byte[] content = readZipEntryContent(zipInputStream);
|
||||
String suffix = "png";
|
||||
if (entryName != null && entryName.contains(".")) {
|
||||
suffix = entryName.substring(entryName.lastIndexOf(".") + 1);
|
||||
}
|
||||
String contentType = "image/" + suffix;
|
||||
// 转换为MultipartFile并存储
|
||||
MultipartFile imageFile = new CustomMultipartFile(content, fileName, contentType);
|
||||
R<SysFile> fileResult = remoteFileService.upload(imageFile, "dms-open", "import", SecurityConstants.INNER);
|
||||
if (R.SUCCESS == fileResult.getCode()) {
|
||||
SysFile sysFile = fileResult.getData();
|
||||
AchievementSysFileVo transferVo = new AchievementSysFileVo();
|
||||
BeanUtils.copyProperties(sysFile, transferVo);
|
||||
transferVo.setName(imageFile.getOriginalFilename());
|
||||
transferVo.setK(imageFile.getOriginalFilename());
|
||||
transferVo.setV(sysFile.getUrl());
|
||||
coveImages.put(fileName, transferVo);
|
||||
}
|
||||
}
|
||||
|
||||
zipInputStream.closeEntry();
|
||||
}
|
||||
logger.info("✅ 使用 " + charset.displayName() + " 编码成功读取 ZIP");
|
||||
List<Achievements> saveDataList = excelDataList.stream()
|
||||
.filter(item -> StringUtils.isNotEmpty(item.getSource()) && StringUtils.isNotEmpty(item.getAchievementName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
saveDataList.forEach(achievements -> {
|
||||
List<Object> mp4ImagesExt1List = mp4ImagesExt1.entrySet().stream()
|
||||
.filter(item -> item.getKey().contains(achievements.getAchievementName()))
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toList());
|
||||
List<Object> mp4ImagesExt2List = mp4ImagesExt2.entrySet().stream()
|
||||
.filter(item -> item.getKey().contains(achievements.getAchievementName()))
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toList());
|
||||
List<Object> filterAttachmentList = attachmentMap.entrySet().stream()
|
||||
.filter(item -> item.getKey().contains("入驻承诺书") || item.getKey().contains(achievements.getAchievementName()))
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toList());
|
||||
List<Object> coveImagesList = coveImages.entrySet().stream()
|
||||
.filter(item -> item.getKey().contains(achievements.getAchievementName()))
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toList());
|
||||
if (!mp4ImagesExt1List.isEmpty()){
|
||||
achievements.setExt1(JSONObject.toJSONString(mp4ImagesExt1List));
|
||||
achievements.setAttachmentCount(achievements.getAttachmentCount() + mp4ImagesExt1List.size());
|
||||
}
|
||||
if (!mp4ImagesExt2List.isEmpty()){
|
||||
achievements.setExt2(JSONObject.toJSONString(mp4ImagesExt2List));
|
||||
achievements.setAttachmentCount(achievements.getAttachmentCount() + mp4ImagesExt2List.size());
|
||||
}
|
||||
if (!filterAttachmentList.isEmpty()){
|
||||
achievements.setAttachments(JSONObject.toJSONString(filterAttachmentList));
|
||||
achievements.setAttachmentCount(achievements.getAttachmentCount() + filterAttachmentList.size());
|
||||
}
|
||||
if (!coveImagesList.isEmpty()){
|
||||
achievements.setImages(JSONObject.toJSONString(coveImagesList));
|
||||
achievements.setAttachmentCount(achievements.getAttachmentCount() + coveImagesList.size());
|
||||
}
|
||||
});
|
||||
|
||||
// 保存 Excel 数据到数据库
|
||||
String operName = SecurityUtils.getUsername();
|
||||
Map<String, Object> resultMap = saveDataList.isEmpty() ? new HashMap<>() : batchInsertAchievements(saveDataList, updateSupport, operName);
|
||||
//
|
||||
return resultMap.get("message") ==null ? "未去读取到数据,请确认文件压缩目录是否正确" : resultMap.get("message").toString();
|
||||
} catch (IOException e) {
|
||||
logger.error("读取文件失败: " + e.getMessage());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.error("使用 " + charset.displayName() + " 编码失败: " + ex.getMessage());
|
||||
} finally {
|
||||
if (zipInputStream != null) {
|
||||
try {
|
||||
zipInputStream.close();
|
||||
}catch (IOException exc){
|
||||
exc.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存流内容到临时文件
|
||||
*/
|
||||
private File saveToTempFile(ZipInputStream zipInputStream, String fileName) throws IOException {
|
||||
Path tempFile = Files.createTempFile("temp_", "_" + fileName);
|
||||
try (FileOutputStream fos = new FileOutputStream(tempFile.toFile())) {
|
||||
byte[] buffer = new byte[8192];
|
||||
int len;
|
||||
while ((len = zipInputStream.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
return tempFile.toFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取 ZipEntry 的内容到字节数组(Java 8 兼容)
|
||||
*/
|
||||
private byte[] readZipEntryContent(ZipInputStream zipInputStream) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[8192]; // 8KB 缓冲区
|
||||
int len;
|
||||
while ((len = zipInputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
// 辅助方法:判断是否为图片
|
||||
private boolean isImageFile(String fileName) {
|
||||
String lower = fileName.toLowerCase();
|
||||
return lower.endsWith(".jpg") || lower.endsWith(".jpeg") ||
|
||||
lower.endsWith(".png") || lower.endsWith(".gif") || lower.endsWith(".bmp");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名(去掉路径)
|
||||
*/
|
||||
private String getFileName(String path) {
|
||||
if (path == null || path.isEmpty()) return "";
|
||||
int lastSlash = path.lastIndexOf('/');
|
||||
if (lastSlash >= 0) {
|
||||
return path.substring(lastSlash + 1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父路径(去掉文件名)
|
||||
*/
|
||||
private String getParentPath(String path) {
|
||||
if (path == null || path.isEmpty()) return "";
|
||||
int lastSlash = path.lastIndexOf('/');
|
||||
if (lastSlash >= 0) {
|
||||
return path.substring(0, lastSlash);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String buildFileInfoByIdentifiers(String identifiers) {
|
||||
if (StringUtils.isEmpty(identifiers)) {
|
||||
return identifiers;
|
||||
}
|
||||
R<List<SysFileInfo>> result = remoteFileService.getFileListByIdentifier(identifiers);
|
||||
return JSON.toJSONString(result.getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,34 @@
|
|||
package com.microservices.dms.achievementLibrary.service.impl;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
import com.microservices.common.core.constant.UserConstants;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.AchievementTeam;
|
||||
import com.microservices.dms.achievementLibrary.domain.Achievements;
|
||||
import com.microservices.dms.achievementLibrary.mapper.AchievementTeamMapper;
|
||||
import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
|
||||
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
|
||||
import com.microservices.system.api.domain.SysUser;
|
||||
import com.microservices.system.api.RemoteFileService;
|
||||
import com.microservices.system.api.model.LoginUser;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.microservices.dms.achievementLibrary.mapper.SchoolEnterpriseAchievementsMapper;
|
||||
import com.microservices.dms.achievementLibrary.domain.SchoolEnterpriseAchievements;
|
||||
import com.microservices.dms.achievementLibrary.service.ISchoolEnterpriseAchievementsService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
/**
|
||||
* 校企成果Service业务层处理
|
||||
|
|
@ -41,6 +50,9 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
|
|||
@Autowired
|
||||
private AchievementsMapper achievementsMapper;
|
||||
|
||||
@Autowired
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 查询校企成果
|
||||
*
|
||||
|
|
@ -124,6 +136,144 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
|
|||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入成果数据(包含图片处理)
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
@Slave
|
||||
public String batchInsertSchoolEnterpriseAchievements(List<SchoolEnterpriseAchievements> list,
|
||||
Map<String, MultipartFile> imageMap,
|
||||
boolean updateSupport,
|
||||
String operName) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
throw new RuntimeException("导入成果数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
int imageErrorNum = 0; // 新增:图片处理失败数
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
StringBuilder imageErrorMsg = new StringBuilder(); // 新增:图片错误信息
|
||||
|
||||
for (SchoolEnterpriseAchievements schoolEnterpriseAchievement : list) {
|
||||
try {
|
||||
// 处理图片字段(优化后:返回处理结果,不抛出异常)
|
||||
String imageHandleResult = handleAchievementImage(schoolEnterpriseAchievement, imageMap);
|
||||
if (imageHandleResult.contains("失败") || imageHandleResult.contains("异常")) {
|
||||
imageErrorNum++;
|
||||
imageErrorMsg.append("<br/>").append(imageErrorNum).append("、成果 ").append(schoolEnterpriseAchievement.getAchievementName()).append(" 图片处理失败:").append(imageHandleResult);
|
||||
}
|
||||
|
||||
// 原有查重和入库逻辑(不受图片处理影响)
|
||||
SchoolEnterpriseAchievements exist = schoolEnterpriseAchievementsMapper.selectSchoolEnterpriseAchievementsByName(schoolEnterpriseAchievement.getAchievementName());
|
||||
if (exist == null) {
|
||||
schoolEnterpriseAchievement.setCreateBy(operName);
|
||||
schoolEnterpriseAchievement.setCreateTime(new Date());
|
||||
schoolEnterpriseAchievement.setUpdateBy(operName);
|
||||
schoolEnterpriseAchievement.setUpdateTime(new Date());
|
||||
schoolEnterpriseAchievement.setStatus("2");
|
||||
schoolEnterpriseAchievementsMapper.insertSchoolEnterpriseAchievements(schoolEnterpriseAchievement);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、成果 ").append(schoolEnterpriseAchievement.getAchievementName()).append(" 导入成功");
|
||||
} else {
|
||||
if (updateSupport) {
|
||||
schoolEnterpriseAchievement.setId(exist.getId());
|
||||
schoolEnterpriseAchievement.setCreateBy(exist.getCreateBy());
|
||||
schoolEnterpriseAchievement.setCreateTime(exist.getCreateTime());
|
||||
schoolEnterpriseAchievement.setUpdateBy(operName);
|
||||
schoolEnterpriseAchievement.setUpdateTime(new Date());
|
||||
schoolEnterpriseAchievementsMapper.updateSchoolEnterpriseAchievements(schoolEnterpriseAchievement);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、成果 ").append(schoolEnterpriseAchievement.getAchievementName()).append(" 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、成果 ").append(schoolEnterpriseAchievement.getAchievementName()).append(" 已存在(未开启更新)");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、成果 " + schoolEnterpriseAchievement.getAchievementName() + " 导入失败:";
|
||||
failureMsg.append(msg).append(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 组装最终提示信息(包含图片处理错误)
|
||||
StringBuilder finalMsg = new StringBuilder();
|
||||
if (successNum > 0) {
|
||||
finalMsg.append("共 ").append(successNum).append(" 条数据导入/更新成功:").append(successMsg);
|
||||
}
|
||||
if (failureNum > 0) {
|
||||
finalMsg.append("<br/>共 ").append(failureNum).append(" 条数据导入失败:").append(failureMsg);
|
||||
}
|
||||
if (imageErrorNum > 0) {
|
||||
finalMsg.append("<br/>共 ").append(imageErrorNum).append(" 条数据图片处理失败:").append(imageErrorMsg);
|
||||
}
|
||||
|
||||
return finalMsg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理成果图片:上传并格式化存储(FastJSON解析版)
|
||||
* @param achievement 成果实体
|
||||
* @param imageMap Excel解析出的图片映射表
|
||||
* @return 图片处理结果提示(成功/失败信息)
|
||||
*/
|
||||
private String handleAchievementImage(SchoolEnterpriseAchievements achievement, Map<String, MultipartFile> imageMap) {
|
||||
String imageCellKey = achievement.getImages();
|
||||
if (StringUtils.isEmpty(imageCellKey) || !imageMap.containsKey(imageCellKey)) {
|
||||
achievement.setImages("[]");
|
||||
return "无图片,跳过处理";
|
||||
}
|
||||
|
||||
try {
|
||||
MultipartFile file = imageMap.get(imageCellKey);
|
||||
byte[] fileBytes = file.getBytes();
|
||||
|
||||
if (fileBytes == null || fileBytes.length == 0) {
|
||||
return "图片文件为空,跳过处理";
|
||||
}
|
||||
|
||||
// 构建 HashMap 参数
|
||||
String originalFilename = StringUtils.isEmpty(file.getOriginalFilename())
|
||||
? "excel_import_image_" + System.currentTimeMillis() + ".png"
|
||||
: file.getOriginalFilename();
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("base64Data", Base64.getEncoder().encodeToString(fileBytes));
|
||||
params.put("fileName", originalFilename);
|
||||
params.put("contentType", file.getContentType());
|
||||
params.put("size", fileBytes.length);
|
||||
|
||||
// 调用 Base64 上传接口
|
||||
R<?> fileResult = remoteFileService.uploadBase64(params, "dms", "import", SecurityConstants.INNER);
|
||||
|
||||
// 解析结果(与原逻辑相同)
|
||||
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData())) {
|
||||
String errorMsg = !StringUtils.isNull(fileResult) ? fileResult.getMsg() : "接口返回异常";
|
||||
return "图片上传失败:" + errorMsg;
|
||||
}
|
||||
|
||||
JSONObject resultJson = JSONObject.parseObject(JSONObject.toJSONString(fileResult.getData()));
|
||||
String fileOriginName = resultJson.getString("fileOriginName");
|
||||
String url = resultJson.getString("downloadUrl");
|
||||
Integer fileId = resultJson.getInteger("fileId");
|
||||
|
||||
if (StringUtils.isEmpty(fileOriginName) || StringUtils.isEmpty(url) || fileId == null) {
|
||||
return "图片上传成功,但返回数据不完整";
|
||||
}
|
||||
|
||||
String imageJson = String.format("[{\"k\":\"%s\",\"v\":\"%s\",\"id\":%d}]",
|
||||
fileOriginName, url, fileId);
|
||||
achievement.setImages(imageJson);
|
||||
|
||||
return "图片处理成功";
|
||||
|
||||
} catch (Exception e) {
|
||||
return "图片处理异常:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改校企成果
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.microservices.dms.common.controller;
|
|||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.common.security.annotation.RequiresLogin;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
|
||||
import com.microservices.dms.achievementLibrary.service.BlockChainService;
|
||||
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
|
||||
|
|
@ -107,6 +109,44 @@ public class OpenController extends BaseController {
|
|||
return getDataTable(achievementsService.getAllResult(achQueryVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成果详细信息
|
||||
*/
|
||||
@GetMapping(value = "/achievements/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(achievementsService.selectAchievementsById(id, true));
|
||||
}
|
||||
|
||||
@ApiOperation("首页成果分类统计")
|
||||
@GetMapping("/achievements/typeStatistic")
|
||||
public AjaxResult achievementsTypeStatistic() {
|
||||
return success(achievementsService.achievementsTypeStatistic());
|
||||
}
|
||||
|
||||
@ApiOperation("首页成果来源统计")
|
||||
@GetMapping("/achievements/sourceStatistic")
|
||||
public AjaxResult achievementsSourceStatistic() {
|
||||
return success(achievementsService.achievementsSourceStatistic());
|
||||
}
|
||||
|
||||
@ApiOperation("根据成果ID,获取成果的相关行为数据统计(点击量、搜索量、附件下载量、收藏、关注)")
|
||||
@GetMapping("/achievements/getActDataStatisticById")
|
||||
public AjaxResult getActDataStatisticById(Long id) {
|
||||
return success(achievementsService.getActDataStatisticById(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取开源竞赛的相关成果")
|
||||
@GetMapping("/achievements/getRelatedAchCompetition")
|
||||
public AjaxResult getRelatedAchCompetition(Long id, Long sourceId) {
|
||||
return success(achievementsService.getRelatedAchCompetition(id, sourceId));
|
||||
}
|
||||
|
||||
@ApiOperation("根据当前用户以及成果ID,获取当前成果的 是否收藏与关注状态")
|
||||
@GetMapping("/achievements/getWatchFavoriteStatusById")
|
||||
public AjaxResult getWatchFavoriteStatusById(Long id, Long userId) {
|
||||
return success(achievementsService.getWatchFavoriteStatusById(id, userId));
|
||||
}
|
||||
|
||||
@ApiOperation("近七日用户行为数据")
|
||||
@GetMapping("/achievements/getUerActionData")
|
||||
public AjaxResult getUerActionData() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.microservices.dms.common.vo;
|
||||
|
||||
import com.microservices.system.api.domain.SysFile;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AchievementSysFileVo extends SysFile {
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String k;
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private String v;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.microservices.dms.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NameCountVo {
|
||||
private String name;
|
||||
private long cnt;
|
||||
}
|
||||
|
|
@ -1,11 +1,15 @@
|
|||
package com.microservices.dms.resourceLibrary.controller;
|
||||
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.CompetitionListVo;
|
||||
import com.microservices.dms.resourceLibrary.service.CompetitionResourceLibraryService;
|
||||
|
|
@ -17,6 +21,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
|
@ -78,6 +83,17 @@ public class CompetitionResourceLibraryController extends BaseController {
|
|||
util.exportExcel(response, list, "数据");
|
||||
}
|
||||
|
||||
@PostMapping("/importData")
|
||||
@Log(title = "竞赛资源库", businessType = BusinessType.INSERT)
|
||||
public AjaxResult importData(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception {
|
||||
ExcelUtil<CompetitionResourceLibrary> util = new ExcelUtil<CompetitionResourceLibrary>(CompetitionResourceLibrary.class);
|
||||
List<CompetitionResourceLibrary> list = util.importExcel(StringUtils.EMPTY, file.getInputStream(), 0);
|
||||
String operName = SecurityUtils.getUsername();
|
||||
String message = competitionResourceLibraryService.batchInsertCompetitionResourceLibrary(list, updateSupport, operName);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(competitionResourceLibraryService.selectCompetitionResourceLibraryById(id));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.microservices.dms.resourceLibrary.controller;
|
||||
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -8,16 +9,18 @@ import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
|||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.dms.resourceLibrary.domain.ProjectResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.ProjectListVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.TaskListVo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.UserActionDataVo;
|
||||
import com.microservices.dms.resourceLibrary.service.ProjectResourceLibraryService;
|
||||
import com.microservices.dms.resourceLibrary.service.TaskResourceLibraryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
|
@ -122,6 +125,23 @@ public class ProjectResourceLibraryController extends BaseController {
|
|||
util.exportExcel(response, list, "数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入项目资源库数据
|
||||
*/
|
||||
@PostMapping("/importData")
|
||||
@Log(title = "项目资源库", businessType = BusinessType.INSERT)
|
||||
public AjaxResult importData(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception {
|
||||
ExcelUtil<ProjectResourceLibrary> util = new ExcelUtil<>(ProjectResourceLibrary.class);
|
||||
// 解析Excel,获取实体列表
|
||||
List<ProjectResourceLibrary> list = util.importExcel(StringUtils.EMPTY, file.getInputStream(), 0);
|
||||
// 调用业务层处理
|
||||
String operName = SecurityUtils.getUsername();
|
||||
String message = projectResourceLibraryService.batchInsertProjectResourceLibrary(list, updateSupport, operName);
|
||||
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(projectResourceLibraryService.selectProjectResourceLibraryById(id));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.microservices.dms.resourceLibrary.controller;
|
||||
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -8,6 +9,7 @@ import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
|||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.TaskListVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.UserActionDataVo;
|
||||
|
|
@ -18,6 +20,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
|
@ -134,6 +137,17 @@ public class TaskResourceLibraryController extends BaseController {
|
|||
util.exportExcel(response, list, "数据");
|
||||
}
|
||||
|
||||
@PostMapping("/importData")
|
||||
@Log(title = "任务资源库", businessType = BusinessType.INSERT)
|
||||
public AjaxResult importData(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception {
|
||||
ExcelUtil<TaskResourceLibrary> util = new ExcelUtil<TaskResourceLibrary>(TaskResourceLibrary.class);
|
||||
List<TaskResourceLibrary> list = util.importExcel(StringUtils.EMPTY, file.getInputStream(), 0);
|
||||
String operName = SecurityUtils.getUsername();
|
||||
String message = taskResourceLibraryService.batchInsertTaskResourceLibrary(list, updateSupport, operName);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(taskResourceLibraryService.selectTaskResourceLibraryById(id));
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.microservices.common.core.annotation.Excel;
|
||||
import com.microservices.common.core.web.domain.BaseEntity;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
|
||||
|
|
@ -19,10 +20,12 @@ public class CompetitionResourceLibrary extends BaseEntity {
|
|||
/**
|
||||
* 开放竞赛ID
|
||||
*/
|
||||
@Excel(name = "竞赛ID")
|
||||
private Long openCompetitionId;
|
||||
/**
|
||||
* 开放竞赛名称
|
||||
*/
|
||||
@Excel(name = "竞赛名称")
|
||||
private String openCompetitionName;
|
||||
/**
|
||||
* 开放竞赛创建者
|
||||
|
|
@ -31,23 +34,28 @@ public class CompetitionResourceLibrary extends BaseEntity {
|
|||
/**
|
||||
* 竞赛领域
|
||||
*/
|
||||
@Excel(name = "成果领域")
|
||||
private String competitionField;
|
||||
/**
|
||||
* 竞赛状态 status: 0 未上架 1上架
|
||||
*/
|
||||
@Excel(name = "竞赛状态", readConverterExp = "0=未上架,1=上架")
|
||||
private String competitionStatus;
|
||||
/**
|
||||
* 竞赛提交名称
|
||||
*/
|
||||
@Excel(name = "作品名称")
|
||||
private String competitionSubmissionName;
|
||||
/**
|
||||
* 作品提交时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "作品提交时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date submissionTime;
|
||||
/**
|
||||
* 提交者
|
||||
*/
|
||||
@Excel(name = "提交人")
|
||||
private String submitter;
|
||||
/**
|
||||
* 提交类型
|
||||
|
|
@ -76,11 +84,13 @@ public class CompetitionResourceLibrary extends BaseEntity {
|
|||
/**
|
||||
* 是否已转入成果库 0否 1是
|
||||
*/
|
||||
@Excel(name = "转入状态", readConverterExp = "0=未转入,1=已转入")
|
||||
private Integer isTransferredToResultLibrary;
|
||||
/**
|
||||
* 转入成果库时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "转入时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date transferredToResultLibraryTime;
|
||||
/**
|
||||
* 是否精选成果
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.microservices.common.core.annotation.Excel;
|
||||
import com.microservices.common.core.web.domain.BaseEntity;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
|
||||
|
|
@ -18,8 +19,10 @@ public class ProjectResourceLibrary extends BaseEntity {
|
|||
private static final long serialVersionUID = 1L;
|
||||
private Long id;
|
||||
//项目资源名称
|
||||
@Excel(name = "项目名称")
|
||||
private String projectName;
|
||||
//项目领域
|
||||
@Excel(name = "成果领域")
|
||||
private String projectDomain;
|
||||
//项目领域名称
|
||||
private String projectDomainName;
|
||||
|
|
@ -27,19 +30,24 @@ public class ProjectResourceLibrary extends BaseEntity {
|
|||
private String identifier;
|
||||
private String userIdentifier;
|
||||
//开源项目ID
|
||||
@Excel(name = "项目ID")
|
||||
private Long projectId;
|
||||
//仓库ID
|
||||
private Long repositoryId;
|
||||
//版本Id
|
||||
private Long versionReleasesId;
|
||||
//项目是否已公开
|
||||
@Excel(name = "是否公开", readConverterExp = "0=否,1=是")
|
||||
private Long isPublic;
|
||||
//发版名称
|
||||
@Excel(name = "发行版名称")
|
||||
private String releaseName;
|
||||
//发版时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "发版时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date releaseDate;
|
||||
//发版人
|
||||
@Excel(name = "发版人")
|
||||
private String releasePerson;
|
||||
//发版类型
|
||||
private String releaseType;
|
||||
|
|
@ -54,9 +62,11 @@ public class ProjectResourceLibrary extends BaseEntity {
|
|||
//联系时间
|
||||
private String contactPhone;
|
||||
//是否已转入成果库
|
||||
@Excel(name = "转入状态", readConverterExp = "0=未转入,1=已转入")
|
||||
private Long isTransferredToAchievement;
|
||||
//转入成果库时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "转入时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date transferDate;
|
||||
//是否精选成果
|
||||
private Long isSelectedAchievement;
|
||||
|
|
|
|||
|
|
@ -21,21 +21,28 @@ public class TaskResourceLibrary extends BaseEntity {
|
|||
//
|
||||
private Long id;
|
||||
//创客任务ID
|
||||
@Excel(name = "任务ID")
|
||||
private Long taskId;
|
||||
//
|
||||
private Long paperId;
|
||||
//创客任务名称
|
||||
@Excel(name = "任务名称")
|
||||
private String taskName;
|
||||
//任务领域
|
||||
@Excel(name = "成果领域")
|
||||
private String taskDomain;
|
||||
//创客任务金额
|
||||
@Excel(name = "任务金额(元)")
|
||||
private BigDecimal taskAmount;
|
||||
//胜出交稿名称
|
||||
@Excel(name = "成果编号")
|
||||
private String submissionName;
|
||||
//交稿时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "交稿时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date submissionDate;
|
||||
//交稿人
|
||||
@Excel(name = "交稿人")
|
||||
private String submitterName;
|
||||
//交稿类型
|
||||
private String submissionType;
|
||||
|
|
@ -50,9 +57,11 @@ public class TaskResourceLibrary extends BaseEntity {
|
|||
//联系电话
|
||||
private String contactPhone;
|
||||
//是否已转入成果库
|
||||
@Excel(name = "转入状态", readConverterExp = "0=未转入,1=已转入")
|
||||
private Long isTransferredToResultsLibrary;
|
||||
//转入成果库时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "转入时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date transferToResultsDate;
|
||||
//是否精选成果 0否 1是
|
||||
private Long isSelectedResult;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ public interface CompetitionResourceLibraryMapper {
|
|||
|
||||
CompetitionResourceLibrary selectCompetitionResourceLibraryById(Long id);
|
||||
|
||||
CompetitionResourceLibrary selectCompetitionResourceLibraryByCompetitionName(@Param("competitionName") String competitionName);
|
||||
|
||||
List<CompetitionResourceLibrary> selectCompetitionResourceLibraryList(CompetitionResourceLibrary competitionResourceLibrary);
|
||||
|
||||
int insertCompetitionResourceLibrary(CompetitionResourceLibrary competitionResourceLibrary);
|
||||
|
|
|
|||
|
|
@ -73,4 +73,6 @@ public interface ProjectResourceLibraryMapper {
|
|||
String getUserIdBYLogin(@Param("userId")String userId);
|
||||
|
||||
UserProjectTransferRecords selectIssueEndInfo(@Param("issueId") String issueId);
|
||||
|
||||
ProjectResourceLibrary selectProjectResourceLibraryByProjectName(@Param("projectName") String projectName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,4 +110,6 @@ public interface TaskResourceLibraryMapper {
|
|||
int delWatcher(Watcher watcher);
|
||||
|
||||
double getConvertedTaskAmount2();
|
||||
|
||||
TaskResourceLibrary selectTaskResourceLibraryByTaskName(@Param("taskName") String taskName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,4 +149,61 @@ public class CompetitionResourceLibraryService {
|
|||
// 这里替换成你的实际逻辑
|
||||
return competitionResourceLibraryMapper.getReviewCompetitionCount();
|
||||
}
|
||||
|
||||
public String batchInsertCompetitionResourceLibrary(List<CompetitionResourceLibrary> list, boolean updateSupport, String operName) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return "导入数据为空";
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
for (CompetitionResourceLibrary competitionResourceLibrary : list) {
|
||||
try {
|
||||
String competitionName = competitionResourceLibrary.getOpenCompetitionName();
|
||||
if (competitionName == null || competitionName.trim().isEmpty()) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、竞赛名称为空,导入失败");
|
||||
continue;
|
||||
}
|
||||
|
||||
CompetitionResourceLibrary existCompetition = competitionResourceLibraryMapper.selectCompetitionResourceLibraryByCompetitionName(competitionName);
|
||||
|
||||
if (existCompetition == null) {
|
||||
// 不存在,插入
|
||||
competitionResourceLibrary.setCreateBy(operName);
|
||||
competitionResourceLibrary.setCreateTime(DateUtils.getNowDate());
|
||||
competitionResourceLibraryMapper.insertCompetitionResourceLibrary(competitionResourceLibrary);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、竞赛 ").append(competitionName).append(" 导入成功");
|
||||
} else if (updateSupport) {
|
||||
// 存在且支持更新
|
||||
competitionResourceLibrary.setId(existCompetition.getId());
|
||||
competitionResourceLibrary.setUpdateBy(operName);
|
||||
competitionResourceLibrary.setUpdateTime(DateUtils.getNowDate());
|
||||
competitionResourceLibraryMapper.updateCompetitionResourceLibrary(competitionResourceLibrary);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、竞赛 ").append(competitionName).append(" 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、竞赛 ").append(competitionName).append(" 已存在");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、竞赛 " + competitionResourceLibrary.getOpenCompetitionName() + " 导入失败";
|
||||
failureMsg.append(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "导入完成,共 " + failureNum + " 条数据格式不正确:");
|
||||
if (successNum > 0) {
|
||||
failureMsg.append("<br/>成功导入 ").append(successNum).append(" 条数据");
|
||||
}
|
||||
return failureMsg.toString();
|
||||
}
|
||||
successMsg.insert(0, "导入成功,共 " + successNum + " 条数据:");
|
||||
return successMsg.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,4 +140,62 @@ public class ProjectResourceLibraryService {
|
|||
public long getTotalConversionCount() {
|
||||
return projectResourceLibraryMapper.getTotalConversionCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入项目资源库数据
|
||||
*/
|
||||
public String batchInsertProjectResourceLibrary(List<ProjectResourceLibrary> list, boolean updateSupport, String operName) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
throw new RuntimeException("导入项目资源数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
for (ProjectResourceLibrary projectResourceLibrary : list) {
|
||||
try {
|
||||
// 查重:根据项目名称查询
|
||||
ProjectResourceLibrary exist = projectResourceLibraryMapper.selectProjectResourceLibraryByProjectName(projectResourceLibrary.getProjectName());
|
||||
if (exist == null) {
|
||||
projectResourceLibrary.setCreateBy(operName);
|
||||
projectResourceLibrary.setCreateTime(new Date());
|
||||
projectResourceLibrary.setUpdateBy(operName);
|
||||
projectResourceLibrary.setUpdateTime(new Date());
|
||||
projectResourceLibraryMapper.insertProjectResourceLibrary(projectResourceLibrary);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、项目 ").append(projectResourceLibrary.getProjectName()).append(" 导入成功");
|
||||
} else {
|
||||
if (updateSupport) {
|
||||
projectResourceLibrary.setId(exist.getId());
|
||||
projectResourceLibrary.setCreateBy(exist.getCreateBy());
|
||||
projectResourceLibrary.setCreateTime(exist.getCreateTime());
|
||||
projectResourceLibrary.setUpdateBy(operName);
|
||||
projectResourceLibrary.setUpdateTime(new Date());
|
||||
projectResourceLibraryMapper.updateProjectResourceLibrary(projectResourceLibrary);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、项目 ").append(projectResourceLibrary.getProjectName()).append(" 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、项目 ").append(projectResourceLibrary.getProjectName()).append(" 已存在(未开启更新)");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、项目 " + projectResourceLibrary.getProjectName() + " 导入失败:";
|
||||
failureMsg.append(msg).append(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 组装最终提示信息
|
||||
StringBuilder finalMsg = new StringBuilder();
|
||||
if (successNum > 0) {
|
||||
finalMsg.append("共 ").append(successNum).append(" 条数据导入/更新成功:").append(successMsg);
|
||||
}
|
||||
if (failureNum > 0) {
|
||||
finalMsg.append("<br/>共 ").append(failureNum).append(" 条数据导入失败:").append(failureMsg);
|
||||
}
|
||||
|
||||
return finalMsg.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.microservices.dms.constant.TaskConstant.MARKER_SPACE_DOWNLOAD_API_BY_ID;
|
||||
|
||||
|
|
@ -209,4 +211,61 @@ public class TaskResourceLibraryService {
|
|||
public int delWatcher(Watcher watcher) {
|
||||
return taskResourceLibraryMapper.delWatcher(watcher);
|
||||
}
|
||||
|
||||
public String batchInsertTaskResourceLibrary(List<TaskResourceLibrary> list, boolean updateSupport, String operName) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return "导入数据为空";
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
for (TaskResourceLibrary taskResourceLibrary : list) {
|
||||
try {
|
||||
String taskName = taskResourceLibrary.getTaskName();
|
||||
if (taskName == null || taskName.trim().isEmpty()) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、任务名称为空,导入失败");
|
||||
continue;
|
||||
}
|
||||
|
||||
TaskResourceLibrary existTask = taskResourceLibraryMapper.selectTaskResourceLibraryByTaskName(taskName);
|
||||
|
||||
if (existTask == null) {
|
||||
// 不存在,插入
|
||||
taskResourceLibrary.setCreateBy(operName);
|
||||
taskResourceLibrary.setCreateTime(DateUtils.getNowDate());
|
||||
taskResourceLibraryMapper.insertTaskResourceLibrary(taskResourceLibrary);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、任务 ").append(taskName).append(" 导入成功");
|
||||
} else if (updateSupport) {
|
||||
// 存在且支持更新
|
||||
taskResourceLibrary.setId(existTask.getId());
|
||||
taskResourceLibrary.setUpdateBy(operName);
|
||||
taskResourceLibrary.setUpdateTime(DateUtils.getNowDate());
|
||||
taskResourceLibraryMapper.updateTaskResourceLibrary(taskResourceLibrary);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、任务 ").append(taskName).append(" 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、任务 ").append(taskName).append(" 已存在");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、任务 " + taskResourceLibrary.getTaskName() + " 导入失败";
|
||||
failureMsg.append(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "导入完成,共 " + failureNum + " 条数据格式不正确:");
|
||||
if (successNum > 0) {
|
||||
failureMsg.append("<br/>成功导入 ").append(successNum).append(" 条数据");
|
||||
}
|
||||
return failureMsg.toString();
|
||||
}
|
||||
successMsg.insert(0, "导入成功,共 " + successNum + " 条数据:");
|
||||
return successMsg.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package com.microservices.dms.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 自定义MultipartFile实现(通用版,无外部依赖)
|
||||
*/
|
||||
public class CustomMultipartFile implements MultipartFile {
|
||||
private final byte[] content;
|
||||
private final String filename;
|
||||
private final String contentType;
|
||||
|
||||
public CustomMultipartFile(byte[] content, String filename, String contentType) {
|
||||
this.content = content;
|
||||
this.filename = filename;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return content == null || content.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return content.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(java.io.File dest) throws IOException, IllegalStateException {
|
||||
try (java.io.OutputStream os = new java.io.FileOutputStream(dest)) {
|
||||
os.write(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.microservices.dms.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class FileMultipartFile implements MultipartFile {
|
||||
|
||||
private final File file;
|
||||
// private final String name;
|
||||
private final String originalFilename;
|
||||
private final String contentType;
|
||||
private byte[] content; // 延迟加载缓存
|
||||
|
||||
public FileMultipartFile(File file, String originalFilename, String contentType) {
|
||||
this.file = file;
|
||||
this.originalFilename = originalFilename;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
// 简化构造方法(自动推断文件名和ContentType)
|
||||
public FileMultipartFile(File file) {
|
||||
this.file = file;
|
||||
this.originalFilename = file.getName();
|
||||
this.contentType = guessContentType(file.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return originalFilename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return file.length() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return file.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
if (content == null) {
|
||||
content = Files.readAllBytes(file.toPath());
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
try (InputStream is = new FileInputStream(file);
|
||||
OutputStream os = new FileOutputStream(dest)) {
|
||||
byte[] buffer = new byte[8192];
|
||||
int length;
|
||||
while ((length = is.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 辅助方法:根据文件扩展名猜测ContentType
|
||||
private static String guessContentType(String fileName) {
|
||||
if (fileName == null) return "application/octet-stream";
|
||||
|
||||
String lowerName = fileName.toLowerCase();
|
||||
if (lowerName.endsWith(".mp4")) return "video/mp4";
|
||||
if (lowerName.endsWith(".jpg") || lowerName.endsWith(".jpeg")) return "image/jpeg";
|
||||
if (lowerName.endsWith(".png")) return "image/png";
|
||||
if (lowerName.endsWith(".gif")) return "image/gif";
|
||||
if (lowerName.endsWith(".pdf")) return "application/pdf";
|
||||
if (lowerName.endsWith(".zip")) return "application/zip";
|
||||
if (lowerName.endsWith(".xlsx")) return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
if (lowerName.endsWith(".xls")) return "application/vnd.ms-excel";
|
||||
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9119
|
||||
port: 8080
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -41,13 +41,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="ext1" column="ext1" />
|
||||
<result property="ext2" column="ext2" />
|
||||
<result property="ext3" column="ext3" />
|
||||
<result property="ext4" column="ext4" />
|
||||
<result property="ext5" column="ext5" />
|
||||
<result property="storageType" column="storage_type" />
|
||||
<result property="maturityLevel" column="maturity_level" />
|
||||
<result property="recommendScope" column="recommend_scope" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAchievementsVo">
|
||||
select id, IFNULL(show_ach_name,achievement_name) as "showAchievementName", achievement_name,hot_rank, field_1, field_2, field_3,
|
||||
attachment_count,is_expert_audit,achievement_type, source, source_id, source_link, tags, summary, publishing_unit, address,
|
||||
is_featured, contact_person, contact_number, owner_id, owner_name, status, details, reviewer, review_date, review_comments, images,
|
||||
attachments, create_by, create_time, update_by, update_time,ext1,ext2,ext3 from achievements
|
||||
select id, IFNULL(show_ach_name,achievement_name) as "showAchievementName", achievement_name,field_1,field_2,field_3,achievement_type,source,source_id,source_link,
|
||||
tags,summary,publishing_unit,address,is_featured,contact_person,contact_number,owner_id,owner_name,`status`,details,reviewer,review_date,review_comments,
|
||||
images,attachments,create_by,create_time,update_by,update_time,attachment_count,is_expert_audit,ext1,ext2,ext3,hot_rank,show_ach_name,
|
||||
storage_type,maturity_level,recommend_scope,ext4,ext5
|
||||
</sql>
|
||||
|
||||
<select id="selectAchievementsList" parameterType="Achievements" resultMap="AchievementsResult">
|
||||
|
|
@ -85,6 +90,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectAchievementsById" parameterType="Long" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name,a.field_1,a.field_2,a.field_3,a.achievement_type,a.source,a.source_id,a.source_link,a.tags,a.summary,
|
||||
a.publishing_unit,a.address,a.is_featured,a.contact_person,a.contact_number,a.owner_id,a.owner_name,a.`status`,a.details,a.reviewer,a.review_date,a.review_comments,a.images,a.attachments,a.create_by,a.create_time,
|
||||
a.update_by,a.update_time,a.attachment_count,a.is_expert_audit,a.ext1,a.ext2,a.ext3,a.hot_rank,a.show_ach_name,a.storage_type,a.maturity_level,a.recommend_scope,a.ext4,a.ext5,
|
||||
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = a.id) as watcherSum,
|
||||
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = a.id) as favoriteSum
|
||||
from achievements a
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectAchievementsByAchievementName" parameterType="String" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName",a.achievement_name,a.hot_rank,a.field_1,a.field_2,a.field_3,a.attachment_count,
|
||||
a.is_expert_audit,a.achievement_type,a.source,a.source_id,a.ext1,a.ext2,a.ext3
|
||||
,u.login as "userLogin",IFNULL(u.nickname,owner_name) as "userNickName",ue.gender as "gender",
|
||||
|
|
@ -93,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from achievements a
|
||||
left join users u on a.owner_name = u.login
|
||||
left join user_extensions ue on u.id = ue.user_id
|
||||
where a.id = #{id}
|
||||
where a.achievement_name = #{achievementName}
|
||||
</select>
|
||||
|
||||
<select id="getFileInfoByIdents" resultType="java.util.Map">
|
||||
|
|
@ -142,6 +157,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="ext1 != null">ext1,</if>
|
||||
<if test="ext2 != null">ext2,</if>
|
||||
<if test="ext3 != null">ext3,</if>
|
||||
<if test="ext4 != null">ext4,</if>
|
||||
<if test="ext5 != null">ext5,</if>
|
||||
<if test="storageType != null">storage_type,</if>
|
||||
<if test="maturityLevel != null">maturity_level,</if>
|
||||
<if test="recommendScope != null">recommend_scope,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="showAchievementName != null">#{showAchievementName},</if>
|
||||
|
|
@ -179,6 +199,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="ext1 != null">#{ext1},</if>
|
||||
<if test="ext2 != null">#{ext2},</if>
|
||||
<if test="ext3 != null">#{ext3},</if>
|
||||
<if test="ext4 != null">#{ext4},</if>
|
||||
<if test="ext5 != null">#{ext5},</if>
|
||||
<if test="storageType != null">#{storageType},</if>
|
||||
<if test="maturityLevel != null">#{maturityLevel},</if>
|
||||
<if test="recommendScope != null">#{recommendScope},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -220,6 +245,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="ext3 != null">ext3 = #{ext3},</if>
|
||||
<if test="ext2 != null">ext2 = #{ext2},</if>
|
||||
<if test="ext1 != null">ext1 = #{ext1},</if>
|
||||
<if test="ext4 != null">ext4 = #{ext4},</if>
|
||||
<if test="ext5 != null">ext5 = #{ext5},</if>
|
||||
<if test="storageType != null">storage_type = #{storageType},</if>
|
||||
<if test="maturityLevel != null">maturity_level = #{maturityLevel},</if>
|
||||
<if test="recommendScope != null">recommend_scope = #{recommendScope},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
@ -267,9 +297,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
limit 0,5
|
||||
</select>
|
||||
|
||||
<select id="selectAchievementsByParamNew" parameterType="com.microservices.dms.achievementLibrary.domain.AchQueryVo" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name,a.field_1,a.field_2,a.field_3,a.achievement_type,a.source,a.source_id,a.source_link,a.tags,a.summary,
|
||||
a.publishing_unit,a.address,a.is_featured,a.contact_person,a.contact_number,a.owner_id,a.owner_name,a.`status`,a.details,a.reviewer,a.review_date,a.review_comments,a.images,a.attachments,a.create_by,a.create_time,
|
||||
a.update_by,a.update_time,a.attachment_count,a.is_expert_audit,a.ext1,a.ext2,a.ext3,a.hot_rank,a.show_ach_name,a.storage_type,a.maturity_level,a.recommend_scope,a.ext4,a.ext5,
|
||||
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = a.id) as watcherSum,
|
||||
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = a.id) as favoriteSum
|
||||
from achievements a
|
||||
<where>
|
||||
and 1 = 1
|
||||
<if test='allStatus == false'> and a.status='1'</if>
|
||||
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
|
||||
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
|
||||
<if test="source != null and source != ''"> and a.source = #{source}</if>
|
||||
<if test="maturityLevel != null and maturityLevel != ''"> and a.maturity_level = #{maturityLevel}</if>
|
||||
<if test='areaQuery != null and areaQuery != "" '>
|
||||
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery})
|
||||
</if>
|
||||
<if test='userSelf != null and userSelf == true'>and a.owner_id = #{userId}</if>
|
||||
<if test='sourceList != null '>
|
||||
and a.source in
|
||||
<foreach collection="sourceList" item="source" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{source}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test='achievementTypeList != null '>
|
||||
and a.achievement_type in
|
||||
<foreach collection="achievementTypeList" item="achievementType" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{achievementType}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by
|
||||
<choose>
|
||||
<when test="sortBy == 'createTime'">create_time</when>
|
||||
<when test="sortBy == 'updateTime'">update_time</when>
|
||||
<otherwise>create_time</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="sortOrder == 'asc'">ASC</when>
|
||||
<otherwise>desc</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectAchievementsByParam" parameterType="com.microservices.dms.achievementLibrary.domain.AchQueryVo" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
||||
<if test="source == '' or source == null">
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName",a.achievement_name,a.summary,a.create_time,a.owner_name,a.tags,a.field_1,a.field_2,a.field_3,a.source,a.source_id,
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName",a.achievement_name,a.summary,a.create_time,a.owner_name,a.tags,a.field_1,a.field_2,a.field_3,a.source,a.source_id,a.images,
|
||||
u.login as "userLogin",
|
||||
IFNULL(u.nickname,a.owner_name) as "userNickName",
|
||||
ue.gender as "gender",
|
||||
|
|
@ -282,11 +357,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and a.status='1'
|
||||
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
|
||||
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
|
||||
<if test='areaQuery != null and areaQuery != "" '>
|
||||
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery} or a.field_3 = #{areaQuery})
|
||||
</if>
|
||||
</where>
|
||||
order by a.create_time desc
|
||||
</if>
|
||||
<if test='source=="1"'>
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,a.images,
|
||||
c.name as "field1Name",u.login as "userLogin",
|
||||
IFNULL(u.nickname,a.owner_name) as "userNickName",
|
||||
ue.gender as "gender",
|
||||
|
|
@ -307,16 +385,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
order by create_time desc
|
||||
</if>
|
||||
<if test='source=="2" or source=="3" or source=="4" '>
|
||||
select a.id, IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
|
||||
c.name as "field1Name",u.login as "userLogin",
|
||||
IFNULL(u.nickname,a.owner_name) as "userNickName",
|
||||
ue.gender as "gender",
|
||||
<if test='source=="2" or source=="3" or source=="4" or source=="5" '>
|
||||
select a.id, IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,a.images,
|
||||
c.name as "field1Name",'' as "userLogin",'' as "userNickName",'' as "gender",
|
||||
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = a.id) as watcherSum,
|
||||
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = a.id) as favoriteSum
|
||||
from achievements a
|
||||
left join users u on a.owner_name = u.login
|
||||
left join user_extensions ue on u.id = ue.user_id
|
||||
left join categories c on a.field_1 = c.id
|
||||
<where>
|
||||
and a.status='1'
|
||||
|
|
@ -326,6 +400,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test='areaQuery != null and areaQuery != "" '>
|
||||
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery} or a.field_3 = #{areaQuery})
|
||||
</if>
|
||||
<if test="rongbanName != null and rongbanName != ''"> and a.field_2 = #{rongbanName}</if>
|
||||
</where>
|
||||
order by a.create_time desc
|
||||
</if>
|
||||
|
|
@ -783,6 +858,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
inner join categories p on a.field_1 = p.id
|
||||
where a.id=#{id}
|
||||
</if>
|
||||
<if test='source != null and source == "5"'>
|
||||
select p.name from achievements a
|
||||
inner join categories p on a.field_1 = p.id
|
||||
where a.id=#{id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getField1RemarkByParam" resultType="String">
|
||||
|
|
@ -904,6 +984,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
GROUP BY r.name
|
||||
</select>
|
||||
|
||||
<select id="getAllField2" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
|
||||
select distinct r.field_2 as "name", r.field_2 as "result" from achievements r where source="5"
|
||||
</select>
|
||||
|
||||
<update id="updateRelationAchievements">
|
||||
<if test='source != null and source == "1"'>
|
||||
update project_resource_library set is_transferred_to_achievement='0' ,transfer_date=null where id = #{sourceId}
|
||||
|
|
@ -927,4 +1011,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join personalities p on e.id = p.entity_id
|
||||
where click_type='userDocking' and click_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getSource5Statistic" parameterType="String" resultType="com.microservices.dms.achievementLibrary.domain.AchievementSourceStatisticVo">
|
||||
SELECT
|
||||
count( DISTINCT clickers.id ) AS clickSum,
|
||||
count( DISTINCT achievements.id ) AS achievementSum
|
||||
FROM
|
||||
achievements LEFT JOIN clickers ON clickers.click_type = 'Achievements' AND click_id = achievements.id
|
||||
WHERE
|
||||
achievements.source = '5' and achievements.field_2 = #{name}
|
||||
</select>
|
||||
|
||||
<select id="getSource5Field2" parameterType="String" resultType="com.microservices.dms.achievementLibrary.domain.AchievementSourceStatisticVo">
|
||||
SELECT field_2 as rongbanName, field_3 as rongbanDesc FROM achievements WHERE achievements.source = '5' and achievements.field_2 = #{name} order by id desc limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="groupByAchievementsSource" parameterType="String" resultType="com.microservices.dms.common.vo.NameCountVo">
|
||||
SELECT source as name,count(*) as cnt FROM `achievements` where status = '1' GROUP BY source
|
||||
</select>
|
||||
|
||||
<select id="groupByAchievementsType" parameterType="String" resultType="com.microservices.dms.common.vo.NameCountVo">
|
||||
SELECT achievement_type as name ,count(*) as cnt FROM `achievements` where status = '1' GROUP BY achievement_type
|
||||
</select>
|
||||
|
||||
<select id="isGitlinkAdminUser" parameterType="Long" resultType="int">
|
||||
SELECT count(*) from users where id = #{gitlinkUserId} and admin=1
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -198,6 +198,11 @@
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectCompetitionResourceLibraryByCompetitionName" parameterType="String" resultMap="CompetitionResourceLibraryResult">
|
||||
<include refid="selectCompetitionResourceLibraryVo"/>
|
||||
where open_competition_name = #{competitionName}
|
||||
</select>
|
||||
|
||||
<select id="getAttachments" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select uuid as v, filename as k
|
||||
from attachments
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@
|
|||
from (
|
||||
(select count(1) as "auditSum"
|
||||
from memos
|
||||
where destroy_status is null and hidden = 0 and published_at is not null) a,
|
||||
where destroy_status is null and hidden = 0 and published_at is not null AND root_id IS NULL) a,
|
||||
(select count(1) as "allSum" from memos) b,
|
||||
(select count(1) as "currentYearSum"
|
||||
from memos
|
||||
|
|
|
|||
|
|
@ -469,4 +469,44 @@
|
|||
inner join projects p on i.project_id = p.id
|
||||
where issue_id = #{issueId} and status_id in ('1','2') and i.blockchain_token_num >0
|
||||
</select>
|
||||
|
||||
<select id="selectProjectResourceLibraryByProjectName" parameterType="String"
|
||||
resultType="com.microservices.dms.resourceLibrary.domain.ProjectResourceLibrary">
|
||||
select pl.id,
|
||||
p.name as project_name,
|
||||
p.identifier,
|
||||
p.id as project_id,
|
||||
r.id as repository_id,
|
||||
v.id as version_releases_id,
|
||||
p.is_public as is_public,
|
||||
v.name as release_name,
|
||||
v.updated_at as release_date,
|
||||
(select login from users where id=v.user_id) as release_person,
|
||||
(select login from users where id=v.user_id) as user_identifier,
|
||||
IFNULL(pl.project_domain,p.project_category_id) as project_domain,
|
||||
pl.release_type,
|
||||
pl.release_unit,
|
||||
v.body,
|
||||
IFNULL( pl.release_summary,v.body) as release_summary,
|
||||
IFNULL( pl.release_details,v.body) as release_details,
|
||||
p.description as release_summary,
|
||||
p.description as release_details,
|
||||
pl.contact_person,
|
||||
pl.contact_phone,
|
||||
pl.is_transferred_to_achievement,
|
||||
pl.transfer_date,
|
||||
pl.is_selected_achievement,
|
||||
pl.images,
|
||||
v.zipball_url as attachments,
|
||||
pl.create_by,
|
||||
pl.create_time,
|
||||
pl.update_by,
|
||||
pl.update_time
|
||||
from projects p
|
||||
join repositories r on p.id = r.project_id
|
||||
join version_releases v on r.id = v.repository_id
|
||||
left join project_resource_library pl on v.id = pl.version_releases_id
|
||||
where p.name = #{projectName}
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -513,6 +513,11 @@
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectTaskResourceLibraryByTaskName" parameterType="String" resultMap="TaskResourceLibraryResult">
|
||||
<include refid="selectTaskResourceLibraryVo"/>
|
||||
where task_name = #{taskName}
|
||||
</select>
|
||||
|
||||
<select id="getAttachments" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select b.file_name as k, b.id as v
|
||||
from paper_details pd
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9198
|
||||
port: 8080
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select count(*)
|
||||
from tasks
|
||||
where is_delete = 0 and `status` between 3 and 8
|
||||
and (`name` IS NULL OR NAME NOT REGEXP '[二三四五六七八九2-9]次[))]')
|
||||
</select>
|
||||
<select id="getTotalApplicantCount" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
|
|
@ -57,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select COALESCE(SUM(bounty), 0)
|
||||
from tasks
|
||||
where is_delete = 0 and `status` between 3 and 8
|
||||
and (`name` IS NULL OR NAME NOT REGEXP '[二三四五六七八九2-9]次[))]')
|
||||
</select>
|
||||
<select id="getTaskPublishedCountsByYear" resultType="map">
|
||||
SELECT
|
||||
|
|
@ -67,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
is_delete = 0
|
||||
AND STATUS BETWEEN 3 AND 8
|
||||
and (`name` IS NULL OR NAME NOT REGEXP '[二三四五六七八九2-9]次[))]')
|
||||
AND YEAR(created_at) IN (YEAR(CURDATE()) - 2, YEAR(CURDATE()),YEAR(CURDATE()) - 1, YEAR(CURDATE()))
|
||||
GROUP BY
|
||||
YEAR(created_at)
|
||||
|
|
@ -82,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
is_delete = 0
|
||||
AND STATUS BETWEEN 3 AND 8
|
||||
and (`name` IS NULL OR NAME NOT REGEXP '[二三四五六七八九2-9]次[))]')
|
||||
AND YEAR(created_at) IN (YEAR(CURDATE()) - 2, YEAR(CURDATE()),YEAR(CURDATE()) - 1, YEAR(CURDATE()))
|
||||
GROUP BY
|
||||
YEAR(created_at)
|
||||
|
|
@ -210,7 +214,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getPaidAwardAmount" resultType="java.lang.Float">
|
||||
SELECT COALESCE(SUM(bounty), 0) AS total_bounty
|
||||
FROM tasks
|
||||
WHERE is_delete = 0 AND `status` = 8;
|
||||
WHERE is_delete = 0 AND `status` = 8
|
||||
and (`name` IS NULL OR NAME NOT REGEXP '[二三四五六七八九2-9]次[))]')
|
||||
</select>
|
||||
<select id="getTotalVisits" resultType="java.lang.Integer">
|
||||
SELECT COALESCE(SUM(visits), 0) AS total_visits
|
||||
|
|
|
|||
|
|
@ -1,20 +1,26 @@
|
|||
package com.microservices.file.controller;
|
||||
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.security.annotation.InnerAuth;
|
||||
import com.microservices.file.service.ISysFileInfoService;
|
||||
import com.microservices.system.api.domain.SysFile;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import com.microservices.system.api.utils.StandardMultipartFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件请求处理
|
||||
*
|
||||
|
|
@ -49,4 +55,56 @@ public class SysFileController extends BaseController {
|
|||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping("/upload/base64")
|
||||
public R<SysFileInfo> uploadBase64(@RequestBody Map<String, Object> params,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam("hierarchy") String hierarchy) {
|
||||
try {
|
||||
// 1. 提取参数
|
||||
String base64Data = (String) params.get("base64Data");
|
||||
String fileName = (String) params.get("fileName");
|
||||
String contentType = (String) params.get("contentType");
|
||||
|
||||
// 2. 参数校验
|
||||
if (StringUtils.isEmpty(base64Data)) {
|
||||
return R.fail("base64Data不能为空");
|
||||
}
|
||||
|
||||
// 3. Base64解码
|
||||
byte[] fileBytes;
|
||||
try {
|
||||
fileBytes = Base64.getDecoder().decode(base64Data);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Base64解码失败", e);
|
||||
return R.fail("图片数据格式错误");
|
||||
}
|
||||
|
||||
if (fileBytes.length == 0) {
|
||||
return R.fail("解码后文件为空");
|
||||
}
|
||||
|
||||
// 4. 构造MultipartFile
|
||||
String originalFilename = StringUtils.isEmpty(fileName)
|
||||
? "base64_image_" + System.currentTimeMillis() + ".png"
|
||||
: fileName;
|
||||
|
||||
MultipartFile multipartFile = new StandardMultipartFile(
|
||||
fileBytes,
|
||||
"file", // 字段名,与原接口一致
|
||||
originalFilename,
|
||||
contentType
|
||||
);
|
||||
|
||||
// 5. 复用原有上传逻辑
|
||||
SysFileInfo fileInfo = sysFileInfoService.upload(multipartFile, type, hierarchy);
|
||||
|
||||
return R.ok(fileInfo);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Base64上传文件失败", e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -375,6 +375,7 @@ public class SysFileInfoServiceImpl implements ISysFileInfoService {
|
|||
hierarchy = validPathSafety(hierarchy);
|
||||
}
|
||||
boolean isLocalUpload = true;
|
||||
boolean isOpen = false;
|
||||
Long fileId = null;
|
||||
switch (fileType) {
|
||||
case "pms-gitlink":
|
||||
|
|
@ -415,6 +416,14 @@ public class SysFileInfoServiceImpl implements ISysFileInfoService {
|
|||
isCommonFileType = false;
|
||||
break;
|
||||
}
|
||||
case "dms-open": {
|
||||
// 项目管理下需生成唯一标识,防止用户通过id递增访问
|
||||
sysFileInfo.setFileIdentifier(genFileIdentifier());
|
||||
baseFilePath += "/" + fileType + "/";
|
||||
isCommonFileType = false;
|
||||
isOpen = true;
|
||||
break;
|
||||
}
|
||||
case "resource": {
|
||||
baseFilePath += "/" + fileType + "/";
|
||||
isCommonFileType = false;
|
||||
|
|
@ -492,7 +501,7 @@ public class SysFileInfoServiceImpl implements ISysFileInfoService {
|
|||
if (isCommonFileType) {
|
||||
url = EscapeUtil.removeExtraSlashOfUrl(domain + "/statics/" + filePath);
|
||||
} else if (StringUtils.isNotEmpty(sysFileInfo.getFileIdentifier())) {
|
||||
url = EscapeUtil.removeExtraSlashOfUrl(domain + "/common/downloadByIdentifier/" + sysFileInfo.getFileIdentifier());
|
||||
url = EscapeUtil.removeExtraSlashOfUrl(domain + (isOpen ? "/open/downloadByIdentifier/" : "/common/downloadByIdentifier/") + sysFileInfo.getFileIdentifier());
|
||||
} else {
|
||||
url = EscapeUtil.removeExtraSlashOfUrl(domain + "/open/download/" + fileId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9111
|
||||
port: 8080
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9113
|
||||
port: 8080
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,127 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-modules</artifactId>
|
||||
<version>3.6.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>microservices-modules-mon</artifactId>
|
||||
|
||||
<description>
|
||||
microservices-modules-mon运维监控模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Microservices Common Async -->
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-async</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Microservices Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Microservices Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Microservices Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Microservices Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-httpClient</artifactId>
|
||||
<version>3.6.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.microservices.mon;
|
||||
|
||||
import com.microservices.common.security.annotation.EnableCustomConfig;
|
||||
import com.microservices.common.security.annotation.EnableRyFeignClients;
|
||||
import com.microservices.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 运维监控模块
|
||||
*
|
||||
* @author otto
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class MicroservicesMonApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MicroservicesMonApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 运维监控模块启动成功 ლ(´ڡ`ლ)゙ \n");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.microservices.mon.k8s.controller;
|
||||
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.domain.GenericsAjaxResult;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.mon.k8s.domain.*;
|
||||
import com.microservices.mon.k8s.service.IK8sDashboardService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("dashboard")
|
||||
@Api(tags = "微服务大屏")
|
||||
@RefreshScope
|
||||
public class DashboardController extends BaseController {
|
||||
@Autowired
|
||||
private IK8sDashboardService k8sDashboardService;
|
||||
|
||||
/**
|
||||
* 获取命名空间列表
|
||||
*/
|
||||
@ApiOperation(value = "获取命名空间列表")
|
||||
@GetMapping("/namespace/list")
|
||||
public GenericsTableDataInfo<K8sNamespace> namespaceList(@RequestParam(value = "search", required = false) @ApiParam(value = "根据应用名称查找") String search) {
|
||||
return new GenericsTableDataInfo<>(k8sDashboardService.getNamespaceDetailList(true,search));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取集群节点列表")
|
||||
@GetMapping("/cluster/Nodelist")
|
||||
public GenericsTableDataInfo<K8sClusterNode> clusterNodeList() {
|
||||
return new GenericsTableDataInfo<>(k8sDashboardService.getClusterNodeList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取应用容器Ip列表")
|
||||
@GetMapping("/application/{kind}/{namespace}/{applicationName}/podIdList")
|
||||
public GenericsTableDataInfo<String> applicationPodIdList(@PathVariable("kind") String kind, @PathVariable("namespace") String namespace, @PathVariable("applicationName") String applicationName) {
|
||||
return new GenericsTableDataInfo<>(k8sDashboardService.getApplicationPodIdList(kind, namespace, applicationName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取集群状态数据")
|
||||
@GetMapping("/cluster/status")
|
||||
public GenericsAjaxResult<K8sClusterStatus> clusterStatus() {
|
||||
return GenericsAjaxResult.success(k8sDashboardService.getClusterStatus());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "集群每秒请求率(QPS)")
|
||||
@GetMapping("/cluster/qps")
|
||||
public GenericsTableDataInfo<MetricCommonData> clusterQps() {
|
||||
return new GenericsTableDataInfo<>(k8sDashboardService.getClusterQps());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "最近24小时应用接口请求次数")
|
||||
@GetMapping("/cluster/applicationRequestCount")
|
||||
public GenericsTableDataInfo<ApplicationRequestCountData> applicationRequestCount() {
|
||||
return new GenericsTableDataInfo<>(k8sDashboardService.getApplicationRequestCount());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取Pod容器状态")
|
||||
@GetMapping("/cluster/podContainerStatus/{podName}")
|
||||
public GenericsAjaxResult<K8sPodContainerStatus> podContainerStatus(@PathVariable("podName") String podName) {
|
||||
return GenericsAjaxResult.success(k8sDashboardService.getPodContainerStatus(podName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取服务器节点状态")
|
||||
@GetMapping("/cluster/nodeStatus/{nodeIp}")
|
||||
public GenericsAjaxResult<K8sNodeStatus> nodeStatus(@PathVariable("nodeIp") String nodeIp) {
|
||||
return GenericsAjaxResult.success(k8sDashboardService.getNodeStatus(nodeIp));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取微服务应用功能列表")
|
||||
@GetMapping("/applicationFunction/{kind}/{namespace}/{applicationName}")
|
||||
public GenericsTableDataInfo<ApplicationFunction> applicationFunction(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestParam("podIpList") @ApiParam(value = "Pod Ip列表(使用逗号分割的ip列表字符串)") String podIpList) {
|
||||
return new GenericsTableDataInfo<>(k8sDashboardService.getApplicationFunction(kind, namespace, applicationName, podIpList));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
package com.microservices.mon.k8s.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.domain.GenericsAjaxResult;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.mon.k8s.domain.*;
|
||||
import com.microservices.mon.k8s.domain.vo.ApplicationEnvTypeVo;
|
||||
import com.microservices.mon.k8s.domain.vo.ApplicationTypeVo;
|
||||
import com.microservices.mon.k8s.domain.vo.CommonTypeVo;
|
||||
import com.microservices.mon.k8s.service.IMicroManagementService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("micro")
|
||||
@Api(tags = "微服务管理")
|
||||
@RefreshScope
|
||||
public class MicroManagementController extends BaseController {
|
||||
@Autowired
|
||||
private IMicroManagementService microManagementService;
|
||||
|
||||
@ApiOperation(value = "获取可视化面板容器列表")
|
||||
@GetMapping("/pod/list")
|
||||
public GenericsTableDataInfo<K8sApplicationPod> podList() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getPodList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取微服务运行状态监控数据")
|
||||
@GetMapping("/pod/status/{podName}")
|
||||
public GenericsAjaxResult<K8sPodContainerMetricOverview> podStatus(@PathVariable("podName") String podName,
|
||||
@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return GenericsAjaxResult.success(microManagementService.getPodStatus(podName, step));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取微服务应用详情")
|
||||
@GetMapping("/application/{kind}/{namespace}/{applicationName}/detail")
|
||||
public GenericsAjaxResult<K8sApplication> applicationDetail(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName) {
|
||||
return GenericsAjaxResult.success(microManagementService.getApplicationDetail(kind, namespace, applicationName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除POD容器")
|
||||
@DeleteMapping("/pod/{namespace}/{podName}")
|
||||
public AjaxResult applicationDetail(@PathVariable("namespace") String namespace,
|
||||
@PathVariable("podName") String podName,
|
||||
@RequestParam(value = "isForce", required = false) @ApiParam(value = "是否强制删除") Boolean isForce) {
|
||||
return toAjax(microManagementService.deletePod(namespace, podName, isForce));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "操作应用")
|
||||
@PutMapping("/application/{kind}/{namespace}/{applicationName}/operate/{operationKey}")
|
||||
public AjaxResult operateApplication(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@PathVariable("operationKey") String operationKey) {
|
||||
return toAjax(microManagementService.operateApplication(kind, namespace, applicationName, operationKey));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取应用类型")
|
||||
@GetMapping("/applicationType")
|
||||
public GenericsTableDataInfo<ApplicationTypeVo> applicationType() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getApplicationTypeList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "创建应用")
|
||||
@PostMapping("/application/{kind}")
|
||||
public AjaxResult createApplication(@PathVariable("kind") String kind,
|
||||
@RequestBody String yamlContent) {
|
||||
return AjaxResult.success(microManagementService.createApplication(kind, yamlContent));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取应用Yaml文件")
|
||||
@GetMapping(value = "/application/{kind}/{namespace}/{applicationName}/yamlFile", produces = "application/yaml")
|
||||
public JSONObject getApplicationYamlFile(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName) {
|
||||
return microManagementService.getApplicationYamlFile(kind, namespace, applicationName);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑应用Yaml文件")
|
||||
@PutMapping("/application/{kind}/{namespace}/{applicationName}")
|
||||
public AjaxResult editApplication(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestBody String yamlContent) {
|
||||
return toAjax(microManagementService.editApplication(kind, namespace, applicationName, yamlContent));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除应用")
|
||||
@DeleteMapping("/application/{kind}/{namespace}/{applicationName}")
|
||||
public AjaxResult deleteApplication(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName) {
|
||||
return toAjax(microManagementService.deleteApplication(kind, namespace, applicationName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取应用环境变量")
|
||||
@GetMapping(value = "/application/{kind}/{namespace}/{applicationName}/env")
|
||||
public GenericsTableDataInfo<K8sApplicationEnv> getApplicationEnv(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName) {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getApplicationEnv(kind, namespace, applicationName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取应用环境变量相关可选参数")
|
||||
@GetMapping(value = "/application/{namespace}/envOptionalParameters")
|
||||
public GenericsTableDataInfo<K8sApplicationEnvOptionalParameter> getEnvOptionalParameters(@PathVariable("namespace") String namespace) {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getEnvOptionalParameters(namespace));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新应用环境变量")
|
||||
@PutMapping("/application/{kind}/{namespace}/{applicationName}/env")
|
||||
public AjaxResult updateApplicationEnv(@PathVariable("kind") String kind,
|
||||
@PathVariable("namespace") String namespace,
|
||||
@PathVariable("applicationName") String applicationName,
|
||||
@RequestBody List<K8sApplicationEnv> k8sApplicationEnvList) {
|
||||
return toAjax(microManagementService.updateApplicationEnv(kind, namespace, applicationName, k8sApplicationEnvList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取应用环境变量类型")
|
||||
@GetMapping(value = "/application/envTypes")
|
||||
public GenericsTableDataInfo<ApplicationEnvTypeVo> getEnvTypes() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getEnvTypes());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取网关路由配置")
|
||||
@GetMapping(value = "/gateway/routeConfig")
|
||||
public GenericsTableDataInfo<GatewayRouteConfig> getGatewayRouteConfig() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getGatewayRouteConfig());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新网关路由配置")
|
||||
@PutMapping(value = "/gateway/routeConfig")
|
||||
public AjaxResult updateGatewayRouteConfig(@RequestBody List<GatewayRouteConfig> gatewayRouteConfigList) {
|
||||
return toAjax(microManagementService.updateGatewayRouteConfig(gatewayRouteConfigList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取网关安全认证配置")
|
||||
@GetMapping(value = "/gateway/safetyConfig")
|
||||
public GenericsAjaxResult<GatewaySafetyConfig> getGatewaySafetyConfig() {
|
||||
return GenericsAjaxResult.success(microManagementService.getGatewaySafetyConfig());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新网关安全认证配置")
|
||||
@PutMapping(value = "/gateway/safetyConfig")
|
||||
public AjaxResult updateGatewaySafetyConfig(@RequestBody GatewaySafetyConfig gatewaySafetyConfig) {
|
||||
return toAjax(microManagementService.updateGatewaySafetyConfig(gatewaySafetyConfig));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取网关白名单配置")
|
||||
@GetMapping(value = "/gateway/whitelistConfig")
|
||||
public GenericsAjaxResult<GatewayWhitelistConfig> getGatewayWhitelistConfig() {
|
||||
return GenericsAjaxResult.success(microManagementService.getGatewayWhitelistConfig());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新网关白名单配置")
|
||||
@PutMapping(value = "/gateway/whitelistConfig")
|
||||
public AjaxResult updateGatewayWhitelistConfig(@RequestBody GatewayWhitelistConfig gatewayWhitelistConfig) {
|
||||
return toAjax(microManagementService.updateGatewayWhitelistConfig(gatewayWhitelistConfig));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取存在网关异常处理记录的日期列表")
|
||||
@GetMapping(value = "/gateway/exceptionHandingDateList")
|
||||
public GenericsTableDataInfo<String> getExceptionHandingDateList() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getExceptionHandingDateList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取网关异常处理记录")
|
||||
@GetMapping(value = "/gateway/exceptionHandingRecordList")
|
||||
public GenericsTableDataInfo<String> getExceptionHandingRecordList(@RequestParam(value = "date", required = false) @ApiParam(value = "查看日期") String date) {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getExceptionHandingRecordList(date));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取网关限流跳转参数")
|
||||
@GetMapping(value = "/gateway/flowLimitingPara")
|
||||
public GenericsAjaxResult<JSONObject> getGatewayFlowLimitingPara() {
|
||||
return GenericsAjaxResult.success(microManagementService.getGatewayFlowLimitingPara());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取链路追踪应用列表")
|
||||
@GetMapping(value = "/application/linkTrackingList")
|
||||
public GenericsTableDataInfo<LinkTrackingApplication> getLinkTrackingList(@RequestParam(value = "applicationName", required = false) @ApiParam(value = "应用名称") String applicationName) {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getLinkTrackingList(applicationName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取K8S事件关键活动操作列表")
|
||||
@GetMapping(value = "/k8sEvent/keyActivitiesOperationList")
|
||||
public GenericsTableDataInfo<CommonTypeVo> getKeyActivitiesOperationList() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getK8SEventReasonList("Normal"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取K8S事件关键活动列表")
|
||||
@GetMapping(value = "/k8sEvent/keyActivitiesList")
|
||||
public GenericsTableDataInfo<K8SEvent> getKeyActivitiesList(@RequestParam(value = "reason", required = false) @ApiParam(value = "操作类型") String reason,
|
||||
@RequestParam(value = "startTime", required = false) @ApiParam(value = "开始时间") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false) @ApiParam(value = "结束时间") Date endTime,
|
||||
@RequestParam(value = "isAscOrderByOccurredTime", required = false) @ApiParam(value = "是否根据发生时间升序排序(默认根据发生时间降序排序)") Boolean isAscOrderByOccurredTime,
|
||||
@RequestParam(value = "pageNum", required = false) @ApiParam(value = "当前记录起始索引") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", required = false) @ApiParam(value = "每页显示记录数") Integer pageSize) {
|
||||
return microManagementService.getK8SEventList("Normal", reason, startTime, endTime, isAscOrderByOccurredTime, pageNum, pageSize);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取K8S事异常结束事件原因列表")
|
||||
@GetMapping(value = "/k8sEvent/exceptionEndReasonList")
|
||||
public GenericsTableDataInfo<CommonTypeVo> getExceptionEndReasonList() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getK8SEventReasonList("Warning"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取K8S事件异常结束事件列表")
|
||||
@GetMapping(value = "/k8sEvent/exceptionEndList")
|
||||
public GenericsTableDataInfo<K8SEvent> getExceptionEndListList(@RequestParam(value = "reason", required = false) @ApiParam(value = "操作类型") String reason,
|
||||
@RequestParam(value = "startTime", required = false) @ApiParam(value = "开始时间") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false) @ApiParam(value = "结束时间") Date endTime,
|
||||
@RequestParam(value = "isAscOrderByOccurredTime", required = false) @ApiParam(value = "是否根据发生时间升序排序(默认根据发生时间降序排序)") Boolean isAscOrderByOccurredTime,
|
||||
@RequestParam(value = "pageNum", required = false) @ApiParam(value = "当前记录起始索引") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", required = false) @ApiParam(value = "每页显示记录数") Integer pageSize) {
|
||||
return microManagementService.getK8SEventList("Warning", reason, startTime, endTime, isAscOrderByOccurredTime, pageNum, pageSize);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取K8S资源对象列表")
|
||||
@GetMapping(value = "/k8sEvent/resourceObjectList")
|
||||
public GenericsTableDataInfo<CommonTypeVo> getResourceObjectList() {
|
||||
return new GenericsTableDataInfo<>(microManagementService.getResourceObjectList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取K8S资源占用列表")
|
||||
@GetMapping(value = "/k8sEvent/resourceUsageList")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "Integer")
|
||||
})
|
||||
public GenericsTableDataInfo<K8SResourceUsage> getResourceUsageList(@RequestParam(value = "searchResourceObject", required = false) @ApiParam(value = "资源对象") String searchResourceObject,
|
||||
@RequestParam(value = "startTime", required = false) @ApiParam(value = "开始时间") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false) @ApiParam(value = "结束时间") Date endTime) {
|
||||
return getAllGenericsDataTableToPage(microManagementService.getResourceUsageList(searchResourceObject, startTime, endTime));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.microservices.mon.k8s.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.domain.GenericsAjaxResult;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.mon.k8s.domain.*;
|
||||
import com.microservices.mon.k8s.domain.vo.ApplicationEnvTypeVo;
|
||||
import com.microservices.mon.k8s.domain.vo.ApplicationTypeVo;
|
||||
import com.microservices.mon.k8s.service.IMicroManagementService;
|
||||
import com.microservices.mon.k8s.service.IMicroStatusService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("microStatus")
|
||||
@Api(tags = "微服务状态监控")
|
||||
@RefreshScope
|
||||
public class MicroStatusController extends BaseController {
|
||||
@Autowired
|
||||
private IMicroStatusService microStatusService;
|
||||
|
||||
@ApiOperation(value = "获取容器启停状态")
|
||||
@GetMapping("/podStartStopStatus")
|
||||
public GenericsAjaxResult<K8sPodStartStopStatus> getPodStartStopStatus() {
|
||||
return GenericsAjaxResult.success(microStatusService.getPodStartStopStatus());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取容器CPU使用率")
|
||||
@GetMapping("/podCpuUsage")
|
||||
public GenericsTableDataInfo<K8sPodContainerMetric> getPodCpuUsage(@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return new GenericsTableDataInfo<>(microStatusService.getPodCpuUsage(step));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取容器内存使用情况")
|
||||
@GetMapping("/podMemoryUsage")
|
||||
public GenericsTableDataInfo<K8sPodContainerMetric> getPodMemoryUsage(@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return new GenericsTableDataInfo<>(microStatusService.getPodMemoryUsage(step));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取容器硬盘读取情况")
|
||||
@GetMapping("/podDiskReads")
|
||||
public GenericsTableDataInfo<K8sPodContainerMetric> getPodDiskReads(@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return new GenericsTableDataInfo<>(microStatusService.getPodDiskReads(step));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取容器硬盘写入情况")
|
||||
@GetMapping("/podDiskWrites")
|
||||
public GenericsTableDataInfo<K8sPodContainerMetric> getPodDiskWrites(@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return new GenericsTableDataInfo<>(microStatusService.getPodDiskWrites(step));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取容器网络接收情况")
|
||||
@GetMapping("/podNetworkReception")
|
||||
public GenericsTableDataInfo<K8sPodContainerMetric> getPodNetworkReception(@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return new GenericsTableDataInfo<>(microStatusService.getPodNetworkReception(step));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取容器网络发送情况")
|
||||
@GetMapping("/podNetworkTransmission")
|
||||
public GenericsTableDataInfo<K8sPodContainerMetric> getPodNetworkTransmission(@RequestParam(value = "step", required = false) @ApiParam(value = "统计频率") Long step) {
|
||||
return new GenericsTableDataInfo<>(microStatusService.getPodNetworkTransmission(step));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
@Getter
|
||||
public enum ApplicationEnvType {
|
||||
|
||||
KEY_VALUE_PAIR("keyValuePair", "键值对"),
|
||||
RESOURCE("resource", "资源字段"),
|
||||
CONFIG_MAP_KEY("configMapKey", "ConfigMap键"),
|
||||
SECRET_KEY("secretKey", "Secret键"),
|
||||
POD_FIELD("podField", "容器字段"),
|
||||
SECRET("secret", "Secret整体"),
|
||||
CONFIGMAP("configMap", "ConfigMap整体");
|
||||
|
||||
private final String key;
|
||||
private final String alias;
|
||||
|
||||
ApplicationEnvType(String key, String alias) {
|
||||
this.key = key;
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public static ApplicationEnvType getApplicationEnvTypeByKey(String type) {
|
||||
for (ApplicationEnvType applicationEnvType : ApplicationEnvType.values()) {
|
||||
if (StringUtils.equals(applicationEnvType.getKey(), type)) {
|
||||
return applicationEnvType;
|
||||
}
|
||||
}
|
||||
throw new ServiceException("该应用环境变量类型不存在(环境变量类型[%s])", type);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel("应用功能")
|
||||
public class ApplicationFunction {
|
||||
@ApiModelProperty(value = "应用功能标识")
|
||||
private String key;
|
||||
@ApiModelProperty(value = "应用功能名称")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "应用功能访问所需参数")
|
||||
private JSONObject variables;
|
||||
|
||||
public void setKeyAndName(ApplicationFunctionType applicationFunctionType) {
|
||||
this.key = applicationFunctionType.getKey();
|
||||
this.name = applicationFunctionType.getName();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
@Getter
|
||||
public enum ApplicationFunctionType {
|
||||
LINK_TRACKING("LinkTracking", "链路追踪", "mon-skywalking-key"),
|
||||
FLOW_CONTROL("FlowControl", "流量控制", "mon-sentinel-key"),
|
||||
CONFIGURATION_MANAGEMENT("ConfigurationManagement", "配置管理", ""),
|
||||
REGISTRATION_CENTER("RegistrationCenter", "注册中心", "mon-nacos-key"),
|
||||
GATEWAY_MANAGEMENT("GatewayManagement", "网关管理", "mon-gateway-key"),
|
||||
START_AND_STOP_MANAGEMENT("StartAndStopManagement", "启停管理", "");
|
||||
private final String key;
|
||||
private final String name;
|
||||
private final String k8sLabel;
|
||||
|
||||
ApplicationFunctionType(String key, String name, String k8sLabel) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.k8sLabel = k8sLabel;
|
||||
}
|
||||
|
||||
public static ApplicationFunctionType getByLabelsKey(String k8sLabel) {
|
||||
if (StringUtils.isNotEmpty(k8sLabel)) {
|
||||
for (ApplicationFunctionType type : ApplicationFunctionType.values()) {
|
||||
if (type.getK8sLabel().equals(k8sLabel)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel("应用请求次数对象")
|
||||
public class ApplicationRequestCountData {
|
||||
|
||||
@ApiModelProperty(value = "序号")
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String applicationAlias;
|
||||
|
||||
@ApiModelProperty(value = "请求次数")
|
||||
private Long requestCount;
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.mon.k8s.domain.vo.RancherApplicationVo;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
@Getter
|
||||
public enum ApplicationStartAndStopType {
|
||||
START("start", "启动", false),
|
||||
STOP("stop", "停止", false),
|
||||
FORCE_STOP("forceStop", "强制停止", false),
|
||||
RESTART("restart", "重启", true),
|
||||
PAUSED("paused", "暂停", true),
|
||||
RESUME("resume", "恢复", true);
|
||||
private final String key;
|
||||
private final String name;
|
||||
private final Boolean isDaemonSetOperation;
|
||||
|
||||
ApplicationStartAndStopType(String key, String name, Boolean isDaemonSetOperation) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.isDaemonSetOperation = isDaemonSetOperation;
|
||||
}
|
||||
|
||||
public static JSONArray getOperationList(String kind, K8sApplication k8sApplication) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (k8sApplication == null) {
|
||||
return jsonArray;
|
||||
}
|
||||
for (ApplicationStartAndStopType value : values()) {
|
||||
if ("DaemonSet".equals(kind) && !value.isDaemonSetOperation) {
|
||||
continue;
|
||||
}
|
||||
boolean shouldAdd = false;
|
||||
|
||||
switch (value) {
|
||||
case START:
|
||||
if (k8sApplication.getReplicas() == null || k8sApplication.getReplicas() == 0) {
|
||||
shouldAdd = true;
|
||||
}
|
||||
break;
|
||||
case STOP:
|
||||
case FORCE_STOP:
|
||||
case RESTART:
|
||||
if (k8sApplication.getReplicas() != null && k8sApplication.getReplicas() > 0) {
|
||||
shouldAdd = true;
|
||||
}
|
||||
break;
|
||||
case PAUSED:
|
||||
if (!k8sApplication.getPaused()) {
|
||||
shouldAdd = true;
|
||||
}
|
||||
break;
|
||||
case RESUME:
|
||||
if (k8sApplication.getPaused()) {
|
||||
shouldAdd = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldAdd) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("operationKey", value.getKey());
|
||||
jsonObject.put("operationName", value.getName());
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
public static boolean containsKey(String operationKey) {
|
||||
for (ApplicationStartAndStopType value : values()) {
|
||||
if (StringUtils.equals(value.getKey(), operationKey)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ApplicationStartAndStopType getByKey(String operationKey) {
|
||||
for (ApplicationStartAndStopType value : values()) {
|
||||
if (StringUtils.equals(value.getKey(), operationKey)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
@Getter
|
||||
public enum ApplicationType {
|
||||
DAEMON_SET("DaemonSet", "apps.daemonsets", "确保每个节点(或指定节点)上都运行一个容器副本", "daemonsets"),
|
||||
DEPLOYMENT("Deployment", "apps.deployments", "管理无状态应用的容器副本,支持声明式更新和回滚", "deployments"),
|
||||
STATEFUL_SET("StatefulSet", "apps.statefulsets", "管理有状态应用,为容器提供稳定的标识和持久化存储", "statefulsets");
|
||||
private final String key;
|
||||
private final String fullName;
|
||||
private final String description;
|
||||
private final String name;
|
||||
|
||||
ApplicationType(String key, String fullName, String description, String name) {
|
||||
this.key = key;
|
||||
this.fullName = fullName;
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static ApplicationType getApplicationTypeByKey(String key) {
|
||||
for (ApplicationType value : ApplicationType.values()) {
|
||||
if (StringUtils.equalsIgnoreCase(value.getKey(), key)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new ServiceException("该应用类型不存在(应用类型[%s])", key);
|
||||
}
|
||||
|
||||
public static Boolean isApplicationType(String key) {
|
||||
for (ApplicationType value : ApplicationType.values()) {
|
||||
if (StringUtils.equalsIgnoreCase(value.getKey(), key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("网关路由配置")
|
||||
public class GatewayRouteConfig {
|
||||
@ApiModelProperty(value = "路由标识")
|
||||
private String id;
|
||||
@ApiModelProperty(value = "目标地址")
|
||||
private String uri;
|
||||
@ApiModelProperty(value = "转发规则")
|
||||
private List<String> predicates;
|
||||
@ApiModelProperty(value = "过滤规则")
|
||||
private List<String> filters;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("网关安全认证配置")
|
||||
public class GatewaySafetyConfig {
|
||||
@ApiModelProperty(value = "允许请求来源")
|
||||
private List<String> allowedOriginPatterns;
|
||||
@ApiModelProperty(value = "允许请求头")
|
||||
private List<String> allowedHeaders;
|
||||
@ApiModelProperty(value = "预检请求缓存时间")
|
||||
private Integer maxAge=360000;
|
||||
@ApiModelProperty(value = "允许请求方法")
|
||||
private List<String> allowedMethods;
|
||||
@ApiModelProperty(value = "允许证书")
|
||||
private Boolean allowCredentials = true;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("网关白名单配置")
|
||||
public class GatewayWhitelistConfig {
|
||||
@ApiModelProperty(value = "白名单列表")
|
||||
private List<String> whites;
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("K8S事件")
|
||||
public class K8SEvent {
|
||||
@ApiModelProperty(value = "事件id")
|
||||
private String docId;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "发生时间")
|
||||
private Date occurredTime;
|
||||
@ApiModelProperty(value = "操作类型/异常原因")
|
||||
private String reason;
|
||||
@ApiModelProperty(value = "事件发生对象")
|
||||
private String object;
|
||||
@ApiModelProperty(value = "事件发生子对象")
|
||||
private String childObject;
|
||||
@ApiModelProperty(value = "所处命名空间")
|
||||
private String namespace;
|
||||
@ApiModelProperty(value = "运行结果/详细信息")
|
||||
private String message;
|
||||
|
||||
public static GenericsTableDataInfo<K8SEvent> toK8SEventTable(JSONObject esQueryRes) {
|
||||
List<K8SEvent> k8SEventList = new ArrayList<>();
|
||||
Long total = getK8SEventTotal(esQueryRes, k8SEventList);
|
||||
return new GenericsTableDataInfo<>(k8SEventList, total);
|
||||
}
|
||||
|
||||
public static List<K8SEvent> toK8SEventList(JSONObject esQueryRes) {
|
||||
List<K8SEvent> k8SEventList = new ArrayList<>();
|
||||
getK8SEventTotal(esQueryRes, k8SEventList);
|
||||
return k8SEventList;
|
||||
}
|
||||
|
||||
private static Long getK8SEventTotal(JSONObject esQueryRes, List<K8SEvent> k8SEventList) {
|
||||
Long total = 0L;
|
||||
if (esQueryRes.getJSONObject("hits") != null && esQueryRes.getJSONObject("hits").getJSONArray("hits") != null) {
|
||||
JSONObject hits = esQueryRes.getJSONObject("hits");
|
||||
JSONArray dataHits = hits.getJSONArray("hits");
|
||||
|
||||
for (int i = 0; i < dataHits.size(); i++) {
|
||||
JSONObject dataHit = dataHits.getJSONObject(i);
|
||||
K8SEvent k8SEvent = new K8SEvent();
|
||||
k8SEvent.setDocId(dataHit.getString("_id"));
|
||||
JSONObject source = dataHit.getJSONObject("_source");
|
||||
k8SEvent.setOccurredTime(source.getDate("lastTimestamp"));
|
||||
k8SEvent.setReason(source.getString("reason"));
|
||||
if (source.getJSONObject("involvedObject") != null) {
|
||||
JSONObject involvedObject = source.getJSONObject("involvedObject");
|
||||
k8SEvent.setObject(String.format("%s:%s", involvedObject.getString("kind"), involvedObject.getString("name")));
|
||||
k8SEvent.setChildObject(involvedObject.getString("fieldPath"));
|
||||
k8SEvent.setNamespace(involvedObject.getString("namespace"));
|
||||
}
|
||||
|
||||
k8SEvent.setMessage(source.getString("message"));
|
||||
k8SEventList.add(k8SEvent);
|
||||
}
|
||||
total = hits.getJSONObject("total").getLong("value");
|
||||
}
|
||||
return total;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("K8S资源占用情况")
|
||||
public class K8SResourceUsage {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "发生时间")
|
||||
private Date occurredTime;
|
||||
@ApiModelProperty(value = "资源类型")
|
||||
private String resourceType;
|
||||
@ApiModelProperty(value = "资源对象")
|
||||
private String resourceObject;
|
||||
@ApiModelProperty(value = "资源占用情况")
|
||||
private String message;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.microservices.mon.k8s.utils.MonUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel("K8S应用")
|
||||
public class K8sApplication {
|
||||
|
||||
@ApiModelProperty(value = "应用Id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "应用别名")
|
||||
private String alias;
|
||||
|
||||
@ApiModelProperty(value = "应用类型")
|
||||
private String kind;
|
||||
|
||||
@ApiModelProperty(value = "所属命名空间")
|
||||
private String namespace;
|
||||
|
||||
@ApiModelProperty(value = "副本数量")
|
||||
private Integer replicas;
|
||||
|
||||
@ApiModelProperty(value = "有效副本数量(当有效副本数为0时代表应用失败呈现红色;当有效副本数大于0但小于副本数时代表应用部分失败呈现橙色;当有效副本数等于副本数代表应用正常呈现蓝色)")
|
||||
private Integer readyReplicas;
|
||||
|
||||
@ApiModelProperty(value = "容器选择器")
|
||||
private String podSelector;
|
||||
|
||||
@ApiModelProperty(value = "Docker镜像")
|
||||
private String dockerImage;
|
||||
|
||||
@ApiModelProperty(value = "重启次数")
|
||||
private Integer restartCount;
|
||||
|
||||
@ApiModelProperty(value = "存活时间")
|
||||
private String survivalTime;
|
||||
|
||||
@ApiModelProperty(value = "运行状态")
|
||||
private K8sApplicationAndPodState state;
|
||||
|
||||
@ApiModelProperty(value = "暂停编排")
|
||||
private Boolean paused;
|
||||
|
||||
private List<K8sApplicationPod> podList;
|
||||
|
||||
// public void setDockerImage(String dockerImage) {
|
||||
// this.dockerImage = MonUtils.getDockerImage(dockerImage);
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel("应用状态")
|
||||
public class K8sApplicationAndPodState {
|
||||
|
||||
@ApiModelProperty(value = "状态标识")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "应用展示名称(中文)")
|
||||
private String alias;
|
||||
|
||||
@ApiModelProperty(value = "是否错误")
|
||||
private Boolean isError;
|
||||
|
||||
@ApiModelProperty(value = "状态消息")
|
||||
private String message;
|
||||
|
||||
public static K8sApplicationAndPodState k8sApplicationStopState(String stateName) {
|
||||
K8sApplicationAndPodState state = new K8sApplicationAndPodState();
|
||||
state.setName(stateName);
|
||||
state.setIsError(false);
|
||||
state.setMessage("");
|
||||
state.setApplicationAliasByName(stateName);
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setApplicationAliasByName(String name) {
|
||||
this.name = name;
|
||||
if ("active".equalsIgnoreCase(name)) {
|
||||
this.alias = "运行中";
|
||||
} else if ("updating".equalsIgnoreCase(name)) {
|
||||
this.alias = "更新中";
|
||||
} else if ("in-progress".equalsIgnoreCase(name)) {
|
||||
this.alias = "处理中";
|
||||
} else if ("error".equalsIgnoreCase(name)) {
|
||||
this.alias = "运行失败";
|
||||
} else if ("paused".equalsIgnoreCase(name)) {
|
||||
this.alias = "暂停编排";
|
||||
} else if ("pending".equalsIgnoreCase(name)) {
|
||||
this.alias = "等待中";
|
||||
} else if ("stop".equalsIgnoreCase(name)) {
|
||||
this.alias = "已停止运行";
|
||||
} else {
|
||||
this.alias = name;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPodAliasAndErrorByName(String name) {
|
||||
this.name = name;
|
||||
this.isError=true;
|
||||
|
||||
if ("imagePullBackOff".equalsIgnoreCase(name)) {
|
||||
this.alias = "镜像拉取失败";
|
||||
} else if ("pending".equalsIgnoreCase(name)) {
|
||||
this.alias = "等待中";
|
||||
this.isError=false;
|
||||
} else if ("running".equalsIgnoreCase(name)) {
|
||||
this.alias = "运行中";
|
||||
this.isError=false;
|
||||
} else if ("podScheduled".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器已调度";
|
||||
this.isError=false;
|
||||
} else if ("containersReady".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器已就绪";
|
||||
this.isError=false;
|
||||
} else if ("initialized".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器已初始化";
|
||||
this.isError=false;
|
||||
} else if ("ready".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器已准备就绪";
|
||||
this.isError=false;
|
||||
} else if ("crashLoopBackOff".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器崩溃循环重启";
|
||||
} else if ("invalidImageName".equalsIgnoreCase(name)) {
|
||||
this.alias = "无法解析镜像名称";
|
||||
} else if ("imageInspectError".equalsIgnoreCase(name)) {
|
||||
this.alias = "无法校验镜像";
|
||||
} else if ("errImageNeverPull".equalsIgnoreCase(name)) {
|
||||
this.alias = "策略禁止拉取镜像";
|
||||
} else if ("registryUnavailable".equalsIgnoreCase(name)) {
|
||||
this.alias = "连接不到镜像中心";
|
||||
} else if ("errImagePull".equalsIgnoreCase(name)) {
|
||||
this.alias = "拉取镜像出错";
|
||||
} else if ("createContainerConfigError".equalsIgnoreCase(name)) {
|
||||
this.alias = "不能创建容器配置";
|
||||
} else if ("createContainerError".equalsIgnoreCase(name)) {
|
||||
this.alias = "创建容器失败";
|
||||
} else if ("runContainerError".equalsIgnoreCase(name)) {
|
||||
this.alias = "启动容器失败";
|
||||
} else if ("postStartHookError".equalsIgnoreCase(name)) {
|
||||
this.alias = "执行hook报错";
|
||||
} else if ("containersNotInitialized".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器未初始化完毕";
|
||||
} else if ("containersNotReady".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器未准备完毕";
|
||||
} else if ("containerCreating".equalsIgnoreCase(name)) {
|
||||
this.alias = "容器创建中";
|
||||
this.isError=false;
|
||||
} else if ("podInitializing".equalsIgnoreCase(name)) {
|
||||
this.alias = "Pod 初始化中";
|
||||
this.isError=false;
|
||||
} else if ("dockerDaemonNotReady".equalsIgnoreCase(name)) {
|
||||
this.alias = "Docker 未完全启动";
|
||||
} else if ("networkPluginNotReady".equalsIgnoreCase(name)) {
|
||||
this.alias = "网络插件未完全启动";
|
||||
} else if ("evicted".equalsIgnoreCase(name)) {
|
||||
this.alias = "Pod 被驱赶";
|
||||
} else if ("terminating".equalsIgnoreCase(name)) {
|
||||
this.alias = "删除中";
|
||||
this.isError=false;
|
||||
} else {
|
||||
this.alias = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel("K8S应用环境变量")
|
||||
public class K8sApplicationEnv {
|
||||
|
||||
@ApiModelProperty(value = "环境变量类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "环境变量键")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "环境变量值")
|
||||
private JSONObject valueObj;
|
||||
|
||||
/**
|
||||
* 将 Kubernetes 容器 env 数组中的单个元素(JSONObject 形式)转换成内部统一的 K8sApplicationEnv 对象。
|
||||
*
|
||||
* <p>支持解析以下四种 value 来源:</p>
|
||||
* <ul>
|
||||
* <li>普通键值对:{@code {"name":"KEY","value":"VAL"}}</li>
|
||||
* <li>资源字段引用:{@code {"name":"CPU_LIMIT","valueFrom":{"resourceFieldRef":{...}}}}</li>
|
||||
* <li>ConfigMap 键引用:{@code {"name":"CM_KEY","valueFrom":{"configMapKeyRef":{...}}}}</li>
|
||||
* <li>Secret 键引用:{@code {"name":"SECRET_KEY","valueFrom":{"secretKeyRef":{...}}}}</li>
|
||||
* <li>Pod 字段引用:{@code {"name":"POD_IP","valueFrom":{"fieldRef":{...}}}}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param envJsonObject 单条 env 的原始 JSON 对象;允许为 null
|
||||
* @return 转换后的 K8sApplicationEnv 实例;无法识别或入参为 null 时返回 null
|
||||
*/
|
||||
public static K8sApplicationEnv envJsonObjectToK8sApplicationEnv(JSONObject envJsonObject) {
|
||||
K8sApplicationEnv k8sApplicationEnv = null;
|
||||
if (envJsonObject != null) {
|
||||
JSONObject valueObj = new JSONObject();
|
||||
if (envJsonObject.containsKey("value")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envJsonObject.getString("name"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.KEY_VALUE_PAIR.getKey());
|
||||
valueObj.put("value", envJsonObject.getString("value"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
} else if (envJsonObject.containsKey("valueFrom")) {
|
||||
JSONObject valueFromJson = envJsonObject.getJSONObject("valueFrom");
|
||||
if (valueFromJson.containsKey("resourceFieldRef")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envJsonObject.getString("name"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.RESOURCE.getKey());
|
||||
JSONObject resourceFieldRef = valueFromJson.getJSONObject("resourceFieldRef");
|
||||
valueObj.put("name", resourceFieldRef.getString("containerName"));
|
||||
valueObj.put("key", resourceFieldRef.getString("resource"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
} else if (valueFromJson.containsKey("configMapKeyRef")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envJsonObject.getString("name"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.CONFIG_MAP_KEY.getKey());
|
||||
JSONObject configMapKeyRef = valueFromJson.getJSONObject("configMapKeyRef");
|
||||
valueObj.put("name", configMapKeyRef.getString("name"));
|
||||
valueObj.put("key", configMapKeyRef.getString("key"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
} else if (valueFromJson.containsKey("secretKeyRef")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envJsonObject.getString("name"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.SECRET_KEY.getKey());
|
||||
JSONObject secretKeyRef = valueFromJson.getJSONObject("secretKeyRef");
|
||||
valueObj.put("name", secretKeyRef.getString("name"));
|
||||
valueObj.put("key", secretKeyRef.getString("key"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
} else if (valueFromJson.containsKey("fieldRef")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envJsonObject.getString("name"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.POD_FIELD.getKey());
|
||||
JSONObject fieldRef = valueFromJson.getJSONObject("fieldRef");
|
||||
valueObj.put("value", fieldRef.getString("fieldPath"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return k8sApplicationEnv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Kubernetes 容器 envFrom 数组中的单个元素(JSONObject 形式)转换成内部统一的 K8sApplicationEnv 对象。
|
||||
*
|
||||
* <p>支持解析以下两种来源:</p>
|
||||
* <ul>
|
||||
* <li>整个 ConfigMap:{@code {"prefix":"PRE_","configMapRef":{"name":"cm-name"}}}</li>
|
||||
* <li>整个 Secret:{@code {"prefix":"PRE_","secretRef":{"name":"secret-name"}}}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>注意:prefix 可能为 null。</p>
|
||||
*
|
||||
* @param envFromJson 单条 envFrom 的原始 JSON 对象;允许为 null
|
||||
* @return 转换后的 K8sApplicationEnv 实例;无法识别或入参为 null 时返回 null
|
||||
*/
|
||||
public static K8sApplicationEnv envFromJsonObjectToK8sApplicationEnv(JSONObject envFromJson) {
|
||||
K8sApplicationEnv k8sApplicationEnv = null;
|
||||
if (envFromJson != null) {
|
||||
JSONObject valueObj = new JSONObject();
|
||||
if (envFromJson.containsKey("configMapRef")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envFromJson.getString("prefix"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.CONFIGMAP.getKey());
|
||||
JSONObject configMapRef = envFromJson.getJSONObject("configMapRef");
|
||||
valueObj.put("name", configMapRef.getString("name"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
} else if (envFromJson.containsKey("secretRef")) {
|
||||
k8sApplicationEnv = new K8sApplicationEnv();
|
||||
k8sApplicationEnv.setKey(envFromJson.getString("prefix"));
|
||||
k8sApplicationEnv.setType(ApplicationEnvType.SECRET.getKey());
|
||||
JSONObject secretRef = envFromJson.getJSONObject("secretRef");
|
||||
valueObj.put("name", secretRef.getString("name"));
|
||||
k8sApplicationEnv.setValueObj(valueObj);
|
||||
}
|
||||
}
|
||||
return k8sApplicationEnv;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel("K8S应用环境变量")
|
||||
public class K8sApplicationEnvOptionalParameter {
|
||||
|
||||
@ApiModelProperty(value = "环境变量参数类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "环境变量参数名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "环境变量参数键值")
|
||||
private List<String> keys;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.microservices.mon.k8s.utils.MonUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel("K8S容器")
|
||||
public class K8sApplicationPod {
|
||||
|
||||
@ApiModelProperty(value = "容器Id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "容器名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "所属命名空间")
|
||||
private String namespace;
|
||||
|
||||
@ApiModelProperty(value = "容器Ip")
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "重启次数")
|
||||
private Integer restartCount;
|
||||
|
||||
@ApiModelProperty(value = "运行状态")
|
||||
private K8sApplicationAndPodState state;
|
||||
|
||||
@ApiModelProperty(value = "是否正常运行")
|
||||
private Boolean isRunning;
|
||||
|
||||
@ApiModelProperty(value = "存活时间")
|
||||
private String survivalTime;
|
||||
|
||||
@ApiModelProperty(value = "所有权")
|
||||
private String serviceAccountName;
|
||||
|
||||
@ApiModelProperty(value = "容器端口")
|
||||
private String ports;
|
||||
|
||||
@ApiModelProperty(value = "Docker镜像")
|
||||
private String dockerImage;
|
||||
|
||||
@ApiModelProperty(value = "副本数量")
|
||||
private Integer replicas;
|
||||
|
||||
@ApiModelProperty(value = "有效副本数量")
|
||||
private Integer readyReplicas;
|
||||
|
||||
@ApiModelProperty(value = "所属堆栈")
|
||||
private String stack;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdTime;
|
||||
|
||||
// public void setDockerImage(String dockerImage) {
|
||||
// this.dockerImage = MonUtils.getDockerImage(dockerImage);
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.microservices.mon.k8s.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel("集群节点")
|
||||
public class K8sClusterNode {
|
||||
@ApiModelProperty(value = "节点标识")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "节点名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "节点IP")
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "节点角色(Master/Worker)")
|
||||
private String role;
|
||||
|
||||
@ApiModelProperty(value = "是否就绪")
|
||||
private Boolean Ready;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue