yunhao.wang 7 years ago
commit 19714088d2

@ -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) ;
}

@ -50,6 +50,13 @@ public interface ISysMenuService {
void deleteSysMenuById(String id);
/**
* id
* @param ids id
* @return
*/
void deleteSysMenuByIds(String[] ids);
/**
*
*
* @param sysMenu

@ -50,6 +50,13 @@ public interface ISysRoleService {
void deleteSysRoleById(String id);
/**
* id
* @param ids id
* @return
*/
void deleteSysRoleByIds(String[] ids);
/**
*
*
* @param sysRole

@ -177,6 +177,7 @@ public class DepartmentController {
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteDepartmentByIds(String[] ids){
try{
ids = ConvertBean.modelSafeArrayNumber(ids,true);
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())

@ -46,6 +46,7 @@ public class OrganizeController {
//条件验证
ValidatorBean.beginValid(organize)
.notNull("name", organize.getName())
.notNull("organizeCode", organize.getOrganizeCode())
.notNull("organizeTypeId", organize.getOrganizeTypeId());
//新增初始化
@ -72,6 +73,7 @@ public class OrganizeController {
ValidatorBean.beginValid(organize)
.notNull("id", organize.getId())
.notNull("name", organize.getName())
.notNull("organizeCode", organize.getOrganizeCode())
.notNull("organizeTypeId", organize.getOrganizeTypeId());
ConvertBean.modelUpdate(organize, AuthUtil.getSessionUser());
@ -185,6 +187,7 @@ public class OrganizeController {
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteOrganizeByIds(String[] ids){
try{
ids = ConvertBean.modelSafeArrayNumber(ids,true);
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())

@ -56,8 +56,9 @@ public class PositionController {
position.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue());
}
positionService.insertPosition(position);
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
Position pos = positionService.insertPosition(position);
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultObject(pos);
} catch (ImppBusiException busExcep) {
LOGGER.error(busExcep.getErrorMsg() + "{}", busExcep.getErrorDetail(), busExcep);
return ResultBean.fail(busExcep.getErrorShow());
@ -77,7 +78,7 @@ public class PositionController {
//条件验证
ValidatorBean.beginValid(position)
.notNull("id",position.getId())
.notNull("positionName",position.getName())
.notNull("name",position.getName())
.notNull("positionCode",position.getPositionCode());
//修改初始化
@ -173,6 +174,7 @@ public class PositionController {
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deletePositionByIds(String[] ids){
try{
ids = ConvertBean.modelSafeArrayNumber(ids,true);
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())

@ -10,6 +10,7 @@
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
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;
@ -126,7 +127,7 @@ public class SysMenuController {
@GetMapping(value="/query")
@ApiOperation(value="查询权限",notes="组合查询权限,外带分页功能")
public ResultBean queryPosition(SysMenu menu, Pager pager){
public ResultBean querySysMenu(SysMenu menu, Pager pager){
try{
ListPager<SysMenu> listPager = sysMenuService.querySysMenu(menu, pager);
@ -187,6 +188,7 @@ public class SysMenuController {
public ResultBean updateBatchStatus(String[] ids,int status) {
try {
// 数据校验
ids = ConvertBean.modelSafeArrayNumber(ids,true);
ValidatorBean.checkNotNull(ids, "功能id 不能为空");
ValidatorBean.checkNotZero(status, "功能状态不能为空");
@ -202,7 +204,28 @@ public class SysMenuController {
}
}
@DeleteMapping(value = "/batch-delete")
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteSysMenuByIds(String[] ids){
try{
ids = ConvertBean.modelSafeArrayNumber(ids,true);
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("请选择需要删除的资源。")
.build();
}
sysMenuService.deleteSysMenuByIds(ids);
return ResultBean.success("删除成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
}
}
}

@ -243,11 +243,12 @@ public class SysRoleController {
@ApiOperation(value = "批量新增角色权限关系", notes = "批量新增角色权限关系")
public ResultBean insertBatchRefMenu(String[] roleIds,String[] menuIds) {
try {
roleIds = ConvertBean.modelSafeArrayNumber(roleIds,true);
menuIds = ConvertBean.modelSafeArrayNumber(menuIds,true);
// 数据校验
ValidatorBean.checkNotNull(roleIds, "角色roleIds 不能为空");
roleIds = ConvertBean.modelSafeArrayNumber(roleIds,true);
if(roleIds.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
@ -267,4 +268,28 @@ public class SysRoleController {
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
}
}
@DeleteMapping(value = "/batch-delete")
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteSysRoleByIds(String[] ids){
try{
ids = ConvertBean.modelSafeArrayNumber(ids,true);
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("请选择需要删除的资源。")
.build();
}
sysRoleService.deleteSysRoleByIds(ids);
return ResultBean.success("删除成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
}
}
}

@ -217,6 +217,7 @@ public class SysUserController {
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteBatchSysUserByIds(String[] ids){
try{
ids = ConvertBean.modelSafeArrayNumber(ids,true);
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
@ -241,6 +242,8 @@ public class SysUserController {
@ApiOperation(value = "批量修改系统功能状态", notes = "根据ID修改系统功能状态")
public ResultBean updateBatchStatus(String[] ids,int status) {
try {
ids = ConvertBean.modelSafeArrayNumber(ids,true);
// 数据校验
ValidatorBean.checkNotNull(ids, "功能id 不能为空");
ValidatorBean.checkNotZero(status, "功能状态不能为空");

@ -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);
}
}
}
}

@ -5,6 +5,7 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Organize;
import cn.estsh.i3plus.pojo.platform.repository.DepartmentRepository;
@ -37,18 +38,21 @@ 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){
//冗余父节点信息
if (department.getParentId() != null && department.getParentId().intValue() > 0) {
if (department.getParentId() != null && department.getParentId() > 0) {
LOGGER.info("部门信息 DEPARTMENT :{}", department.getParentId());
Department parentPosition = departmentRDao.getById(department.getParentId());
ValidatorBean.checkNotNull(parentPosition);
ValidatorBean.checkNotNull(parentPosition,"上级部门信息不存在");
department.setRedParentName(parentPosition.getName());
}
@ -115,7 +119,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,11 +132,14 @@ public class DepartmentService implements IDepartmentService {
}
}
// 父节点检查
coreTreeService.doValidatorDepartmentParentId(department);
// 查询父级部门名称
if (department.getParentId() != null && department.getParentId() > 0) {
LOGGER.info("部门信息 DEPARTMENT :{}", department.getParentId());
Department parentPosition = departmentRDao.getById(department.getParentId());
ValidatorBean.checkNotNull(parentPosition);
ValidatorBean.checkNotNull(parentPosition,"上级部门信息不存在");
department.setRedParentName(parentPosition.getName());
}
@ -147,6 +154,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 +201,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,16 +57,22 @@ public class OrganizeService implements IOrganizeService {
}
}
// 父节点检查
coreTreeService.doValidatorOrganizeParentId(organize);
// 冗余父节点
if(organize.getParentId() != null){
if(organize.getParentId() != null && organize.getParentId() > 0){
Organize org = getOrganizeById(organize.getParentId().toString());
ValidatorBean.checkNotNull(org);
ValidatorBean.checkNotNull(org,"上级组织信息不存在");
organize.setRedParentName(org.getName());
}
// 更新数据
organizeRDao.update(organize);
// 修改冗余信息
organizeRDao.updateByProperties("parentId",organize.getId(),
"redParentName",organize.getName());
}
@Override
@ -117,9 +126,9 @@ public class OrganizeService implements IOrganizeService {
long count = organizeRDao.findByPropertyCount("organizeCode", organize.getOrganizeCode());
if(count <= 0){
// 冗余信息
if(organize.getParentId() != null && organize.getParentId().intValue() > 0){
if(organize.getParentId() != null && organize.getParentId() > 0){
Organize org = getOrganizeById(organize.getParentId().toString());
ValidatorBean.checkNotNull(org);
ValidatorBean.checkNotNull(org,"上级组织信息不存在");
organize.setRedParentName(org.getName());
}

@ -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,18 +34,24 @@ 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());
Position parentPosition = positionRDao.getById(position.getParentId());
ValidatorBean.checkNotNull(parentPosition);
ValidatorBean.checkNotNull(parentPosition,"上级岗位信息不存在");
position.setRedParentName(parentPosition.getName());
}
@ -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,11 +87,14 @@ public class PositionService implements IPositionService {
}
}
// 父节点检查
coreTreeService.doValidatorPositionParentId(position);
// 查询父级岗位名称
if (position.getParentId() != null && position.getParentId() > 0) {
LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId());
Position parentPosition = positionRDao.getById(position.getParentId());
ValidatorBean.checkNotNull(parentPosition);
ValidatorBean.checkNotNull(parentPosition,"上级岗位信息不存在");
position.setRedParentName(parentPosition.getName());
}
@ -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);
}
}

@ -6,13 +6,14 @@ import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.platform.bean.Organize;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
import cn.estsh.i3plus.pojo.platform.repository.RefRoleMenuRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysMenuRepository;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,6 +36,12 @@ public class SysMenuService implements ISysMenuService {
@Autowired
private SysMenuRepository sysMenuRDao;
@Autowired
private CoreTreeService coreTreeService;
@Autowired
private RefRoleMenuRepository refRoleMenuRDao;
@Override
public void updateSysMenu(SysMenu sysMenu) {
LOGGER.info("系统功能 SYS_MENU :{}", sysMenu);
@ -54,16 +61,36 @@ public class SysMenuService implements ISysMenuService {
}
}
// 父节点检查
coreTreeService.doValidatorSysMenuParentId(sysMenu);
if (sysMenu.getParentId() != null && sysMenu.getParentId() > 0) {
SysMenu parent = sysMenuRDao.getById(sysMenu.getParentId());
ValidatorBean.checkNotNull(parent,"上级权限信息不存在");
sysMenu.setRedParentName(parent.getName());
}
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
@ -88,21 +115,44 @@ public class SysMenuService implements ISysMenuService {
.build();
}
refRoleMenuRDao.deleteByProperties("menuId",id);
sysMenuRDao.deleteById(Long.parseLong(id));
}
@Override
public void deleteSysMenuByIds(String[] ids) {
LOGGER.info("系统功能 SYS_MENU ids :{}", ids);
long positionCount = sysMenuRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("存在相关系统功能信息无法删除!")
.setErrorSolution("请先删除子集信息在操作")
.build();
}else {
Long[] array = new Long[ids.length];
for (int i = 0; i < ids.length; i++) {
array[i] = Long.parseLong(ids[i]);
}
refRoleMenuRDao.deleteByTypeLong("menuId",array);
sysMenuRDao.deleteByIds(array);
}
}
@Override
public SysMenu insertSysMenu(SysMenu sysMenu) {
LOGGER.info("系统功能 SYS_MENU :{}", sysMenu);
// 代码唯一校验
long count = sysMenuRDao.findByPropertyCount("menuCode", sysMenu.getMenuCode());
if(count <= 0){
if (sysMenu.getParentId() != null && sysMenu.getParentId().intValue() > 0) {
if (sysMenu.getParentId() != null && sysMenu.getParentId() > 0) {
SysMenu parent = sysMenuRDao.getById(sysMenu.getParentId());
if(null != parent){
sysMenu.setRedParentName(parent.getName());
}
ValidatorBean.checkNotNull(parent,"上级权限信息不存在");
sysMenu.setRedParentName(parent.getName());
}
return sysMenuRDao.insert(sysMenu);
}else {

@ -74,9 +74,30 @@ public class SysRoleService implements ISysRoleService {
@Override
public void deleteSysRoleById(String id) {
LOGGER.info("系统角色 SYS_ROLE Key:{}", id);
refRoleMenuRDao.deleteByProperties("roleId",id);
sysRoleRDao.deleteById(Long.parseLong(id));
}
@Override
public void deleteSysRoleByIds(String[] ids) {
LOGGER.info("系统角色 SYS_ROLE ids :{}", ids);
long positionCount = sysRoleRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("存在相关系统功能信息无法删除!")
.setErrorSolution("请先删除子集信息在操作")
.build();
}else {
Long[] array = new Long[ids.length];
for (int i = 0; i < ids.length; i++) {
array[i] = Long.parseLong(ids[i]);
}
refRoleMenuRDao.deleteByTypeLong("roleId",array);
sysRoleRDao.deleteByIds(array);
}
}
@Override
public SysRole insertSysRole(SysRole sysRole) {
@ -132,7 +153,7 @@ public class SysRoleService implements ISysRoleService {
if(CommonEnumUtil.METHOD_LEVEL.MODULE.getValue() == menu.getMenuTypeId().intValue()){
moduleListRdd.add(menu.getName());
}
if(CommonEnumUtil.METHOD_LEVEL.BUTTON.getValue() == menu.getMenuTypeId().intValue()){
if(CommonEnumUtil.METHOD_LEVEL.METHOD.getValue() == menu.getMenuTypeId().intValue()){
featuresListRdd.add(menu.getName());
}
}

@ -117,13 +117,12 @@ public class SysUserService implements ISysUserService {
public void updateBatchSysUserStatus(String[] ids, int status, SessionUser user) {
LOGGER.info("平台用户 SYS_USER DELETE By ids :{} status:{}, SessionUser :{}", ids,status,user);
// 标记用户已删除
String where = CoreHqlPack.packHqlIds("id", ids);
List<SysUser> list = sysUserRDao.findByHqlWhere(where);
if(null != list && list.size() > 0){
for (SysUser sysUser : list) {
sysUser.setUserStatusId(status);
sysUser.setIsValid(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
sysUser.setIsValid(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
ConvertBean.modelUpdate(sysUser,user);
}
sysUserRDao.saveAll(list);

@ -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