|
@@ -1,5 +1,6 @@
|
|
|
package com.jeeplus.test.jobPosion.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -27,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Api("职务分类管理")
|
|
|
@RestController
|
|
@@ -81,11 +83,21 @@ public class PositionCategoryController {
|
|
|
PositionLogDTO positionLogDTO = new PositionLogDTO();
|
|
|
PositionCategory positionCategory = PositionCategoryWrapper.INSTANCE.toEntity(positionCategoryDTO);
|
|
|
if(StrUtil.isNotEmpty(positionCategoryDTO.getId())){
|
|
|
+ List<PositionCategory> positionCategories = positionCategoryService.list(new QueryWrapper<PositionCategory>()
|
|
|
+ .ne("id",positionCategoryDTO.getId()).eq("name", positionCategoryDTO.getName()));
|
|
|
+ if(CollectionUtil.isNotEmpty(positionCategories)){
|
|
|
+ return ResponseEntity.badRequest().body("职务分类名称不可以重复");
|
|
|
+ }
|
|
|
PositionCategory byId = positionCategoryService.getById(positionCategoryDTO.getId());
|
|
|
positionLogDTO.setType(PositionTypeEnum.POSITION_CATEGORY.getValue());
|
|
|
positionLogDTO.setOperationType("编辑职务分类");
|
|
|
positionLogDTO.setOperationContent("编辑职务分类: 职务分类名称由“"+byId.getName()+"”变更为“"+positionCategoryDTO.getName()+"”");
|
|
|
}else{
|
|
|
+ List<PositionCategory> positionCategories = positionCategoryService.list(new QueryWrapper<PositionCategory>()
|
|
|
+ .eq("name", positionCategoryDTO.getName()));
|
|
|
+ if(CollectionUtil.isNotEmpty(positionCategories)){
|
|
|
+ return ResponseEntity.badRequest().body("职务分类名称不可以重复");
|
|
|
+ }
|
|
|
positionLogDTO.setType(PositionTypeEnum.POSITION_CATEGORY.getValue());
|
|
|
positionLogDTO.setOperationType("创建职务分类");
|
|
|
positionLogDTO.setOperationContent("创建职务分类: "+positionCategoryDTO.getName());
|