feat: 数据分组服务实现.
This commit is contained in:
@@ -1,176 +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());
|
||||
}
|
||||
|
||||
}
|
||||
// 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());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
@@ -1,176 +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());
|
||||
}
|
||||
|
||||
}
|
||||
// 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());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
@@ -1,17 +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.domain.DataGroupDO;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 内部对象转换器
|
||||
*
|
||||
@@ -28,14 +23,6 @@ public interface DataGroupConvert {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ public interface DataGroupProviderConvert {
|
||||
|
||||
DataGroupProviderConvert MAPPER = Mappers.getMapper(DataGroupProviderConvert.class);
|
||||
|
||||
DataGroupDTO to(DataGroupVO dto);
|
||||
|
||||
DataGroupDO to(DataGroupDTO dto);
|
||||
|
||||
DataGroupDTO to(DataGroupDO domain);
|
||||
@@ -35,8 +33,6 @@ public interface DataGroupProviderConvert {
|
||||
|
||||
DataGroupDO to(DataGroupUpdateDTO update);
|
||||
|
||||
DataGroupQueryRequest toRequest(DataGroupQueryDTO request);
|
||||
|
||||
DataGroupCreateRequest toRequest(DataGroupCreateDTO request);
|
||||
|
||||
DataGroupUpdateRequest toRequest(DataGroupUpdateDTO request);
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
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.domain.DataGroupRelDO;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupRelCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupRelCreateRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组关联 内部对象转换器
|
||||
*
|
||||
@@ -26,16 +20,6 @@ public interface DataGroupRelConvert {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
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.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;
|
||||
|
||||
@@ -25,22 +22,14 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ 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 java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组 Mapper 接口
|
||||
*
|
||||
@@ -16,18 +18,15 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface DataGroupDAO extends IMapper<DataGroupDO> {
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
* 通过 parentId 查询
|
||||
*
|
||||
* @param entity entity
|
||||
* @return 查询条件
|
||||
* @param parentIdList parentIdList
|
||||
* @return rows
|
||||
*/
|
||||
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());
|
||||
default List<DataGroupDO> selectByParentId(List<Long> parentIdList) {
|
||||
LambdaQueryWrapper<DataGroupDO> wrapper = this.lambda()
|
||||
.in(DataGroupDO::getParentId, parentIdList);
|
||||
return this.selectList(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.orion.ops.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.ops.module.infra.entity.domain.DataGroupRelDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据分组关联 Mapper 接口
|
||||
*
|
||||
@@ -16,18 +18,15 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface DataGroupRelDAO extends IMapper<DataGroupRelDO> {
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
* 通过 groupId 删除
|
||||
*
|
||||
* @param entity entity
|
||||
* @return 查询条件
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
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());
|
||||
default int deleteByGroupId(List<Long> idList) {
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.lambda()
|
||||
.in(DataGroupRelDO::getGroupId, idList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,12 +2,8 @@ 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 com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupRelCacheDTO;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -27,4 +23,18 @@ public interface DataGroupCacheKeyDefine {
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
CacheKeyDefine DATA_GROUP_REL_GROUP = new CacheKeyBuilder()
|
||||
.key("data:group-rel:group:{}")
|
||||
.desc("数据分组数据关联-分组 ${groupId}")
|
||||
.type(DataGroupRelCacheDTO.class)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
CacheKeyDefine DATA_GROUP_REL_TYPE = new CacheKeyBuilder()
|
||||
.key("data:group-rel:type:{}")
|
||||
.desc("数据分组数据关联-类型 ${type}")
|
||||
.type(DataGroupRelCacheDTO.class)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.orion.ops.module.infra.entity.dto;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 数据分组 缓存对象
|
||||
@@ -38,16 +39,4 @@ public class DataGroupCacheDTO implements Serializable {
|
||||
@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,11 +1,12 @@
|
||||
package com.orion.ops.module.infra.entity.dto;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 数据分组关联 缓存对象
|
||||
@@ -32,22 +33,7 @@ public class DataGroupRelCacheDTO implements Serializable {
|
||||
@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,6 +1,5 @@
|
||||
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;
|
||||
@@ -11,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.*;
|
||||
|
||||
/**
|
||||
* 数据分组 创建请求对象
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,18 +1,13 @@
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* 数据分组关联 创建请求对象
|
||||
@@ -36,12 +31,6 @@ public class DataGroupRelCreateRequest implements Serializable {
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 16)
|
||||
@Schema(description = "组类型")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* 数据分组 更新请求对象
|
||||
@@ -32,21 +28,13 @@ public class DataGroupUpdateRequest 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;
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.orion.ops.module.infra.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据分组 视图响应对象
|
||||
@@ -32,22 +33,4 @@ public class DataGroupVO 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
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 com.orion.ops.module.infra.entity.dto.DataGroupRelCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupRelCreateRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -22,99 +15,61 @@ import java.util.List;
|
||||
public interface DataGroupRelService {
|
||||
|
||||
/**
|
||||
* 创建数据分组关联
|
||||
* 添加关联
|
||||
*
|
||||
* @param request request
|
||||
* @return id
|
||||
*/
|
||||
Long createDataGroupRel(DataGroupRelCreateRequest request);
|
||||
void addGroupRel(DataGroupRelCreateRequest request);
|
||||
|
||||
/**
|
||||
* 更新数据分组关联
|
||||
* 添加关联
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
* @param list list
|
||||
*/
|
||||
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);
|
||||
void addGroupRel(List<DataGroupRelCreateRequest> list);
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组关联
|
||||
*
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelVO> getDataGroupRelListByCache();
|
||||
List<DataGroupRelCacheDTO> getGroupRelListByCache(String type);
|
||||
|
||||
/**
|
||||
* 查询数据分组关联数量
|
||||
* 通过缓存查询数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupRelCount(DataGroupRelQueryRequest request);
|
||||
|
||||
/**
|
||||
* 分页查询数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @param type type
|
||||
* @param groupId groupId
|
||||
* @return rows
|
||||
*/
|
||||
DataGrid<DataGroupRelVO> getDataGroupRelPage(DataGroupRelQueryRequest request);
|
||||
List<DataGroupRelCacheDTO> getGroupRelListByCache(String type, Long groupId);
|
||||
|
||||
/**
|
||||
* 删除数据分组关联
|
||||
*
|
||||
* @param id id
|
||||
* @param type type
|
||||
* @param relId relId
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelById(Long id);
|
||||
Integer deleteByRelId(String type, Long relId);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组关联
|
||||
*
|
||||
* @param idList idList
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRelByIdList(List<Long> idList);
|
||||
Integer deleteByRelIdList(String type, List<Long> relIdList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组关联
|
||||
* 批量删除数据分组关联
|
||||
*
|
||||
* @param request request
|
||||
* @param type type
|
||||
* @param groupIdList groupIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupRel(DataGroupRelQueryRequest request);
|
||||
Integer deleteByGroupIdList(String type, List<Long> groupIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
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 com.orion.ops.module.infra.entity.dto.DataGroupCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupUpdateRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,68 +24,22 @@ public interface DataGroupService {
|
||||
Long createDataGroup(DataGroupCreateRequest request);
|
||||
|
||||
/**
|
||||
* 更新数据分组
|
||||
* 重命名分组
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
* @return id
|
||||
*/
|
||||
Integer updateDataGroupById(DataGroupUpdateRequest request);
|
||||
Integer renameDataGroup(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);
|
||||
// FIXME drag
|
||||
|
||||
/**
|
||||
* 通过缓存查询数据分组
|
||||
*
|
||||
* @param type type
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupVO> getDataGroupListByCache();
|
||||
|
||||
/**
|
||||
* 查询数据分组数量
|
||||
*
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Long getDataGroupCount(DataGroupQueryRequest request);
|
||||
|
||||
/**
|
||||
* 分页查询数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
DataGrid<DataGroupVO> getDataGroupPage(DataGroupQueryRequest request);
|
||||
List<DataGroupCacheDTO> getDataGroupListByCache(String type);
|
||||
|
||||
/**
|
||||
* 删除数据分组
|
||||
@@ -101,20 +49,4 @@ public interface DataGroupService {
|
||||
*/
|
||||
Integer deleteDataGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据分组
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据条件删除数据分组
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroup(DataGroupQueryRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
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.define.cache.CacheKeyDefine;
|
||||
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.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.ops.module.infra.convert.DataGroupRelConvert;
|
||||
import com.orion.ops.module.infra.dao.DataGroupDAO;
|
||||
import com.orion.ops.module.infra.dao.DataGroupRelDAO;
|
||||
import com.orion.ops.module.infra.define.cache.DataGroupCacheKeyDefine;
|
||||
import com.orion.ops.module.infra.entity.domain.DataGroupDO;
|
||||
import com.orion.ops.module.infra.entity.domain.DataGroupRelDO;
|
||||
import com.orion.ops.module.infra.entity.dto.DataGroupRelCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupRelCreateRequest;
|
||||
import com.orion.ops.module.infra.service.DataGroupRelService;
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -41,94 +39,133 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
|
||||
@Resource
|
||||
private DataGroupDAO dataGroupDAO;
|
||||
|
||||
@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);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addGroupRel(DataGroupRelCreateRequest request) {
|
||||
DataGroupRelCreateRequest record = DataGroupRelCreateRequest.builder()
|
||||
.groupId(Valid.notNull(request.getGroupId()))
|
||||
.relId(Valid.notNull(request.getRelId()))
|
||||
.sort(request.getSort())
|
||||
.build();
|
||||
// 插入
|
||||
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;
|
||||
SpringHolder.getBean(DataGroupRelService.class)
|
||||
.addGroupRel(Lists.singleton(record));
|
||||
}
|
||||
|
||||
@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();
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addGroupRel(List<DataGroupRelCreateRequest> list) {
|
||||
if (Lists.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
// 转换
|
||||
return DataGroupRelConvert.MAPPER.to(records);
|
||||
// 设置默认排序
|
||||
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));
|
||||
// 查询分组信息
|
||||
List<DataGroupDO> groups = dataGroupDAO.selectBatchIds(groupMapping.keySet());
|
||||
Valid.eq(groups.size(), groupMapping.size(), ErrorMessage.GROUP_ABSENT);
|
||||
Map<Long, String> groupTypeMapping = groups.stream()
|
||||
.collect(Collectors.toMap(DataGroupDO::getId, DataGroupDO::getType));
|
||||
// 查询关联是否存在
|
||||
groupMapping.forEach((k, v) -> {
|
||||
List<Long> relIdList = v.stream()
|
||||
.map(DataGroupRelCreateRequest::getRelId)
|
||||
.collect(Collectors.toList());
|
||||
// 查询关联
|
||||
List<Long> presentRelIdList = dataGroupRelDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataGroupRelDO::getGroupId, k)
|
||||
.in(DataGroupRelDO::getRelId, relIdList)
|
||||
.then()
|
||||
.stream()
|
||||
.map(DataGroupRelDO::getRelId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (!presentRelIdList.isEmpty()) {
|
||||
// 删除待插入的重复数据
|
||||
v.removeIf(s -> presentRelIdList.contains(s.getRelId()));
|
||||
}
|
||||
});
|
||||
// 构建插入数据
|
||||
List<DataGroupRelDO> records = new ArrayList<>();
|
||||
groupMapping.forEach((k, v) -> {
|
||||
v.forEach(s -> records.add(DataGroupRelDO.builder()
|
||||
.groupId(k)
|
||||
.type(groupTypeMapping.get(k))
|
||||
.relId(s.getRelId())
|
||||
.sort(s.getSort())
|
||||
.build()));
|
||||
});
|
||||
// 插入
|
||||
dataGroupRelDAO.insertBatch(records);
|
||||
// 删除缓存
|
||||
List<String> groupKeyList = groups.stream()
|
||||
.map(DataGroupDO::getId)
|
||||
.map(DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP::format)
|
||||
.collect(Collectors.toList());
|
||||
groups.stream()
|
||||
.map(DataGroupDO::getType)
|
||||
.distinct()
|
||||
.map(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE::format)
|
||||
.forEach(groupKeyList::add);
|
||||
RedisStrings.delete(groupKeyList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupRelVO> getDataGroupRelList(DataGroupRelQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DataGroupRelDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dataGroupRelDAO.of(wrapper).list(DataGroupRelConvert.MAPPER::to);
|
||||
public List<DataGroupRelCacheDTO> getGroupRelListByCache(String type) {
|
||||
return this.getGroupRelListByCache(
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type),
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE,
|
||||
() -> dataGroupRelDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataGroupRelDO::getType, type)
|
||||
.then()
|
||||
.list(DataGroupRelConvert.MAPPER::toCache)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupRelVO> getDataGroupRelListByCache() {
|
||||
public List<DataGroupRelCacheDTO> getGroupRelListByCache(String type, Long groupId) {
|
||||
return this.getGroupRelListByCache(
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP.format(type),
|
||||
DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP,
|
||||
() -> dataGroupRelDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataGroupRelDO::getType, type)
|
||||
.eq(DataGroupRelDO::getGroupId, groupId)
|
||||
.then()
|
||||
.list(DataGroupRelConvert.MAPPER::toCache)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分组引用缓存
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param valueSupplier valueSupplier
|
||||
* @return values
|
||||
*/
|
||||
public List<DataGroupRelCacheDTO> getGroupRelListByCache(String key,
|
||||
CacheKeyDefine define,
|
||||
Supplier<List<DataGroupRelCacheDTO>> valueSupplier) {
|
||||
// 查询缓存
|
||||
List<DataGroupRelCacheDTO> list = RedisMaps.valuesJson(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
List<DataGroupRelCacheDTO> list = RedisStrings.getJsonArray(key, define);
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = dataGroupRelDAO.of().list(DataGroupRelConvert.MAPPER::toCache);
|
||||
list = valueSupplier.get();
|
||||
// 添加默认值 防止穿透
|
||||
if (list.isEmpty()) {
|
||||
list.add(DataGroupRelCacheDTO.builder()
|
||||
@@ -136,112 +173,61 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
.build());
|
||||
}
|
||||
// 设置缓存
|
||||
RedisMaps.putAllJson(DataGroupRelCacheKeyDefine.DATA_GROUP_REL.getKey(), s -> s.getId().toString(), list);
|
||||
RedisMaps.setExpire(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
RedisStrings.setJson(key, define, list);
|
||||
}
|
||||
// 删除默认值
|
||||
return list.stream()
|
||||
.filter(s -> !s.getId().equals(Const.NONE_ID))
|
||||
.map(DataGroupRelConvert.MAPPER::to)
|
||||
list.removeIf(s -> s.getId().equals(Const.NONE_ID));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteByRelId(String type, Long relId) {
|
||||
return SpringHolder.getBean(DataGroupRelService.class)
|
||||
.deleteByRelIdList(type, Lists.singleton(relId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteByRelIdList(String type, List<Long> relIdList) {
|
||||
if (Strings.isBlank(type) || Lists.isEmpty(relIdList)) {
|
||||
return 0;
|
||||
}
|
||||
// 查询 group
|
||||
List<Long> groupIdList = dataGroupRelDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataGroupRelDO::getType, type)
|
||||
.in(DataGroupRelDO::getRelId, relIdList)
|
||||
.then()
|
||||
.stream()
|
||||
.map(DataGroupRelDO::getGroupId)
|
||||
.distinct()
|
||||
.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);
|
||||
// 删除数据库
|
||||
int effect = dataGroupRelDAO.deleteBatchIds(relIdList);
|
||||
// 获取缓存 key
|
||||
List<String> keyList = Lists.of(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type));
|
||||
groupIdList.stream()
|
||||
.map(DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP::format)
|
||||
.forEach(keyList::add);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL, id);
|
||||
RedisStrings.delete(keyList);
|
||||
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);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteByGroupIdList(String type, List<Long> groupIdList) {
|
||||
// 删除数据库
|
||||
int effect = dataGroupRelDAO.deleteByGroupId(groupIdList);
|
||||
// 删除缓存
|
||||
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);
|
||||
List<String> keyList = Lists.of(DataGroupCacheKeyDefine.DATA_GROUP_REL_TYPE.format(type));
|
||||
groupIdList.stream()
|
||||
.map(DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP::format)
|
||||
.forEach(keyList::add);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupRelCacheKeyDefine.DATA_GROUP_REL);
|
||||
RedisStrings.delete(keyList);
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,32 +2,25 @@ 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.convert.DataGroupConvert;
|
||||
import com.orion.ops.module.infra.dao.DataGroupDAO;
|
||||
import com.orion.ops.module.infra.define.cache.DataGroupCacheKeyDefine;
|
||||
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.request.data.DataGroupCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataGroupUpdateRequest;
|
||||
import com.orion.ops.module.infra.service.DataGroupRelService;
|
||||
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 org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
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;
|
||||
|
||||
@@ -45,6 +38,9 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
@Resource
|
||||
private DataGroupDAO dataGroupDAO;
|
||||
|
||||
@Resource
|
||||
private DataGroupRelService dataGroupRelService;
|
||||
|
||||
@Override
|
||||
public Long createDataGroup(DataGroupCreateRequest request) {
|
||||
log.info("DataGroupService-createDataGroup request: {}", JSON.toJSONString(request));
|
||||
@@ -57,79 +53,44 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
Long id = record.getId();
|
||||
log.info("DataGroupService-createDataGroup id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP.format(request.getType()));
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateDataGroupById(DataGroupUpdateRequest request) {
|
||||
public Integer renameDataGroup(DataGroupUpdateRequest request) {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
log.info("DataGroupService-updateDataGroupById id: {}, request: {}", id, JSON.toJSONString(request));
|
||||
String name = Valid.notBlank(request.getName());
|
||||
// 查询
|
||||
DataGroupDO record = dataGroupDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
Valid.notNull(record, ErrorMessage.GROUP_ABSENT);
|
||||
// 转换
|
||||
DataGroupDO updateRecord = DataGroupConvert.MAPPER.to(request);
|
||||
DataGroupDO updateRecord = DataGroupDO.builder()
|
||||
.id(id)
|
||||
.name(name)
|
||||
.parentId(record.getParentId())
|
||||
.build();
|
||||
// 查询数据是否冲突
|
||||
this.checkDataGroupPresent(updateRecord);
|
||||
// 更新
|
||||
int effect = dataGroupDAO.updateById(updateRecord);
|
||||
log.info("DataGroupService-updateDataGroupById effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP.format(record.getType()));
|
||||
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() {
|
||||
public List<DataGroupCacheDTO> getDataGroupListByCache(String type) {
|
||||
// 查询缓存
|
||||
List<DataGroupCacheDTO> list = RedisMaps.valuesJson(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
String key = DataGroupCacheKeyDefine.DATA_GROUP.format(type);
|
||||
List<DataGroupCacheDTO> list = RedisStrings.getJsonArray(key, DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = dataGroupDAO.of().list(DataGroupConvert.MAPPER::toCache);
|
||||
list = dataGroupDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataGroupDO::getType, type)
|
||||
.then()
|
||||
.list(DataGroupConvert.MAPPER::toCache);
|
||||
// 添加默认值 防止穿透
|
||||
if (list.isEmpty()) {
|
||||
list.add(DataGroupCacheDTO.builder()
|
||||
@@ -137,69 +98,53 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
.build());
|
||||
}
|
||||
// 设置缓存
|
||||
RedisMaps.putAllJson(DataGroupCacheKeyDefine.DATA_GROUP.getKey(), s -> s.getId().toString(), list);
|
||||
RedisMaps.setExpire(DataGroupCacheKeyDefine.DATA_GROUP);
|
||||
RedisStrings.setJson(key, DataGroupCacheKeyDefine.DATA_GROUP, list);
|
||||
}
|
||||
// 删除默认值
|
||||
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);
|
||||
list.removeIf(s -> s.getId().equals(Const.NONE_ID));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
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);
|
||||
Valid.notNull(record, ErrorMessage.GROUP_ABSENT);
|
||||
String type = record.getType();
|
||||
// 查询子级
|
||||
List<Long> deleteIdList = Lists.of(id);
|
||||
this.flatChildrenId(Lists.singleton(id), deleteIdList);
|
||||
// 删除分组
|
||||
int effect = dataGroupDAO.deleteBatchIds(deleteIdList);
|
||||
// 删除组内数据
|
||||
dataGroupRelService.deleteByGroupIdList(type, deleteIdList);
|
||||
log.info("DataGroupService-deleteDataGroupById id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataGroupCacheKeyDefine.DATA_GROUP, id);
|
||||
RedisStrings.delete(DataGroupCacheKeyDefine.DATA_GROUP.format(type));
|
||||
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;
|
||||
/**
|
||||
* 获取所有子节点 id
|
||||
*
|
||||
* @param parentIdList parentIdList
|
||||
* @param result result
|
||||
*/
|
||||
private void flatChildrenId(List<Long> parentIdList, List<Long> result) {
|
||||
// 查询数据
|
||||
List<DataGroupDO> rows = dataGroupDAO.selectByParentId(parentIdList);
|
||||
if (rows.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Long> idList = rows.stream()
|
||||
.map(DataGroupDO::getId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
result.addAll(idList);
|
||||
// 递归
|
||||
this.flatChildrenId(idList, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,27 +166,4 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.orion.ops.module.infra.enums.FavoriteTypeEnum;
|
||||
import com.orion.ops.module.infra.service.FavoriteService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -126,7 +125,6 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void deleteFavoriteByUserIdList(List<Long> userIdList) {
|
||||
if (Lists.isEmpty(userIdList)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user