用户管理

角色管理
功能管理
组织管理
部门管理
岗位管理
功能优化
yun-zuoyi
wei.peng 7 years ago
parent fcc72d46eb
commit 4b31fac721

@ -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, "功能状态不能为空");

@ -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;
@ -48,10 +49,10 @@ public class DepartmentService implements IDepartmentService {
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());
}
@ -138,7 +139,7 @@ public class DepartmentService implements IDepartmentService {
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());
}

@ -61,9 +61,9 @@ 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());
}
@ -126,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());
}

@ -51,7 +51,7 @@ public class PositionService implements IPositionService {
LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId());
Position parentPosition = positionRDao.getById(position.getParentId());
ValidatorBean.checkNotNull(parentPosition);
ValidatorBean.checkNotNull(parentPosition,"上级岗位信息不存在");
position.setRedParentName(parentPosition.getName());
}
@ -94,7 +94,7 @@ public class PositionService implements IPositionService {
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());
}

@ -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;
@ -38,6 +39,9 @@ public class SysMenuService implements ISysMenuService {
@Autowired
private CoreTreeService coreTreeService;
@Autowired
private RefRoleMenuRepository refRoleMenuRDao;
@Override
public void updateSysMenu(SysMenu sysMenu) {
LOGGER.info("系统功能 SYS_MENU :{}", sysMenu);
@ -60,6 +64,12 @@ 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());
@ -105,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);

Loading…
Cancel
Save