|
@@ -4,10 +4,13 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.text.StrFormatter;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.persagy.dc.basic.constant.DigitalMessageConstant;
|
|
|
+import com.persagy.dc.basic.utils.DigitalCommonUtils;
|
|
|
import com.persagy.dc.basic.utils.DigitalMessageHelper;
|
|
|
import com.persagy.dc.common.constant.ValidEnum;
|
|
|
import com.persagy.dc.common.exception.BusinessException;
|
|
@@ -16,6 +19,8 @@ import com.persagy.dc.define.dao.ObjectTypeMapper;
|
|
|
import com.persagy.dc.define.entity.ObjectType;
|
|
|
import com.persagy.dc.define.service.IObjectTypeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.cache.annotation.CacheEvict;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -37,6 +42,41 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
|
private DigitalMessageHelper messageSender;
|
|
|
|
|
|
@Override
|
|
|
+ @Cacheable(key = "targetClass + methodName + #p0 + #p1")
|
|
|
+ public List<ObjectType> queryByProjectAndApp(String projectId, String appId) {
|
|
|
+ // TODO 指定条件查询使用Redis
|
|
|
+ QueryWrapper<ObjectType> wrapper = new QueryWrapper<>();
|
|
|
+ DigitalCommonUtils.ensureProjectCriteria(wrapper, projectId);
|
|
|
+ if(StrUtil.isNotBlank(appId)) {
|
|
|
+ // TODO 根据应用ID关联订阅条件
|
|
|
+
|
|
|
+ }
|
|
|
+ return queryByCondition(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Cacheable(key = "targetClass + methodName")
|
|
|
+ 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);
|
|
|
+ return CollUtil.fieldValueAsMap(voList, "code", "name");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page queryByProjectAndApp(Page page, String projectId, String appId) {
|
|
|
+ // TODO 分页查询使用ES
|
|
|
+ QueryWrapper<ObjectType> wrapper = new QueryWrapper<>();
|
|
|
+ DigitalCommonUtils.ensureProjectCriteria(wrapper, projectId);
|
|
|
+ if(StrUtil.isNotBlank(appId)) {
|
|
|
+ // TODO 根据应用ID关联订阅条件
|
|
|
+
|
|
|
+ }
|
|
|
+ return queryByCondition(page, wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<ObjectType> queryByCondition(Wrapper<ObjectType> queryWrapper) {
|
|
|
return dao.selectList(queryWrapper);
|
|
|
}
|
|
@@ -47,6 +87,7 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @CacheEvict(allEntries = true)
|
|
|
public List<ObjectType> insert(List<ObjectType> voList) {
|
|
|
if(CollUtil.isEmpty(voList)) {
|
|
|
return null;
|
|
@@ -64,6 +105,7 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @CacheEvict(allEntries = true)
|
|
|
public List<ObjectType> update(List<ObjectType> voList) {
|
|
|
if(CollUtil.isEmpty(voList)) {
|
|
|
return null;
|
|
@@ -125,6 +167,7 @@ public class ObjectTypeServiceImpl implements IObjectTypeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @CacheEvict(allEntries = true)
|
|
|
public void delete(List<String> idList) {
|
|
|
if(CollUtil.isEmpty(idList)) {
|
|
|
return;
|