|
|
@ -5,9 +5,12 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysDictionary;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysDictionary;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@ -32,6 +35,16 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void insertSysDictionary(SysDictionary sysDictionary) {
|
|
|
|
public void insertSysDictionary(SysDictionary sysDictionary) {
|
|
|
|
|
|
|
|
long repeatCount = sysDictionaryRDao.findByPropertyCount("dictionaryCode",sysDictionary.getDictionaryCode());
|
|
|
|
|
|
|
|
if (repeatCount > 0){
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.IO_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("字典代码已存在")
|
|
|
|
|
|
|
|
.setErrorSolution("请重新输入字典代码")
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查询父级字典名称
|
|
|
|
// 查询父级字典名称
|
|
|
|
if (sysDictionary.getParentId() != null && sysDictionary.getParentId() > 0) {
|
|
|
|
if (sysDictionary.getParentId() != null && sysDictionary.getParentId() > 0) {
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", sysDictionary.getParentId());
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", sysDictionary.getParentId());
|
|
|
@ -41,7 +54,7 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
sysDictionary.setRedParentName(parentSysDictionary.getName());
|
|
|
|
sysDictionary.setRedParentName(parentSysDictionary.getName());
|
|
|
|
sysDictionary.setRedParentCode(parentSysDictionary.getDictionaryCode());
|
|
|
|
sysDictionary.setRedParentCode(parentSysDictionary.getDictionaryCode());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sysDictionary.setParentId(-1L);
|
|
|
|
sysDictionary.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY sysDictionary:{}",sysDictionary);
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY sysDictionary:{}",sysDictionary);
|
|
|
@ -56,6 +69,18 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateSysDictionary(SysDictionary sysDictionary) {
|
|
|
|
public void updateSysDictionary(SysDictionary sysDictionary) {
|
|
|
|
|
|
|
|
// 校验唯一
|
|
|
|
|
|
|
|
String hqlPack = CoreHqlPack.packHqlSysDictionaryCode(sysDictionary);
|
|
|
|
|
|
|
|
long repeatCount = sysDictionaryRDao.findByHqlWhereCount(hqlPack);
|
|
|
|
|
|
|
|
if (repeatCount > 0){
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.IO_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("字典代码已存在")
|
|
|
|
|
|
|
|
.setErrorSolution("请重新输入字典代码")
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查询父级字典名称
|
|
|
|
// 查询父级字典名称
|
|
|
|
if (sysDictionary.getParentId() != null && sysDictionary.getParentId() > 0) {
|
|
|
|
if (sysDictionary.getParentId() != null && sysDictionary.getParentId() > 0) {
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", sysDictionary.getParentId());
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", sysDictionary.getParentId());
|
|
|
@ -64,8 +89,6 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
|
|
|
|
|
|
|
|
sysDictionary.setRedParentName(parentSysDictionary.getName());
|
|
|
|
sysDictionary.setRedParentName(parentSysDictionary.getName());
|
|
|
|
sysDictionary.setRedParentCode(parentSysDictionary.getDictionaryCode());
|
|
|
|
sysDictionary.setRedParentCode(parentSysDictionary.getDictionaryCode());
|
|
|
|
} else {
|
|
|
|
|
|
|
|
sysDictionary.setParentId(-1L);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY sysDictionary:{}",sysDictionary);
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY sysDictionary:{}",sysDictionary);
|
|
|
@ -81,9 +104,7 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public SysDictionary getSysDictionaryById(String id) {
|
|
|
|
public SysDictionary getSysDictionaryById(String id) {
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY id:{}",id);
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY id:{}",id);
|
|
|
|
SysDictionary ds = sysDictionaryRDao.getById(Long.parseLong(id));
|
|
|
|
return sysDictionaryRDao.getById(Long.parseLong(id));
|
|
|
|
System.out.println(ds);
|
|
|
|
|
|
|
|
return ds;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -95,14 +116,11 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ListPager querySysDictionaryByPager(SysDictionary sysDictionary, Pager pager) {
|
|
|
|
public ListPager querySysDictionaryByPager(SysDictionary sysDictionary, Pager pager) {
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY SysDictionary:{},Pager:{}",sysDictionary,pager);
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY SysDictionary:{},Pager:{}",sysDictionary,pager);
|
|
|
|
if(sysDictionary == null) {
|
|
|
|
sysDictionary = sysDictionary == null ? new SysDictionary():sysDictionary;
|
|
|
|
pager = PagerHelper.getPager(pager, sysDictionaryRDao.listCount());
|
|
|
|
|
|
|
|
return new ListPager(sysDictionaryRDao.listPager(pager),pager);
|
|
|
|
String hqlPack = CoreHqlPack.packHqlSysDictionary(sysDictionary);
|
|
|
|
}else {
|
|
|
|
pager = PagerHelper.getPager(pager, sysDictionaryRDao.findByHqlWhereCount(hqlPack));
|
|
|
|
String hqlPack = CoreHqlPack.packHqlSysDictionary(sysDictionary);
|
|
|
|
return new ListPager(sysDictionaryRDao.findByHqlWherePage(hqlPack + sysDictionary.orderBy(),pager),pager);
|
|
|
|
pager = PagerHelper.getPager(pager, sysDictionaryRDao.findByHqlWhereCount(hqlPack));
|
|
|
|
|
|
|
|
return new ListPager(sysDictionaryRDao.findByHqlWherePage(hqlPack + sysDictionary.orderBy(),pager),pager);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -110,4 +128,15 @@ public class SysDictionaryService implements ISysDictionaryService {
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", CommonEnumUtil.PARENT.DEFAULT.getValue());
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", CommonEnumUtil.PARENT.DEFAULT.getValue());
|
|
|
|
return sysDictionaryRDao.findByProperty("parentId",(long)CommonEnumUtil.PARENT.DEFAULT.getValue());
|
|
|
|
return sysDictionaryRDao.findByProperty("parentId",(long)CommonEnumUtil.PARENT.DEFAULT.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void deleteSysDictionaryByIds(String[] ids) {
|
|
|
|
|
|
|
|
LOGGER.info("字典 SYS_DICTIONARY ids:{}", ids.toString());
|
|
|
|
|
|
|
|
Long[] array = new Long[ids.length];
|
|
|
|
|
|
|
|
for (int i = 0; i < ids.length; i++) {
|
|
|
|
|
|
|
|
array[i] = Long.parseLong(ids[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sysDictionaryRDao.deleteByIds(array);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|