feat: 数据分组服务实现.
This commit is contained in:
@@ -21,7 +21,7 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst {
|
||||
|
||||
String INTRANET_IP = "内网IP";
|
||||
|
||||
Long ROOT_MENU_ID = 0L;
|
||||
Long ROOT_PARENT_ID = 0L;
|
||||
|
||||
Integer DEFAULT_SORT = 10;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orion.ops.module.infra.api;
|
||||
|
||||
import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupCreateDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupUpdateDTO;
|
||||
import com.orion.ops.module.infra.enums.DataGroupTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,66 +19,37 @@ public interface DataGroupApi {
|
||||
/**
|
||||
* 创建数据分组
|
||||
*
|
||||
* @param type type
|
||||
* @param dto dto
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroup(DataGroupCreateDTO dto);
|
||||
Long createDataGroup(DataGroupTypeEnum type, DataGroupCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 更新数据分组
|
||||
* 重命名分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupById(DataGroupUpdateDTO dto);
|
||||
Integer renameDataGroup(DataGroupUpdateDTO dto);
|
||||
|
||||
/**
|
||||
* 根据条件更新数据分组
|
||||
*
|
||||
* @param query query
|
||||
* @param update update
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroup(DataGroupQueryDTO query, DataGroupUpdateDTO update);
|
||||
|
||||
/**
|
||||
* 查询数据分组
|
||||
*
|
||||
* @param id id
|
||||
* @return row
|
||||
*/
|
||||
DataGroupDTO getDataGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 批量查询数据分组
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupDTO> getDataGroupByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 查询全部数据分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupDTO> getDataGroupList(DataGroupQueryDTO dto);
|
||||
// FIXME drag
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组
|
||||
*
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupDTO> getDataGroupListByCache();
|
||||
List<DataGroupDTO> getDataGroupList(DataGroupTypeEnum type);
|
||||
|
||||
/**
|
||||
* 查询数据分组数量
|
||||
* 通过缓存查询数据分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return count
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
Long getDataGroupCount(DataGroupQueryDTO dto);
|
||||
List<DataGroupDTO> getDataGroupTree(DataGroupTypeEnum type);
|
||||
|
||||
/**
|
||||
* 删除数据分组
|
||||
@@ -85,20 +59,4 @@ public interface DataGroupApi {
|
||||
*/
|
||||
Integer deleteDataGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroup(DataGroupQueryDTO dto);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.orion.ops.module.infra.api;
|
||||
|
||||
import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupRelCreateDTO;
|
||||
import com.orion.ops.module.infra.enums.DataGroupTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据分组关联 对外服务类
|
||||
@@ -14,91 +17,63 @@ import java.util.List;
|
||||
public interface DataGroupRelApi {
|
||||
|
||||
/**
|
||||
* 创建数据分组关联
|
||||
* 添加关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroupRel(DataGroupRelCreateDTO dto);
|
||||
void addGroupRel(DataGroupRelCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 更新数据分组关联
|
||||
* 添加关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
* @param list list
|
||||
*/
|
||||
Integer updateDataGroupRelById(DataGroupRelUpdateDTO dto);
|
||||
void addGroupRel(List<DataGroupRelCreateDTO> list);
|
||||
|
||||
/**
|
||||
* 根据条件更新数据分组关联
|
||||
* 通过缓存查询数据分组关联
|
||||
* <p>
|
||||
* groupId - relId
|
||||
*
|
||||
* @param query query
|
||||
* @param update update
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupRel(DataGroupRelQueryDTO query, DataGroupRelUpdateDTO update);
|
||||
|
||||
/**
|
||||
* 查询数据分组关联
|
||||
*
|
||||
* @param id id
|
||||
* @return row
|
||||
*/
|
||||
DataGroupRelDTO getDataGroupRelById(Long id);
|
||||
|
||||
/**
|
||||
* 批量查询数据分组关联
|
||||
*
|
||||
* @param idList idList
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDTO> getDataGroupRelByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 查询全部数据分组关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDTO> getDataGroupRelList(DataGroupRelQueryDTO dto);
|
||||
Map<Long, Set<Long>> getGroupRelList(DataGroupTypeEnum type);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组关联
|
||||
*
|
||||
* @param type type
|
||||
* @param groupId groupId
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDTO> getDataGroupRelListByCache();
|
||||
|
||||
/**
|
||||
* 查询数据分组关联数量
|
||||
*
|
||||
* @param dto dto
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupRelCount(DataGroupRelQueryDTO dto);
|
||||
Set<Long> getGroupRelList(DataGroupTypeEnum type, Long groupId);
|
||||
|
||||
/**
|
||||
* 删除数据分组关联
|
||||
*
|
||||
* @param id id
|
||||
* @param type type
|
||||
* @param relId relId
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelById(Long id);
|
||||
Integer deleteByRelId(DataGroupTypeEnum type, Long relId);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组关联
|
||||
*
|
||||
* @param idList idList
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelByIdList(List<Long> idList);
|
||||
Integer deleteByRelIdList(DataGroupTypeEnum type, List<Long> relIdList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组关联
|
||||
* 批量删除数据分组关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @param type type
|
||||
* @param groupIdList groupIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRel(DataGroupRelQueryDTO dto);
|
||||
Integer deleteByGroupIdList(DataGroupTypeEnum type, List<Long> groupIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组 创建请求业务对象
|
||||
@@ -36,13 +34,4 @@ public class DataGroupCreateDTO implements Serializable {
|
||||
@Schema(description = "组名称")
|
||||
private String name;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 业务对象
|
||||
@@ -32,22 +34,10 @@ public class DataGroupDTO implements Serializable {
|
||||
@Schema(description = "组名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updater;
|
||||
@Schema(description = "子节点")
|
||||
private List<DataGroupDTO> children;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组 查询请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataGroupQueryDTO", description = "数据分组 查询请求业务对象")
|
||||
public class DataGroupQueryDTO implements Serializable {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "组名称")
|
||||
private String name;
|
||||
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -6,12 +6,8 @@ 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;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 创建请求业务对象
|
||||
@@ -35,13 +31,4 @@ public class DataGroupRelCreateDTO implements Serializable {
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataGroupRelDTO", description = "数据分组关联 业务对象")
|
||||
public class DataGroupRelDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "组id")
|
||||
private Long groupId;
|
||||
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updater;
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 查询请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataGroupRelQueryDTO", description = "数据分组关联 查询请求业务对象")
|
||||
public class DataGroupRelQueryDTO implements Serializable {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "组id")
|
||||
private Long groupId;
|
||||
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
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;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 更新请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataGroupRelUpdateDTO", description = "数据分组关联 更新请求业务对象")
|
||||
public class DataGroupRelUpdateDTO implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "组id")
|
||||
private Long groupId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -6,12 +6,9 @@ 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;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组 更新请求业务对象
|
||||
@@ -31,21 +28,13 @@ public class DataGroupUpdateDTO implements Serializable {
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "组名称")
|
||||
private String name;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.orion.ops.module.infra.enums;
|
||||
|
||||
/**
|
||||
* 数据分组类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/11/8 18:57
|
||||
*/
|
||||
public enum DataGroupTypeEnum {
|
||||
|
||||
/**
|
||||
* 主机
|
||||
*/
|
||||
HOST,
|
||||
|
||||
;
|
||||
|
||||
public static DataGroupTypeEnum of(String type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
for (DataGroupTypeEnum value : values()) {
|
||||
if (value.name().equals(type)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,4 +16,16 @@ public enum TagTypeEnum {
|
||||
|
||||
;
|
||||
|
||||
public static TagTypeEnum of(String type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
for (TagTypeEnum value : values()) {
|
||||
if (value.name().equals(type)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,176 +1,66 @@
|
||||
// package com.orion.ops.module.infra.api.impl;
|
||||
//
|
||||
// import com.alibaba.fastjson.JSON;
|
||||
// import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
// import com.orion.lang.utils.collect.Lists;
|
||||
// import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
// import com.orion.ops.framework.common.utils.Valid;
|
||||
// import com.orion.ops.module.infra.entity.vo.*;
|
||||
// import com.orion.ops.module.infra.entity.request.data.*;
|
||||
// import com.orion.ops.module.infra.convert.*;
|
||||
// import com.orion.ops.module.infra.entity.dto.*;
|
||||
// import com.orion.ops.module.infra.define.cache.*;
|
||||
// import com.orion.ops.module.infra.define.operator.*;
|
||||
// import com.orion.ops.module.infra.api.*;
|
||||
// import com.orion.ops.module.infra.api.impl.*;
|
||||
// import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
// import com.orion.ops.module.infra.convert.*;
|
||||
// import com.orion.ops.module.infra.entity.domain.DataGroupDO;
|
||||
// import com.orion.ops.module.infra.dao.DataGroupDAO;
|
||||
// import com.orion.ops.module.infra.service.DataGroupService;
|
||||
// import lombok.extern.slf4j.Slf4j;
|
||||
// import org.springframework.stereotype.Service;
|
||||
//
|
||||
// import javax.annotation.Resource;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.List;
|
||||
// import java.util.stream.Collectors;
|
||||
//
|
||||
// /**
|
||||
// * 数据分组 对外服务实现类
|
||||
// *
|
||||
// * @author Jiahang Li
|
||||
// * @version 1.0.0
|
||||
// * @since 2023-11-7 18:44
|
||||
// */
|
||||
// @Slf4j
|
||||
// @Service
|
||||
// public class DataGroupApiImpl implements DataGroupApi {
|
||||
//
|
||||
// @Resource
|
||||
// private DataGroupService dataGroupService;
|
||||
//
|
||||
// @Resource
|
||||
// private DataGroupDAO dataGroupDAO;
|
||||
//
|
||||
// @Override
|
||||
// public Long createDataGroup(DataGroupCreateDTO dto) {
|
||||
// log.info("DataGroupApi.createDataGroup dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 转换
|
||||
// DataGroupCreateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto);
|
||||
// // 创建
|
||||
// return dataGroupService.createDataGroup(request);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer updateDataGroupById(DataGroupUpdateDTO dto) {
|
||||
// log.info("DataGroupApi.updateDataGroupById dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 转换
|
||||
// DataGroupUpdateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto);
|
||||
// // 修改
|
||||
// return dataGroupService.updateDataGroupById(request);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer updateDataGroup(DataGroupQueryDTO query, DataGroupUpdateDTO update) {
|
||||
// log.info("DataGroupApi.updateDataGroup query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// Valid.valid(query);
|
||||
// Valid.valid(update);
|
||||
// // 更新
|
||||
// int effect = dataGroupService.updateDataGroup(DataGroupProviderConvert.MAPPER.toRequest(query),
|
||||
// DataGroupProviderConvert.MAPPER.toRequest(update));
|
||||
// log.info("DataGroupApi.updateDataGroup effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public DataGroupDTO getDataGroupById(Long id) {
|
||||
// log.info("DataGroupApi.getDataGroupById id: {}", id);
|
||||
// Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// // 修改
|
||||
// DataGroupDO record = dataGroupDAO.selectById(id);
|
||||
// if (record == null) {
|
||||
// return null;
|
||||
// }
|
||||
// // 转换
|
||||
// return DataGroupProviderConvert.MAPPER.to(record);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataGroupDTO> getDataGroupByIdList(List<Long> idList) {
|
||||
// log.info("DataGroupApi.getDataGroupByIdList idList: {}", idList);
|
||||
// if (Lists.isEmpty(idList)) {
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
// // 查询
|
||||
// List<DataGroupDO> rows = dataGroupDAO.selectBatchIds(idList);
|
||||
// // 转换
|
||||
// return DataGroupProviderConvert.MAPPER.toList(rows);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataGroupDTO> getDataGroupList(DataGroupQueryDTO dto) {
|
||||
// log.info("DataGroupApi.getDataGroupList dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(dto);
|
||||
// // 查询
|
||||
// return dataGroupDAO.of(wrapper).list(DataGroupProviderConvert.MAPPER::to);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataGroupDTO> getDataGroupListByCache() {
|
||||
// return dataGroupService.getDataGroupListByCache()
|
||||
// .stream()
|
||||
// .map(DataGroupProviderConvert.MAPPER::to)
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Long getDataGroupCount(DataGroupQueryDTO dto) {
|
||||
// log.info("DataGroupApi.getDataGroupCount dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(dto);
|
||||
// // 查询
|
||||
// return dataGroupDAO.selectCount(wrapper);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataGroupById(Long id) {
|
||||
// log.info("DataGroupApi.deleteDataGroupById id: {}", id);
|
||||
// Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// // 删除
|
||||
// Integer effect = dataGroupService.deleteDataGroupById(id);
|
||||
// log.info("DataGroupApi.deleteDataGroupById id: {}, effect: {}", id, effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataGroupByIdList(List<Long> idList) {
|
||||
// log.info("DataGroupApi.deleteDataGroupByIdList idList: {}", idList);
|
||||
// Valid.notEmpty(idList, ErrorMessage.ID_MISSING);
|
||||
// // 删除
|
||||
// Integer effect = dataGroupService.deleteDataGroupByIdList(idList);
|
||||
// log.info("DataGroupApi.deleteDataGroupByIdList effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataGroup(DataGroupQueryDTO dto) {
|
||||
// log.info("DataGroupApi.deleteDataGroup dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 删除
|
||||
// Integer effect = dataGroupService.deleteDataGroup(DataGroupProviderConvert.MAPPER.toRequest(dto));
|
||||
// log.info("DataGroupApi.deleteDataGroup effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 构建查询 wrapper
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return wrapper
|
||||
// */
|
||||
// private LambdaQueryWrapper<DataGroupDO> buildQueryWrapper(DataGroupQueryDTO dto) {
|
||||
// return dataGroupDAO.wrapper()
|
||||
// .eq(DataGroupDO::getId, dto.getId())
|
||||
// .eq(DataGroupDO::getParentId, dto.getParentId())
|
||||
// .eq(DataGroupDO::getName, dto.getName())
|
||||
// .eq(DataGroupDO::getType, dto.getType())
|
||||
// .eq(DataGroupDO::getSort, dto.getSort());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
package com.orion.ops.module.infra.api.impl;
|
||||
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.infra.api.DataGroupApi;
|
||||
import com.orion.ops.module.infra.convert.DataGroupProviderConvert;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO;
|
||||
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.request.data.DataGroupCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupUpdateRequest;
|
||||
import com.orion.ops.module.infra.enums.DataGroupTypeEnum;
|
||||
import com.orion.ops.module.infra.service.DataGroupService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 对外服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataGroupApiImpl implements DataGroupApi {
|
||||
|
||||
@Resource
|
||||
private DataGroupService dataGroupService;
|
||||
|
||||
@Override
|
||||
public Long createDataGroup(DataGroupTypeEnum type, DataGroupCreateDTO dto) {
|
||||
Valid.valid(dto);
|
||||
DataGroupCreateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto);
|
||||
request.setType(type.name());
|
||||
return dataGroupService.createDataGroup(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer renameDataGroup(DataGroupUpdateDTO dto) {
|
||||
Valid.valid(dto);
|
||||
DataGroupUpdateRequest request = DataGroupProviderConvert.MAPPER.toRequest(dto);
|
||||
return dataGroupService.renameDataGroup(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupDTO> getDataGroupList(DataGroupTypeEnum type) {
|
||||
List<DataGroupCacheDTO> rows = dataGroupService.getDataGroupListByCache(type.name());
|
||||
return DataGroupProviderConvert.MAPPER.toList(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupDTO> getDataGroupTree(DataGroupTypeEnum type) {
|
||||
List<DataGroupCacheDTO> rows = dataGroupService.getDataGroupTreeByCache(type.name());
|
||||
return DataGroupProviderConvert.MAPPER.toList(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupById(Long id) {
|
||||
return dataGroupService.deleteDataGroupById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,176 +1,81 @@
|
||||
// package com.orion.ops.module.infra.api.impl;
|
||||
//
|
||||
// import com.alibaba.fastjson.JSON;
|
||||
// import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
// import com.orion.lang.utils.collect.Lists;
|
||||
// import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
// import com.orion.ops.framework.common.utils.Valid;
|
||||
// import com.orion.ops.module.infra.entity.vo.*;
|
||||
// import com.orion.ops.module.infra.entity.request.data.*;
|
||||
// import com.orion.ops.module.infra.convert.*;
|
||||
// import com.orion.ops.module.infra.entity.dto.*;
|
||||
// import com.orion.ops.module.infra.define.cache.*;
|
||||
// import com.orion.ops.module.infra.define.operator.*;
|
||||
// import com.orion.ops.module.infra.api.*;
|
||||
// import com.orion.ops.module.infra.api.impl.*;
|
||||
// import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
// import com.orion.ops.module.infra.convert.*;
|
||||
// import com.orion.ops.module.infra.entity.domain.DataGroupRelDO;
|
||||
// import com.orion.ops.module.infra.dao.DataGroupRelDAO;
|
||||
// import com.orion.ops.module.infra.service.DataGroupRelService;
|
||||
// import lombok.extern.slf4j.Slf4j;
|
||||
// import org.springframework.stereotype.Service;
|
||||
//
|
||||
// import javax.annotation.Resource;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.List;
|
||||
// import java.util.stream.Collectors;
|
||||
//
|
||||
// /**
|
||||
// * 数据分组关联 对外服务实现类
|
||||
// *
|
||||
// * @author Jiahang Li
|
||||
// * @version 1.0.0
|
||||
// * @since 2023-11-7 18:44
|
||||
// */
|
||||
// @Slf4j
|
||||
// @Service
|
||||
// public class DataGroupRelApiImpl implements DataGroupRelApi {
|
||||
//
|
||||
// @Resource
|
||||
// private DataGroupRelService dataGroupRelService;
|
||||
//
|
||||
// @Resource
|
||||
// private DataGroupRelDAO dataGroupRelDAO;
|
||||
//
|
||||
// @Override
|
||||
// public Long createDataGroupRel(DataGroupRelCreateDTO dto) {
|
||||
// log.info("DataGroupRelApi.createDataGroupRel dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 转换
|
||||
// DataGroupRelCreateRequest request = DataGroupRelProviderConvert.MAPPER.toRequest(dto);
|
||||
// // 创建
|
||||
// return dataGroupRelService.createDataGroupRel(request);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer updateDataGroupRelById(DataGroupRelUpdateDTO dto) {
|
||||
// log.info("DataGroupRelApi.updateDataGroupRelById dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 转换
|
||||
// DataGroupRelUpdateRequest request = DataGroupRelProviderConvert.MAPPER.toRequest(dto);
|
||||
// // 修改
|
||||
// return dataGroupRelService.updateDataGroupRelById(request);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer updateDataGroupRel(DataGroupRelQueryDTO query, DataGroupRelUpdateDTO update) {
|
||||
// log.info("DataGroupRelApi.updateDataGroupRel query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// Valid.valid(query);
|
||||
// Valid.valid(update);
|
||||
// // 更新
|
||||
// int effect = dataGroupRelService.updateDataGroupRel(DataGroupRelProviderConvert.MAPPER.toRequest(query),
|
||||
// DataGroupRelProviderConvert.MAPPER.toRequest(update));
|
||||
// log.info("DataGroupRelApi.updateDataGroupRel effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public DataGroupRelDTO getDataGroupRelById(Long id) {
|
||||
// log.info("DataGroupRelApi.getDataGroupRelById id: {}", id);
|
||||
// Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// // 修改
|
||||
// DataGroupRelDO record = dataGroupRelDAO.selectById(id);
|
||||
// if (record == null) {
|
||||
// return null;
|
||||
// }
|
||||
// // 转换
|
||||
// return DataGroupRelProviderConvert.MAPPER.to(record);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataGroupRelDTO> getDataGroupRelByIdList(List<Long> idList) {
|
||||
// log.info("DataGroupRelApi.getDataGroupRelByIdList idList: {}", idList);
|
||||
// if (Lists.isEmpty(idList)) {
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
// // 查询
|
||||
// List<DataGroupRelDO> rows = dataGroupRelDAO.selectBatchIds(idList);
|
||||
// // 转换
|
||||
// return DataGroupRelProviderConvert.MAPPER.toList(rows);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataGroupRelDTO> getDataGroupRelList(DataGroupRelQueryDTO dto) {
|
||||
// log.info("DataGroupRelApi.getDataGroupRelList dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(dto);
|
||||
// // 查询
|
||||
// return dataGroupRelDAO.of(wrapper).list(DataGroupRelProviderConvert.MAPPER::to);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataGroupRelDTO> getDataGroupRelListByCache() {
|
||||
// return dataGroupRelService.getDataGroupRelListByCache()
|
||||
// .stream()
|
||||
// .map(DataGroupRelProviderConvert.MAPPER::to)
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Long getDataGroupRelCount(DataGroupRelQueryDTO dto) {
|
||||
// log.info("DataGroupRelApi.getDataGroupRelCount dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(dto);
|
||||
// // 查询
|
||||
// return dataGroupRelDAO.selectCount(wrapper);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataGroupRelById(Long id) {
|
||||
// log.info("DataGroupRelApi.deleteDataGroupRelById id: {}", id);
|
||||
// Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// // 删除
|
||||
// Integer effect = dataGroupRelService.deleteDataGroupRelById(id);
|
||||
// log.info("DataGroupRelApi.deleteDataGroupRelById id: {}, effect: {}", id, effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataGroupRelByIdList(List<Long> idList) {
|
||||
// log.info("DataGroupRelApi.deleteDataGroupRelByIdList idList: {}", idList);
|
||||
// Valid.notEmpty(idList, ErrorMessage.ID_MISSING);
|
||||
// // 删除
|
||||
// Integer effect = dataGroupRelService.deleteDataGroupRelByIdList(idList);
|
||||
// log.info("DataGroupRelApi.deleteDataGroupRelByIdList effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataGroupRel(DataGroupRelQueryDTO dto) {
|
||||
// log.info("DataGroupRelApi.deleteDataGroupRel dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 删除
|
||||
// Integer effect = dataGroupRelService.deleteDataGroupRel(DataGroupRelProviderConvert.MAPPER.toRequest(dto));
|
||||
// log.info("DataGroupRelApi.deleteDataGroupRel effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 构建查询 wrapper
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return wrapper
|
||||
// */
|
||||
// private LambdaQueryWrapper<DataGroupRelDO> buildQueryWrapper(DataGroupRelQueryDTO dto) {
|
||||
// return dataGroupRelDAO.wrapper()
|
||||
// .eq(DataGroupRelDO::getId, dto.getId())
|
||||
// .eq(DataGroupRelDO::getGroupId, dto.getGroupId())
|
||||
// .eq(DataGroupRelDO::getRelId, dto.getRelId())
|
||||
// .eq(DataGroupRelDO::getType, dto.getType())
|
||||
// .eq(DataGroupRelDO::getSort, dto.getSort());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
package com.orion.ops.module.infra.api.impl;
|
||||
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.infra.api.DataGroupRelApi;
|
||||
import com.orion.ops.module.infra.convert.DataGroupRelProviderConvert;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupRelCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupRelCreateDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupRelCreateRequest;
|
||||
import com.orion.ops.module.infra.enums.DataGroupTypeEnum;
|
||||
import com.orion.ops.module.infra.service.DataGroupRelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据分组关联 对外服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataGroupRelApiImpl implements DataGroupRelApi {
|
||||
|
||||
@Resource
|
||||
private DataGroupRelService dataGroupRelService;
|
||||
|
||||
@Override
|
||||
public void addGroupRel(DataGroupRelCreateDTO dto) {
|
||||
Valid.valid(dto);
|
||||
DataGroupRelCreateRequest request = DataGroupRelProviderConvert.MAPPER.toRequest(dto);
|
||||
dataGroupRelService.addGroupRel(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroupRel(List<DataGroupRelCreateDTO> list) {
|
||||
Valid.valid(list);
|
||||
List<DataGroupRelCreateRequest> rows = DataGroupRelProviderConvert.MAPPER.toList(list);
|
||||
dataGroupRelService.addGroupRel(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Set<Long>> getGroupRelList(DataGroupTypeEnum type) {
|
||||
List<DataGroupRelCacheDTO> rows = dataGroupRelService.getGroupRelListByCache(type.name());
|
||||
return rows.stream().collect(
|
||||
Collectors.groupingBy(
|
||||
DataGroupRelCacheDTO::getGroupId,
|
||||
Collectors.mapping(DataGroupRelCacheDTO::getRelId, Collectors.toSet())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getGroupRelList(DataGroupTypeEnum type, Long groupId) {
|
||||
List<DataGroupRelCacheDTO> rows = dataGroupRelService.getGroupRelListByCache(type.name(), groupId);
|
||||
return rows.stream()
|
||||
.map(DataGroupRelCacheDTO::getRelId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByRelId(DataGroupTypeEnum type, Long relId) {
|
||||
return dataGroupRelService.deleteByRelId(type.name(), relId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByRelIdList(DataGroupTypeEnum type, List<Long> relIdList) {
|
||||
return dataGroupRelService.deleteByRelIdList(type.name(), relIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByGroupIdList(DataGroupTypeEnum type, List<Long> groupIdList) {
|
||||
return dataGroupRelService.deleteByGroupIdList(type.name(), groupIdList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.orion.ops.module.infra.convert;
|
||||
|
||||
import com.orion.ops.module.infra.entity.domain.*;
|
||||
import com.orion.ops.module.infra.entity.vo.*;
|
||||
import com.orion.ops.module.infra.entity.request.data.*;
|
||||
import com.orion.ops.module.infra.convert.*;
|
||||
import com.orion.ops.module.infra.entity.dto.*;
|
||||
import com.orion.ops.module.infra.define.cache.*;
|
||||
import com.orion.ops.module.infra.define.operator.*;
|
||||
import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
import com.orion.ops.module.infra.entity.domain.DataGroupDO;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO;
|
||||
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.request.data.DataGroupCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupUpdateRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@@ -29,14 +28,12 @@ public interface DataGroupProviderConvert {
|
||||
|
||||
DataGroupDTO to(DataGroupDO domain);
|
||||
|
||||
DataGroupDO to(DataGroupQueryDTO domain);
|
||||
|
||||
DataGroupDO to(DataGroupUpdateDTO update);
|
||||
|
||||
DataGroupCreateRequest toRequest(DataGroupCreateDTO request);
|
||||
|
||||
DataGroupUpdateRequest toRequest(DataGroupUpdateDTO request);
|
||||
|
||||
List<DataGroupDTO> toList(List<DataGroupDO> list);
|
||||
List<DataGroupDTO> toList(List<DataGroupCacheDTO> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.orion.ops.module.infra.convert;
|
||||
|
||||
import com.orion.ops.module.infra.entity.domain.DataGroupRelDO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupRelCreateDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupRelDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupRelUpdateDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupRelCreateRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -22,14 +19,8 @@ public interface DataGroupRelProviderConvert {
|
||||
|
||||
DataGroupRelProviderConvert MAPPER = Mappers.getMapper(DataGroupRelProviderConvert.class);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelDTO dto);
|
||||
|
||||
DataGroupRelDTO to(DataGroupRelDO domain);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelUpdateDTO update);
|
||||
|
||||
DataGroupRelCreateRequest toRequest(DataGroupRelCreateDTO request);
|
||||
|
||||
List<DataGroupRelDTO> toList(List<DataGroupRelDO> list);
|
||||
List<DataGroupRelCreateRequest> toList(List<DataGroupRelCreateDTO> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.ops.module.infra.entity.domain.DataGroupDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,6 +18,15 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface DataGroupDAO extends IMapper<DataGroupDO> {
|
||||
|
||||
/**
|
||||
* 查询最大排序
|
||||
*
|
||||
* @param parentId parentId
|
||||
* @param type type
|
||||
* @return max(sort)
|
||||
*/
|
||||
Integer selectMaxSort(@Param("parentId") Long parentId, @Param("type") String type);
|
||||
|
||||
/**
|
||||
* 通过 parentId 查询
|
||||
*
|
||||
|
||||
@@ -16,9 +16,16 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public interface DataGroupCacheKeyDefine {
|
||||
|
||||
CacheKeyDefine DATA_GROUP = new CacheKeyBuilder()
|
||||
.key("data:group:{}")
|
||||
.desc("数据分组 ${type}")
|
||||
CacheKeyDefine DATA_GROUP_LIST = new CacheKeyBuilder()
|
||||
.key("data:group-list:{}")
|
||||
.desc("数据分组列表结构 ${type}")
|
||||
.type(DataGroupCacheDTO.class)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
CacheKeyDefine DATA_GROUP_TREE = new CacheKeyBuilder()
|
||||
.key("data:group-tree:{}")
|
||||
.desc("数据分组树结构 ${type}")
|
||||
.type(DataGroupCacheDTO.class)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
@@ -42,8 +42,4 @@ public class DataGroupRelDO extends BaseDO {
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@TableField("sort")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 缓存对象
|
||||
@@ -33,10 +34,10 @@ public class DataGroupCacheDTO implements Serializable {
|
||||
@Schema(description = "组名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "子节点")
|
||||
private List<DataGroupCacheDTO> children;
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,4 @@ public class DataGroupRelCacheDTO implements Serializable {
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,4 @@ public class DataGroupCreateRequest implements Serializable {
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,4 @@ public class DataGroupRelCreateRequest implements Serializable {
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.orion.ops.module.infra.enums;
|
||||
|
||||
import com.orion.lang.utils.convert.Converts;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -12,7 +11,6 @@ import java.math.BigDecimal;
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/17 11:18
|
||||
*/
|
||||
@Getter
|
||||
public enum DictValueTypeEnum {
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,20 +27,28 @@ public interface DataGroupService {
|
||||
* 重命名分组
|
||||
*
|
||||
* @param request request
|
||||
* @return id
|
||||
* @return effect
|
||||
*/
|
||||
Integer renameDataGroup(DataGroupUpdateRequest request);
|
||||
|
||||
// FIXME drag
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组
|
||||
* 通过缓存查询数据分组 - 列表
|
||||
*
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupCacheDTO> getDataGroupListByCache(String type);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组 - 树结构
|
||||
*
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupCacheDTO> getDataGroupTreeByCache(String type);
|
||||
|
||||
/**
|
||||
* 删除数据分组
|
||||
*
|
||||
|
||||
@@ -51,7 +51,6 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
DataGroupRelCreateRequest record = DataGroupRelCreateRequest.builder()
|
||||
.groupId(Valid.notNull(request.getGroupId()))
|
||||
.relId(Valid.notNull(request.getRelId()))
|
||||
.sort(request.getSort())
|
||||
.build();
|
||||
// 插入
|
||||
SpringHolder.getBean(DataGroupRelService.class)
|
||||
@@ -64,12 +63,6 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
if (Lists.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
// 设置默认排序
|
||||
list.forEach(s -> {
|
||||
if (s.getSort() == null) {
|
||||
s.setSort(Const.DEFAULT_SORT);
|
||||
}
|
||||
});
|
||||
// 通过 groupId 分组
|
||||
Map<Long, List<DataGroupRelCreateRequest>> groupMapping = list.stream()
|
||||
.collect(Collectors.groupingBy(DataGroupRelCreateRequest::getGroupId));
|
||||
@@ -105,7 +98,6 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
.groupId(k)
|
||||
.type(groupTypeMapping.get(k))
|
||||
.relId(s.getRelId())
|
||||
.sort(s.getSort())
|
||||
.build()));
|
||||
});
|
||||
// 插入
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -48,12 +49,16 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
DataGroupDO record = DataGroupConvert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.checkDataGroupPresent(record);
|
||||
// 查询最大排序
|
||||
Integer sort = dataGroupDAO.selectMaxSort(request.getParentId(), request.getType());
|
||||
record.setSort(sort + Const.DEFAULT_SORT);
|
||||
// 插入
|
||||
int effect = dataGroupDAO.insert(record);
|
||||
Long id = record.getId();
|
||||
log.info("DataGroupService-createDataGroup id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP.format(request.getType()));
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(request.getType()),
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(request.getType()));
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -75,15 +80,16 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
// 更新
|
||||
int effect = dataGroupDAO.updateById(updateRecord);
|
||||
// 删除缓存
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP.format(record.getType()));
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(record.getType()),
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(record.getType()));
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupCacheDTO> getDataGroupListByCache(String type) {
|
||||
// 查询缓存
|
||||
String key = DataGroupCacheKeyDefine.DATA_GROUP.format(type);
|
||||
List<DataGroupCacheDTO> list = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
String key = DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type);
|
||||
List<DataGroupCacheDTO> list = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP_LIST);
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = dataGroupDAO.of()
|
||||
@@ -98,13 +104,66 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
.build());
|
||||
}
|
||||
// 设置缓存
|
||||
RedisStrings.setJson(key, DataGroupCacheKeyDefine.DATA_GROUP, list);
|
||||
RedisStrings.setJson(key, DataGroupCacheKeyDefine.DATA_GROUP_LIST, list);
|
||||
}
|
||||
// 删除默认值
|
||||
list.removeIf(s -> s.getId().equals(Const.NONE_ID));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupCacheDTO> getDataGroupTreeByCache(String type) {
|
||||
// 查询缓存
|
||||
String key = DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type);
|
||||
List<DataGroupCacheDTO> treeData = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP_TREE);
|
||||
if (treeData.isEmpty()) {
|
||||
// 查询列表缓存
|
||||
List<DataGroupCacheDTO> rows = this.getDataGroupListByCache(type);
|
||||
// 添加默认值 防止穿透
|
||||
if (Lists.isEmpty(rows)) {
|
||||
treeData = Lists.of(DataGroupCacheDTO.builder()
|
||||
.id(Const.NONE_ID)
|
||||
.build());
|
||||
} else {
|
||||
// 构建树
|
||||
DataGroupCacheDTO rootNode = DataGroupCacheDTO.builder()
|
||||
.parentId(Const.ROOT_PARENT_ID)
|
||||
.sort(Const.DEFAULT_SORT)
|
||||
.build();
|
||||
this.buildGroupTree(rootNode, rows);
|
||||
treeData = rootNode.getChildren();
|
||||
}
|
||||
// 设置缓存
|
||||
RedisStrings.setJson(key, DataGroupCacheKeyDefine.DATA_GROUP_LIST, treeData);
|
||||
}
|
||||
// 删除默认值
|
||||
treeData.removeIf(s -> s.getId().equals(Const.NONE_ID));
|
||||
return treeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树
|
||||
*
|
||||
* @param parentNode parentNode
|
||||
* @param nodes nodes
|
||||
*/
|
||||
private void buildGroupTree(DataGroupCacheDTO parentNode,
|
||||
List<DataGroupCacheDTO> nodes) {
|
||||
// 获取子节点
|
||||
List<DataGroupCacheDTO> childrenNodes = nodes.stream()
|
||||
.filter(s -> parentNode.getParentId().equals(s.getParentId()))
|
||||
.sorted(Comparator.comparing(DataGroupCacheDTO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
if (childrenNodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
parentNode.setChildren(childrenNodes);
|
||||
// 遍历子节点
|
||||
for (DataGroupCacheDTO childrenNode : childrenNodes) {
|
||||
this.buildGroupTree(childrenNode, nodes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteDataGroupById(Long id) {
|
||||
@@ -122,7 +181,8 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
dataGroupRelService.deleteByGroupIdList(type, deleteIdList);
|
||||
log.info("DataGroupService-deleteDataGroupById id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP.format(type));
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP_LIST.format(type),
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_TREE.format(type));
|
||||
return effect;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ public class SystemMenuServiceImpl implements SystemMenuService {
|
||||
// 验证父菜单参数
|
||||
if (MenuTypeEnum.PARENT_MENU.equals(type)) {
|
||||
// 父菜单创建的 parentId 为 0
|
||||
domain.setParentId(Const.ROOT_MENU_ID);
|
||||
domain.setParentId(Const.ROOT_PARENT_ID);
|
||||
// 验证必填参数
|
||||
Valid.valid(SystemMenuConvert.MAPPER.toMenuValidate(domain));
|
||||
return;
|
||||
|
||||
@@ -21,4 +21,12 @@
|
||||
id, parent_id, name, type, sort, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
<select id="selectMaxSort" resultType="java.lang.Integer">
|
||||
SELECT IFNULL(MAX(sort), 0)
|
||||
FROM data_group
|
||||
WHERE deleted = 0
|
||||
AND type = #{type}
|
||||
AND parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<result column="group_id" property="groupId"/>
|
||||
<result column="rel_id" property="relId"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="creator" property="creator"/>
|
||||
@@ -18,7 +17,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, group_id, rel_id, type, sort, create_time, update_time, creator, updater, deleted
|
||||
id, group_id, rel_id, type, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user