|
@@ -16,7 +16,7 @@ import com.persagy.dc.common.constant.ValidEnum;
|
|
import com.persagy.dc.common.exception.BusinessException;
|
|
import com.persagy.dc.common.exception.BusinessException;
|
|
import com.persagy.dc.common.model.entity.BaseEntity;
|
|
import com.persagy.dc.common.model.entity.BaseEntity;
|
|
import com.persagy.dc.define.dao.ObjectTypeMapper;
|
|
import com.persagy.dc.define.dao.ObjectTypeMapper;
|
|
-import com.persagy.dc.define.entity.ObjectType;
|
|
|
|
|
|
+import com.persagy.dc.define.entity.ObjectTypeDefine;
|
|
import com.persagy.dc.define.service.IObjectTypeService;
|
|
import com.persagy.dc.define.service.IObjectTypeService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.cache.annotation.CacheConfig;
|
|
import org.springframework.cache.annotation.CacheConfig;
|
|
@@ -45,9 +45,9 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Cacheable(key = "targetClass + methodName + #p0 + #p1")
|
|
@Cacheable(key = "targetClass + methodName + #p0 + #p1")
|
|
- public List<ObjectType> queryByProjectAndApp(String projectId, String appId) {
|
|
|
|
|
|
+ public List<ObjectTypeDefine> queryByProjectAndApp(String projectId, String appId) {
|
|
// TODO 指定条件查询使用Redis
|
|
// TODO 指定条件查询使用Redis
|
|
- QueryWrapper<ObjectType> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
+ QueryWrapper<ObjectTypeDefine> wrapper = new QueryWrapper<>();
|
|
DigitalCommonUtils.ensureProjectCriteria(wrapper, projectId);
|
|
DigitalCommonUtils.ensureProjectCriteria(wrapper, projectId);
|
|
if(StrUtil.isNotBlank(appId)) {
|
|
if(StrUtil.isNotBlank(appId)) {
|
|
// TODO 根据应用ID关联订阅条件
|
|
// TODO 根据应用ID关联订阅条件
|
|
@@ -59,17 +59,17 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
@Override
|
|
@Override
|
|
@Cacheable(key = "targetClass + methodName")
|
|
@Cacheable(key = "targetClass + methodName")
|
|
public Map<String, String> queryCodeNameMap() {
|
|
public Map<String, String> queryCodeNameMap() {
|
|
- LambdaQueryWrapper<ObjectType> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
- wrapper.select(ObjectType::getId, ObjectType::getCode, ObjectType::getName);
|
|
|
|
- wrapper.eq(ObjectType::getValid, ValidEnum.TRUE.getType());
|
|
|
|
- List<ObjectType> voList = queryByCondition(wrapper);
|
|
|
|
|
|
+ LambdaQueryWrapper<ObjectTypeDefine> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.select(ObjectTypeDefine::getId, ObjectTypeDefine::getCode, ObjectTypeDefine::getName);
|
|
|
|
+ wrapper.eq(ObjectTypeDefine::getValid, ValidEnum.TRUE.getType());
|
|
|
|
+ List<ObjectTypeDefine> voList = queryByCondition(wrapper);
|
|
return CollUtil.fieldValueAsMap(voList, "code", "name");
|
|
return CollUtil.fieldValueAsMap(voList, "code", "name");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page queryByProjectAndApp(Page page, String projectId, String appId) {
|
|
public Page queryByProjectAndApp(Page page, String projectId, String appId) {
|
|
// TODO 分页查询使用ES
|
|
// TODO 分页查询使用ES
|
|
- QueryWrapper<ObjectType> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
+ QueryWrapper<ObjectTypeDefine> wrapper = new QueryWrapper<>();
|
|
DigitalCommonUtils.ensureProjectCriteria(wrapper, projectId);
|
|
DigitalCommonUtils.ensureProjectCriteria(wrapper, projectId);
|
|
if(StrUtil.isNotBlank(appId)) {
|
|
if(StrUtil.isNotBlank(appId)) {
|
|
// TODO 根据应用ID关联订阅条件
|
|
// TODO 根据应用ID关联订阅条件
|
|
@@ -79,18 +79,18 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ObjectType> queryByCondition(Wrapper<ObjectType> queryWrapper) {
|
|
|
|
|
|
+ public List<ObjectTypeDefine> queryByCondition(Wrapper<ObjectTypeDefine> queryWrapper) {
|
|
return dao.selectList(queryWrapper);
|
|
return dao.selectList(queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Page queryByCondition(Page page, Wrapper<ObjectType> queryWrapper) {
|
|
|
|
|
|
+ public Page queryByCondition(Page page, Wrapper<ObjectTypeDefine> queryWrapper) {
|
|
return dao.selectPage(page, queryWrapper);
|
|
return dao.selectPage(page, queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@CacheEvict(allEntries = true)
|
|
@CacheEvict(allEntries = true)
|
|
- public List<ObjectType> insert(List<ObjectType> voList) {
|
|
|
|
|
|
+ public List<ObjectTypeDefine> insert(List<ObjectTypeDefine> voList) {
|
|
if(CollUtil.isEmpty(voList)) {
|
|
if(CollUtil.isEmpty(voList)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -108,16 +108,16 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@CacheEvict(allEntries = true)
|
|
@CacheEvict(allEntries = true)
|
|
- public List<ObjectType> update(List<ObjectType> voList) {
|
|
|
|
|
|
+ public List<ObjectTypeDefine> update(List<ObjectTypeDefine> voList) {
|
|
if(CollUtil.isEmpty(voList)) {
|
|
if(CollUtil.isEmpty(voList)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
validateOnSave(voList, true);
|
|
validateOnSave(voList, true);
|
|
List<String> idList = CollUtil.getFieldValues(voList, BaseEntity.PROP_ID, String.class);
|
|
List<String> idList = CollUtil.getFieldValues(voList, BaseEntity.PROP_ID, String.class);
|
|
- List<ObjectType> dbList = dao.selectBatchIds(idList);
|
|
|
|
- Map<String, ObjectType> dbMap = CollectionUtil.fieldValueMap(dbList, BaseEntity.PROP_ID);
|
|
|
|
|
|
+ List<ObjectTypeDefine> dbList = dao.selectBatchIds(idList);
|
|
|
|
+ Map<String, ObjectTypeDefine> dbMap = CollectionUtil.fieldValueMap(dbList, BaseEntity.PROP_ID);
|
|
voList.forEach(vo -> {
|
|
voList.forEach(vo -> {
|
|
- ObjectType dbVO = MapUtil.get(dbMap, vo.getId(), ObjectType.class);
|
|
|
|
|
|
+ ObjectTypeDefine dbVO = MapUtil.get(dbMap, vo.getId(), ObjectTypeDefine.class);
|
|
// 容错处理
|
|
// 容错处理
|
|
if(dbVO == null) {
|
|
if(dbVO == null) {
|
|
return;
|
|
return;
|
|
@@ -138,10 +138,10 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
* @param voList
|
|
* @param voList
|
|
* @param isUpdate
|
|
* @param isUpdate
|
|
*/
|
|
*/
|
|
- private void validateOnSave(List<ObjectType> voList, boolean isUpdate) {
|
|
|
|
|
|
+ private void validateOnSave(List<ObjectTypeDefine> voList, boolean isUpdate) {
|
|
Set<String> codeSet = new HashSet<>();
|
|
Set<String> codeSet = new HashSet<>();
|
|
List<String> idList = new ArrayList<>();
|
|
List<String> idList = new ArrayList<>();
|
|
- for(ObjectType vo:voList) {
|
|
|
|
|
|
+ for(ObjectTypeDefine vo:voList) {
|
|
// 编码重复
|
|
// 编码重复
|
|
if(!codeSet.add(vo.getCode())) {
|
|
if(!codeSet.add(vo.getCode())) {
|
|
throw new BusinessException(StrFormatter.format("存在重复编码{},不允许保存!", vo.getCode()));
|
|
throw new BusinessException(StrFormatter.format("存在重复编码{},不允许保存!", vo.getCode()));
|
|
@@ -152,15 +152,15 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 查询条件
|
|
// 查询条件
|
|
- LambdaQueryWrapper<ObjectType> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper.select(ObjectType::getCode);
|
|
|
|
- queryWrapper.in(ObjectType::getValid, ValidEnum.TRUE.getType());
|
|
|
|
- queryWrapper.in(ObjectType::getCode, codeSet);
|
|
|
|
|
|
+ LambdaQueryWrapper<ObjectTypeDefine> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.select(ObjectTypeDefine::getCode);
|
|
|
|
+ queryWrapper.in(ObjectTypeDefine::getValid, ValidEnum.TRUE.getType());
|
|
|
|
+ queryWrapper.in(ObjectTypeDefine::getCode, codeSet);
|
|
if(isUpdate) {
|
|
if(isUpdate) {
|
|
- queryWrapper.notIn(ObjectType::getId, idList);
|
|
|
|
|
|
+ queryWrapper.notIn(ObjectTypeDefine::getId, idList);
|
|
}
|
|
}
|
|
// 查询重复的编码
|
|
// 查询重复的编码
|
|
- List<ObjectType> dbList = dao.selectList(queryWrapper);
|
|
|
|
|
|
+ List<ObjectTypeDefine> dbList = dao.selectList(queryWrapper);
|
|
if(CollUtil.isEmpty(dbList)) {
|
|
if(CollUtil.isEmpty(dbList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -174,10 +174,10 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
if(CollUtil.isEmpty(idList)) {
|
|
if(CollUtil.isEmpty(idList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- List<ObjectType> dbList = dao.selectBatchIds(idList);
|
|
|
|
- Map<String, ObjectType> dbMap = CollectionUtil.fieldValueMap(dbList, BaseEntity.PROP_ID);
|
|
|
|
|
|
+ List<ObjectTypeDefine> dbList = dao.selectBatchIds(idList);
|
|
|
|
+ Map<String, ObjectTypeDefine> dbMap = CollectionUtil.fieldValueMap(dbList, BaseEntity.PROP_ID);
|
|
idList.forEach(id -> {
|
|
idList.forEach(id -> {
|
|
- ObjectType dbVO = MapUtil.get(dbMap, id, ObjectType.class);
|
|
|
|
|
|
+ ObjectTypeDefine dbVO = MapUtil.get(dbMap, id, ObjectTypeDefine.class);
|
|
// 容错处理
|
|
// 容错处理
|
|
if(dbVO == null) {
|
|
if(dbVO == null) {
|
|
return;
|
|
return;
|
|
@@ -185,7 +185,7 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
// 删除前消息 - 暂不提供同步消息
|
|
// 删除前消息 - 暂不提供同步消息
|
|
/// messageSender.sendMessage(DigitalMessageConstant.OPERATE_BEFORE_DELETE, null, dbVO, true);
|
|
/// messageSender.sendMessage(DigitalMessageConstant.OPERATE_BEFORE_DELETE, null, dbVO, true);
|
|
// 删除
|
|
// 删除
|
|
- ObjectType vo = new ObjectType();
|
|
|
|
|
|
+ ObjectTypeDefine vo = new ObjectTypeDefine();
|
|
vo.setId(id);
|
|
vo.setId(id);
|
|
vo.setValid(ValidEnum.FALSE.getType());
|
|
vo.setValid(ValidEnum.FALSE.getType());
|
|
dao.updateById(vo);
|
|
dao.updateById(vo);
|