|
@@ -5,6 +5,10 @@ import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopCostInstTp;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopCostInstTpItem;
|
|
|
+import com.zhongzheng.modules.top.financial.service.ITopCostInstTpItemService;
|
|
|
import com.zhongzheng.modules.top.system.bo.TopInstCategoryAddBo;
|
|
|
import com.zhongzheng.modules.top.system.bo.TopInstCategoryEditBo;
|
|
|
import com.zhongzheng.modules.top.system.bo.TopInstCategoryQueryBo;
|
|
@@ -13,6 +17,7 @@ import com.zhongzheng.modules.top.system.domain.TopInstitution;
|
|
|
import com.zhongzheng.modules.top.system.mapper.TopInstCategoryMapper;
|
|
|
import com.zhongzheng.modules.top.system.service.ITopInstCategoryService;
|
|
|
import com.zhongzheng.modules.top.system.vo.TopInstCategoryVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -33,6 +38,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class TopInstCategoryServiceImpl extends ServiceImpl<TopInstCategoryMapper, TopInstCategory> implements ITopInstCategoryService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITopCostInstTpItemService iTopCostInstTpItemService;
|
|
|
+
|
|
|
@Override
|
|
|
public TopInstCategoryVo queryById(Long costCatId){
|
|
|
TopInstCategory db = this.baseMapper.selectById(costCatId);
|
|
@@ -91,6 +99,11 @@ public class TopInstCategoryServiceImpl extends ServiceImpl<TopInstCategoryMappe
|
|
|
*/
|
|
|
private void validEntityBeforeSave(TopInstCategory entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ if(iTopCostInstTpItemService.count(new LambdaQueryWrapper<TopCostInstTpItem>()
|
|
|
+ .eq(TopCostInstTpItem::getCostCatId, entity.getCostCatId())
|
|
|
+ .ne(TopCostInstTpItem::getStatus, -1))>0){
|
|
|
+ throw new CustomException("该分类已被使用,无法编辑和删除");
|
|
|
+ }
|
|
|
if(checkNameUnique(entity)){
|
|
|
throw new CustomException("名称重复");
|
|
|
}
|
|
@@ -104,7 +117,21 @@ public class TopInstCategoryServiceImpl extends ServiceImpl<TopInstCategoryMappe
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean deleteBatch(TopInstCategoryEditBo bo) {
|
|
|
+ for(Long id : bo.getCostCatIds()){
|
|
|
+ TopInstCategory update = new TopInstCategory();
|
|
|
+ update.setCostCatId(id);
|
|
|
+ update.setStatus(-1);
|
|
|
+ this.updateById(update);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
private boolean checkNameUnique(TopInstCategory entity) {
|
|
|
+ if(Validator.isEmpty(entity.getCategoryName())){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
TopInstCategory info = getOne(new LambdaQueryWrapper<TopInstCategory>()
|
|
|
.eq(TopInstCategory::getCategoryName,entity.getCategoryName()).ne(TopInstCategory::getStatus,-1)
|
|
|
.last("limit 1"));
|