review: 重构代码.
This commit is contained in:
@@ -20,6 +20,8 @@ import java.util.Date;
|
|||||||
@Data
|
@Data
|
||||||
public class BaseDO implements Serializable {
|
public class BaseDO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.math.*;
|
|||||||
@Schema(name = "${type}Export", description = "$!{table.comment}导出对象")
|
@Schema(name = "${type}Export", description = "$!{table.comment}导出对象")
|
||||||
public class ${type}Export implements Serializable {
|
public class ${type}Export implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final String TITLE = "$!{table.comment}导出";
|
public static final String TITLE = "$!{table.comment}导出";
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import java.math.*;
|
|||||||
@Schema(name = "${type}CreateRequest", description = "$!{table.comment} 创建请求对象")
|
@Schema(name = "${type}CreateRequest", description = "$!{table.comment} 创建请求对象")
|
||||||
public class ${type}CreateRequest implements Serializable {
|
public class ${type}CreateRequest implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
#if("$!field.propertyName" != "id")
|
#if("$!field.propertyName" != "id")
|
||||||
#if("$field.propertyType" == "String")
|
#if("$field.propertyType" == "String")
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.math.*;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Schema(name = "${type}UpdateRequest", description = "$!{table.comment} 更新请求对象")
|
@Schema(name = "${type}UpdateRequest", description = "$!{table.comment} 更新请求对象")
|
||||||
public class ${type}UpdateRequest implements Serializable {
|
public class ${type}UpdateRequest implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$field.propertyType" == "String")
|
#if("$field.propertyType" == "String")
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.math.*;
|
|||||||
@Schema(name = "${type}CreateDTO", description = "$!{table.comment} 创建请求业务对象")
|
@Schema(name = "${type}CreateDTO", description = "$!{table.comment} 创建请求业务对象")
|
||||||
public class ${type}CreateDTO implements Serializable {
|
public class ${type}CreateDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
#if("$!field.propertyName" != "id")
|
#if("$!field.propertyName" != "id")
|
||||||
#if("$field.propertyType" == "String")
|
#if("$field.propertyType" == "String")
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import java.math.*;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Schema(name = "${type}QueryDTO", description = "$!{table.comment} 查询请求业务对象")
|
@Schema(name = "${type}QueryDTO", description = "$!{table.comment} 查询请求业务对象")
|
||||||
public class ${type}QueryDTO implements Serializable {
|
public class ${type}QueryDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$field.propertyType" == "String" && "$field.metaInfo.jdbcType" != "LONGVARCHAR")
|
#if("$field.propertyType" == "String" && "$field.metaInfo.jdbcType" != "LONGVARCHAR")
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import java.math.*;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Schema(name = "${type}UpdateDTO", description = "$!{table.comment} 更新请求业务对象")
|
@Schema(name = "${type}UpdateDTO", description = "$!{table.comment} 更新请求业务对象")
|
||||||
public class ${type}UpdateDTO implements Serializable {
|
public class ${type}UpdateDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$field.propertyType" == "String")
|
#if("$field.propertyType" == "String")
|
||||||
|
|||||||
@@ -29,17 +29,9 @@ Authorization: {{token}}
|
|||||||
|
|
||||||
|
|
||||||
### 查询主机
|
### 查询主机
|
||||||
POST {{baseUrl}}/asset/host/list-all
|
GET {{baseUrl}}/asset/host/list
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: {{token}}
|
Authorization: {{token}}
|
||||||
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"name": "",
|
|
||||||
"code": "",
|
|
||||||
"address": ""
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### 分页查询主机
|
### 分页查询主机
|
||||||
POST {{baseUrl}}/asset/host/query
|
POST {{baseUrl}}/asset/host/query
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public class HostController {
|
|||||||
@Resource
|
@Resource
|
||||||
private HostConfigService hostConfigService;
|
private HostConfigService hostConfigService;
|
||||||
|
|
||||||
|
// fixme host_config 设置为缓存
|
||||||
|
|
||||||
@OperatorLog(HostOperatorType.CREATE)
|
@OperatorLog(HostOperatorType.CREATE)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建主机")
|
@Operation(summary = "创建主机")
|
||||||
@@ -79,11 +81,11 @@ public class HostController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@PostMapping("/list-all")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "查询主机")
|
@Operation(summary = "查询主机")
|
||||||
@PreAuthorize("@ss.hasPermission('asset:host:query')")
|
@PreAuthorize("@ss.hasPermission('asset:host:query')")
|
||||||
public List<HostVO> getHostListAll(@Validated @RequestBody HostQueryRequest request) {
|
public List<HostVO> getHostList() {
|
||||||
return hostService.getHostList(request);
|
return hostService.getHostListByCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
// 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<HostVO> getHostList() {
|
||||||
|
// return hostService.getHostListByCache();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @IgnoreLog(IgnoreLogMode.RET)
|
||||||
|
// @PostMapping("/query")
|
||||||
|
// @Operation(summary = "分页查询主机")
|
||||||
|
// @PreAuthorize("@ss.hasPermission('asset:host:query')")
|
||||||
|
// public DataGrid<HostVO> 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<HostConfigVO> 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);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
@@ -62,7 +62,7 @@ public class HostKeyController {
|
|||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "查询主机秘钥详情")
|
@Operation(summary = "查询主机秘钥详情")
|
||||||
@Parameter(name = "id", description = "id", required = true)
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
@PreAuthorize("@ss.hasAnyPermission('asset:host-key:detail', 'asset:host-key:update')")
|
@PreAuthorize("@ss.hasAnyPermission('asset:host-key:query-detail', 'asset:host-key:update')")
|
||||||
public HostKeyVO getHostKey(@RequestParam("id") Long id) {
|
public HostKeyVO getHostKey(@RequestParam("id") Long id) {
|
||||||
return hostKeyService.getHostKeyById(id);
|
return hostKeyService.getHostKeyById(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.orion.ops.module.asset.convert;
|
package com.orion.ops.module.asset.convert;
|
||||||
|
|
||||||
import com.orion.ops.module.asset.entity.domain.HostDO;
|
import com.orion.ops.module.asset.entity.domain.HostDO;
|
||||||
|
import com.orion.ops.module.asset.entity.dto.HostCacheDTO;
|
||||||
import com.orion.ops.module.asset.entity.request.host.HostCreateRequest;
|
import com.orion.ops.module.asset.entity.request.host.HostCreateRequest;
|
||||||
import com.orion.ops.module.asset.entity.request.host.HostQueryRequest;
|
import com.orion.ops.module.asset.entity.request.host.HostQueryRequest;
|
||||||
import com.orion.ops.module.asset.entity.request.host.HostUpdateRequest;
|
import com.orion.ops.module.asset.entity.request.host.HostUpdateRequest;
|
||||||
@@ -8,8 +9,6 @@ import com.orion.ops.module.asset.entity.vo.HostVO;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主机 内部对象转换器
|
* 主机 内部对象转换器
|
||||||
*
|
*
|
||||||
@@ -30,6 +29,8 @@ public interface HostConvert {
|
|||||||
|
|
||||||
HostVO to(HostDO domain);
|
HostVO to(HostDO domain);
|
||||||
|
|
||||||
List<HostVO> to(List<HostDO> list);
|
HostVO to(HostCacheDTO cache);
|
||||||
|
|
||||||
|
HostCacheDTO toCache(HostDO domain);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.orion.ops.module.asset.define.cache;
|
|||||||
|
|
||||||
import com.orion.lang.define.cache.CacheKeyBuilder;
|
import com.orion.lang.define.cache.CacheKeyBuilder;
|
||||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||||
|
import com.orion.ops.module.asset.entity.dto.HostCacheDTO;
|
||||||
import com.orion.ops.module.asset.entity.dto.HostIdentityCacheDTO;
|
import com.orion.ops.module.asset.entity.dto.HostIdentityCacheDTO;
|
||||||
import com.orion.ops.module.asset.entity.dto.HostKeyCacheDTO;
|
import com.orion.ops.module.asset.entity.dto.HostKeyCacheDTO;
|
||||||
|
|
||||||
@@ -16,18 +17,25 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public interface HostCacheKeyDefine {
|
public interface HostCacheKeyDefine {
|
||||||
|
|
||||||
|
CacheKeyDefine HOST_INFO = new CacheKeyBuilder()
|
||||||
|
.key("host:info:list")
|
||||||
|
.desc("主机列表")
|
||||||
|
.type(HostCacheDTO.class)
|
||||||
|
.timeout(1, TimeUnit.DAYS)
|
||||||
|
.build();
|
||||||
|
|
||||||
CacheKeyDefine HOST_KEY = new CacheKeyBuilder()
|
CacheKeyDefine HOST_KEY = new CacheKeyBuilder()
|
||||||
.key("host:key:list")
|
.key("host:key:list")
|
||||||
.desc("主机秘钥列表")
|
.desc("主机秘钥列表")
|
||||||
.type(HostKeyCacheDTO.class)
|
.type(HostKeyCacheDTO.class)
|
||||||
.timeout(1, TimeUnit.HOURS)
|
.timeout(1, TimeUnit.DAYS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
CacheKeyDefine HOST_IDENTITY = new CacheKeyBuilder()
|
CacheKeyDefine HOST_IDENTITY = new CacheKeyBuilder()
|
||||||
.key("host:identity:list")
|
.key("host:identity:list")
|
||||||
.desc("主机身份列表")
|
.desc("主机身份列表")
|
||||||
.type(HostIdentityCacheDTO.class)
|
.type(HostIdentityCacheDTO.class)
|
||||||
.timeout(1, TimeUnit.HOURS)
|
.timeout(1, TimeUnit.DAYS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.orion.ops.module.asset.entity.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主机 缓存对象
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023-9-11 14:16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Schema(name = "HostCacheDTO", description = "主机 缓存对象")
|
||||||
|
public class HostCacheDTO implements Serializable {
|
||||||
|
|
||||||
|
@Schema(description = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "主机名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "主机编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "主机地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -44,10 +44,9 @@ public interface HostService {
|
|||||||
/**
|
/**
|
||||||
* 查询主机
|
* 查询主机
|
||||||
*
|
*
|
||||||
* @param request request
|
|
||||||
* @return rows
|
* @return rows
|
||||||
*/
|
*/
|
||||||
List<HostVO> getHostList(HostQueryRequest request);
|
List<HostVO> getHostListByCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询主机
|
* 分页查询主机
|
||||||
|
|||||||
@@ -7,15 +7,19 @@ import com.orion.lang.utils.Booleans;
|
|||||||
import com.orion.lang.utils.Strings;
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.lang.utils.collect.Lists;
|
import com.orion.lang.utils.collect.Lists;
|
||||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||||
|
import com.orion.ops.framework.common.constant.Const;
|
||||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.ops.framework.common.utils.Valid;
|
import com.orion.ops.framework.common.utils.Valid;
|
||||||
|
import com.orion.ops.framework.redis.core.utils.RedisMaps;
|
||||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||||
import com.orion.ops.module.asset.convert.HostConfigConvert;
|
import com.orion.ops.module.asset.convert.HostConfigConvert;
|
||||||
import com.orion.ops.module.asset.convert.HostConvert;
|
import com.orion.ops.module.asset.convert.HostConvert;
|
||||||
import com.orion.ops.module.asset.dao.HostConfigDAO;
|
import com.orion.ops.module.asset.dao.HostConfigDAO;
|
||||||
import com.orion.ops.module.asset.dao.HostDAO;
|
import com.orion.ops.module.asset.dao.HostDAO;
|
||||||
|
import com.orion.ops.module.asset.define.cache.HostCacheKeyDefine;
|
||||||
import com.orion.ops.module.asset.entity.domain.HostConfigDO;
|
import com.orion.ops.module.asset.entity.domain.HostConfigDO;
|
||||||
import com.orion.ops.module.asset.entity.domain.HostDO;
|
import com.orion.ops.module.asset.entity.domain.HostDO;
|
||||||
|
import com.orion.ops.module.asset.entity.dto.HostCacheDTO;
|
||||||
import com.orion.ops.module.asset.entity.request.host.HostCreateRequest;
|
import com.orion.ops.module.asset.entity.request.host.HostCreateRequest;
|
||||||
import com.orion.ops.module.asset.entity.request.host.HostQueryRequest;
|
import com.orion.ops.module.asset.entity.request.host.HostQueryRequest;
|
||||||
import com.orion.ops.module.asset.entity.request.host.HostUpdateRequest;
|
import com.orion.ops.module.asset.entity.request.host.HostUpdateRequest;
|
||||||
@@ -51,6 +55,8 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
public class HostServiceImpl implements HostService {
|
public class HostServiceImpl implements HostService {
|
||||||
|
|
||||||
|
// FIXME 这里的收藏删除
|
||||||
|
|
||||||
private static final ThreadLocal<List<Long>> FAVORITE_HOLDER = new ThreadLocal<>();
|
private static final ThreadLocal<List<Long>> FAVORITE_HOLDER = new ThreadLocal<>();
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -87,6 +93,8 @@ public class HostServiceImpl implements HostService {
|
|||||||
}
|
}
|
||||||
// 创建配置
|
// 创建配置
|
||||||
hostConfigService.initHostConfig(id);
|
hostConfigService.initHostConfig(id);
|
||||||
|
// 删除缓存
|
||||||
|
RedisMaps.delete(HostCacheKeyDefine.HOST_INFO);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +113,8 @@ public class HostServiceImpl implements HostService {
|
|||||||
// 更新
|
// 更新
|
||||||
int effect = hostDAO.updateById(updateRecord);
|
int effect = hostDAO.updateById(updateRecord);
|
||||||
log.info("HostService-updateHostById effect: {}", effect);
|
log.info("HostService-updateHostById effect: {}", effect);
|
||||||
|
// 删除缓存
|
||||||
|
RedisMaps.delete(HostCacheKeyDefine.HOST_INFO);
|
||||||
// 更新 tag
|
// 更新 tag
|
||||||
tagRelApi.setTagRel(TagTypeEnum.HOST, id, request.getTags());
|
tagRelApi.setTagRel(TagTypeEnum.HOST, id, request.getTags());
|
||||||
return effect;
|
return effect;
|
||||||
@@ -123,21 +133,27 @@ public class HostServiceImpl implements HostService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> getHostList(HostQueryRequest request) {
|
public List<HostVO> getHostListByCache() {
|
||||||
try {
|
// 查询缓存
|
||||||
// 条件
|
List<HostCacheDTO> list = RedisMaps.valuesJson(HostCacheKeyDefine.HOST_INFO);
|
||||||
LambdaQueryWrapper<HostDO> wrapper = this.buildQueryWrapper(request);
|
if (list.isEmpty()) {
|
||||||
if (wrapper == null) {
|
// 查询数据库
|
||||||
return Lists.empty();
|
list = hostDAO.of().list(HostConvert.MAPPER::toCache);
|
||||||
|
// 添加默认值 防止穿透
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
list.add(HostCacheDTO.builder()
|
||||||
|
.id(Const.NONE_ID)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
// 查询
|
// 设置缓存
|
||||||
List<HostVO> hosts = hostDAO.of(wrapper).list(HostConvert.MAPPER::to);
|
RedisMaps.putAllJson(HostCacheKeyDefine.HOST_INFO.getKey(), s -> s.getId().toString(), list);
|
||||||
// 查询拓展信息
|
RedisMaps.setExpire(HostCacheKeyDefine.HOST_INFO);
|
||||||
this.setExtraInfo(request, hosts);
|
|
||||||
return hosts;
|
|
||||||
} finally {
|
|
||||||
FAVORITE_HOLDER.remove();
|
|
||||||
}
|
}
|
||||||
|
// 删除默认值
|
||||||
|
return list.stream()
|
||||||
|
.filter(s -> !s.getId().equals(Const.NONE_ID))
|
||||||
|
.map(HostConvert.MAPPER::to)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -171,6 +187,8 @@ public class HostServiceImpl implements HostService {
|
|||||||
// 删除
|
// 删除
|
||||||
int effect = hostDAO.deleteById(id);
|
int effect = hostDAO.deleteById(id);
|
||||||
log.info("HostService-deleteHostById effect: {}", effect);
|
log.info("HostService-deleteHostById effect: {}", effect);
|
||||||
|
// 删除缓存
|
||||||
|
RedisMaps.delete(HostCacheKeyDefine.HOST_INFO, id);
|
||||||
// 删除配置
|
// 删除配置
|
||||||
hostConfigDAO.deleteByHostId(id);
|
hostConfigDAO.deleteByHostId(id);
|
||||||
// 删除 tag 引用
|
// 删除 tag 引用
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class TagController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "查询标签")
|
@Operation(summary = "查询标签")
|
||||||
@Parameter(name = "type", description = "type", required = true)
|
@Parameter(name = "type", description = "type", required = true)
|
||||||
public List<TagVO> getTagListAll(@RequestParam("type") String type) {
|
public List<TagVO> getTagList(@RequestParam("type") String type) {
|
||||||
return tagService.getTagList(type);
|
return tagService.getTagList(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class DictKeyServiceImpl implements DictKeyService {
|
|||||||
Long id = record.getId();
|
Long id = record.getId();
|
||||||
log.info("DictKeyService-createDictKey id: {}, effect: {}", id, effect);
|
log.info("DictKeyService-createDictKey id: {}, effect: {}", id, effect);
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
RedisMaps.delete(DictCacheKeyDefine.DICT_KEY);
|
RedisUtils.delete(DictCacheKeyDefine.DICT_KEY);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,8 +191,8 @@ public class DictKeyServiceImpl implements DictKeyService {
|
|||||||
// 删除配置值
|
// 删除配置值
|
||||||
dictValueService.deleteDictValueByKeyId(id);
|
dictValueService.deleteDictValueByKeyId(id);
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
RedisUtils.delete(DictCacheKeyDefine.DICT_KEY.getKey(),
|
RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, id);
|
||||||
DictCacheKeyDefine.DICT_SCHEMA.format(record.getKeyName()));
|
RedisUtils.delete(DictCacheKeyDefine.DICT_SCHEMA.format(record.getKeyName()));
|
||||||
log.info("DictKeyService-deleteDictKeyById id: {}, effect: {}", id, effect);
|
log.info("DictKeyService-deleteDictKeyById id: {}, effect: {}", id, effect);
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,7 @@ public class DictKeyServiceImpl implements DictKeyService {
|
|||||||
dictValueService.deleteDictValueByKeyIdList(idList);
|
dictValueService.deleteDictValueByKeyIdList(idList);
|
||||||
log.info("DictKeyService-deleteDictKeyByIdList effect: {}", effect);
|
log.info("DictKeyService-deleteDictKeyByIdList effect: {}", effect);
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
RedisMaps.delete(DictCacheKeyDefine.DICT_KEY);
|
RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, idList);
|
||||||
List<String> schemaKeys = dictKeys.stream()
|
List<String> schemaKeys = dictKeys.stream()
|
||||||
.map(DictKeyDO::getKeyName)
|
.map(DictKeyDO::getKeyName)
|
||||||
.map(DictCacheKeyDefine.DICT_SCHEMA::format)
|
.map(DictCacheKeyDefine.DICT_SCHEMA::format)
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ export function getHost(params: HostQueryRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询主机
|
* 查询全部主机
|
||||||
*/
|
*/
|
||||||
export function getHostListAll(request: HostQueryRequest) {
|
export function getHostList() {
|
||||||
return axios.post<Array<HostQueryResponse>>('/asset/host/list-all', request);
|
return axios.get<Array<HostQueryResponse>>('/asset/host/list');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,13 +57,13 @@
|
|||||||
|
|
||||||
const cacheStore = useCacheStore();
|
const cacheStore = useCacheStore();
|
||||||
|
|
||||||
const isFirst = ref(false);
|
const unTriggerChange = ref(false);
|
||||||
const menuData = ref<Array<MenuQueryResponse>>([]);
|
const menuData = ref<Array<MenuQueryResponse>>([]);
|
||||||
const checkedKeys = ref<Array<number>>([]);
|
const checkedKeys = ref<Array<number>>([]);
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
const init = (keys: Array<number>) => {
|
const init = (keys: Array<number>) => {
|
||||||
isFirst.value = true;
|
unTriggerChange.value = true;
|
||||||
checkedKeys.value = keys;
|
checkedKeys.value = keys;
|
||||||
if (!menuData.value.length) {
|
if (!menuData.value.length) {
|
||||||
menuData.value = [...cacheStore.menus];
|
menuData.value = [...cacheStore.menus];
|
||||||
@@ -75,12 +75,44 @@
|
|||||||
return checkedKeys.value;
|
return checkedKeys.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
defineExpose({ init, getValue });
|
// 选择
|
||||||
|
const checked = (rule: undefined | ((s: string) => boolean)) => {
|
||||||
|
unTriggerChange.value = true;
|
||||||
|
const nodes: Array<MenuQueryResponse> = [];
|
||||||
|
flatNodes(menuData.value, nodes);
|
||||||
|
if (rule) {
|
||||||
|
const checkedNodes = nodes.filter(s => s.permission)
|
||||||
|
.filter(s => rule(s?.permission))
|
||||||
|
.map(s => s.id)
|
||||||
|
.filter(Boolean);
|
||||||
|
checkedKeys.value = [...new Set([...checkedKeys.value, ...checkedNodes])];
|
||||||
|
} else {
|
||||||
|
checkedKeys.value = nodes.map(s => s.id).filter(Boolean);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 取消选择
|
||||||
|
const unchecked = (rule: undefined | ((s: string) => boolean)) => {
|
||||||
|
unTriggerChange.value = true;
|
||||||
|
const nodes: Array<MenuQueryResponse> = [];
|
||||||
|
flatNodes(menuData.value, nodes);
|
||||||
|
if (rule) {
|
||||||
|
const uncheckedNodes = nodes.filter(s => s.permission)
|
||||||
|
.filter(s => rule(s?.permission))
|
||||||
|
.map(s => s.id)
|
||||||
|
.filter(Boolean);
|
||||||
|
checkedKeys.value = [...checkedKeys.value].filter(s => !uncheckedNodes.includes(s));
|
||||||
|
} else {
|
||||||
|
checkedKeys.value = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({ init, getValue, checked, unchecked });
|
||||||
|
|
||||||
// 监听级联变化
|
// 监听级联变化
|
||||||
watch(checkedKeys, (after: Array<number>, before: Array<number>) => {
|
watch(checkedKeys, (after: Array<number>, before: Array<number>) => {
|
||||||
if (isFirst.value) {
|
if (unTriggerChange.value) {
|
||||||
isFirst.value = false;
|
unTriggerChange.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const afterLength = after.length;
|
const afterLength = after.length;
|
||||||
@@ -136,18 +168,31 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 展开节点
|
||||||
|
const flatNodes = (nodes: Array<MenuQueryResponse>, result: Array<MenuQueryResponse>) => {
|
||||||
|
if (!nodes || !nodes.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodes.forEach(s => {
|
||||||
|
result.push(s);
|
||||||
|
flatNodes(s.children, result);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 级联选择菜单
|
// 级联选择菜单
|
||||||
const checkMenu = (id: number) => {
|
const checkMenu = (id: number) => {
|
||||||
|
unTriggerChange.value = true;
|
||||||
// 查询当前节点
|
// 查询当前节点
|
||||||
const node = findNode(id, menuData.value);
|
const node = findNode(id, menuData.value);
|
||||||
const childrenId: number[] = [];
|
const childrenId: number[] = [];
|
||||||
// 获取所在子节点id
|
// 获取所在子节点id
|
||||||
flatChildrenId(node?.children, childrenId);
|
flatChildrenId(node?.children, childrenId);
|
||||||
checkedKeys.value.push(...childrenId);
|
checkedKeys.value = [...new Set([...checkedKeys.value, ...childrenId])];
|
||||||
};
|
};
|
||||||
|
|
||||||
// 级联取消选择菜单
|
// 级联取消选择菜单
|
||||||
const uncheckMenu = (id: number) => {
|
const uncheckMenu = (id: number) => {
|
||||||
|
unTriggerChange.value = true;
|
||||||
// 查询当前节点
|
// 查询当前节点
|
||||||
const node = findNode(id, menuData.value);
|
const node = findNode(id, menuData.value);
|
||||||
const childrenId: number[] = [];
|
const childrenId: number[] = [];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
title-align="start"
|
title-align="start"
|
||||||
title="分配菜单"
|
title="分配菜单"
|
||||||
width="80%"
|
width="80%"
|
||||||
:top="80"
|
:top="40"
|
||||||
:body-style="{padding: '16px 16px 0 16px', 'margin-bottom': '16px'}"
|
:body-style="{padding: '16px 16px 0 16px', 'margin-bottom': '16px'}"
|
||||||
:align-center="false"
|
:align-center="false"
|
||||||
:draggable="true"
|
:draggable="true"
|
||||||
@@ -15,11 +15,29 @@
|
|||||||
:on-before-ok="handlerOk"
|
:on-before-ok="handlerOk"
|
||||||
@close="handleClose">
|
@close="handleClose">
|
||||||
<div class="role-menu-wrapper">
|
<div class="role-menu-wrapper">
|
||||||
<a-alert class="mb8 usn">
|
<a-alert class="usn mb8">
|
||||||
<span>{{ roleRecord.name }} {{ roleRecord.code }}</span>
|
<span>{{ roleRecord.name }} {{ roleRecord.code }}</span>
|
||||||
<span class="mx8">-</span>
|
<span class="mx8">-</span>
|
||||||
<span>菜单分配后需要用户手动刷新页面才会生效</span>
|
<span>菜单分配后需要用户手动刷新页面才会生效</span>
|
||||||
</a-alert>
|
</a-alert>
|
||||||
|
<div class="usn mb8">
|
||||||
|
<a-space>
|
||||||
|
<template v-for="opt of quickGrantMenuOperator" :key="opt.name">
|
||||||
|
<a-button size="mini" type="text" @click="() => { table.checked(opt.rule) }">
|
||||||
|
{{ '全选' + opt.name }}
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
</a-space>
|
||||||
|
</div>
|
||||||
|
<div class="usn mb8">
|
||||||
|
<a-space>
|
||||||
|
<template v-for="opt of quickGrantMenuOperator" :key="opt.name">
|
||||||
|
<a-button size="mini" type="text" @click="() => { table.unchecked(opt.rule) }">
|
||||||
|
{{ '反选' + opt.name }}
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
</a-space>
|
||||||
|
</div>
|
||||||
<!-- 菜单 -->
|
<!-- 菜单 -->
|
||||||
<menu-grant-table ref="table" />
|
<menu-grant-table ref="table" />
|
||||||
</div>
|
</div>
|
||||||
@@ -42,6 +60,7 @@
|
|||||||
import { useCacheStore } from '@/store';
|
import { useCacheStore } from '@/store';
|
||||||
import { getMenuList } from '@/api/system/menu';
|
import { getMenuList } from '@/api/system/menu';
|
||||||
import MenuGrantTable from '@/components/system/menu/grant/menu-grant-table.vue';
|
import MenuGrantTable from '@/components/system/menu/grant/menu-grant-table.vue';
|
||||||
|
import { quickGrantMenuOperator } from '../types/const';
|
||||||
|
|
||||||
const { visible, setVisible } = useVisible();
|
const { visible, setVisible } = useVisible();
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
@@ -113,7 +132,7 @@
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.role-menu-wrapper {
|
.role-menu-wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: calc(100vh - 285px);
|
max-height: calc(100vh - 230px);
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,6 +6,44 @@ export const RoleStatus = {
|
|||||||
ENABLED: 1,
|
ENABLED: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 快速分配菜单操作
|
||||||
|
export const quickGrantMenuOperator = [
|
||||||
|
{
|
||||||
|
name: '',
|
||||||
|
rule: undefined
|
||||||
|
}, {
|
||||||
|
name: '查询',
|
||||||
|
rule: (perm: string) => {
|
||||||
|
return perm.includes('query') || perm.includes('view');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: '新增',
|
||||||
|
rule: (perm: string) => {
|
||||||
|
return perm.includes('add') || perm.includes('create');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: '修改',
|
||||||
|
rule: (perm: string) => {
|
||||||
|
return perm.includes('update') || perm.includes('modify');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: '删除',
|
||||||
|
rule: (perm: string) => {
|
||||||
|
return perm.includes('delete') || perm.includes('remove');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: '导入',
|
||||||
|
rule: (perm: string) => {
|
||||||
|
return perm.includes('import');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: '导出',
|
||||||
|
rule: (perm: string) => {
|
||||||
|
return perm.includes('export');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// 角色状态 字典项
|
// 角色状态 字典项
|
||||||
export const roleStatusKey = 'systemRoleStatus';
|
export const roleStatusKey = 'systemRoleStatus';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user