生成数据分组代码
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
package com.orion.ops.module.infra.api;
|
||||
|
||||
import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 对外服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
public interface DataGroupApi {
|
||||
|
||||
/**
|
||||
* 创建数据分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroup(DataGroupCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 更新数据分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupById(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);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组
|
||||
*
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupDTO> getDataGroupListByCache();
|
||||
|
||||
/**
|
||||
* 查询数据分组数量
|
||||
*
|
||||
* @param dto dto
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupCount(DataGroupQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 删除数据分组
|
||||
*
|
||||
* @param id id
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroup(DataGroupQueryDTO dto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.orion.ops.module.infra.api;
|
||||
|
||||
import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组关联 对外服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
public interface DataGroupRelApi {
|
||||
|
||||
/**
|
||||
* 创建数据分组关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroupRel(DataGroupRelCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 更新数据分组关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupRelById(DataGroupRelUpdateDTO dto);
|
||||
|
||||
/**
|
||||
* 根据条件更新数据分组关联
|
||||
*
|
||||
* @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
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDTO> getDataGroupRelByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 查询全部数据分组关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDTO> getDataGroupRelList(DataGroupRelQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组关联
|
||||
*
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDTO> getDataGroupRelListByCache();
|
||||
|
||||
/**
|
||||
* 查询数据分组关联数量
|
||||
*
|
||||
* @param dto dto
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupRelCount(DataGroupRelQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 删除数据分组关联
|
||||
*
|
||||
* @param id id
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组关联
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组关联
|
||||
*
|
||||
* @param dto dto
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRel(DataGroupRelQueryDTO dto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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 = "DataGroupCreateDTO", description = "数据分组 创建请求业务对象")
|
||||
public class DataGroupCreateDTO implements Serializable {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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 = "DataGroupDTO", description = "数据分组 业务对象")
|
||||
public class DataGroupDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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 = "DataGroupRelCreateDTO", description = "数据分组关联 创建请求业务对象")
|
||||
public class DataGroupRelCreateDTO implements Serializable {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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 = "DataGroupUpdateDTO", description = "数据分组 更新请求业务对象")
|
||||
public class DataGroupUpdateDTO implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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 org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 内部对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataGroupConvert {
|
||||
|
||||
DataGroupConvert MAPPER = Mappers.getMapper(DataGroupConvert.class);
|
||||
|
||||
DataGroupDO to(DataGroupCreateRequest request);
|
||||
|
||||
DataGroupDO to(DataGroupUpdateRequest request);
|
||||
|
||||
DataGroupDO to(DataGroupQueryRequest request);
|
||||
|
||||
DataGroupVO to(DataGroupDO domain);
|
||||
|
||||
List<DataGroupVO> to(List<DataGroupDO> list);
|
||||
|
||||
DataGroupVO to(DataGroupCacheDTO cache);
|
||||
|
||||
DataGroupCacheDTO toCache(DataGroupDO domain);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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 org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 对外服务对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataGroupProviderConvert {
|
||||
|
||||
DataGroupProviderConvert MAPPER = Mappers.getMapper(DataGroupProviderConvert.class);
|
||||
|
||||
DataGroupDTO to(DataGroupVO dto);
|
||||
|
||||
DataGroupDO to(DataGroupDTO dto);
|
||||
|
||||
DataGroupDTO to(DataGroupDO domain);
|
||||
|
||||
DataGroupDO to(DataGroupQueryDTO domain);
|
||||
|
||||
DataGroupDO to(DataGroupUpdateDTO update);
|
||||
|
||||
DataGroupQueryRequest toRequest(DataGroupQueryDTO request);
|
||||
|
||||
DataGroupCreateRequest toRequest(DataGroupCreateDTO request);
|
||||
|
||||
DataGroupUpdateRequest toRequest(DataGroupUpdateDTO request);
|
||||
|
||||
List<DataGroupDTO> toList(List<DataGroupDO> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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 org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组关联 内部对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataGroupRelConvert {
|
||||
|
||||
DataGroupRelConvert MAPPER = Mappers.getMapper(DataGroupRelConvert.class);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelCreateRequest request);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelUpdateRequest request);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelQueryRequest request);
|
||||
|
||||
DataGroupRelVO to(DataGroupRelDO domain);
|
||||
|
||||
List<DataGroupRelVO> to(List<DataGroupRelDO> list);
|
||||
|
||||
DataGroupRelVO to(DataGroupRelCacheDTO cache);
|
||||
|
||||
DataGroupRelCacheDTO toCache(DataGroupRelDO domain);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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 org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组关联 对外服务对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataGroupRelProviderConvert {
|
||||
|
||||
DataGroupRelProviderConvert MAPPER = Mappers.getMapper(DataGroupRelProviderConvert.class);
|
||||
|
||||
DataGroupRelDTO to(DataGroupRelVO dto);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelDTO dto);
|
||||
|
||||
DataGroupRelDTO to(DataGroupRelDO domain);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelQueryDTO domain);
|
||||
|
||||
DataGroupRelDO to(DataGroupRelUpdateDTO update);
|
||||
|
||||
DataGroupRelQueryRequest toRequest(DataGroupRelQueryDTO request);
|
||||
|
||||
DataGroupRelCreateRequest toRequest(DataGroupRelCreateDTO request);
|
||||
|
||||
DataGroupRelUpdateRequest toRequest(DataGroupRelUpdateDTO request);
|
||||
|
||||
List<DataGroupRelDTO> toList(List<DataGroupRelDO> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orion.ops.module.infra.dao;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 数据分组 Mapper 接口
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataGroupDAO extends IMapper<DataGroupDO> {
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
*
|
||||
* @param entity entity
|
||||
* @return 查询条件
|
||||
*/
|
||||
default LambdaQueryWrapper<DataGroupDO> queryCondition(DataGroupDO entity) {
|
||||
return this.wrapper()
|
||||
.eq(DataGroupDO::getId, entity.getId())
|
||||
.eq(DataGroupDO::getParentId, entity.getParentId())
|
||||
.eq(DataGroupDO::getName, entity.getName())
|
||||
.eq(DataGroupDO::getType, entity.getType())
|
||||
.eq(DataGroupDO::getSort, entity.getSort());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orion.ops.module.infra.dao;
|
||||
|
||||
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.DataGroupRelDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 数据分组关联 Mapper 接口
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataGroupRelDAO extends IMapper<DataGroupRelDO> {
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
*
|
||||
* @param entity entity
|
||||
* @return 查询条件
|
||||
*/
|
||||
default LambdaQueryWrapper<DataGroupRelDO> queryCondition(DataGroupRelDO entity) {
|
||||
return this.wrapper()
|
||||
.eq(DataGroupRelDO::getId, entity.getId())
|
||||
.eq(DataGroupRelDO::getGroupId, entity.getGroupId())
|
||||
.eq(DataGroupRelDO::getRelId, entity.getRelId())
|
||||
.eq(DataGroupRelDO::getType, entity.getType())
|
||||
.eq(DataGroupRelDO::getSort, entity.getSort());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.ops.module.infra.define.cache;
|
||||
|
||||
import com.orion.lang.define.cache.CacheKeyBuilder;
|
||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||
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 java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 数据分组缓存 key
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
public interface DataGroupCacheKeyDefine {
|
||||
|
||||
CacheKeyDefine DATA_GROUP = new CacheKeyBuilder()
|
||||
.key("data:group:{}")
|
||||
.desc("数据分组 ${type}")
|
||||
.type(DataGroupCacheDTO.class)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.ops.module.infra.define.cache;
|
||||
|
||||
import com.orion.lang.define.cache.CacheKeyBuilder;
|
||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||
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 java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 数据分组关联缓存 key
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
public interface DataGroupRelCacheKeyDefine {
|
||||
|
||||
CacheKeyDefine DATA_GROUP_REL = new CacheKeyBuilder()
|
||||
.key("data:group-rel:{}")
|
||||
.desc("数据分组关联 ${groupId}")
|
||||
.type(DataGroupRelCacheDTO.class)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orion.ops.module.infra.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.*;
|
||||
|
||||
/**
|
||||
* 数据分组 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Module("infra:data-group")
|
||||
public class DataGroupOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String CREATE = "data-group:create";
|
||||
|
||||
public static final String UPDATE = "data-group:update";
|
||||
|
||||
public static final String DELETE = "data-group:delete";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建数据分组"),
|
||||
new OperatorType(M, UPDATE, "更新数据分组"),
|
||||
new OperatorType(H, DELETE, "删除数据分组"),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orion.ops.module.infra.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.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Module("infra:data-group-rel")
|
||||
public class DataGroupRelOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String CREATE = "data-group-rel:create";
|
||||
|
||||
public static final String UPDATE = "data-group-rel:update";
|
||||
|
||||
public static final String DELETE = "data-group-rel:delete";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建数据分组关联"),
|
||||
new OperatorType(M, UPDATE, "更新数据分组关联"),
|
||||
new OperatorType(H, DELETE, "删除数据分组关联"),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "data_group", autoResultMap = true)
|
||||
@Schema(name = "DataGroupDO", description = "数据分组 实体对象")
|
||||
public class DataGroupDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
@TableField("parent_id")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "组名称")
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "组类型")
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@TableField("sort")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "data_group_rel", autoResultMap = true)
|
||||
@Schema(name = "DataGroupRelDO", description = "数据分组关联 实体对象")
|
||||
public class DataGroupRelDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "组id")
|
||||
@TableField("group_id")
|
||||
private Long groupId;
|
||||
|
||||
@Schema(description = "引用id")
|
||||
@TableField("rel_id")
|
||||
private Long relId;
|
||||
|
||||
@Schema(description = "组类型")
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@TableField("sort")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orion.ops.module.infra.entity.dto;
|
||||
|
||||
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 = "DataGroupCacheDTO", description = "数据分组 缓存对象")
|
||||
public class DataGroupCacheDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orion.ops.module.infra.entity.dto;
|
||||
|
||||
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 = "DataGroupRelCacheDTO", description = "数据分组关联 缓存对象")
|
||||
public class DataGroupRelCacheDTO 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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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 = "DataGroupCreateRequest", description = "数据分组 创建请求对象")
|
||||
public class DataGroupCreateRequest implements Serializable {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.ops.framework.common.entity.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组 查询请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "DataGroupQueryRequest", description = "数据分组 查询请求对象")
|
||||
public class DataGroupQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "搜索")
|
||||
private String searchValue;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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 = "DataGroupRelCreateRequest", description = "数据分组关联 创建请求对象")
|
||||
public class DataGroupRelCreateRequest implements Serializable {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.ops.framework.common.entity.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 查询请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "DataGroupRelQueryRequest", description = "数据分组关联 查询请求对象")
|
||||
public class DataGroupRelQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "搜索")
|
||||
private String searchValue;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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 = "DataGroupRelUpdateRequest", description = "数据分组关联 更新请求对象")
|
||||
public class DataGroupRelUpdateRequest 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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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 = "DataGroupUpdateRequest", description = "数据分组 更新请求对象")
|
||||
public class DataGroupUpdateRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orion.ops.module.infra.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
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 = "DataGroupRelVO", description = "数据分组关联 视图响应对象")
|
||||
public class DataGroupRelVO 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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orion.ops.module.infra.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
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 = "DataGroupVO", description = "数据分组 视图响应对象")
|
||||
public class DataGroupVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.orion.ops.module.infra.service;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组关联 服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
public interface DataGroupRelService {
|
||||
|
||||
/**
|
||||
* 创建数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroupRel(DataGroupRelCreateRequest request);
|
||||
|
||||
/**
|
||||
* 更新数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupRelById(DataGroupRelUpdateRequest request);
|
||||
|
||||
/**
|
||||
* 根据条件更新数据分组关联
|
||||
*
|
||||
* @param query query
|
||||
* @param update update
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupRel(DataGroupRelQueryRequest query, DataGroupRelUpdateRequest update);
|
||||
|
||||
/**
|
||||
* 查询数据分组关联
|
||||
*
|
||||
* @param id id
|
||||
* @return row
|
||||
*/
|
||||
DataGroupRelVO getDataGroupRelById(Long id);
|
||||
|
||||
/**
|
||||
* 批量查询数据分组关联
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelVO> getDataGroupRelByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 查询全部数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelVO> getDataGroupRelList(DataGroupRelQueryRequest request);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组关联
|
||||
*
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelVO> getDataGroupRelListByCache();
|
||||
|
||||
/**
|
||||
* 查询数据分组关联数量
|
||||
*
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupRelCount(DataGroupRelQueryRequest request);
|
||||
|
||||
/**
|
||||
* 分页查询数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
DataGrid<DataGroupRelVO> getDataGroupRelPage(DataGroupRelQueryRequest request);
|
||||
|
||||
/**
|
||||
* 删除数据分组关联
|
||||
*
|
||||
* @param id id
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组关联
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRel(DataGroupRelQueryRequest request);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.orion.ops.module.infra.service;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
public interface DataGroupService {
|
||||
|
||||
/**
|
||||
* 创建数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroup(DataGroupCreateRequest request);
|
||||
|
||||
/**
|
||||
* 更新数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroupById(DataGroupUpdateRequest request);
|
||||
|
||||
/**
|
||||
* 根据条件更新数据分组
|
||||
*
|
||||
* @param query query
|
||||
* @param update update
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataGroup(DataGroupQueryRequest query, DataGroupUpdateRequest update);
|
||||
|
||||
/**
|
||||
* 查询数据分组
|
||||
*
|
||||
* @param id id
|
||||
* @return row
|
||||
*/
|
||||
DataGroupVO getDataGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 批量查询数据分组
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupVO> getDataGroupByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 查询全部数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupVO> getDataGroupList(DataGroupQueryRequest request);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组
|
||||
*
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupVO> getDataGroupListByCache();
|
||||
|
||||
/**
|
||||
* 查询数据分组数量
|
||||
*
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupCount(DataGroupQueryRequest request);
|
||||
|
||||
/**
|
||||
* 分页查询数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
DataGrid<DataGroupVO> getDataGroupPage(DataGroupQueryRequest request);
|
||||
|
||||
/**
|
||||
* 删除数据分组
|
||||
*
|
||||
* @param id id
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroup(DataGroupQueryRequest request);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.FileNames;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisMaps;
|
||||
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.domain.DataGroupRelDO;
|
||||
import com.orion.ops.module.infra.dao.DataGroupRelDAO;
|
||||
import com.orion.ops.module.infra.service.DataGroupRelService;
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据分组关联 服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
|
||||
@Resource
|
||||
private DataGroupRelDAO dataGroupRelDAO;
|
||||
|
||||
@Override
|
||||
public Long createDataGroupRel(DataGroupRelCreateRequest request) {
|
||||
log.info("DataGroupRelService-createDataGroupRel request: {}", JSON.toJSONString(request));
|
||||
// 转换
|
||||
DataGroupRelDO record = DataGroupRelConvert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.checkDataGroupRelPresent(record);
|
||||
// 插入
|
||||
int effect = dataGroupRelDAO.insert(record);
|
||||
Long id = record.getId();
|
||||
log.info("DataGroupRelService-createDataGroupRel id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateDataGroupRelById(DataGroupRelUpdateRequest request) {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
log.info("DataGroupRelService-updateDataGroupRelById id: {}, request: {}", id, JSON.toJSONString(request));
|
||||
// 查询
|
||||
DataGroupRelDO record = dataGroupRelDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
DataGroupRelDO updateRecord = DataGroupRelConvert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.checkDataGroupRelPresent(updateRecord);
|
||||
// 更新
|
||||
int effect = dataGroupRelDAO.updateById(updateRecord);
|
||||
log.info("DataGroupRelService-updateDataGroupRelById effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateDataGroupRel(DataGroupRelQueryRequest query, DataGroupRelUpdateRequest update) {
|
||||
log.info("DataGroupRelService.updateDataGroupRel query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(query);
|
||||
// 转换
|
||||
DataGroupRelDO updateRecord = DataGroupRelConvert.MAPPER.to(update);
|
||||
// 更新
|
||||
int effect = dataGroupRelDAO.update(updateRecord, wrapper);
|
||||
log.info("DataGroupRelService.updateDataGroupRel effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGroupRelVO getDataGroupRelById(Long id) {
|
||||
// 查询
|
||||
DataGroupRelDO record = dataGroupRelDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
return DataGroupRelConvert.MAPPER.to(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupRelVO> getDataGroupRelByIdList(List<Long> idList) {
|
||||
// 查询
|
||||
List<DataGroupRelDO> records = dataGroupRelDAO.selectBatchIds(idList);
|
||||
if (records.isEmpty()) {
|
||||
return Lists.empty();
|
||||
}
|
||||
// 转换
|
||||
return DataGroupRelConvert.MAPPER.to(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupRelVO> getDataGroupRelList(DataGroupRelQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupRelDAO.of(wrapper).list(DataGroupRelConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupRelVO> getDataGroupRelListByCache() {
|
||||
// 查询缓存
|
||||
List<DataGroupRelCacheDTO> list = RedisMaps.valuesJson(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = dataGroupRelDAO.of().list(DataGroupRelConvert.MAPPER::toCache);
|
||||
// 添加默认值 防止穿透
|
||||
if (list.isEmpty()) {
|
||||
list.add(DataGroupRelCacheDTO.builder()
|
||||
.id(Const.NONE_ID)
|
||||
.build());
|
||||
}
|
||||
// 设置缓存
|
||||
RedisMaps.putAllJson(DataGroupRelCacheKeyDefine.DATA_GROUP_REL.getKey(), s -> s.getId().toString(), list);
|
||||
RedisMaps.setExpire(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
}
|
||||
// 删除默认值
|
||||
return list.stream()
|
||||
.filter(s -> !s.getId().equals(Const.NONE_ID))
|
||||
.map(DataGroupRelConvert.MAPPER::to)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDataGroupRelCount(DataGroupRelQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupRelDAO.selectCount(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGrid<DataGroupRelVO> getDataGroupRelPage(DataGroupRelQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupRelDAO.of(wrapper)
|
||||
.page(request)
|
||||
.dataGrid(DataGroupRelConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupRelById(Long id) {
|
||||
log.info("DataGroupRelService-deleteDataGroupRelById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
DataGroupRelDO record = dataGroupRelDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 删除
|
||||
int effect = dataGroupRelDAO.deleteById(id);
|
||||
log.info("DataGroupRelService-deleteDataGroupRelById id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL, id);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupRelByIdList(List<Long> idList) {
|
||||
log.info("DataGroupRelService-deleteDataGroupRelByIdList idList: {}", idList);
|
||||
int effect = dataGroupRelDAO.deleteBatchIds(idList);
|
||||
log.info("DataGroupRelService-deleteDataGroupRelByIdList effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL, idList);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupRel(DataGroupRelQueryRequest request) {
|
||||
log.info("DataGroupRelService.deleteDataGroupRel request: {}", JSON.toJSONString(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 删除
|
||||
int effect = dataGroupRelDAO.delete(wrapper);
|
||||
log.info("DataGroupRelService.deleteDataGroupRel effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否存在
|
||||
*
|
||||
* @param domain domain
|
||||
*/
|
||||
private void checkDataGroupRelPresent(DataGroupRelDO domain) {
|
||||
// 构造条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = dataGroupRelDAO.wrapper()
|
||||
// 更新时忽略当前记录
|
||||
.ne(DataGroupRelDO::getId, domain.getId())
|
||||
// 用其他字段做重复校验
|
||||
.eq(DataGroupRelDO::getGroupId, domain.getGroupId())
|
||||
.eq(DataGroupRelDO::getRelId, domain.getRelId())
|
||||
.eq(DataGroupRelDO::getType, domain.getType())
|
||||
.eq(DataGroupRelDO::getSort, domain.getSort());
|
||||
// 检查是否存在
|
||||
boolean present = dataGroupRelDAO.of(wrapper).present();
|
||||
Valid.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<DataGroupRelDO> buildQueryWrapper(DataGroupRelQueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
return dataGroupRelDAO.wrapper()
|
||||
.eq(DataGroupRelDO::getId, request.getId())
|
||||
.eq(DataGroupRelDO::getGroupId, request.getGroupId())
|
||||
.eq(DataGroupRelDO::getRelId, request.getRelId())
|
||||
.eq(DataGroupRelDO::getType, request.getType())
|
||||
.eq(DataGroupRelDO::getSort, request.getSort())
|
||||
.and(Strings.isNotEmpty(searchValue), c -> c
|
||||
.eq(DataGroupRelDO::getId, searchValue).or()
|
||||
.eq(DataGroupRelDO::getGroupId, searchValue).or()
|
||||
.eq(DataGroupRelDO::getRelId, searchValue).or()
|
||||
.eq(DataGroupRelDO::getType, searchValue).or()
|
||||
.eq(DataGroupRelDO::getSort, searchValue)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.FileNames;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisMaps;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisStrings;
|
||||
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.domain.DataGroupDO;
|
||||
import com.orion.ops.module.infra.dao.DataGroupDAO;
|
||||
import com.orion.ops.module.infra.service.DataGroupService;
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据分组 服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataGroupServiceImpl implements DataGroupService {
|
||||
|
||||
@Resource
|
||||
private DataGroupDAO dataGroupDAO;
|
||||
|
||||
@Override
|
||||
public Long createDataGroup(DataGroupCreateRequest request) {
|
||||
log.info("DataGroupService-createDataGroup request: {}", JSON.toJSONString(request));
|
||||
// 转换
|
||||
DataGroupDO record = DataGroupConvert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.checkDataGroupPresent(record);
|
||||
// 插入
|
||||
int effect = dataGroupDAO.insert(record);
|
||||
Long id = record.getId();
|
||||
log.info("DataGroupService-createDataGroup id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateDataGroupById(DataGroupUpdateRequest request) {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
log.info("DataGroupService-updateDataGroupById id: {}, request: {}", id, JSON.toJSONString(request));
|
||||
// 查询
|
||||
DataGroupDO record = dataGroupDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
DataGroupDO updateRecord = DataGroupConvert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.checkDataGroupPresent(updateRecord);
|
||||
// 更新
|
||||
int effect = dataGroupDAO.updateById(updateRecord);
|
||||
log.info("DataGroupService-updateDataGroupById effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateDataGroup(DataGroupQueryRequest query, DataGroupUpdateRequest update) {
|
||||
log.info("DataGroupService.updateDataGroup query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(query);
|
||||
// 转换
|
||||
DataGroupDO updateRecord = DataGroupConvert.MAPPER.to(update);
|
||||
// 更新
|
||||
int effect = dataGroupDAO.update(updateRecord, wrapper);
|
||||
log.info("DataGroupService.updateDataGroup effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGroupVO getDataGroupById(Long id) {
|
||||
// 查询
|
||||
DataGroupDO record = dataGroupDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
return DataGroupConvert.MAPPER.to(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupVO> getDataGroupByIdList(List<Long> idList) {
|
||||
// 查询
|
||||
List<DataGroupDO> records = dataGroupDAO.selectBatchIds(idList);
|
||||
if (records.isEmpty()) {
|
||||
return Lists.empty();
|
||||
}
|
||||
// 转换
|
||||
return DataGroupConvert.MAPPER.to(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupVO> getDataGroupList(DataGroupQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupDAO.of(wrapper).list(DataGroupConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupVO> getDataGroupListByCache() {
|
||||
// 查询缓存
|
||||
List<DataGroupCacheDTO> list = RedisMaps.valuesJson(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = dataGroupDAO.of().list(DataGroupConvert.MAPPER::toCache);
|
||||
// 添加默认值 防止穿透
|
||||
if (list.isEmpty()) {
|
||||
list.add(DataGroupCacheDTO.builder()
|
||||
.id(Const.NONE_ID)
|
||||
.build());
|
||||
}
|
||||
// 设置缓存
|
||||
RedisMaps.putAllJson(DataGroupCacheKeyDefine.DATA_GROUP.getKey(), s -> s.getId().toString(), list);
|
||||
RedisMaps.setExpire(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
}
|
||||
// 删除默认值
|
||||
return list.stream()
|
||||
.filter(s -> !s.getId().equals(Const.NONE_ID))
|
||||
.map(DataGroupConvert.MAPPER::to)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDataGroupCount(DataGroupQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupDAO.selectCount(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGrid<DataGroupVO> getDataGroupPage(DataGroupQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupDAO.of(wrapper)
|
||||
.page(request)
|
||||
.dataGrid(DataGroupConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupById(Long id) {
|
||||
log.info("DataGroupService-deleteDataGroupById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
DataGroupDO record = dataGroupDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 删除
|
||||
int effect = dataGroupDAO.deleteById(id);
|
||||
log.info("DataGroupService-deleteDataGroupById id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP, id);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupByIdList(List<Long> idList) {
|
||||
log.info("DataGroupService-deleteDataGroupByIdList idList: {}", idList);
|
||||
int effect = dataGroupDAO.deleteBatchIds(idList);
|
||||
log.info("DataGroupService-deleteDataGroupByIdList effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP, idList);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroup(DataGroupQueryRequest request) {
|
||||
log.info("DataGroupService.deleteDataGroup request: {}", JSON.toJSONString(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 删除
|
||||
int effect = dataGroupDAO.delete(wrapper);
|
||||
log.info("DataGroupService.deleteDataGroup effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否存在
|
||||
*
|
||||
* @param domain domain
|
||||
*/
|
||||
private void checkDataGroupPresent(DataGroupDO domain) {
|
||||
// 构造条件
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = dataGroupDAO.wrapper()
|
||||
// 更新时忽略当前记录
|
||||
.ne(DataGroupDO::getId, domain.getId())
|
||||
// 用其他字段做重复校验
|
||||
.eq(DataGroupDO::getParentId, domain.getParentId())
|
||||
.eq(DataGroupDO::getName, domain.getName())
|
||||
.eq(DataGroupDO::getType, domain.getType());
|
||||
// 检查是否存在
|
||||
boolean present = dataGroupDAO.of(wrapper).present();
|
||||
Valid.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<DataGroupDO> buildQueryWrapper(DataGroupQueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
return dataGroupDAO.wrapper()
|
||||
.eq(DataGroupDO::getId, request.getId())
|
||||
.eq(DataGroupDO::getParentId, request.getParentId())
|
||||
.eq(DataGroupDO::getName, request.getName())
|
||||
.eq(DataGroupDO::getType, request.getType())
|
||||
.eq(DataGroupDO::getSort, request.getSort())
|
||||
.and(Strings.isNotEmpty(searchValue), c -> c
|
||||
.eq(DataGroupDO::getId, searchValue).or()
|
||||
.eq(DataGroupDO::getParentId, searchValue).or()
|
||||
.eq(DataGroupDO::getName, searchValue).or()
|
||||
.eq(DataGroupDO::getType, searchValue).or()
|
||||
.eq(DataGroupDO::getSort, searchValue)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orion.ops.module.infra.dao.DataGroupDAO">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.orion.ops.module.infra.entity.domain.DataGroupDO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="name" property="name"/>
|
||||
<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"/>
|
||||
<result column="updater" property="updater"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, parent_id, name, type, sort, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orion.ops.module.infra.dao.DataGroupRelDAO">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.orion.ops.module.infra.entity.domain.DataGroupRelDO">
|
||||
<id column="id" property="id"/>
|
||||
<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"/>
|
||||
<result column="updater" property="updater"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, group_id, rel_id, type, sort, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user