bug51790+51775相关人员表必填校验及新增责任领域的修改

This commit is contained in:
xiejunyu
2022-05-10 15:00:11 +08:00
parent 1e5c55a4fa
commit a6344f7a26
4 changed files with 59 additions and 21 deletions
@@ -20,6 +20,7 @@ import com.jero.modules.system.service.ISysDictItemService;
import com.jero.modules.system.service.ISysDictService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -83,17 +84,33 @@ public class SysDictItemController {
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDictItem> add(@RequestBody SysDictItem sysDictItem) {
Result<SysDictItem> result = new Result<SysDictItem>();
try {
sysDictItem.setCreateTime(new Date());
sysDictItem.setDelFlag(CommonConstant.DEL_FLAG_0);
sysDictItem.setItemValue(UUID.randomUUID().toString().replace("-", ""));
//查询同名数据
List<SysDictItem> exitDictItemList = sysDictItemMapper.selctItemByName(sysDictItem.getItemText());
if(CollectionUtils.isNotEmpty(exitDictItemList)){
SysDictItem dictItemDB = exitDictItemList.get(0);
//有同名,已删数据->更新delFlag,恢复
if(dictItemDB.getDelFlag() == CommonConstant.DEL_FLAG_1){
sysDictItemService.updateDictDelFlag(CommonConstant.DEL_FLAG_0,dictItemDB.getId());
}else{
if(CutEnum.CN.getValue().equals(sysDictItem.getCut())) {
throw new JeroBootException("名称不能重复!");
}else{
throw new JeroBootException("The name cannot be duplicate!");
}
}
}else {
try {
sysDictItem.setCreateTime(new Date());
sysDictItem.setDelFlag(CommonConstant.DEL_FLAG_0);
sysDictItem.setItemValue(UUID.randomUUID().toString().replace("-", ""));
// sysDictItem.setItemValue(String.valueOf(RandomUtils.nextLong()));
sysDictItem.setStatus(1);
sysDictItemService.save(sysDictItem);
result.success("保存成功!");
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
sysDictItem.setStatus(1);
sysDictItemService.save(sysDictItem);
result.success("保存成功!");
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败");
}
}
return result;
}
@@ -111,4 +111,6 @@ public class SysDictItem implements Serializable {
@ApiModelProperty(value = "字典英文名称")
private String enName;
@TableField(exist = false)
private String cut;
}
@@ -43,4 +43,7 @@ public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
/**查询相关人员表里用过的责任领域次数*/
@Select("select count(prp.duty_territory) from project_related_personnel as prp where prp.duty_territory=#{itemValue}")
int selectCountDutyTerritory(String itemValue);
@Select("select * from sys_dict_item where item_text=#{itemText}")
List<SysDictItem> selctItemByName(String itemText);
}