功能优化

yun-zuoyi
wei.peng 7 years ago
parent 5b5b07be3f
commit 7cc85aab78

@ -38,6 +38,12 @@ public interface ICoreTreeService {
void findPositionChildrenTreePack(Position parent,int step);
/**
* IDID
* @param position
*/
void doValidatorPositionParentId(Position position) ;
/**
*
* @param parentId
* @return
@ -59,6 +65,12 @@ public interface ICoreTreeService {
void findDepartmentChildrenTreePack(Department parent,int step);
/**
* IDID
* @param department
*/
void doValidatorDepartmentParentId(Department department) ;
/**
*
* @param parentId
* @return
@ -80,6 +92,12 @@ public interface ICoreTreeService {
void findOrganizeChildrenTreePack(Organize parent,int step);
/**
* IDID
* @param organize
*/
void doValidatorOrganizeParentId(Organize organize) ;
/**
*
* @param parentId
* @return
@ -100,4 +118,10 @@ public interface ICoreTreeService {
*/
void findSysMenuChildrenTreePack(SysMenu parent, int step);
/**
* IDID
* @param menu
*/
void doValidatorSysMenuParentId(SysMenu menu) ;
}

@ -1,11 +1,14 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.repository.DepartmentRepository;
import cn.estsh.i3plus.pojo.platform.repository.OrganizeRepository;
import cn.estsh.i3plus.pojo.platform.repository.PositionRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysMenuRepository;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -81,6 +84,12 @@ public class CoreTreeService implements ICoreTreeService {
}
@Override
public void doValidatorPositionParentId(Position position) {
findPositionChildrenTreePack(position,0);
validatorPositionParentId(position.getChildList(),position.getParentId());
}
@Override
public List<Department> findDepartmentTreeByParentId(long parentId) {
List<Department> result = departmentRDao.findByProperty("parentId", parentId);
@ -123,6 +132,12 @@ public class CoreTreeService implements ICoreTreeService {
}
@Override
public void doValidatorDepartmentParentId(Department department) {
findDepartmentChildrenTreePack(department,0);
validatorDepartmentParentId(department.getChildList(),department.getParentId());
}
@Override
public List<Organize> findOrganizeTreeByParentId(long parentId) {
List<Organize> result = organizeRDao.findByProperty("parentId", parentId);
@ -164,6 +179,12 @@ public class CoreTreeService implements ICoreTreeService {
}
@Override
public void doValidatorOrganizeParentId(Organize organize) {
findOrganizeChildrenTreePack(organize,0);
validatorOrganizeParentId(organize.getChildList(),organize.getParentId());
}
@Override
public List<SysMenu> findSysMenuTreeByParentId(long parentId) {
List<SysMenu> result = menuRDao.findByProperty("parentId", parentId);
@ -203,4 +224,82 @@ public class CoreTreeService implements ICoreTreeService {
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childList.size(), step);
parent.setChildList(childList);
}
@Override
public void doValidatorSysMenuParentId(SysMenu menu) {
findSysMenuChildrenTreePack(menu,0);
validatorSysMenuParentId(menu.getChildList(),menu.getParentId());
}
private void validatorPositionParentId(List<Position> list, Long parentId){
if(list != null && list.size() > 0){
for (Position position : list) {
// 判断子集的ID 是否是 父节点ID
if(position.getId().equals(parentId) || position.getId().equals(position.getParentId())){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("上级岗位不能为子岗位")
.setErrorSolution("请重新操作")
.build();
}
validatorPositionParentId(position.getChildList(),parentId);
}
}
}
private void validatorDepartmentParentId(List<Department> list, Long parentId){
if(list != null && list.size() > 0){
for (Department department : list) {
// 判断子集的ID 是否是 父节点ID
if(department.getId().equals(parentId) || department.getId().equals(department.getParentId())){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("上级部门不能为子部门")
.setErrorSolution("请重新操作")
.build();
}
validatorDepartmentParentId(department.getChildList(),parentId);
}
}
}
private void validatorOrganizeParentId(List<Organize> list, Long parentId){
if(list != null && list.size() > 0){
for (Organize organize : list) {
// 判断子集的ID 是否是 父节点ID
if(organize.getId().equals(parentId) || organize.getId().equals(organize.getParentId())){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("上级部门不能为子部门")
.setErrorSolution("请重新操作")
.build();
}
validatorOrganizeParentId(organize.getChildList(),parentId);
}
}
}
private void validatorSysMenuParentId(List<SysMenu> list, Long parentId){
if(list != null && list.size() > 0){
for (SysMenu menu : list) {
// 判断子集的ID 是否是 父节点ID
if(menu.getId().equals(parentId) || menu.getId().equals(menu.getParentId())){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("上级部门不能为子部门")
.setErrorSolution("请重新操作")
.build();
}
validatorSysMenuParentId(menu.getChildList(),parentId);
}
}
}
}

@ -37,11 +37,14 @@ public class DepartmentService implements IDepartmentService {
@Autowired
private OrganizeRepository organizeRDao;
@Autowired
private CoreTreeService coreTreeService;
@Override
public Department insertDepartment(Department department) {
LOGGER.info("部门信息 Department department:{}", department);
// 代码唯一校验
long count = organizeRDao.findByPropertyCount("departmentCode", department.getDepartmentCode());
long count = departmentRDao.findByPropertyCount("departmentCode", department.getDepartmentCode());
if(count <= 0){
//冗余父节点信息
@ -115,7 +118,7 @@ public class DepartmentService implements IDepartmentService {
LOGGER.info("部门信息 DEPARTMENT department :{}", department);
// 唯一校验 CODE 相同 ID 不同 则视为相同
List<Department> list = departmentRDao.findByProperty("departmentCode", department.getDepartmentCode());
if(null != list && list.size() > 0){
if(list != null && list.size() > 0){
for (Department dep : list) {
if(!dep.getId().equals(department.getId())){
throw ImppExceptionBuilder.newInstance()
@ -128,6 +131,9 @@ public class DepartmentService implements IDepartmentService {
}
}
// 父节点检查
coreTreeService.doValidatorDepartmentParentId(department);
// 查询父级部门名称
if (department.getParentId() != null && department.getParentId() > 0) {
LOGGER.info("部门信息 DEPARTMENT :{}", department.getParentId());
@ -147,6 +153,10 @@ public class DepartmentService implements IDepartmentService {
// 新增部门
LOGGER.info("部门信息 DEPARTMENT department:{}",department);
departmentRDao.update(department);
// 修改冗余信息
// 修改冗余信息
departmentRDao.updateByProperties("parentId",department.getId(),
"redParentName",department.getName());
}
@Override
@ -190,7 +200,7 @@ public class DepartmentService implements IDepartmentService {
String hqlPack = CoreHqlPack.packHqlDepartment(department);
pager = PagerHelper.getPager(pager, departmentRDao.findByHqlWhereCount(hqlPack));
return new ListPager(departmentRDao.findByHqlWherePage(
hqlPack + department.getOrderByParam(),pager),pager);
hqlPack + department.orderBy(),pager),pager);
}
}

@ -36,6 +36,9 @@ public class OrganizeService implements IOrganizeService {
@Autowired
private OrganizeRepository organizeRDao;
@Autowired
private CoreTreeService coreTreeService;
@Override
public void updateOrganize(Organize organize) {
LOGGER.info("组织 ORGANIZE :{}", organize);
@ -54,6 +57,9 @@ public class OrganizeService implements IOrganizeService {
}
}
// 父节点检查
coreTreeService.doValidatorOrganizeParentId(organize);
// 冗余父节点
if(organize.getParentId() != null){
Organize org = getOrganizeById(organize.getParentId().toString());
@ -64,6 +70,9 @@ public class OrganizeService implements IOrganizeService {
// 更新数据
organizeRDao.update(organize);
// 修改冗余信息
organizeRDao.updateByProperties("parentId",organize.getId(),
"redParentName",organize.getName());
}
@Override

@ -8,6 +8,7 @@ import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.Organize;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.i3plus.pojo.platform.repository.PositionRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysUserRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
@ -33,12 +34,18 @@ public class PositionService implements IPositionService {
@Autowired
private PositionRepository positionRDao;
@Autowired
private CoreTreeService coreTreeService;
@Autowired
private SysUserRepository sysUserRDao;
@Override
public Position insertPosition(Position position) {
LOGGER.info("岗位信息 POSITION position:{}", position);
// CODE 唯一校验
long count = positionRDao.findByPropertyCount("positionCode", position.getPositionCode());
if(count > 0){
if(count <= 0){
// 查询父级岗位名称
if (position.getParentId() != null && position.getParentId() > 0) {
LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId());
@ -66,7 +73,7 @@ public class PositionService implements IPositionService {
LOGGER.info("岗位信息 POSITION position:{}", position);
// 唯一校验 CODE 相同 ID 不同 则视为相同
List<Position> list = positionRDao.findByProperty("organizeCode", position.getPositionCode());
List<Position> list = positionRDao.findByProperty("positionCode", position.getPositionCode());
if(null != list && list.size() > 0){
for (Position pos : list) {
if(!pos.getId().equals(position.getId())){
@ -80,6 +87,9 @@ public class PositionService implements IPositionService {
}
}
// 父节点检查
coreTreeService.doValidatorPositionParentId(position);
// 查询父级岗位名称
if (position.getParentId() != null && position.getParentId() > 0) {
LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId());
@ -92,6 +102,9 @@ public class PositionService implements IPositionService {
// 修改岗位信息
LOGGER.info("岗位信息 POSITION position:{}", position);
positionRDao.update(position);
// 修改冗余信息
positionRDao.updateByProperties("parentId",position.getId(),
"redParentName",position.getName());
}
@Override
@ -174,7 +187,7 @@ public class PositionService implements IPositionService {
} else {
String hqlPack = CoreHqlPack.packHqlPosition(position);
pager = PagerHelper.getPager(pager, positionRDao.findByHqlWhereCount(hqlPack));
return new ListPager(positionRDao.findByHqlWherePage(hqlPack + position.getOrderByParam(),pager),pager);
return new ListPager(positionRDao.findByHqlWherePage(hqlPack + position.orderBy(),pager),pager);
}
}

@ -35,6 +35,9 @@ public class SysMenuService implements ISysMenuService {
@Autowired
private SysMenuRepository sysMenuRDao;
@Autowired
private CoreTreeService coreTreeService;
@Override
public void updateSysMenu(SysMenu sysMenu) {
LOGGER.info("系统功能 SYS_MENU :{}", sysMenu);
@ -54,16 +57,30 @@ public class SysMenuService implements ISysMenuService {
}
}
// 父节点检查
coreTreeService.doValidatorSysMenuParentId(sysMenu);
sysMenuRDao.update(sysMenu);
sysMenuRDao.updateByProperties("parentId",sysMenu.getId(),
"redParentName",sysMenu.getName());
}
@Override
public void updateSysMenuStatus(String id, int status, SessionUser user) {
LOGGER.info("系统功能 SYS_MENU id:{} status:{} user:{}", id,status,user);
SysMenu menu = sysMenuRDao.getById(Long.parseLong(id));
menu.setMenuStatus(status);
menu.setModifyUser(user.getUserName());
sysMenuRDao.update(menu);
if(menu != null){
menu.setMenuStatus(status);
menu.setModifyUser(user.getUserName());
sysMenuRDao.update(menu);
}else {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.IMPP.getCode())
.setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
.setErrorDetail("数据不存在")
.setErrorSolution("请重新操作")
.build();
}
}
@Override

@ -83,7 +83,7 @@ public class SystemResourceService implements ISystemResourceService {
}else {
String hqlPack = CoreHqlPack.packHqlSysLocaleLanguage(lang);
pager = PagerHelper.getPager(pager, sysLocaleLanguageRDao.findByHqlWhereCount(hqlPack));
return new ListPager(sysLocaleLanguageRDao.findByHqlWherePage(hqlPack + lang.getOrderByParam(),pager),pager);
return new ListPager(sysLocaleLanguageRDao.findByHqlWherePage(hqlPack + lang.orderBy(),pager),pager);
}
}

Loading…
Cancel
Save