feat: 移动主机分组.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
### 创建主机分组
|
||||
POST {{baseUrl}}/asset/host-group/create
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"parentId": -1,
|
||||
"name": ""
|
||||
}
|
||||
|
||||
|
||||
### 查询主机分组
|
||||
GET {{baseUrl}}/asset/host-group/tree
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
### 修改名称
|
||||
PUT {{baseUrl}}/asset/host-group/rename
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"id": "",
|
||||
"name": ""
|
||||
}
|
||||
|
||||
|
||||
### 移动位置
|
||||
PUT {{baseUrl}}/asset/host-group/move
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"id": "",
|
||||
"targetId": "",
|
||||
"position": ""
|
||||
}
|
||||
|
||||
|
||||
### 删除主机分组
|
||||
DELETE {{baseUrl}}/asset/host-group/delete?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
@@ -4,12 +4,15 @@ import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.asset.define.operator.HostOperatorType;
|
||||
import com.orion.ops.module.asset.convert.HostGroupConvert;
|
||||
import com.orion.ops.module.asset.define.operator.HostGroupOperatorType;
|
||||
import com.orion.ops.module.asset.entity.vo.HostGroupTreeVO;
|
||||
import com.orion.ops.module.asset.service.HostService;
|
||||
import com.orion.ops.module.infra.api.DataGroupApi;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupCreateDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupUpdateDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupMoveDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupRenameDTO;
|
||||
import com.orion.ops.module.infra.enums.DataGroupTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -43,13 +46,7 @@ public class HostGroupController {
|
||||
@Resource
|
||||
private DataGroupApi dataGroupApi;
|
||||
|
||||
// TODO 配置权限
|
||||
// TODO 配置操作日志类型
|
||||
// TODO 拖拽
|
||||
// TODO http
|
||||
// TODO 聚合查询关联
|
||||
|
||||
@OperatorLog(HostOperatorType.CREATE)
|
||||
@OperatorLog(HostGroupOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建主机分组")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-group:create')")
|
||||
@@ -59,21 +56,30 @@ public class HostGroupController {
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/tree")
|
||||
@Operation(summary = "创建主机分组")
|
||||
@Operation(summary = "查询主机分组")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-group:query')")
|
||||
public List<DataGroupDTO> queryHostGroup() {
|
||||
return dataGroupApi.getDataGroupTree(DataGroupTypeEnum.HOST);
|
||||
public List<HostGroupTreeVO> queryHostGroup() {
|
||||
List<DataGroupDTO> rows = dataGroupApi.getDataGroupTree(DataGroupTypeEnum.HOST);
|
||||
return HostGroupConvert.MAPPER.toList(rows);
|
||||
}
|
||||
|
||||
@OperatorLog(HostOperatorType.UPDATE)
|
||||
@OperatorLog(HostGroupOperatorType.RENAME)
|
||||
@PutMapping("/rename")
|
||||
@Operation(summary = "修改名称")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-group:update')")
|
||||
public Integer updateHostGroupName(@Validated @RequestBody DataGroupUpdateDTO request) {
|
||||
public Integer updateHostGroupName(@Validated @RequestBody DataGroupRenameDTO request) {
|
||||
return dataGroupApi.renameDataGroup(request);
|
||||
}
|
||||
|
||||
@OperatorLog(HostOperatorType.DELETE)
|
||||
@OperatorLog(HostGroupOperatorType.MOVE)
|
||||
@PutMapping("/move")
|
||||
@Operation(summary = "移动位置")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-group:update')")
|
||||
public Integer moveHostGroup(@Validated @RequestBody DataGroupMoveDTO request) {
|
||||
return dataGroupApi.moveDataGroup(request);
|
||||
}
|
||||
|
||||
@OperatorLog(HostGroupOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除主机分组")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-group:delete')")
|
||||
@@ -81,5 +87,11 @@ public class HostGroupController {
|
||||
return dataGroupApi.deleteDataGroupById(id);
|
||||
}
|
||||
|
||||
|
||||
// TODO 关联操作配置权限
|
||||
// TODO 关联操作配置操作日志类型
|
||||
// TODO 关联 增 删 查
|
||||
// TODO 聚合查询关联
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.orion.ops.module.asset.convert;
|
||||
|
||||
import com.orion.ops.module.asset.entity.vo.HostGroupTreeVO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 主机配置 内部对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-9-11 14:16
|
||||
*/
|
||||
@Mapper
|
||||
public interface HostGroupConvert {
|
||||
|
||||
HostGroupConvert MAPPER = Mappers.getMapper(HostGroupConvert.class);
|
||||
|
||||
List<HostGroupTreeVO> toList(List<DataGroupDTO> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orion.ops.module.asset.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.Module;
|
||||
import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.H;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L;
|
||||
|
||||
/**
|
||||
* 主机分组 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/10 17:30
|
||||
*/
|
||||
@Module("asset:host-group")
|
||||
public class HostGroupOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String CREATE = "host-group:create";
|
||||
|
||||
public static final String RENAME = "host-group:rename";
|
||||
|
||||
public static final String MOVE = "host-group:move";
|
||||
|
||||
public static final String DELETE = "host-group:delete";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建主机分组 <sb>${name}</sb>"),
|
||||
new OperatorType(L, RENAME, "重命名主机分组 <sb>${before}</sb> -> <sb>${name}</sb>"),
|
||||
new OperatorType(L, MOVE, "移动主机分组 <sb>${source}</sb> 到 <sb>${target}(${position})</sb>"),
|
||||
new OperatorType(H, DELETE, "删除主机分组 <sb>${name}</sb>"),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.orion.ops.module.asset.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 主机秘钥 视图响应对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-9-20 11:55
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "HostGroupTreeVO", description = "主机秘钥 视图响应对象")
|
||||
public class HostGroupTreeVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("key")
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@JsonProperty("title")
|
||||
@Schema(description = "组名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "子节点")
|
||||
private List<HostGroupTreeVO> children;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user