|
|
|
@ -2,6 +2,7 @@ package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysDictionaryService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseConstWords;
|
|
|
|
@ -15,7 +16,6 @@ import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
@ -58,9 +58,15 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
// 条件验证
|
|
|
|
|
ValidatorBean.beginValid(sysDictionary)
|
|
|
|
|
.notNull("name",sysDictionary.getName())
|
|
|
|
|
.notNull("dictionarySoftType",sysDictionary.getDictionarySoftType())
|
|
|
|
|
.notNull("dictionaryCode",sysDictionary.getDictionaryCode())
|
|
|
|
|
.notNull("dictionaryValue",sysDictionary.getDictionaryValue());
|
|
|
|
|
.notNull("parentId",sysDictionary.getParentId())
|
|
|
|
|
.notNull("dictionarySoftType",sysDictionary.getDictionarySoftType());
|
|
|
|
|
|
|
|
|
|
// 父级必须设置字典代码
|
|
|
|
|
if(sysDictionary.getParentIdVal() == CommonEnumUtil.PARENT.DEFAULT.getValue()){
|
|
|
|
|
ValidatorBean.checkNotNull(sysDictionary.getDictionaryCode(),"字典代码不能为空");
|
|
|
|
|
} else {
|
|
|
|
|
ValidatorBean.checkNotNull(sysDictionary.getDictionaryValue(),"字典参数值不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增初始化
|
|
|
|
|
sysDictionary.setIsDefault(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
@ -90,9 +96,24 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
ValidatorBean.beginValid(sysDictionary)
|
|
|
|
|
.notNull("id",sysDictionary.getId())
|
|
|
|
|
.notNull("name",sysDictionary.getName())
|
|
|
|
|
.notNull("dictionarySoftType",sysDictionary.getDictionarySoftType())
|
|
|
|
|
.notNull("dictionaryCode",sysDictionary.getDictionaryCode())
|
|
|
|
|
.notNull("dictionaryValue",sysDictionary.getDictionaryValue());
|
|
|
|
|
.notNull("parentId",sysDictionary.getParentId())
|
|
|
|
|
.notNull("dictionarySoftType",sysDictionary.getDictionarySoftType());
|
|
|
|
|
|
|
|
|
|
// 父级必须设置字典代码
|
|
|
|
|
if(sysDictionary.getParentIdVal() == CommonEnumUtil.PARENT.DEFAULT.getValue()){
|
|
|
|
|
ValidatorBean.checkNotNull(sysDictionary.getDictionaryCode(),"字典代码不能为空");
|
|
|
|
|
} else {
|
|
|
|
|
ValidatorBean.checkNotNull(sysDictionary.getDictionaryValue(),"字典参数值不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sysDictionary.getParentIdVal() == sysDictionary.getId()){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
|
|
|
|
.setErrorDetail("父级字典不能为当前字典项")
|
|
|
|
|
.setErrorSolution("请重新选择")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改初始化
|
|
|
|
|
ConvertBean.modelUpdate(sysDictionary,user);
|
|
|
|
@ -120,6 +141,10 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
// 条件验证
|
|
|
|
|
ValidatorBean.checkNotNull(idStr,"id不能为空");
|
|
|
|
|
SysDictionary sysDictionary = sysDictionaryService.getSysDictionaryById(Long.parseLong(idStr));
|
|
|
|
|
List<SysDictionary> childList = null;
|
|
|
|
|
if(sysDictionary.getParentIdVal() == CommonEnumUtil.PARENT.DEFAULT.getValue()){
|
|
|
|
|
childList = sysDictionaryService.findSysDictionaryByParentId(sysDictionary.getId());
|
|
|
|
|
}
|
|
|
|
|
if(sysDictionary == null){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
@ -127,7 +152,14 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
.setErrorDetail("字典不存在")
|
|
|
|
|
.setErrorSolution("请重新选择")
|
|
|
|
|
.build();
|
|
|
|
|
}else if(sysDictionary.getIsDefault().intValue() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) {
|
|
|
|
|
}else if(!childList.isEmpty()){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
|
|
|
|
.setErrorDetail("无法删除,存在子级字典:" + childList.get(0).getName())
|
|
|
|
|
.setErrorSolution("请重新选择")
|
|
|
|
|
.build();
|
|
|
|
|
} else if(sysDictionary.getIsDefault().intValue() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
|
|
|
@ -196,7 +228,7 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/find/{softType}/{code}")
|
|
|
|
|
@ApiOperation(value = "根据微服务与父级code查询字典项", notes = "根据微服务与父级code查询字典项")
|
|
|
|
|
public ResultBean findSysDictionaryByParentCode(@PathVariable("softType")Integer softType,@PathVariable("code") String code) {
|
|
|
|
|
public ResultBean findSysDictionaryByParentCode(@PathVariable("softType")Integer softType, @PathVariable("code") String code) {
|
|
|
|
|
try {
|
|
|
|
|
List<SysDictionary> sysDictionaryList = sysDictionaryService.findSysDictionaryBySoftTypeAndParentCode(softType,code);
|
|
|
|
|
return ResultBean.success("操作成功").setResultList(sysDictionaryList).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
@ -306,7 +338,7 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
*/
|
|
|
|
|
@DeleteMapping("/batch-delete")
|
|
|
|
|
@ApiOperation(value = "批量删除消息",notes = "批量删除消息")
|
|
|
|
|
public ResultBean deleteSysDictionaryByIds(String[] ids){
|
|
|
|
|
public ResultBean deleteSysDictionaryByIds(String[] ids) {
|
|
|
|
|
try{
|
|
|
|
|
if(ids.length == 0){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
@ -331,7 +363,7 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/default/{id}")
|
|
|
|
|
@ApiOperation(value = "设置默认字典值",notes = "根据id设置默认字典值")
|
|
|
|
|
public ResultBean updateSysDictionaryDefaultById(@PathVariable("id") String idStr){
|
|
|
|
|
public ResultBean updateSysDictionaryDefaultById(@PathVariable("id") String idStr) {
|
|
|
|
|
try {
|
|
|
|
|
//条件验证
|
|
|
|
|
ValidatorBean.checkNotNull(idStr,"id不能为空");
|
|
|
|
@ -351,7 +383,7 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/tree")
|
|
|
|
|
@ApiOperation(value = "查询字典树",notes = "查询字典树")
|
|
|
|
|
public ResultBean findSysDictionaryTree(){
|
|
|
|
|
public ResultBean findSysDictionaryTree() {
|
|
|
|
|
try {
|
|
|
|
|
// 根据软件类型分组
|
|
|
|
|
Map group = sysDictionaryService.findSysDictionaryByTop().stream().collect(Collectors.groupingBy(SysDictionary::getDictionarySoftType));
|
|
|
|
@ -381,9 +413,9 @@ public class SysDictionaryController extends CoreBaseController{
|
|
|
|
|
* @param softType 软件模块
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/find-soft-type/{id}")
|
|
|
|
|
@GetMapping("/find-top-soft-type/{id}")
|
|
|
|
|
@ApiOperation(value = "根据模块查询顶级字典",notes = "根据模块查询顶级字典")
|
|
|
|
|
public ResultBean findSysDictionaryByTopBySoftType(@PathVariable("id")Integer softType){
|
|
|
|
|
public ResultBean findSysDictionaryByTopBySoftType(@PathVariable("id")Integer softType) {
|
|
|
|
|
try {
|
|
|
|
|
List<SysDictionary> dictionaryList = sysDictionaryService.findSysDictionaryByTopBySoftType(softType);
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(dictionaryList);
|
|
|
|
|