From cc6581ba2f82fbfd31c7dc5a3e21778ea2e5f6e1 Mon Sep 17 00:00:00 2001 From: elliotshi Date: Wed, 25 Dec 2019 17:55:08 +0800 Subject: [PATCH 1/6] enhance #538 support to query CI data history. v0.1 --- cmdb-ui/src/api/server.js | 21 +++-- cmdb-ui/src/pages/designing/ci-data.vue | 116 ++++++++++++++++++++---- 2 files changed, 113 insertions(+), 24 deletions(-) diff --git a/cmdb-ui/src/api/server.js b/cmdb-ui/src/api/server.js index cd7ebbb18..7addd6e45 100755 --- a/cmdb-ui/src/api/server.js +++ b/cmdb-ui/src/api/server.js @@ -1,12 +1,16 @@ import { req as request, baseURL } from "./base"; -import { pluginErrorMessage } from "./base-pulgin" +import { pluginErrorMessage } from "./base-pulgin"; let req = request; if (window.request) { req = { - post: (url, ...params) => pluginErrorMessage(window.request.post(baseURL + url, ...params)), - get: (url, ...params) => pluginErrorMessage(window.request.get(baseURL + url, ...params)), - delete: (url, ...params) => pluginErrorMessage(window.request.delete(baseURL + url, ...params)), - put: (url, ...params) => pluginErrorMessage(window.request.put(baseURL + url, ...params)) + post: (url, ...params) => + pluginErrorMessage(window.request.post(baseURL + url, ...params)), + get: (url, ...params) => + pluginErrorMessage(window.request.get(baseURL + url, ...params)), + delete: (url, ...params) => + pluginErrorMessage(window.request.delete(baseURL + url, ...params)), + put: (url, ...params) => + pluginErrorMessage(window.request.put(baseURL + url, ...params)) }; } @@ -172,9 +176,7 @@ export const getApplicationFrameworkDesignDataTree = guid => req.get(`/data-tree/application-framework-design?system-design-guid=${guid}`); export const getDeployCiData = (data, payload) => req.post( - `/deploy-designs/tabs/ci-data?code-id=${data.codeId}&env-code=${ - data.envCode - }&system-design-guid=${data.systemDesignGuid}`, + `/deploy-designs/tabs/ci-data?code-id=${data.codeId}&env-code=${data.envCode}&system-design-guid=${data.systemDesignGuid}`, payload ); export const getDeployDesignTabs = () => req.get(`/deploy-designs/tabs`); @@ -235,6 +237,9 @@ export const deleteEnumCodes = data => { export const queryCiData = data => { return req.post(`/ci-types/${data.id}/ci-data/query`, data.queryObject); }; +export const queryCiDataByType = data => { + return req.post(`/ci-types/${data.id}/ci-data/queryByType`, data.queryObject); +}; export const getCiTypeAttributes = id => { return req.get(`/ci-types/${id}/attributes`); }; diff --git a/cmdb-ui/src/pages/designing/ci-data.vue b/cmdb-ui/src/pages/designing/ci-data.vue index 85aecc86c..e395e545d 100755 --- a/cmdb-ui/src/pages/designing/ci-data.vue +++ b/cmdb-ui/src/pages/designing/ci-data.vue @@ -37,17 +37,35 @@ :ref="'table' + ci.id" > +
+
更新时间
+ +
查询类型
+ +
+ + From 9660073af492f13dd24d05b2c0e6de93f71a25e3 Mon Sep 17 00:00:00 2001 From: xuxuzhesi Date: Thu, 26 Dec 2019 18:50:13 +0800 Subject: [PATCH 2/6] #538 Supports querying the latest ci data for the non-deleted status of confirm --- .../cmdb/config/ApplicationProperties.java | 1 + .../ui/UICiDataManagementController.java | 10 +++++++- .../ui/helper/UIWrapperService.java | 24 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/cmdb-core/src/main/java/com/webank/cmdb/config/ApplicationProperties.java b/cmdb-core/src/main/java/com/webank/cmdb/config/ApplicationProperties.java index ec17342f6..12694f274 100644 --- a/cmdb-core/src/main/java/com/webank/cmdb/config/ApplicationProperties.java +++ b/cmdb-core/src/main/java/com/webank/cmdb/config/ApplicationProperties.java @@ -45,6 +45,7 @@ public class UIProperties { private String referenceCodeOfRelate = "relation"; private String propertyNameOfState = "state"; private String enumCodeOfStateDelete = "delete"; + private Integer enumIdOfStateDelete = 36; private String propertyNameOfFixedDate = "fixed_date"; private String enumCategoryNameOfEnv = "deploy_environment"; private String catNameOfArchitectureDesign = "tab_of_architecture_design"; diff --git a/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/UICiDataManagementController.java b/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/UICiDataManagementController.java index c701ac8f3..7a6e71311 100644 --- a/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/UICiDataManagementController.java +++ b/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/UICiDataManagementController.java @@ -212,7 +212,15 @@ public Object queryCiData(@PathVariable(value = "ci-type-id") int ciTypeId, @RequestBody QueryRequest queryObject) { return wrapperService.queryCiData(ciTypeId, queryObject); } - + + @RolesAllowed({ MENU_DESIGNING_CI_DATA_MANAGEMENT, MENU_DESIGNING_CI_DATA_ENQUIRY }) + @PostMapping("/ci-types/{ci-type-id}/ci-data/query-by-type") + @ResponseBody + public Object queryCiDataByType(@PathVariable(value = "ci-type-id") int ciTypeId, + @RequestBody QueryRequest queryObject) { + return wrapperService.queryCiDataByType(ciTypeId, queryObject); + } + @PostMapping("/referenceCiData/{reference-attr-id}/query") @ResponseBody public Object queryReferenceCiData(@PathVariable(value = "reference-attr-id") int referenceAttrId, diff --git a/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java b/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java index 401e3e01f..e164ee2d1 100644 --- a/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java +++ b/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java @@ -474,6 +474,30 @@ public QueryResponse queryCiData(Integer ciTypeId, QueryRequest queryObj } return ciService.query(ciTypeId, queryObject); } + + public QueryResponse queryCiDataByType(Integer ciTypeId, QueryRequest queryObject) { + if (queryObject == null) { + queryObject = QueryRequest.defaultQueryObject().descendingSortBy(CmdbConstants.DEFAULT_FIELD_CREATED_DATE); + } else if (queryObject.getSorting() == null || queryObject.getSorting().getField() == null) { + queryObject.getDialect().setShowCiHistory(false); + queryObject.setSorting(new Sorting(false, CmdbConstants.DEFAULT_FIELD_CREATED_DATE)); + } + queryObject.addNotEqualsFilter("state", uiProperties.getEnumIdOfStateDelete()); + QueryResponse query = ciService.query(ciTypeId, queryObject); + List ciDataIds = new ArrayList<>(); + if(query.getContents()==null||query.getContents().size()<=0) { + return query; + } + query.getContents().forEach(cidata -> { + if(cidata.getData().get("fixed_date")==null) { + ciDataIds.add((String)cidata.getData().get("p_guid")); + }else { + ciDataIds.add((String)cidata.getData().get("guid")); + } + }); + queryObject.addInFilter("guid", ciDataIds); + return ciService.query(ciTypeId, queryObject); + } public List> updateCiData(Integer ciTypeId, List> ciData) { return ciService.update(ciTypeId, ciData); From 0f5082133923f16b21951774d31f55f2704126bf Mon Sep 17 00:00:00 2001 From: xuxuzhesi Date: Thu, 26 Dec 2019 22:38:17 +0800 Subject: [PATCH 3/6] #538 Fix the query cidata for type 2 --- .../com/webank/cmdb/controller/ui/helper/UIWrapperService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java b/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java index e164ee2d1..3aa842d99 100644 --- a/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java +++ b/cmdb-core/src/main/java/com/webank/cmdb/controller/ui/helper/UIWrapperService.java @@ -496,6 +496,7 @@ public QueryResponse queryCiDataByType(Integer ciTypeId, QueryRequest qu } }); queryObject.addInFilter("guid", ciDataIds); + queryObject.getDialect().setShowCiHistory(true); return ciService.query(ciTypeId, queryObject); } From e1ffa0c405dcf0ea8c855b78e57a39a2570a4727 Mon Sep 17 00:00:00 2001 From: elliotshi Date: Fri, 27 Dec 2019 09:58:33 +0800 Subject: [PATCH 4/6] 538 bugfix ajust on api and params --- cmdb-ui/src/api/server.js | 5 ++++- cmdb-ui/src/pages/designing/ci-data.vue | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmdb-ui/src/api/server.js b/cmdb-ui/src/api/server.js index 7addd6e45..6afa3f7e0 100755 --- a/cmdb-ui/src/api/server.js +++ b/cmdb-ui/src/api/server.js @@ -238,7 +238,10 @@ export const queryCiData = data => { return req.post(`/ci-types/${data.id}/ci-data/query`, data.queryObject); }; export const queryCiDataByType = data => { - return req.post(`/ci-types/${data.id}/ci-data/queryByType`, data.queryObject); + return req.post( + `/ci-types/${data.id}/ci-data/query-by-type`, + data.queryObject + ); }; export const getCiTypeAttributes = id => { return req.get(`/ci-types/${id}/attributes`); diff --git a/cmdb-ui/src/pages/designing/ci-data.vue b/cmdb-ui/src/pages/designing/ci-data.vue index e395e545d..97feb2c48 100755 --- a/cmdb-ui/src/pages/designing/ci-data.vue +++ b/cmdb-ui/src/pages/designing/ci-data.vue @@ -41,7 +41,7 @@
更新时间
x.name === "update_date" + x => x.name === "updated_date" ); if (!this.queryDate) { if (~dateObjIdx) this.payload.filters.splice(dateObjIdx, 1); @@ -136,9 +136,9 @@ export default { this.payload.filters = filters; } else { this.payload.filters.push({ - name: "update_date", - operator: "eq", - value: moment(this.queryDate).valueOf() + name: "updated_date", + operator: "lt", + value: moment(this.queryDate).format("YYYY-MM-DD HH:mm:ss") }); } } From 258ef4bc3639030432896bbe72ec031661ca86ea Mon Sep 17 00:00:00 2001 From: elliotshi Date: Fri, 27 Dec 2019 11:22:48 +0800 Subject: [PATCH 5/6] 538 enhance i18n --- cmdb-ui/src/locale/i18n/en-US.json | 7 ++++++- cmdb-ui/src/locale/i18n/zh-CN.json | 7 ++++++- cmdb-ui/src/pages/designing/ci-data.vue | 10 +++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cmdb-ui/src/locale/i18n/en-US.json b/cmdb-ui/src/locale/i18n/en-US.json index 2dd122b9e..6deccf521 100755 --- a/cmdb-ui/src/locale/i18n/en-US.json +++ b/cmdb-ui/src/locale/i18n/en-US.json @@ -244,5 +244,10 @@ "auto_fill_change_special_delimiter": "更换特殊连接符", "auto_fill_filter_modal_title": "过滤条件", "auto_fill_filter_modal_button": "添加过滤条件", - "auto_fill_filter_placeholder": " <-- 点此开始编辑填充规则" + "auto_fill_filter_placeholder": " <-- 点此开始编辑填充规则", + "updated_time": "Updated Time", + "query_type": "Query Type", + "type_latest": "Latest", + "type_all": "All", + "type_reality": "现实" } diff --git a/cmdb-ui/src/locale/i18n/zh-CN.json b/cmdb-ui/src/locale/i18n/zh-CN.json index 5b81a2013..7ed78b127 100755 --- a/cmdb-ui/src/locale/i18n/zh-CN.json +++ b/cmdb-ui/src/locale/i18n/zh-CN.json @@ -244,5 +244,10 @@ "auto_fill_change_special_delimiter": "更换特殊连接符", "auto_fill_filter_modal_title": "过滤条件", "auto_fill_filter_modal_button": "添加过滤条件", - "auto_fill_filter_placeholder": " <-- 点此开始编辑填充规则" + "auto_fill_filter_placeholder": " <-- 点此开始编辑填充规则", + "updated_time": "更新时间", + "query_type": "查询类型", + "type_latest": "最新", + "type_all": "所有", + "type_reality": "现实" } diff --git a/cmdb-ui/src/pages/designing/ci-data.vue b/cmdb-ui/src/pages/designing/ci-data.vue index 97feb2c48..667598884 100755 --- a/cmdb-ui/src/pages/designing/ci-data.vue +++ b/cmdb-ui/src/pages/designing/ci-data.vue @@ -38,7 +38,7 @@ >
-
更新时间
+
{{ $t("updated_time") }}
-
查询类型
+
{{ $t("query_type") }}
From 50038832b9f4a10603c8d57b040337a11fea838e Mon Sep 17 00:00:00 2001 From: elliotshi Date: Fri, 27 Dec 2019 11:34:48 +0800 Subject: [PATCH 6/6] 538 enhance i18n adjust --- cmdb-ui/src/locale/i18n/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdb-ui/src/locale/i18n/en-US.json b/cmdb-ui/src/locale/i18n/en-US.json index 6deccf521..38afe7d5b 100755 --- a/cmdb-ui/src/locale/i18n/en-US.json +++ b/cmdb-ui/src/locale/i18n/en-US.json @@ -249,5 +249,5 @@ "query_type": "Query Type", "type_latest": "Latest", "type_all": "All", - "type_reality": "现实" + "type_reality": "Confirmed" }