From e9047c59c0537c0cb95d3e41b14476146ba6d6c6 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Wed, 20 Sep 2023 12:13:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=BB=E6=9C=BA=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E4=BB=A3=E7=A0=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HostIdentityController.http | 92 ++++++++ .../controller/HostIdentityController.java | 118 ++++++++++ .../asset/controller/HostKeyController.http | 92 ++++++++ .../asset/controller/HostKeyController.java | 118 ++++++++++ .../asset/convert/HostIdentityConvert.java | 37 +++ .../module/asset/convert/HostKeyConvert.java | 37 +++ .../ops/module/asset/dao/HostIdentityDAO.java | 33 +++ .../ops/module/asset/dao/HostKeyDAO.java | 33 +++ .../asset/entity/domain/HostIdentityDO.java | 46 ++++ .../module/asset/entity/domain/HostKeyDO.java | 46 ++++ .../entity/export/HostIdentityExport.java | 67 ++++++ .../asset/entity/export/HostKeyExport.java | 67 ++++++ .../host/HostIdentityCreateRequest.java | 47 ++++ .../host/HostIdentityQueryRequest.java | 42 ++++ .../host/HostIdentityUpdateRequest.java | 51 +++++ .../request/host/HostKeyCreateRequest.java | 47 ++++ .../request/host/HostKeyQueryRequest.java | 43 ++++ .../request/host/HostKeyUpdateRequest.java | 52 +++++ .../asset/entity/vo/HostIdentityVO.java | 52 +++++ .../ops/module/asset/entity/vo/HostKeyVO.java | 52 +++++ .../asset/service/HostIdentityService.java | 120 ++++++++++ .../module/asset/service/HostKeyService.java | 120 ++++++++++ .../service/impl/HostIdentityServiceImpl.java | 212 ++++++++++++++++++ .../service/impl/HostKeyServiceImpl.java | 212 ++++++++++++++++++ .../resources/mapper/HostIdentityMapper.xml | 24 ++ .../main/resources/mapper/HostKeyMapper.xml | 24 ++ orion-ops-ui/src/api/asset/host-identity.ts | 119 ++++++++++ orion-ops-ui/src/api/asset/host-key.ts | 119 ++++++++++ .../src/router/routes/modules/asset.ts | 8 + .../components/host-identity-form-modal.vue | 151 +++++++++++++ .../components/host-identity-table.vue | 209 +++++++++++++++++ .../src/views/asset/host-identity/index.vue | 32 +++ .../views/asset/host-identity/types/const.ts | 0 .../asset/host-identity/types/enum.types.ts | 0 .../asset/host-identity/types/form.rules.ts | 37 +++ .../host-identity/types/table.columns.ts | 73 ++++++ .../components/host-key-form-modal.vue | 151 +++++++++++++ .../host-key/components/host-key-table.vue | 209 +++++++++++++++++ .../src/views/asset/host-key/index.vue | 32 +++ .../src/views/asset/host-key/types/const.ts | 0 .../views/asset/host-key/types/enum.types.ts | 0 .../views/asset/host-key/types/form.rules.ts | 40 ++++ .../asset/host-key/types/table.columns.ts | 75 +++++++ 43 files changed, 3139 insertions(+) create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.http create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.http create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostIdentityConvert.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostKeyConvert.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostIdentityDAO.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostKeyDAO.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostIdentityDO.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostKeyDO.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostIdentityExport.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostKeyExport.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityCreateRequest.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityQueryRequest.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityUpdateRequest.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyCreateRequest.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyQueryRequest.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyUpdateRequest.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostIdentityVO.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostKeyVO.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostIdentityService.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostKeyService.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostIdentityServiceImpl.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostIdentityMapper.xml create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostKeyMapper.xml create mode 100644 orion-ops-ui/src/api/asset/host-identity.ts create mode 100644 orion-ops-ui/src/api/asset/host-key.ts create mode 100644 orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue create mode 100644 orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue create mode 100644 orion-ops-ui/src/views/asset/host-identity/index.vue create mode 100644 orion-ops-ui/src/views/asset/host-identity/types/const.ts create mode 100644 orion-ops-ui/src/views/asset/host-identity/types/enum.types.ts create mode 100644 orion-ops-ui/src/views/asset/host-identity/types/form.rules.ts create mode 100644 orion-ops-ui/src/views/asset/host-identity/types/table.columns.ts create mode 100644 orion-ops-ui/src/views/asset/host-key/components/host-key-form-modal.vue create mode 100644 orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue create mode 100644 orion-ops-ui/src/views/asset/host-key/index.vue create mode 100644 orion-ops-ui/src/views/asset/host-key/types/const.ts create mode 100644 orion-ops-ui/src/views/asset/host-key/types/enum.types.ts create mode 100644 orion-ops-ui/src/views/asset/host-key/types/form.rules.ts create mode 100644 orion-ops-ui/src/views/asset/host-key/types/table.columns.ts diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.http b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.http new file mode 100644 index 00000000..c3822fad --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.http @@ -0,0 +1,92 @@ +### 创建主机身份 +POST {{baseUrl}}/asset/host-identity/create +Content-Type: application/json +Authorization: {{token}} + +{ + "name": "", + "username": "", + "password": "", + "keyId": "" +} + + +### 通过 id 更新主机身份 +PUT {{baseUrl}}/asset/host-identity/update +Content-Type: application/json +Authorization: {{token}} + +{ + "id": "", + "name": "", + "username": "", + "password": "", + "keyId": "" +} + + +### 通过 id 查询主机身份 +GET {{baseUrl}}/asset/host-identity/get?id=1 +Authorization: {{token}} + + +### 通过 id 批量查询主机身份 +GET {{baseUrl}}/asset/host-identity/list?idList=1,2,3 +Authorization: {{token}} + + +### 查询主机身份 +POST {{baseUrl}}/asset/host-identity/list-all +Content-Type: application/json +Authorization: {{token}} + +{ + "id": "", + "name": "", + "username": "", + "password": "", + "keyId": "" +} + + +### 分页查询主机身份 +POST {{baseUrl}}/asset/host-identity/query +Content-Type: application/json +Authorization: {{token}} + +{ + "page": 1, + "limit": 10, + "id": "", + "name": "", + "username": "", + "password": "", + "keyId": "" +} + + +### 通过 id 删除主机身份 +DELETE {{baseUrl}}/asset/host-identity/delete?id=1 +Authorization: {{token}} + + +### 通过 id 批量删除主机身份 +DELETE {{baseUrl}}/asset/host-identity/delete-batch?idList=1,2,3 +Authorization: {{token}} + + +### 导出主机身份 +POST {{baseUrl}}/asset/host-identity/export +Content-Type: application/json +Authorization: {{token}} + +{ + "id": "", + "name": "", + "username": "", + "password": "", + "keyId": "" +} + + +### diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.java new file mode 100644 index 00000000..a6f2e20c --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostIdentityController.java @@ -0,0 +1,118 @@ +package com.orion.ops.module.asset.controller; + +import com.orion.lang.define.wrapper.DataGrid; +import com.orion.ops.framework.common.annotation.IgnoreLog; +import com.orion.ops.framework.common.annotation.RestWrapper; +import com.orion.ops.framework.common.constant.IgnoreLogMode; +import com.orion.ops.framework.common.valid.group.Page; +import com.orion.ops.module.asset.service.*; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; +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 javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * 主机身份 api + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Tag(name = "asset - 主机身份服务") +@Slf4j +@Validated +@RestWrapper +@RestController +@RequestMapping("/asset/host-identity") +@SuppressWarnings({"ELValidationInJSP", "SpringElInspection"}) +public class HostIdentityController { + + @Resource + private HostIdentityService hostIdentityService; + + @PostMapping("/create") + @Operation(summary = "创建主机身份") + @PreAuthorize("@ss.hasPermission('asset:host-identity:create')") + public Long createHostIdentity(@Validated @RequestBody HostIdentityCreateRequest request) { + return hostIdentityService.createHostIdentity(request); + } + + @PutMapping("/update") + @Operation(summary = "通过 id 更新主机身份") + @PreAuthorize("@ss.hasPermission('asset:host-identity:update')") + public Integer updateHostIdentity(@Validated @RequestBody HostIdentityUpdateRequest request) { + return hostIdentityService.updateHostIdentityById(request); + } + + @IgnoreLog(IgnoreLogMode.RET) + @GetMapping("/get") + @Operation(summary = "通过 id 查询主机身份") + @Parameter(name = "id", description = "id", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-identity:query')") + public HostIdentityVO getHostIdentity(@RequestParam("id") Long id) { + return hostIdentityService.getHostIdentityById(id); + } + + @IgnoreLog(IgnoreLogMode.RET) + @GetMapping("/list") + @Operation(summary = "通过 id 批量查询主机身份") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-identity:query')") + public List getHostIdentityList(@RequestParam("idList") List idList) { + return hostIdentityService.getHostIdentityByIdList(idList); + } + + @IgnoreLog(IgnoreLogMode.RET) + @PostMapping("/list-all") + @Operation(summary = "查询主机身份") + @PreAuthorize("@ss.hasPermission('asset:host-identity:query')") + public List getHostIdentityListAll(@Validated @RequestBody HostIdentityQueryRequest request) { + return hostIdentityService.getHostIdentityList(request); + } + + @IgnoreLog(IgnoreLogMode.RET) + @PostMapping("/query") + @Operation(summary = "分页查询主机身份") + @PreAuthorize("@ss.hasPermission('asset:host-identity:query')") + public DataGrid getHostIdentityPage(@Validated(Page.class) @RequestBody HostIdentityQueryRequest request) { + return hostIdentityService.getHostIdentityPage(request); + } + + @DeleteMapping("/delete") + @Operation(summary = "通过 id 删除主机身份") + @Parameter(name = "id", description = "id", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-identity:delete')") + public Integer deleteHostIdentity(@RequestParam("id") Long id) { + return hostIdentityService.deleteHostIdentityById(id); + } + + @DeleteMapping("/delete-batch") + @Operation(summary = "通过 id 批量删除主机身份") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-identity:delete')") + public Integer batchDeleteHostIdentity(@RequestParam("idList") List idList) { + return hostIdentityService.batchDeleteHostIdentityByIdList(idList); + } + + @PostMapping("/export") + @Operation(summary = "导出主机身份") + @PreAuthorize("@ss.hasPermission('asset:host-identity:export')") + public void exportHostIdentity(@Validated @RequestBody HostIdentityQueryRequest request, + HttpServletResponse response) throws IOException { + hostIdentityService.exportHostIdentity(request, response); + } + +} + diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.http b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.http new file mode 100644 index 00000000..76f4d235 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.http @@ -0,0 +1,92 @@ +### 创建主机秘钥 +POST {{baseUrl}}/asset/host-key/create +Content-Type: application/json +Authorization: {{token}} + +{ + "name": "", + "publicKey": "", + "privateKey": "", + "password": "" +} + + +### 通过 id 更新主机秘钥 +PUT {{baseUrl}}/asset/host-key/update +Content-Type: application/json +Authorization: {{token}} + +{ + "id": "", + "name": "", + "publicKey": "", + "privateKey": "", + "password": "" +} + + +### 通过 id 查询主机秘钥 +GET {{baseUrl}}/asset/host-key/get?id=1 +Authorization: {{token}} + + +### 通过 id 批量查询主机秘钥 +GET {{baseUrl}}/asset/host-key/list?idList=1,2,3 +Authorization: {{token}} + + +### 查询主机秘钥 +POST {{baseUrl}}/asset/host-key/list-all +Content-Type: application/json +Authorization: {{token}} + +{ + "id": "", + "name": "", + "publicKey": "", + "privateKey": "", + "password": "" +} + + +### 分页查询主机秘钥 +POST {{baseUrl}}/asset/host-key/query +Content-Type: application/json +Authorization: {{token}} + +{ + "page": 1, + "limit": 10, + "id": "", + "name": "", + "publicKey": "", + "privateKey": "", + "password": "" +} + + +### 通过 id 删除主机秘钥 +DELETE {{baseUrl}}/asset/host-key/delete?id=1 +Authorization: {{token}} + + +### 通过 id 批量删除主机秘钥 +DELETE {{baseUrl}}/asset/host-key/delete-batch?idList=1,2,3 +Authorization: {{token}} + + +### 导出主机秘钥 +POST {{baseUrl}}/asset/host-key/export +Content-Type: application/json +Authorization: {{token}} + +{ + "id": "", + "name": "", + "publicKey": "", + "privateKey": "", + "password": "" +} + + +### diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.java new file mode 100644 index 00000000..b3e70044 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/HostKeyController.java @@ -0,0 +1,118 @@ +package com.orion.ops.module.asset.controller; + +import com.orion.lang.define.wrapper.DataGrid; +import com.orion.ops.framework.common.annotation.IgnoreLog; +import com.orion.ops.framework.common.annotation.RestWrapper; +import com.orion.ops.framework.common.constant.IgnoreLogMode; +import com.orion.ops.framework.common.valid.group.Page; +import com.orion.ops.module.asset.service.*; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; +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 javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * 主机秘钥 api + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Tag(name = "asset - 主机秘钥服务") +@Slf4j +@Validated +@RestWrapper +@RestController +@RequestMapping("/asset/host-key") +@SuppressWarnings({"ELValidationInJSP", "SpringElInspection"}) +public class HostKeyController { + + @Resource + private HostKeyService hostKeyService; + + @PostMapping("/create") + @Operation(summary = "创建主机秘钥") + @PreAuthorize("@ss.hasPermission('asset:host-key:create')") + public Long createHostKey(@Validated @RequestBody HostKeyCreateRequest request) { + return hostKeyService.createHostKey(request); + } + + @PutMapping("/update") + @Operation(summary = "通过 id 更新主机秘钥") + @PreAuthorize("@ss.hasPermission('asset:host-key:update')") + public Integer updateHostKey(@Validated @RequestBody HostKeyUpdateRequest request) { + return hostKeyService.updateHostKeyById(request); + } + + @IgnoreLog(IgnoreLogMode.RET) + @GetMapping("/get") + @Operation(summary = "通过 id 查询主机秘钥") + @Parameter(name = "id", description = "id", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-key:query')") + public HostKeyVO getHostKey(@RequestParam("id") Long id) { + return hostKeyService.getHostKeyById(id); + } + + @IgnoreLog(IgnoreLogMode.RET) + @GetMapping("/list") + @Operation(summary = "通过 id 批量查询主机秘钥") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-key:query')") + public List getHostKeyList(@RequestParam("idList") List idList) { + return hostKeyService.getHostKeyByIdList(idList); + } + + @IgnoreLog(IgnoreLogMode.RET) + @PostMapping("/list-all") + @Operation(summary = "查询主机秘钥") + @PreAuthorize("@ss.hasPermission('asset:host-key:query')") + public List getHostKeyListAll(@Validated @RequestBody HostKeyQueryRequest request) { + return hostKeyService.getHostKeyList(request); + } + + @IgnoreLog(IgnoreLogMode.RET) + @PostMapping("/query") + @Operation(summary = "分页查询主机秘钥") + @PreAuthorize("@ss.hasPermission('asset:host-key:query')") + public DataGrid getHostKeyPage(@Validated(Page.class) @RequestBody HostKeyQueryRequest request) { + return hostKeyService.getHostKeyPage(request); + } + + @DeleteMapping("/delete") + @Operation(summary = "通过 id 删除主机秘钥") + @Parameter(name = "id", description = "id", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-key:delete')") + public Integer deleteHostKey(@RequestParam("id") Long id) { + return hostKeyService.deleteHostKeyById(id); + } + + @DeleteMapping("/delete-batch") + @Operation(summary = "通过 id 批量删除主机秘钥") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-key:delete')") + public Integer batchDeleteHostKey(@RequestParam("idList") List idList) { + return hostKeyService.batchDeleteHostKeyByIdList(idList); + } + + @PostMapping("/export") + @Operation(summary = "导出主机秘钥") + @PreAuthorize("@ss.hasPermission('asset:host-key:export')") + public void exportHostKey(@Validated @RequestBody HostKeyQueryRequest request, + HttpServletResponse response) throws IOException { + hostKeyService.exportHostKey(request, response); + } + +} + diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostIdentityConvert.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostIdentityConvert.java new file mode 100644 index 00000000..3be84d79 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostIdentityConvert.java @@ -0,0 +1,37 @@ +package com.orion.ops.module.asset.convert; + +import com.orion.ops.module.asset.entity.domain.*; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 主机身份 内部对象转换器 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Mapper +public interface HostIdentityConvert { + + HostIdentityConvert MAPPER = Mappers.getMapper(HostIdentityConvert.class); + + HostIdentityDO to(HostIdentityCreateRequest request); + + HostIdentityDO to(HostIdentityUpdateRequest request); + + HostIdentityDO to(HostIdentityQueryRequest request); + + HostIdentityVO to(HostIdentityDO domain); + + HostIdentityExport toExport(HostIdentityDO domain); + + List to(List list); + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostKeyConvert.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostKeyConvert.java new file mode 100644 index 00000000..e4779e87 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/convert/HostKeyConvert.java @@ -0,0 +1,37 @@ +package com.orion.ops.module.asset.convert; + +import com.orion.ops.module.asset.entity.domain.*; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 主机秘钥 内部对象转换器 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Mapper +public interface HostKeyConvert { + + HostKeyConvert MAPPER = Mappers.getMapper(HostKeyConvert.class); + + HostKeyDO to(HostKeyCreateRequest request); + + HostKeyDO to(HostKeyUpdateRequest request); + + HostKeyDO to(HostKeyQueryRequest request); + + HostKeyVO to(HostKeyDO domain); + + HostKeyExport toExport(HostKeyDO domain); + + List to(List list); + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostIdentityDAO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostIdentityDAO.java new file mode 100644 index 00000000..28ea0bfa --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostIdentityDAO.java @@ -0,0 +1,33 @@ +package com.orion.ops.module.asset.dao; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orion.ops.framework.mybatis.core.mapper.IMapper; +import com.orion.ops.module.asset.entity.domain.HostIdentityDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 主机身份 Mapper 接口 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Mapper +public interface HostIdentityDAO extends IMapper { + + /** + * 获取查询条件 + * + * @param entity entity + * @return 查询条件 + */ + default LambdaQueryWrapper queryCondition(HostIdentityDO entity) { + return this.wrapper() + .eq(HostIdentityDO::getId, entity.getId()) + .eq(HostIdentityDO::getName, entity.getName()) + .eq(HostIdentityDO::getUsername, entity.getUsername()) + .eq(HostIdentityDO::getPassword, entity.getPassword()) + .eq(HostIdentityDO::getKeyId, entity.getKeyId()); + } + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostKeyDAO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostKeyDAO.java new file mode 100644 index 00000000..7d9e7346 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/dao/HostKeyDAO.java @@ -0,0 +1,33 @@ +package com.orion.ops.module.asset.dao; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orion.ops.framework.mybatis.core.mapper.IMapper; +import com.orion.ops.module.asset.entity.domain.HostKeyDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 主机秘钥 Mapper 接口 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Mapper +public interface HostKeyDAO extends IMapper { + + /** + * 获取查询条件 + * + * @param entity entity + * @return 查询条件 + */ + default LambdaQueryWrapper queryCondition(HostKeyDO entity) { + return this.wrapper() + .eq(HostKeyDO::getId, entity.getId()) + .eq(HostKeyDO::getName, entity.getName()) + .eq(HostKeyDO::getPublicKey, entity.getPublicKey()) + .eq(HostKeyDO::getPrivateKey, entity.getPrivateKey()) + .eq(HostKeyDO::getPassword, entity.getPassword()); + } + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostIdentityDO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostIdentityDO.java new file mode 100644 index 00000000..900a24ca --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostIdentityDO.java @@ -0,0 +1,46 @@ +package com.orion.ops.module.asset.entity.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.orion.ops.framework.mybatis.core.domain.BaseDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +/** + * 主机身份 实体对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName(value = "host_identity", autoResultMap = true) +@Schema(name = "HostIdentityDO", description = "主机身份 实体对象") +public class HostIdentityDO extends BaseDO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @Schema(description = "名称") + @TableField("name") + private String name; + + @Schema(description = "用户名") + @TableField("username") + private String username; + + @Schema(description = "用户密码") + @TableField("password") + private String password; + + @Schema(description = "秘钥id") + @TableField("key_id") + private Long keyId; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostKeyDO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostKeyDO.java new file mode 100644 index 00000000..9b897caf --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/HostKeyDO.java @@ -0,0 +1,46 @@ +package com.orion.ops.module.asset.entity.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.orion.ops.framework.mybatis.core.domain.BaseDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +/** + * 主机秘钥 实体对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName(value = "host_key", autoResultMap = true) +@Schema(name = "HostKeyDO", description = "主机秘钥 实体对象") +public class HostKeyDO extends BaseDO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @Schema(description = "名称") + @TableField("name") + private String name; + + @Schema(description = "公钥文本") + @TableField("public_key") + private String publicKey; + + @Schema(description = "私钥文本") + @TableField("private_key") + private String privateKey; + + @Schema(description = "密码") + @TableField("password") + private String password; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostIdentityExport.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostIdentityExport.java new file mode 100644 index 00000000..199656a4 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostIdentityExport.java @@ -0,0 +1,67 @@ +package com.orion.ops.module.asset.entity.export; + +import com.orion.lang.utils.time.Dates; +import com.orion.office.excel.annotation.ExportField; +import com.orion.office.excel.annotation.ExportSheet; +import com.orion.office.excel.annotation.ExportTitle; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.io.Serializable; +import java.util.*; + +/** + * 主机身份 导出对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ExportTitle(title = HostIdentityExport.TITLE) +@ExportSheet(name = "主机身份", filterHeader = true, freezeHeader = true, indexToSort = true) +@Schema(name = "HostIdentityExport", description = "主机身份导出对象") +public class HostIdentityExport implements Serializable { + + public static final String TITLE = "主机身份导出"; + + @Schema(description = "id") + @ExportField(index = 0, header = "id", width = 16) + private Long id; + + @Schema(description = "名称") + @ExportField(index = 1, header = "名称", width = 16) + private String name; + + @Schema(description = "用户名") + @ExportField(index = 2, header = "用户名", width = 16) + private String username; + + @Schema(description = "用户密码") + @ExportField(index = 3, header = "用户密码", width = 16) + private String password; + + @Schema(description = "秘钥id") + @ExportField(index = 4, header = "秘钥id", width = 16) + private Long keyId; + + @ExportField(index = 5, header = "创建时间", width = 16, format = Dates.YMD_HMS) + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + @ExportField(index = 6, header = "修改时间", width = 16, format = Dates.YMD_HMS) + private Date updateTime; + + @Schema(description = "创建人") + @ExportField(index = 7, header = "创建人", width = 16) + private String creator; + + @Schema(description = "修改人") + @ExportField(index = 8, header = "修改人", width = 16) + private String updater; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostKeyExport.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostKeyExport.java new file mode 100644 index 00000000..fde38d2a --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/export/HostKeyExport.java @@ -0,0 +1,67 @@ +package com.orion.ops.module.asset.entity.export; + +import com.orion.lang.utils.time.Dates; +import com.orion.office.excel.annotation.ExportField; +import com.orion.office.excel.annotation.ExportSheet; +import com.orion.office.excel.annotation.ExportTitle; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.io.Serializable; +import java.util.*; + +/** + * 主机秘钥 导出对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ExportTitle(title = HostKeyExport.TITLE) +@ExportSheet(name = "主机秘钥", filterHeader = true, freezeHeader = true, indexToSort = true) +@Schema(name = "HostKeyExport", description = "主机秘钥导出对象") +public class HostKeyExport implements Serializable { + + public static final String TITLE = "主机秘钥导出"; + + @Schema(description = "id") + @ExportField(index = 0, header = "id", width = 16) + private Long id; + + @Schema(description = "名称") + @ExportField(index = 1, header = "名称", width = 16) + private String name; + + @Schema(description = "公钥文本") + @ExportField(index = 2, header = "公钥文本", width = 16) + private String publicKey; + + @Schema(description = "私钥文本") + @ExportField(index = 3, header = "私钥文本", width = 16) + private String privateKey; + + @Schema(description = "密码") + @ExportField(index = 4, header = "密码", width = 16) + private String password; + + @ExportField(index = 5, header = "创建时间", width = 16, format = Dates.YMD_HMS) + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + @ExportField(index = 6, header = "修改时间", width = 16, format = Dates.YMD_HMS) + private Date updateTime; + + @Schema(description = "创建人") + @ExportField(index = 7, header = "创建人", width = 16) + private String creator; + + @Schema(description = "修改人") + @ExportField(index = 8, header = "修改人", width = 16) + private String updater; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityCreateRequest.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityCreateRequest.java new file mode 100644 index 00000000..4dd6e474 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityCreateRequest.java @@ -0,0 +1,47 @@ +package com.orion.ops.module.asset.entity.request.host; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * 主机身份 创建请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "HostIdentityCreateRequest", description = "主机身份 创建请求对象") +public class HostIdentityCreateRequest implements Serializable { + + @NotBlank + @Size(max = 64) + @Schema(description = "名称") + private String name; + + @NotBlank + @Size(max = 128) + @Schema(description = "用户名") + private String username; + + @NotBlank + @Size(max = 512) + @Schema(description = "用户密码") + private String password; + + @NotNull + @Schema(description = "秘钥id") + private Long keyId; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityQueryRequest.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityQueryRequest.java new file mode 100644 index 00000000..1578548b --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityQueryRequest.java @@ -0,0 +1,42 @@ +package com.orion.ops.module.asset.entity.request.host; + +import com.orion.ops.framework.common.entity.PageRequest; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.Size; + +/** + * 主机身份 查询请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Schema(name = "HostIdentityQueryRequest", description = "主机身份 查询请求对象") +public class HostIdentityQueryRequest extends PageRequest { + + @Schema(description = "id") + private Long id; + + @Size(max = 64) + @Schema(description = "名称") + private String name; + + @Size(max = 128) + @Schema(description = "用户名") + private String username; + + @Size(max = 512) + @Schema(description = "用户密码") + private String password; + + @Schema(description = "秘钥id") + private Long keyId; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityUpdateRequest.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityUpdateRequest.java new file mode 100644 index 00000000..e3de0b41 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostIdentityUpdateRequest.java @@ -0,0 +1,51 @@ +package com.orion.ops.module.asset.entity.request.host; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * 主机身份 更新请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "HostIdentityUpdateRequest", description = "主机身份 更新请求对象") +public class HostIdentityUpdateRequest implements Serializable { + + @NotNull + @Schema(description = "id") + private Long id; + + @NotBlank + @Size(max = 64) + @Schema(description = "名称") + private String name; + + @NotBlank + @Size(max = 128) + @Schema(description = "用户名") + private String username; + + @NotBlank + @Size(max = 512) + @Schema(description = "用户密码") + private String password; + + @NotNull + @Schema(description = "秘钥id") + private Long keyId; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyCreateRequest.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyCreateRequest.java new file mode 100644 index 00000000..3b854f0e --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyCreateRequest.java @@ -0,0 +1,47 @@ +package com.orion.ops.module.asset.entity.request.host; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * 主机秘钥 创建请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "HostKeyCreateRequest", description = "主机秘钥 创建请求对象") +public class HostKeyCreateRequest implements Serializable { + + @NotBlank + @Size(max = 64) + @Schema(description = "名称") + private String name; + + @NotBlank + @Size(max = 65535) + @Schema(description = "公钥文本") + private String publicKey; + + @NotBlank + @Size(max = 65535) + @Schema(description = "私钥文本") + private String privateKey; + + @NotBlank + @Size(max = 512) + @Schema(description = "密码") + private String password; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyQueryRequest.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyQueryRequest.java new file mode 100644 index 00000000..0430fcad --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyQueryRequest.java @@ -0,0 +1,43 @@ +package com.orion.ops.module.asset.entity.request.host; + +import com.orion.ops.framework.common.entity.PageRequest; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.Size; + +/** + * 主机秘钥 查询请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Schema(name = "HostKeyQueryRequest", description = "主机秘钥 查询请求对象") +public class HostKeyQueryRequest extends PageRequest { + + @Schema(description = "id") + private Long id; + + @Size(max = 64) + @Schema(description = "名称") + private String name; + + @Size(max = 65535) + @Schema(description = "公钥文本") + private String publicKey; + + @Size(max = 65535) + @Schema(description = "私钥文本") + private String privateKey; + + @Size(max = 512) + @Schema(description = "密码") + private String password; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyUpdateRequest.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyUpdateRequest.java new file mode 100644 index 00000000..de73ca76 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/request/host/HostKeyUpdateRequest.java @@ -0,0 +1,52 @@ +package com.orion.ops.module.asset.entity.request.host; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * 主机秘钥 更新请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "HostKeyUpdateRequest", description = "主机秘钥 更新请求对象") +public class HostKeyUpdateRequest implements Serializable { + + @NotNull + @Schema(description = "id") + private Long id; + + @NotBlank + @Size(max = 64) + @Schema(description = "名称") + private String name; + + @NotBlank + @Size(max = 65535) + @Schema(description = "公钥文本") + private String publicKey; + + @NotBlank + @Size(max = 65535) + @Schema(description = "私钥文本") + private String privateKey; + + @NotBlank + @Size(max = 512) + @Schema(description = "密码") + private String password; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostIdentityVO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostIdentityVO.java new file mode 100644 index 00000000..803b918a --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostIdentityVO.java @@ -0,0 +1,52 @@ +package com.orion.ops.module.asset.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.io.Serializable; +import java.util.*; + +/** + * 主机身份 视图响应对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "HostIdentityVO", description = "主机身份 视图响应对象") +public class HostIdentityVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + private Long id; + + @Schema(description = "名称") + private String name; + + @Schema(description = "用户名") + private String username; + + @Schema(description = "用户密码") + private String password; + + @Schema(description = "秘钥id") + private Long keyId; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; + + @Schema(description = "创建人") + private String creator; + + @Schema(description = "修改人") + private String updater; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostKeyVO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostKeyVO.java new file mode 100644 index 00000000..fda57433 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostKeyVO.java @@ -0,0 +1,52 @@ +package com.orion.ops.module.asset.entity.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.io.Serializable; +import java.util.*; + +/** + * 主机秘钥 视图响应对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "HostKeyVO", description = "主机秘钥 视图响应对象") +public class HostKeyVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + private Long id; + + @Schema(description = "名称") + private String name; + + @Schema(description = "公钥文本") + private String publicKey; + + @Schema(description = "私钥文本") + private String privateKey; + + @Schema(description = "密码") + private String password; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; + + @Schema(description = "创建人") + private String creator; + + @Schema(description = "修改人") + private String updater; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostIdentityService.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostIdentityService.java new file mode 100644 index 00000000..a4f8c570 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostIdentityService.java @@ -0,0 +1,120 @@ +package com.orion.ops.module.asset.service; + +import com.orion.lang.define.wrapper.DataGrid; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * 主机身份 服务类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +public interface HostIdentityService { + + /** + * 创建主机身份 + * + * @param request request + * @return id + */ + Long createHostIdentity(HostIdentityCreateRequest request); + + /** + * 通过 id 更新主机身份 + * + * @param request request + * @return effect + */ + Integer updateHostIdentityById(HostIdentityUpdateRequest request); + + /** + * 更新主机身份 + * + * @param query query + * @param update update + * @return effect + */ + Integer updateHostIdentity(HostIdentityQueryRequest query, HostIdentityUpdateRequest update); + + /** + * 通过 id 查询主机身份 + * + * @param id id + * @return row + */ + HostIdentityVO getHostIdentityById(Long id); + + /** + * 通过 id 批量查询主机身份 + * + * @param idList idList + * @return rows + */ + List getHostIdentityByIdList(List idList); + + /** + * 查询主机身份 + * + * @param request request + * @return rows + */ + List getHostIdentityList(HostIdentityQueryRequest request); + + /** + * 查询主机身份数量 + * + * @param request request + * @return count + */ + Long getHostIdentityCount(HostIdentityQueryRequest request); + + /** + * 分页查询主机身份 + * + * @param request request + * @return rows + */ + DataGrid getHostIdentityPage(HostIdentityQueryRequest request); + + /** + * 通过 id 删除主机身份 + * + * @param id id + * @return effect + */ + Integer deleteHostIdentityById(Long id); + + /** + * 通过 id 批量删除主机身份 + * + * @param idList idList + * @return effect + */ + Integer batchDeleteHostIdentityByIdList(List idList); + + /** + * 删除主机身份 + * + * @param request request + * @return effect + */ + Integer deleteHostIdentity(HostIdentityQueryRequest request); + + /** + * 导出主机身份 + * + * @param request request + * @param response response + * @throws IOException IOException + */ + void exportHostIdentity(HostIdentityQueryRequest request, HttpServletResponse response) throws IOException; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostKeyService.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostKeyService.java new file mode 100644 index 00000000..bd2ff832 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/HostKeyService.java @@ -0,0 +1,120 @@ +package com.orion.ops.module.asset.service; + +import com.orion.lang.define.wrapper.DataGrid; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * 主机秘钥 服务类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +public interface HostKeyService { + + /** + * 创建主机秘钥 + * + * @param request request + * @return id + */ + Long createHostKey(HostKeyCreateRequest request); + + /** + * 通过 id 更新主机秘钥 + * + * @param request request + * @return effect + */ + Integer updateHostKeyById(HostKeyUpdateRequest request); + + /** + * 更新主机秘钥 + * + * @param query query + * @param update update + * @return effect + */ + Integer updateHostKey(HostKeyQueryRequest query, HostKeyUpdateRequest update); + + /** + * 通过 id 查询主机秘钥 + * + * @param id id + * @return row + */ + HostKeyVO getHostKeyById(Long id); + + /** + * 通过 id 批量查询主机秘钥 + * + * @param idList idList + * @return rows + */ + List getHostKeyByIdList(List idList); + + /** + * 查询主机秘钥 + * + * @param request request + * @return rows + */ + List getHostKeyList(HostKeyQueryRequest request); + + /** + * 查询主机秘钥数量 + * + * @param request request + * @return count + */ + Long getHostKeyCount(HostKeyQueryRequest request); + + /** + * 分页查询主机秘钥 + * + * @param request request + * @return rows + */ + DataGrid getHostKeyPage(HostKeyQueryRequest request); + + /** + * 通过 id 删除主机秘钥 + * + * @param id id + * @return effect + */ + Integer deleteHostKeyById(Long id); + + /** + * 通过 id 批量删除主机秘钥 + * + * @param idList idList + * @return effect + */ + Integer batchDeleteHostKeyByIdList(List idList); + + /** + * 删除主机秘钥 + * + * @param request request + * @return effect + */ + Integer deleteHostKey(HostKeyQueryRequest request); + + /** + * 导出主机秘钥 + * + * @param request request + * @param response response + * @throws IOException IOException + */ + void exportHostKey(HostKeyQueryRequest request, HttpServletResponse response) throws IOException; + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostIdentityServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostIdentityServiceImpl.java new file mode 100644 index 00000000..19e933ae --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostIdentityServiceImpl.java @@ -0,0 +1,212 @@ +package com.orion.ops.module.asset.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orion.lang.define.wrapper.DataGrid; +import com.orion.lang.utils.collect.Lists; +import com.orion.office.excel.writer.exporting.ExcelExport; +import com.orion.ops.framework.common.constant.ErrorMessage; +import com.orion.ops.framework.common.utils.FileNames; +import com.orion.ops.framework.common.constant.ErrorMessage; +import com.orion.ops.framework.common.utils.Valid; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; +import com.orion.ops.module.asset.entity.domain.HostIdentityDO; +import com.orion.ops.module.asset.dao.HostIdentityDAO; +import com.orion.ops.module.asset.service.HostIdentityService; +import com.orion.web.servlet.web.Servlets; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; + +/** + * 主机身份 服务实现类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Slf4j +@Service +public class HostIdentityServiceImpl implements HostIdentityService { + + @Resource + private HostIdentityDAO hostIdentityDAO; + + @Override + public Long createHostIdentity(HostIdentityCreateRequest request) { + log.info("HostIdentityService-createHostIdentity request: {}", JSON.toJSONString(request)); + // 转换 + HostIdentityDO record = HostIdentityConvert.MAPPER.to(request); + // 查询数据是否冲突 + this.checkHostIdentityPresent(record); + // 插入 + int effect = hostIdentityDAO.insert(record); + log.info("HostIdentityService-createHostIdentity effect: {}", effect); + return record.getId(); + } + + @Override + public Integer updateHostIdentityById(HostIdentityUpdateRequest request) { + log.info("HostIdentityService-updateHostIdentityById request: {}", JSON.toJSONString(request)); + // 查询 + Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING); + HostIdentityDO record = hostIdentityDAO.selectById(id); + Valid.notNull(record, ErrorMessage.DATA_ABSENT); + // 转换 + HostIdentityDO updateRecord = HostIdentityConvert.MAPPER.to(request); + // 查询数据是否冲突 + this.checkHostIdentityPresent(updateRecord); + // 更新 + int effect = hostIdentityDAO.updateById(updateRecord); + log.info("HostIdentityService-updateHostIdentityById effect: {}", effect); + return effect; + } + + @Override + public Integer updateHostIdentity(HostIdentityQueryRequest query, HostIdentityUpdateRequest update) { + log.info("HostIdentityService.updateHostIdentity query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update)); + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(query); + // 转换 + HostIdentityDO updateRecord = HostIdentityConvert.MAPPER.to(update); + // 更新 + int effect = hostIdentityDAO.update(updateRecord, wrapper); + log.info("HostIdentityService.updateHostIdentity effect: {}", effect); + return effect; + } + + @Override + public HostIdentityVO getHostIdentityById(Long id) { + // 查询 + HostIdentityDO record = hostIdentityDAO.selectById(id); + Valid.notNull(record, ErrorMessage.DATA_ABSENT); + // 转换 + return HostIdentityConvert.MAPPER.to(record); + } + + @Override + public List getHostIdentityByIdList(List idList) { + // 查询 + List records = hostIdentityDAO.selectBatchIds(idList); + if (records.isEmpty()) { + return Lists.empty(); + } + // 转换 + return HostIdentityConvert.MAPPER.to(records); + } + + @Override + public List getHostIdentityList(HostIdentityQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return hostIdentityDAO.of(wrapper).list(HostIdentityConvert.MAPPER::to); + } + + @Override + public Long getHostIdentityCount(HostIdentityQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return hostIdentityDAO.selectCount(wrapper); + } + + @Override + public DataGrid getHostIdentityPage(HostIdentityQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return hostIdentityDAO.of(wrapper) + .page(request) + .dataGrid(HostIdentityConvert.MAPPER::to); + } + + @Override + public Integer deleteHostIdentityById(Long id) { + log.info("HostIdentityService-deleteHostIdentityById id: {}", id); + int effect = hostIdentityDAO.deleteById(id); + log.info("HostIdentityService-deleteHostIdentityById effect: {}", effect); + return effect; + } + + @Override + public Integer batchDeleteHostIdentityByIdList(List idList) { + log.info("HostIdentityService-batchDeleteHostIdentityByIdList idList: {}", idList); + int effect = hostIdentityDAO.deleteBatchIds(idList); + log.info("HostIdentityService-batchDeleteHostIdentityByIdList effect: {}", effect); + return effect; + } + + @Override + public Integer deleteHostIdentity(HostIdentityQueryRequest request) { + log.info("HostIdentityService.deleteHostIdentity request: {}", JSON.toJSONString(request)); + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 删除 + int effect = hostIdentityDAO.delete(wrapper); + log.info("HostIdentityService.deleteHostIdentity effect: {}", effect); + return effect; + } + + @Override + public void exportHostIdentity(HostIdentityQueryRequest request, HttpServletResponse response) throws IOException { + log.info("HostIdentityService.exportHostIdentity request: {}", JSON.toJSONString(request)); + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + List rows = hostIdentityDAO.of(wrapper).list(HostIdentityConvert.MAPPER::toExport); + log.info("HostIdentityService.exportHostIdentity size: {}", rows.size()); + // 导出 + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ExcelExport.create(HostIdentityExport.class) + .addRows(rows) + .write(out) + .close(); + // 传输 + Servlets.transfer(response, out.toByteArray(), FileNames.exportName(HostIdentityExport.TITLE)); + } + + /** + * 检测对象是否存在 + * + * @param domain domain + */ + private void checkHostIdentityPresent(HostIdentityDO domain) { + // 构造条件 + LambdaQueryWrapper wrapper = hostIdentityDAO.wrapper() + // 更新时忽略当前记录 + .ne(HostIdentityDO::getId, domain.getId()) + // 用其他字段做重复校验 + .eq(HostIdentityDO::getName, domain.getName()) + .eq(HostIdentityDO::getUsername, domain.getUsername()) + .eq(HostIdentityDO::getPassword, domain.getPassword()) + .eq(HostIdentityDO::getKeyId, domain.getKeyId()); + // 检查是否存在 + boolean present = hostIdentityDAO.of(wrapper).present(); + Valid.isFalse(present, ErrorMessage.DATA_PRESENT); + } + + /** + * 构建查询 wrapper + * + * @param request request + * @return wrapper + */ + private LambdaQueryWrapper buildQueryWrapper(HostIdentityQueryRequest request) { + return hostIdentityDAO.wrapper() + .eq(HostIdentityDO::getId, request.getId()) + .eq(HostIdentityDO::getName, request.getName()) + .eq(HostIdentityDO::getUsername, request.getUsername()) + .eq(HostIdentityDO::getPassword, request.getPassword()) + .eq(HostIdentityDO::getKeyId, request.getKeyId()); + } + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java new file mode 100644 index 00000000..4943e8ba --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java @@ -0,0 +1,212 @@ +package com.orion.ops.module.asset.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orion.lang.define.wrapper.DataGrid; +import com.orion.lang.utils.collect.Lists; +import com.orion.office.excel.writer.exporting.ExcelExport; +import com.orion.ops.framework.common.constant.ErrorMessage; +import com.orion.ops.framework.common.utils.FileNames; +import com.orion.ops.framework.common.constant.ErrorMessage; +import com.orion.ops.framework.common.utils.Valid; +import com.orion.ops.module.asset.entity.vo.*; +import com.orion.ops.module.asset.entity.request.host.*; +import com.orion.ops.module.asset.entity.export.*; +import com.orion.ops.module.asset.convert.*; +import com.orion.ops.module.asset.entity.domain.HostKeyDO; +import com.orion.ops.module.asset.dao.HostKeyDAO; +import com.orion.ops.module.asset.service.HostKeyService; +import com.orion.web.servlet.web.Servlets; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; + +/** + * 主机秘钥 服务实现类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-9-20 11:55 + */ +@Slf4j +@Service +public class HostKeyServiceImpl implements HostKeyService { + + @Resource + private HostKeyDAO hostKeyDAO; + + @Override + public Long createHostKey(HostKeyCreateRequest request) { + log.info("HostKeyService-createHostKey request: {}", JSON.toJSONString(request)); + // 转换 + HostKeyDO record = HostKeyConvert.MAPPER.to(request); + // 查询数据是否冲突 + this.checkHostKeyPresent(record); + // 插入 + int effect = hostKeyDAO.insert(record); + log.info("HostKeyService-createHostKey effect: {}", effect); + return record.getId(); + } + + @Override + public Integer updateHostKeyById(HostKeyUpdateRequest request) { + log.info("HostKeyService-updateHostKeyById request: {}", JSON.toJSONString(request)); + // 查询 + Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING); + HostKeyDO record = hostKeyDAO.selectById(id); + Valid.notNull(record, ErrorMessage.DATA_ABSENT); + // 转换 + HostKeyDO updateRecord = HostKeyConvert.MAPPER.to(request); + // 查询数据是否冲突 + this.checkHostKeyPresent(updateRecord); + // 更新 + int effect = hostKeyDAO.updateById(updateRecord); + log.info("HostKeyService-updateHostKeyById effect: {}", effect); + return effect; + } + + @Override + public Integer updateHostKey(HostKeyQueryRequest query, HostKeyUpdateRequest update) { + log.info("HostKeyService.updateHostKey query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update)); + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(query); + // 转换 + HostKeyDO updateRecord = HostKeyConvert.MAPPER.to(update); + // 更新 + int effect = hostKeyDAO.update(updateRecord, wrapper); + log.info("HostKeyService.updateHostKey effect: {}", effect); + return effect; + } + + @Override + public HostKeyVO getHostKeyById(Long id) { + // 查询 + HostKeyDO record = hostKeyDAO.selectById(id); + Valid.notNull(record, ErrorMessage.DATA_ABSENT); + // 转换 + return HostKeyConvert.MAPPER.to(record); + } + + @Override + public List getHostKeyByIdList(List idList) { + // 查询 + List records = hostKeyDAO.selectBatchIds(idList); + if (records.isEmpty()) { + return Lists.empty(); + } + // 转换 + return HostKeyConvert.MAPPER.to(records); + } + + @Override + public List getHostKeyList(HostKeyQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return hostKeyDAO.of(wrapper).list(HostKeyConvert.MAPPER::to); + } + + @Override + public Long getHostKeyCount(HostKeyQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return hostKeyDAO.selectCount(wrapper); + } + + @Override + public DataGrid getHostKeyPage(HostKeyQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return hostKeyDAO.of(wrapper) + .page(request) + .dataGrid(HostKeyConvert.MAPPER::to); + } + + @Override + public Integer deleteHostKeyById(Long id) { + log.info("HostKeyService-deleteHostKeyById id: {}", id); + int effect = hostKeyDAO.deleteById(id); + log.info("HostKeyService-deleteHostKeyById effect: {}", effect); + return effect; + } + + @Override + public Integer batchDeleteHostKeyByIdList(List idList) { + log.info("HostKeyService-batchDeleteHostKeyByIdList idList: {}", idList); + int effect = hostKeyDAO.deleteBatchIds(idList); + log.info("HostKeyService-batchDeleteHostKeyByIdList effect: {}", effect); + return effect; + } + + @Override + public Integer deleteHostKey(HostKeyQueryRequest request) { + log.info("HostKeyService.deleteHostKey request: {}", JSON.toJSONString(request)); + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 删除 + int effect = hostKeyDAO.delete(wrapper); + log.info("HostKeyService.deleteHostKey effect: {}", effect); + return effect; + } + + @Override + public void exportHostKey(HostKeyQueryRequest request, HttpServletResponse response) throws IOException { + log.info("HostKeyService.exportHostKey request: {}", JSON.toJSONString(request)); + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + List rows = hostKeyDAO.of(wrapper).list(HostKeyConvert.MAPPER::toExport); + log.info("HostKeyService.exportHostKey size: {}", rows.size()); + // 导出 + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ExcelExport.create(HostKeyExport.class) + .addRows(rows) + .write(out) + .close(); + // 传输 + Servlets.transfer(response, out.toByteArray(), FileNames.exportName(HostKeyExport.TITLE)); + } + + /** + * 检测对象是否存在 + * + * @param domain domain + */ + private void checkHostKeyPresent(HostKeyDO domain) { + // 构造条件 + LambdaQueryWrapper wrapper = hostKeyDAO.wrapper() + // 更新时忽略当前记录 + .ne(HostKeyDO::getId, domain.getId()) + // 用其他字段做重复校验 + .eq(HostKeyDO::getName, domain.getName()) + .eq(HostKeyDO::getPublicKey, domain.getPublicKey()) + .eq(HostKeyDO::getPrivateKey, domain.getPrivateKey()) + .eq(HostKeyDO::getPassword, domain.getPassword()); + // 检查是否存在 + boolean present = hostKeyDAO.of(wrapper).present(); + Valid.isFalse(present, ErrorMessage.DATA_PRESENT); + } + + /** + * 构建查询 wrapper + * + * @param request request + * @return wrapper + */ + private LambdaQueryWrapper buildQueryWrapper(HostKeyQueryRequest request) { + return hostKeyDAO.wrapper() + .eq(HostKeyDO::getId, request.getId()) + .eq(HostKeyDO::getName, request.getName()) + .eq(HostKeyDO::getPublicKey, request.getPublicKey()) + .eq(HostKeyDO::getPrivateKey, request.getPrivateKey()) + .eq(HostKeyDO::getPassword, request.getPassword()); + } + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostIdentityMapper.xml b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostIdentityMapper.xml new file mode 100644 index 00000000..4074854b --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostIdentityMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + id, name, username, password, key_id, create_time, update_time, creator, updater, deleted + + + diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostKeyMapper.xml b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostKeyMapper.xml new file mode 100644 index 00000000..83b6d4ba --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/HostKeyMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + id, name, public_key, private_key, password, create_time, update_time, creator, updater, deleted + + + diff --git a/orion-ops-ui/src/api/asset/host-identity.ts b/orion-ops-ui/src/api/asset/host-identity.ts new file mode 100644 index 00000000..a730b47f --- /dev/null +++ b/orion-ops-ui/src/api/asset/host-identity.ts @@ -0,0 +1,119 @@ +import axios from 'axios'; +import qs from 'query-string'; +import { DataGrid, Pagination } from '@/types/global'; + +/** + * 主机身份创建请求 + */ +export interface HostIdentityCreateRequest { + name?: string; + username?: string; + password?: string; + keyId?: number; +} + +/** + * 主机身份更新请求 + */ +export interface HostIdentityUpdateRequest extends HostIdentityCreateRequest { + id: number; +} + +/** + * 主机身份查询请求 + */ +export interface HostIdentityQueryRequest extends Pagination { + id?: number; + name?: string; + username?: string; + password?: string; + keyId?: number; +} + +/** + * 主机身份查询响应 + */ +export interface HostIdentityQueryResponse { + id?: number; + name?: string; + username?: string; + password?: string; + keyId?: number; + createTime: number; + updateTime: number; + creator: string; + updater: string; +} + +/** + * 创建主机身份 + */ +export function createHostIdentity(request: HostIdentityCreateRequest) { + return axios.post('/asset/host-identity/create', request); +} + +/** + * 通过 id 更新主机身份 + */ +export function updateHostIdentity(request: HostIdentityUpdateRequest) { + return axios.put('/asset/host-identity/update', request); +} + +/** + * 通过 id 查询主机身份 + */ +export function getHostIdentity(id: number) { + return axios.get('/asset/host-identity/get', { params: { id } }); +} + +/** + * 通过 id 批量查询主机身份 + */ +export function getHostIdentityList(idList: Array) { + return axios.get('/asset/host-identity/list', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + +/** + * 查询主机身份 + */ +export function getHostIdentityListAll(request: HostIdentityQueryRequest) { + return axios.post>('/asset/host-identity/list-all', request); +} + +/** + * 分页查询主机身份 + */ +export function getHostIdentityPage(request: HostIdentityQueryRequest) { + return axios.post>('/asset/host-identity/query', request); +} + +/** + * 通过 id 删除主机身份 + */ +export function deleteHostIdentity(id: number) { + return axios.delete('/asset/host-identity/delete', { params: { id } }); +} + +/** + * 通过 id 批量删除主机身份 + */ +export function batchDeleteHostIdentity(idList: Array) { + return axios.delete('/asset/host-identity/delete-batch', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + +/** + * 导出主机身份 + */ +export function exportHostIdentity(request: HostIdentityQueryRequest) { + return axios.post('/asset/host-identity/export', request); +} diff --git a/orion-ops-ui/src/api/asset/host-key.ts b/orion-ops-ui/src/api/asset/host-key.ts new file mode 100644 index 00000000..99fd26d3 --- /dev/null +++ b/orion-ops-ui/src/api/asset/host-key.ts @@ -0,0 +1,119 @@ +import axios from 'axios'; +import qs from 'query-string'; +import { DataGrid, Pagination } from '@/types/global'; + +/** + * 主机秘钥创建请求 + */ +export interface HostKeyCreateRequest { + name?: string; + publicKey?: string; + privateKey?: string; + password?: string; +} + +/** + * 主机秘钥更新请求 + */ +export interface HostKeyUpdateRequest extends HostKeyCreateRequest { + id: number; +} + +/** + * 主机秘钥查询请求 + */ +export interface HostKeyQueryRequest extends Pagination { + id?: number; + name?: string; + publicKey?: string; + privateKey?: string; + password?: string; +} + +/** + * 主机秘钥查询响应 + */ +export interface HostKeyQueryResponse { + id?: number; + name?: string; + publicKey?: string; + privateKey?: string; + password?: string; + createTime: number; + updateTime: number; + creator: string; + updater: string; +} + +/** + * 创建主机秘钥 + */ +export function createHostKey(request: HostKeyCreateRequest) { + return axios.post('/asset/host-key/create', request); +} + +/** + * 通过 id 更新主机秘钥 + */ +export function updateHostKey(request: HostKeyUpdateRequest) { + return axios.put('/asset/host-key/update', request); +} + +/** + * 通过 id 查询主机秘钥 + */ +export function getHostKey(id: number) { + return axios.get('/asset/host-key/get', { params: { id } }); +} + +/** + * 通过 id 批量查询主机秘钥 + */ +export function getHostKeyList(idList: Array) { + return axios.get('/asset/host-key/list', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + +/** + * 查询主机秘钥 + */ +export function getHostKeyListAll(request: HostKeyQueryRequest) { + return axios.post>('/asset/host-key/list-all', request); +} + +/** + * 分页查询主机秘钥 + */ +export function getHostKeyPage(request: HostKeyQueryRequest) { + return axios.post>('/asset/host-key/query', request); +} + +/** + * 通过 id 删除主机秘钥 + */ +export function deleteHostKey(id: number) { + return axios.delete('/asset/host-key/delete', { params: { id } }); +} + +/** + * 通过 id 批量删除主机秘钥 + */ +export function batchDeleteHostKey(idList: Array) { + return axios.delete('/asset/host-key/delete-batch', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + +/** + * 导出主机秘钥 + */ +export function exportHostKey(request: HostKeyQueryRequest) { + return axios.post('/asset/host-key/export', request); +} diff --git a/orion-ops-ui/src/router/routes/modules/asset.ts b/orion-ops-ui/src/router/routes/modules/asset.ts index 3e69df54..d40e9ddb 100644 --- a/orion-ops-ui/src/router/routes/modules/asset.ts +++ b/orion-ops-ui/src/router/routes/modules/asset.ts @@ -10,6 +10,14 @@ const ASSET: AppRouteRecordRaw = { name: 'assetHost', path: '/asset/host', component: () => import('@/views/asset/host/index.vue'), + }, { + name: 'assetHostKey', + path: '/asset/host-key', + component: () => import('@/views/asset/host-key/index.vue'), + }, { + name: 'assetHostIdentity', + path: '/asset/host-identity', + component: () => import('@/views/asset/host-identity/index.vue'), }, ], }; diff --git a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue new file mode 100644 index 00000000..a55b05be --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue @@ -0,0 +1,151 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue new file mode 100644 index 00000000..dd7d5d18 --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue @@ -0,0 +1,209 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/asset/host-identity/index.vue b/orion-ops-ui/src/views/asset/host-identity/index.vue new file mode 100644 index 00000000..e6ab3a6c --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-identity/index.vue @@ -0,0 +1,32 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/asset/host-identity/types/const.ts b/orion-ops-ui/src/views/asset/host-identity/types/const.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/asset/host-identity/types/enum.types.ts b/orion-ops-ui/src/views/asset/host-identity/types/enum.types.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/asset/host-identity/types/form.rules.ts b/orion-ops-ui/src/views/asset/host-identity/types/form.rules.ts new file mode 100644 index 00000000..ab0ba328 --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-identity/types/form.rules.ts @@ -0,0 +1,37 @@ +import { FieldRule } from '@arco-design/web-vue'; + +export const name = [{ + required: true, + message: '请输入名称' +}, { + maxLength: 64, + message: '名称长度不能大于64位' +}] as FieldRule[]; + +export const username = [{ + required: true, + message: '请输入用户名' +}, { + maxLength: 128, + message: '用户名长度不能大于128位' +}] as FieldRule[]; + +export const password = [{ + required: true, + message: '请输入用户密码' +}, { + maxLength: 512, + message: '用户密码长度不能大于512位' +}] as FieldRule[]; + +export const keyId = [{ + required: true, + message: '请输入秘钥id' +}] as FieldRule[]; + +export default { + name, + username, + password, + keyId, +} as Record; diff --git a/orion-ops-ui/src/views/asset/host-identity/types/table.columns.ts b/orion-ops-ui/src/views/asset/host-identity/types/table.columns.ts new file mode 100644 index 00000000..f7179c1f --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-identity/types/table.columns.ts @@ -0,0 +1,73 @@ +import { TableColumnData } from '@arco-design/web-vue/es/table/interface'; +import { dateFormat } from '@/utils'; + +const columns = [ + { + title: 'id', + dataIndex: 'id', + slotName: 'id', + width: 70, + align: 'left', + fixed: 'left', + }, { + title: '名称', + dataIndex: 'name', + slotName: 'name', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '用户名', + dataIndex: 'username', + slotName: 'username', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '用户密码', + dataIndex: 'password', + slotName: 'password', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '秘钥id', + dataIndex: 'keyId', + slotName: 'keyId', + align: 'center', + }, { + title: '创建时间', + dataIndex: 'createTime', + slotName: 'createTime', + align: 'center', + width: 180, + render: ({ record }) => { + return dateFormat(new Date(record.createTime)); + }, + }, { + title: '修改时间', + dataIndex: 'updateTime', + slotName: 'updateTime', + align: 'center', + width: 180, + render: ({ record }) => { + return dateFormat(new Date(record.updateTime)); + }, + }, { + title: '创建人', + dataIndex: 'creator', + slotName: 'creator', + }, { + title: '修改人', + dataIndex: 'updater', + slotName: 'updater', + }, { + title: '操作', + slotName: 'handle', + width: 130, + align: 'center', + fixed: 'right', + }, +] as TableColumnData[]; + +export default columns; diff --git a/orion-ops-ui/src/views/asset/host-key/components/host-key-form-modal.vue b/orion-ops-ui/src/views/asset/host-key/components/host-key-form-modal.vue new file mode 100644 index 00000000..05388df9 --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-key/components/host-key-form-modal.vue @@ -0,0 +1,151 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue b/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue new file mode 100644 index 00000000..d6343fef --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue @@ -0,0 +1,209 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/asset/host-key/index.vue b/orion-ops-ui/src/views/asset/host-key/index.vue new file mode 100644 index 00000000..fc2568ad --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-key/index.vue @@ -0,0 +1,32 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/asset/host-key/types/const.ts b/orion-ops-ui/src/views/asset/host-key/types/const.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/asset/host-key/types/enum.types.ts b/orion-ops-ui/src/views/asset/host-key/types/enum.types.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/asset/host-key/types/form.rules.ts b/orion-ops-ui/src/views/asset/host-key/types/form.rules.ts new file mode 100644 index 00000000..33be6aac --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-key/types/form.rules.ts @@ -0,0 +1,40 @@ +import { FieldRule } from '@arco-design/web-vue'; + +export const name = [{ + required: true, + message: '请输入名称' +}, { + maxLength: 64, + message: '名称长度不能大于64位' +}] as FieldRule[]; + +export const publicKey = [{ + required: true, + message: '请输入公钥文本' +}, { + maxLength: 65535, + message: '公钥文本长度不能大于65535位' +}] as FieldRule[]; + +export const privateKey = [{ + required: true, + message: '请输入私钥文本' +}, { + maxLength: 65535, + message: '私钥文本长度不能大于65535位' +}] as FieldRule[]; + +export const password = [{ + required: true, + message: '请输入密码' +}, { + maxLength: 512, + message: '密码长度不能大于512位' +}] as FieldRule[]; + +export default { + name, + publicKey, + privateKey, + password, +} as Record; diff --git a/orion-ops-ui/src/views/asset/host-key/types/table.columns.ts b/orion-ops-ui/src/views/asset/host-key/types/table.columns.ts new file mode 100644 index 00000000..cfff3357 --- /dev/null +++ b/orion-ops-ui/src/views/asset/host-key/types/table.columns.ts @@ -0,0 +1,75 @@ +import { TableColumnData } from '@arco-design/web-vue/es/table/interface'; +import { dateFormat } from '@/utils'; + +const columns = [ + { + title: 'id', + dataIndex: 'id', + slotName: 'id', + width: 70, + align: 'left', + fixed: 'left', + }, { + title: '名称', + dataIndex: 'name', + slotName: 'name', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '公钥文本', + dataIndex: 'publicKey', + slotName: 'publicKey', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '私钥文本', + dataIndex: 'privateKey', + slotName: 'privateKey', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '密码', + dataIndex: 'password', + slotName: 'password', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '创建时间', + dataIndex: 'createTime', + slotName: 'createTime', + align: 'center', + width: 180, + render: ({ record }) => { + return dateFormat(new Date(record.createTime)); + }, + }, { + title: '修改时间', + dataIndex: 'updateTime', + slotName: 'updateTime', + align: 'center', + width: 180, + render: ({ record }) => { + return dateFormat(new Date(record.updateTime)); + }, + }, { + title: '创建人', + dataIndex: 'creator', + slotName: 'creator', + }, { + title: '修改人', + dataIndex: 'updater', + slotName: 'updater', + }, { + title: '操作', + slotName: 'handle', + width: 130, + align: 'center', + fixed: 'right', + }, +] as TableColumnData[]; + +export default columns;