bug51790+51775相关人员表必填校验及新增责任领域的修改
This commit is contained in:
+27
-10
@@ -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;
|
||||
}
|
||||
|
||||
+2
@@ -111,4 +111,6 @@ public class SysDictItem implements Serializable {
|
||||
@ApiModelProperty(value = "字典英文名称")
|
||||
private String enName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String cut;
|
||||
}
|
||||
|
||||
+3
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user