From d06c073999e4787fa345ca1c27ea60da307e9e0e Mon Sep 17 00:00:00 2001 From: lijiahang Date: Fri, 10 Nov 2023 19:02:38 +0800 Subject: [PATCH] =?UTF-8?q?review:=20=E4=BF=AE=E6=94=B9=20footer.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asset/controller/HostGroupController.java | 228 ++++++-------- orion-ops-ui/src/api/asset/host-group-rel.ts | 114 +++++++ orion-ops-ui/src/api/asset/host-group.ts | 67 +++++ orion-ops-ui/src/assets/style/global.less | 165 +++++++++-- orion-ops-ui/src/assets/style/layout.less | 114 +------ .../src/components/app/footer/index.vue | 39 +-- orion-ops-ui/src/components/index.ts | 6 +- .../system/menu/grant/menu-grant-table.vue | 1 + .../src/components/view/card-list/index.vue | 8 +- orion-ops-ui/src/layout/default-layout.vue | 11 +- .../src/router/routes/modules/asset.ts | 4 + .../host-group/components/host-group-tree.vue | 278 ++++++++++++++++++ .../host-group/components/host-group-view.vue | 141 +++++++++ .../src/views/asset/host-group/index.vue | 72 +++++ .../asset/host/components/host-table.vue | 4 +- .../src/views/user/role/types/const.ts | 26 +- 16 files changed, 968 insertions(+), 310 deletions(-) create mode 100644 orion-ops-ui/src/api/asset/host-group-rel.ts create mode 100644 orion-ops-ui/src/api/asset/host-group.ts create mode 100644 orion-ops-ui/src/views/asset/host-group/components/host-group-tree.vue create mode 100644 orion-ops-ui/src/views/asset/host-group/components/host-group-view.vue create mode 100644 orion-ops-ui/src/views/asset/host-group/index.vue diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostGroupController.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostGroupController.java index fb9f7726..26f9727f 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostGroupController.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostGroupController.java @@ -1,143 +1,85 @@ -// package com.orion.ops.module.asset.controller; -// -// import com.orion.lang.define.wrapper.DataGrid; -// import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog; -// import com.orion.ops.framework.common.validator.group.Page; -// import com.orion.ops.framework.log.core.annotation.IgnoreLog; -// import com.orion.ops.framework.log.core.enums.IgnoreLogMode; -// import com.orion.ops.framework.web.core.annotation.RestWrapper; -// import com.orion.ops.module.asset.define.operator.HostOperatorType; -// import com.orion.ops.module.asset.entity.request.host.*; -// import com.orion.ops.module.asset.entity.vo.HostConfigVO; -// import com.orion.ops.module.asset.entity.vo.HostVO; -// import com.orion.ops.module.asset.service.HostConfigService; -// import com.orion.ops.module.asset.service.HostService; -// import io.swagger.v3.oas.annotations.Operation; -// import io.swagger.v3.oas.annotations.Parameter; -// import io.swagger.v3.oas.annotations.tags.Tag; -// import lombok.extern.slf4j.Slf4j; -// import org.springframework.security.access.prepost.PreAuthorize; -// import org.springframework.validation.annotation.Validated; -// import org.springframework.web.bind.annotation.*; -// -// import javax.annotation.Resource; -// import java.util.List; -// -// /** -// * 主机 api -// * -// * @author Jiahang Li -// * @version 1.0.0 -// * @since 2023-9-11 14:16 -// */ -// @Tag(name = "asset - 主机服务") -// @Slf4j -// @Validated -// @RestWrapper -// @RestController -// @RequestMapping("/asset/host-group") -// @SuppressWarnings({"ELValidationInJSP", "SpringElInspection"}) -// public class HostGroupController { -// -// @Resource -// private HostService hostService; -// -// @Resource -// private HostConfigService hostConfigService; -// -// @OperatorLog(HostOperatorType.CREATE) -// @PostMapping("/create") -// @Operation(summary = "创建主机") -// @PreAuthorize("@ss.hasPermission('asset:host:create')") -// public Long createHost(@Validated @RequestBody HostCreateRequest request) { -// return hostService.createHost(request); -// } -// -// @OperatorLog(HostOperatorType.UPDATE) -// @PutMapping("/update") -// @Operation(summary = "通过 id 更新主机") -// @PreAuthorize("@ss.hasPermission('asset:host:update')") -// public Integer updateHost(@Validated @RequestBody HostUpdateRequest request) { -// return hostService.updateHostById(request); -// } -// -// @IgnoreLog(IgnoreLogMode.RET) -// @GetMapping("/get") -// @Operation(summary = "通过 id 查询主机") -// @Parameter(name = "id", description = "id", required = true) -// @Parameter(name = "extra", description = "是否查询额外信息") -// @Parameter(name = "config", description = "是否查询配置信息") -// @PreAuthorize("@ss.hasPermission('asset:host:query')") -// public HostVO getHost(@RequestParam("id") Long id, -// @RequestParam(name = "extra", required = false) boolean extra, -// @RequestParam(name = "config", required = false) boolean config) { -// HostQueryRequest request = new HostQueryRequest(); -// request.setId(id); -// request.setExtra(extra); -// request.setConfig(config); -// return hostService.getHostById(request); -// } -// -// @IgnoreLog(IgnoreLogMode.RET) -// @PostMapping("/list") -// @Operation(summary = "查询主机") -// @PreAuthorize("@ss.hasPermission('asset:host:query')") -// public List getHostList() { -// return hostService.getHostListByCache(); -// } -// -// @IgnoreLog(IgnoreLogMode.RET) -// @PostMapping("/query") -// @Operation(summary = "分页查询主机") -// @PreAuthorize("@ss.hasPermission('asset:host:query')") -// public DataGrid getHostPage(@Validated(Page.class) @RequestBody HostQueryRequest request) { -// return hostService.getHostPage(request); -// } -// -// @OperatorLog(HostOperatorType.DELETE) -// @DeleteMapping("/delete") -// @Operation(summary = "通过 id 删除主机") -// @Parameter(name = "id", description = "id", required = true) -// @PreAuthorize("@ss.hasPermission('asset:host:delete')") -// public Integer deleteHost(@RequestParam("id") Long id) { -// return hostService.deleteHostById(id); -// } -// -// @IgnoreLog(IgnoreLogMode.RET) -// @GetMapping("/get-config") -// @Operation(summary = "查询主机配置") -// @Parameter(name = "hostId", description = "hostId", required = true) -// @Parameter(name = "type", description = "配置类型", required = true) -// @PreAuthorize("@ss.hasPermission('asset:host:query')") -// public HostConfigVO getHostConfig(@RequestParam("hostId") Long hostId, -// @RequestParam(name = "type") String type) { -// return hostConfigService.getHostConfig(hostId, type); -// } -// -// @IgnoreLog(IgnoreLogMode.RET) -// @GetMapping("/get-config-all") -// @Operation(summary = "查询主机配置 - 全部") -// @Parameter(name = "hostId", description = "hostId", required = true) -// @PreAuthorize("@ss.hasPermission('asset:host:query')") -// public List getHostConfig(@RequestParam("hostId") Long hostId) { -// return hostConfigService.getHostConfig(hostId); -// } -// -// @OperatorLog(HostOperatorType.UPDATE_CONFIG) -// @PutMapping("/update-config") -// @Operation(summary = "更新主机配置") -// @PreAuthorize("@ss.hasPermission('asset:host:update-config')") -// public Integer updateHostConfig(@Validated @RequestBody HostConfigUpdateRequest request) { -// return hostConfigService.updateHostConfig(request); -// } -// -// @OperatorLog(HostOperatorType.UPDATE_CONFIG_STATUS) -// @PutMapping("/update-config-status") -// @Operation(summary = "更新主机配置状态") -// @PreAuthorize("@ss.hasPermission('asset:host:update-config')") -// public Integer updateHostConfigStatus(@Validated @RequestBody HostConfigUpdateStatusRequest request) { -// return hostConfigService.updateHostConfigStatus(request); -// } -// -// } -// +package com.orion.ops.module.asset.controller; + +import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog; +import com.orion.ops.framework.log.core.annotation.IgnoreLog; +import com.orion.ops.framework.log.core.enums.IgnoreLogMode; +import com.orion.ops.framework.web.core.annotation.RestWrapper; +import com.orion.ops.module.asset.define.operator.HostOperatorType; +import com.orion.ops.module.asset.service.HostService; +import com.orion.ops.module.infra.api.DataGroupApi; +import com.orion.ops.module.infra.entity.dto.data.DataGroupCreateDTO; +import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO; +import com.orion.ops.module.infra.entity.dto.data.DataGroupUpdateDTO; +import com.orion.ops.module.infra.enums.DataGroupTypeEnum; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 主机分组 api + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-11-09 16:16 + */ +@Tag(name = "asset - 主机分组服务") +@Slf4j +@Validated +@RestWrapper +@RestController +@RequestMapping("/asset/host-group") +@SuppressWarnings({"ELValidationInJSP", "SpringElInspection"}) +public class HostGroupController { + + @Resource + private HostService hostService; + + @Resource + private DataGroupApi dataGroupApi; + + // TODO 配置权限 + // TODO 配置操作日志类型 + // TODO 拖拽 + // TODO http + // TODO 聚合查询关联 + + @OperatorLog(HostOperatorType.CREATE) + @PostMapping("/create") + @Operation(summary = "创建主机分组") + @PreAuthorize("@ss.hasPermission('asset:host-group:create')") + public Long createHostGroup(@Validated @RequestBody DataGroupCreateDTO request) { + return dataGroupApi.createDataGroup(DataGroupTypeEnum.HOST, request); + } + + @IgnoreLog(IgnoreLogMode.RET) + @GetMapping("/tree") + @Operation(summary = "创建主机分组") + @PreAuthorize("@ss.hasPermission('asset:host-group:query')") + public List queryHostGroup() { + return dataGroupApi.getDataGroupTree(DataGroupTypeEnum.HOST); + } + + @OperatorLog(HostOperatorType.UPDATE) + @PutMapping("/rename") + @Operation(summary = "修改名称") + @PreAuthorize("@ss.hasPermission('asset:host-group:update')") + public Integer updateHostGroupName(@Validated @RequestBody DataGroupUpdateDTO request) { + return dataGroupApi.renameDataGroup(request); + } + + @OperatorLog(HostOperatorType.DELETE) + @DeleteMapping("/delete") + @Operation(summary = "删除主机分组") + @PreAuthorize("@ss.hasPermission('asset:host-group:delete')") + public Integer deleteHostGroup(@RequestParam("id") Long id) { + return dataGroupApi.deleteDataGroupById(id); + } + +} + diff --git a/orion-ops-ui/src/api/asset/host-group-rel.ts b/orion-ops-ui/src/api/asset/host-group-rel.ts new file mode 100644 index 00000000..74a04c9e --- /dev/null +++ b/orion-ops-ui/src/api/asset/host-group-rel.ts @@ -0,0 +1,114 @@ +import type { DataGrid, Pagination } from '@/types/global'; +import type { TableData } from '@arco-design/web-vue/es/table/interface'; +import axios from 'axios'; +import qs from 'query-string'; + +/** + * 数据分组关联创建请求 + */ +export interface DataGroupRelCreateRequest { + groupId?: number; + relId?: number; + type?: string; + sort?: number; +} + +/** + * 数据分组关联更新请求 + */ +export interface DataGroupRelUpdateRequest extends DataGroupRelCreateRequest { + id?: number; +} + +/** + * 数据分组关联查询请求 + */ +export interface DataGroupRelQueryRequest extends Pagination { + searchValue?: string; + id?: number; + groupId?: number; + relId?: number; + type?: string; + sort?: number; +} + +/** + * 数据分组关联查询响应 + */ +export interface DataGroupRelQueryResponse extends TableData { + id: number; + groupId: number; + relId: number; + type: string; + sort: number; + createTime: number; + updateTime: number; + creator: string; + updater: string; +} + +/** + * 创建数据分组关联 + */ +export function createDataGroupRel(request: DataGroupRelCreateRequest) { + return axios.post('/infra/data-group-rel/create', request); +} + +/** + * 更新数据分组关联 + */ +export function updateDataGroupRel(request: DataGroupRelUpdateRequest) { + return axios.put('/infra/data-group-rel/update', request); +} + +/** + * 查询数据分组关联 + */ +export function getDataGroupRel(id: number) { + return axios.get('/infra/data-group-rel/get', { params: { id } }); +} + +/** + * 批量查询数据分组关联 + */ +export function batchGetDataGroupRelList(idList: Array) { + return axios.get('/infra/data-group-rel/batch-get', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + +/** + * 查询全部数据分组关联 + */ +export function getDataGroupRelList(request: DataGroupRelQueryRequest) { + return axios.post>('/infra/data-group-rel/list', request); +} + +/** + * 分页查询数据分组关联 + */ +export function getDataGroupRelPage(request: DataGroupRelQueryRequest) { + return axios.post>('/infra/data-group-rel/query', request); +} + +/** + * 删除数据分组关联 + */ +export function deleteDataGroupRel(id: number) { + return axios.delete('/infra/data-group-rel/delete', { params: { id } }); +} + +/** + * 批量删除数据分组关联 + */ +export function batchDeleteDataGroupRel(idList: Array) { + return axios.delete('/infra/data-group-rel/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-ops-ui/src/api/asset/host-group.ts b/orion-ops-ui/src/api/asset/host-group.ts new file mode 100644 index 00000000..260f7180 --- /dev/null +++ b/orion-ops-ui/src/api/asset/host-group.ts @@ -0,0 +1,67 @@ +import axios from 'axios'; + +/** + * 主机分组创建请求 + */ +export interface HostGroupCreateRequest { + parentId?: number; + name?: string; +} + +/** + * 主机分组更新请求 + */ +export interface HostGroupUpdateRequest extends HostGroupCreateRequest { + id?: number; +} + +/** + * 主机分组查询请求 + */ +export interface HostGroupQueryRequest { + searchValue?: string; + id?: number; + parentId?: number; + name?: string; + type?: string; + sort?: number; +} + +/** + * 主机分组查询响应 + */ +export interface HostGroupQueryResponse { + id: number; + parentId: number; + name: string; + sort: number; + children: Array; +} + +/** + * 创建主机分组 + */ +export function createHostGroup(request: HostGroupCreateRequest) { + return axios.post('/asset/host-group/create', request); +} + +/** + * 更新主机分组 + */ +export function updateHostGroup(request: HostGroupUpdateRequest) { + return axios.put('/asset/host-group/update', request); +} + +/** + * 查询全部主机分组树 + */ +export function getHostGroupTree() { + return axios.get>('/asset/host-group/tree'); +} + +/** + * 删除主机分组 + */ +export function deleteHostGroup(id: number) { + return axios.delete('/asset/host-group/delete', { params: { id } }); +} diff --git a/orion-ops-ui/src/assets/style/global.less b/orion-ops-ui/src/assets/style/global.less index 6cc1b2c3..2b79eb8b 100644 --- a/orion-ops-ui/src/assets/style/global.less +++ b/orion-ops-ui/src/assets/style/global.less @@ -13,9 +13,10 @@ body { -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; --color-scrollbar-track: var(--color-neutral-1); - --color-scrollbar-thumb: #959FAB; + --color-scrollbar-thumb: var(--color-neutral-5); } +// -- echarts .echarts-tooltip-diy { background: linear-gradient(304.17deg, rgba(253, 254, 255, 0.6) -6.04%, @@ -67,31 +68,10 @@ body { } } -.general-card { - border-radius: 4px; - border: none; - - & > .arco-card-header { - height: auto; - padding: 16px; - border: none; - } - - & > .arco-card-body { - padding: 0 16px 16px 16px; - } -} - -.a-query-header-grid { - .arco-grid-item { - &:last-child { - display: flex !important; - } - } -} - -.split-line { - border-color: rgb(var(--gray-2)); +// -- arco +.arco-table-td-content { + color: rgba(var(--gray-9), .95); + font-size: 13px; } .arco-table-cell { @@ -120,6 +100,31 @@ body { } } +.a-query-header-grid { + .arco-grid-item { + &:last-child { + display: flex !important; + } + } +} + +// -- card +.general-card { + border-radius: 4px; + border: none; + + & > .arco-card-header { + height: auto; + padding: 16px; + border: none; + } + + & > .arco-card-body { + padding: 0 16px 16px 16px; + } +} + +// -- click-icon .click-icon-wrapper { display: flex; justify-content: center; @@ -136,6 +141,113 @@ body { background: var(--color-fill-3); } +// -- element +.split-line { + border-color: rgb(var(--gray-2)); +} + +.usn { + user-select: none; +} + +.hide { + display: none; +} + +.pointer { + cursor: pointer; +} + +.mx0 { + margin: 0 0; +} + +.mx2 { + margin: 0 2px; +} + +.mx4 { + margin: 0 4px; +} + +.ml4 { + margin-left: 4px; +} + +.mr4 { + margin-right: 4px; +} + +.mt4 { + margin-top: 4px; +} + +.mb4 { + margin-bottom: 4px; +} + +.mx4 { + margin-left: 4px; + margin-right: 4px; +} + +.my4 { + margin-top: 4px; + margin-bottom: 4px; +} + +.ml8 { + margin-left: 8px; +} + +.mr8 { + margin-right: 8px; +} + +.mt8 { + margin-top: 8px; +} + +.mb8 { + margin-bottom: 8px; +} + +.mx8 { + margin-left: 8px; + margin-right: 8px; +} + +.my8 { + margin-top: 8px; + margin-bottom: 8px; +} + +.ml16 { + margin-left: 16px; +} + +.mr16 { + margin-right: 16px; +} + +.mt16 { + margin-top: 16px; +} + +.mb16 { + margin-bottom: 16px; +} + +.mx16 { + margin-left: 16px; + margin-right: 16px; +} + +.my16 { + margin-top: 16px; + margin-bottom: 16px; +} + .copy-left { color: rgb(var(--arcoblue-6)); cursor: pointer; @@ -150,6 +262,7 @@ body { color: rgb(var(--red-6)); } +// -- 滚动条 #app { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; diff --git a/orion-ops-ui/src/assets/style/layout.less b/orion-ops-ui/src/assets/style/layout.less index d0628e77..03c228ea 100644 --- a/orion-ops-ui/src/assets/style/layout.less +++ b/orion-ops-ui/src/assets/style/layout.less @@ -1,10 +1,13 @@ +// -- container .layout-container { background-color: var(--color-fill-2); padding: 16px; display: flex; flex-direction: column; + position: relative; } +// -- table-view .table-search-card { width: 100%; padding-top: 16px; @@ -64,10 +67,12 @@ } } +// -- modal .modal-form { padding: 24px 20px 4px 20px; } +// -- card-view .card-list-item { height: 100%; display: flex; @@ -105,109 +110,8 @@ padding: 18px 24px 14px 24px; } -.arco-table-td-content { - color: rgba(var(--gray-9), .95); - font-size: 13px; -} - -.usn { - user-select: none; -} - -.hide { - display: none; -} - -.pointer { - cursor: pointer; -} - -.mx0 { - margin: 0 0; -} - -.mx2 { - margin: 0 2px; -} - -.mx4 { - margin: 0 4px; -} - -.ml4 { - margin-left: 4px; -} - -.mr4 { - margin-right: 4px; -} - -.mt4 { - margin-top: 4px; -} - -.mb4 { - margin-bottom: 4px; -} - -.mx4 { - margin-left: 4px; - margin-right: 4px; -} - -.my4 { - margin-top: 4px; - margin-bottom: 4px; -} - -.ml8 { - margin-left: 8px; -} - -.mr8 { - margin-right: 8px; -} - -.mt8 { - margin-top: 8px; -} - -.mb8 { - margin-bottom: 8px; -} - -.mx8 { - margin-left: 8px; - margin-right: 8px; -} - -.my8 { - margin-top: 8px; - margin-bottom: 8px; -} - -.ml16 { - margin-left: 16px; -} - -.mr16 { - margin-right: 16px; -} - -.mt16 { - margin-top: 16px; -} - -.mb16 { - margin-bottom: 16px; -} - -.mx16 { - margin-left: 16px; - margin-right: 16px; -} - -.my16 { - margin-top: 16px; - margin-bottom: 16px; +// -- card +.simple-card { + background: var(--color-bg-2); + border-radius: 4px; } diff --git a/orion-ops-ui/src/components/app/footer/index.vue b/orion-ops-ui/src/components/app/footer/index.vue index 34bff3ab..e07b9539 100644 --- a/orion-ops-ui/src/components/app/footer/index.vue +++ b/orion-ops-ui/src/components/app/footer/index.vue @@ -1,10 +1,17 @@ @@ -16,21 +23,17 @@ display: flex; align-items: center; justify-content: center; - height: 40px; - color: var(--color-text-2); + height: 80px; text-align: center; - &-text { - text-wrap: none; - - a { - text-decoration: none; - } - - .license { - display: inline-block; - margin-left: 16px; - } + a { + text-decoration: none; + color: rgb(var(--primary-6)); } + + .copyright { + color: var(--color-text-3) + } + } diff --git a/orion-ops-ui/src/components/index.ts b/orion-ops-ui/src/components/index.ts index f671547b..c61bd8e7 100644 --- a/orion-ops-ui/src/components/index.ts +++ b/orion-ops-ui/src/components/index.ts @@ -30,10 +30,10 @@ use([ export default { install(Vue: App) { - Vue.component('Chart', Chart); - Vue.component('Breadcrumb', Breadcrumb); + Vue.component('chart', Chart); + Vue.component('breadcrumb', Breadcrumb); Vue.component('a-query-header', AQueryHeader); Vue.component('card-list', CardList); - Vue.component('Editor', Editor); + Vue.component('editor', Editor); }, }; diff --git a/orion-ops-ui/src/components/system/menu/grant/menu-grant-table.vue b/orion-ops-ui/src/components/system/menu/grant/menu-grant-table.vue index 34c8c701..e58eb322 100644 --- a/orion-ops-ui/src/components/system/menu/grant/menu-grant-table.vue +++ b/orion-ops-ui/src/components/system/menu/grant/menu-grant-table.vue @@ -136,6 +136,7 @@ } }); + // fixme 提成公共方法 // 寻找当前节点 const findNode = (id: number, arr: Array): MenuQueryResponse | undefined => { for (let node of arr) { diff --git a/orion-ops-ui/src/components/view/card-list/index.vue b/orion-ops-ui/src/components/view/card-list/index.vue index 5841b3dd..41441b04 100644 --- a/orion-ops-ui/src/components/view/card-list/index.vue +++ b/orion-ops-ui/src/components/view/card-list/index.vue @@ -6,16 +6,16 @@
- +
diff --git a/orion-ops-ui/src/layout/default-layout.vue b/orion-ops-ui/src/layout/default-layout.vue index 953d43d2..33f35340 100644 --- a/orion-ops-ui/src/layout/default-layout.vue +++ b/orion-ops-ui/src/layout/default-layout.vue @@ -4,7 +4,7 @@
- + + + +