|
@@ -1,9 +1,9 @@
|
|
|
package cn.com.yusys.yusp.service.impl;
|
|
package cn.com.yusys.yusp.service.impl;
|
|
|
|
|
|
|
|
-import cn.com.yusys.yusp.domain.dto.AitagTagCategoryCreateDTO;
|
|
|
|
|
-import cn.com.yusys.yusp.domain.dto.AitagTagCategoryUpdateDTO;
|
|
|
|
|
|
|
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryCreateDto;
|
|
|
|
|
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryUpdateDto;
|
|
|
import cn.com.yusys.yusp.domain.entity.AitagTagCategory;
|
|
import cn.com.yusys.yusp.domain.entity.AitagTagCategory;
|
|
|
-import cn.com.yusys.yusp.domain.vo.AitagTagCategoryVO;
|
|
|
|
|
|
|
+import cn.com.yusys.yusp.domain.vo.AitagTagCategoryVo;
|
|
|
import cn.com.yusys.yusp.mapper.AitagTagCategoryMapper;
|
|
import cn.com.yusys.yusp.mapper.AitagTagCategoryMapper;
|
|
|
import cn.com.yusys.yusp.service.AitagTagCategoryService;
|
|
import cn.com.yusys.yusp.service.AitagTagCategoryService;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -21,14 +21,14 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
|
|
|
private AitagTagCategoryMapper aiTagCategoryMapper;
|
|
private AitagTagCategoryMapper aiTagCategoryMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Page<AitagTagCategoryVO> listCategories(int page, int size) {
|
|
|
|
|
|
|
+ public Page<AitagTagCategoryVo> listCategories(int page, int size) {
|
|
|
int offset = (page - 1) * size;
|
|
int offset = (page - 1) * size;
|
|
|
List<AitagTagCategory> records = aiTagCategoryMapper.selectPageCategories(offset, size);
|
|
List<AitagTagCategory> records = aiTagCategoryMapper.selectPageCategories(offset, size);
|
|
|
long total = aiTagCategoryMapper.selectCountAll();
|
|
long total = aiTagCategoryMapper.selectCountAll();
|
|
|
|
|
|
|
|
// 转换为 VO 并动态计算 tagNum
|
|
// 转换为 VO 并动态计算 tagNum
|
|
|
- List<AitagTagCategoryVO> voList = records.stream().map(category -> {
|
|
|
|
|
- AitagTagCategoryVO vo = new AitagTagCategoryVO();
|
|
|
|
|
|
|
+ List<AitagTagCategoryVo> voList = records.stream().map(category -> {
|
|
|
|
|
+ AitagTagCategoryVo vo = new AitagTagCategoryVo();
|
|
|
vo.setId(category.getId());
|
|
vo.setId(category.getId());
|
|
|
vo.setCategoryCode(category.getCategoryCode());
|
|
vo.setCategoryCode(category.getCategoryCode());
|
|
|
vo.setCategoryNm(category.getCategoryNm());
|
|
vo.setCategoryNm(category.getCategoryNm());
|
|
@@ -44,14 +44,14 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
|
|
|
return vo;
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
- Page<AitagTagCategoryVO> pageObj = new Page<>(page, size, total);
|
|
|
|
|
|
|
+ Page<AitagTagCategoryVo> pageObj = new Page<>(page, size, total);
|
|
|
pageObj.setRecords(voList);
|
|
pageObj.setRecords(voList);
|
|
|
return pageObj;
|
|
return pageObj;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public AitagTagCategory createCategory(AitagTagCategoryCreateDTO dto) {
|
|
|
|
|
|
|
+ public AitagTagCategory createCategory(AitagTagCategoryCreateDto dto) {
|
|
|
// 校验唯一性
|
|
// 校验唯一性
|
|
|
if (aiTagCategoryMapper.selectCountByNameAndNotDeleted(dto.getCategoryNm()) > 0) {
|
|
if (aiTagCategoryMapper.selectCountByNameAndNotDeleted(dto.getCategoryNm()) > 0) {
|
|
|
throw new RuntimeException("标签体系名称已存在");
|
|
throw new RuntimeException("标签体系名称已存在");
|
|
@@ -69,7 +69,7 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public AitagTagCategory updateCategory(AitagTagCategoryUpdateDTO dto) {
|
|
|
|
|
|
|
+ public AitagTagCategory updateCategory(AitagTagCategoryUpdateDto dto) {
|
|
|
AitagTagCategory existing = aiTagCategoryMapper.selectById(dto.getId());
|
|
AitagTagCategory existing = aiTagCategoryMapper.selectById(dto.getId());
|
|
|
if (existing == null) {
|
|
if (existing == null) {
|
|
|
throw new RuntimeException("标签体系不存在");
|
|
throw new RuntimeException("标签体系不存在");
|
|
@@ -100,9 +100,18 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
|
|
|
if (category == null) {
|
|
if (category == null) {
|
|
|
throw new RuntimeException("标签体系不存在");
|
|
throw new RuntimeException("标签体系不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 检查标签数量
|
|
|
|
|
+ int tagCount = aiTagCategoryMapper.countTagsByCategoryId(id);
|
|
|
|
|
+ if (tagCount == 0) {
|
|
|
|
|
+ throw new RuntimeException("体系内无可用标签!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查当前状态
|
|
|
if (category.getState() == 0) {
|
|
if (category.getState() == 0) {
|
|
|
- throw new RuntimeException("标签体系已经是启用状态");
|
|
|
|
|
|
|
+ throw new RuntimeException("当前已为启用状态!");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
aiTagCategoryMapper.updateState(id, 0);
|
|
aiTagCategoryMapper.updateState(id, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -112,9 +121,12 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
|
|
|
if (category == null) {
|
|
if (category == null) {
|
|
|
throw new RuntimeException("标签体系不存在");
|
|
throw new RuntimeException("标签体系不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 检查当前状态
|
|
|
if (category.getState() == 1) {
|
|
if (category.getState() == 1) {
|
|
|
- throw new RuntimeException("标签体系已经是停用状态");
|
|
|
|
|
|
|
+ throw new RuntimeException("当前已为停用状态!");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
aiTagCategoryMapper.updateState(id, 1);
|
|
aiTagCategoryMapper.updateState(id, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|