|
|
|
@ -23,6 +23,7 @@ import cn.estsh.i3plus.pojo.platform.repository.SysRefRoleMenuRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysRefUserRoleRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysRoleRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.wms.bean.WmsPart;
|
|
|
|
|
import cn.estsh.impp.framework.base.service.CrudService;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
@ -36,11 +37,13 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Example;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static cn.estsh.i3plus.platform.common.util.PlatformConstWords.IMPP_REQUEST_ID;
|
|
|
|
|
import static cn.estsh.i3plus.platform.common.util.PlatformConstWords.SQL_SERVER_PARAM_MAX_MUM;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -87,18 +90,18 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "更新角色信息",notes = "根据ID 批量更新角色状态信息")
|
|
|
|
|
@ApiOperation(value = "更新角色信息", notes = "根据ID 批量更新角色状态信息")
|
|
|
|
|
public void updateSysRoleStatusByIds(Long[] ids, int status, SessionUser user) {
|
|
|
|
|
LOGGER.info("系统功能 SYS_MENU ids:{} status:{} user:{}", ids, status, user);
|
|
|
|
|
StringBuffer where = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
HqlPack.getInPack(StringUtils.join( ids,","), "id", where);
|
|
|
|
|
HqlPack.getInPack(StringUtils.join(ids, ","), "id", where);
|
|
|
|
|
roleRDao.updateByHqlWhere(where.toString(), "roleStatus", status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "刷新角色菜单关系",notes = "刷新 角色 菜单关系信息")
|
|
|
|
|
public void refreshSysRoleRef(Long roleId,Long[] ids,String userName) {
|
|
|
|
|
@ApiOperation(value = "刷新角色菜单关系", notes = "刷新 角色 菜单关系信息")
|
|
|
|
|
public void refreshSysRoleRef(Long roleId, Long[] ids, String userName) {
|
|
|
|
|
LOGGER.info("系统角色 SYS_ROLE :{}", roleId);
|
|
|
|
|
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
|
|
|
|
|
|
|
|
|
@ -106,33 +109,33 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "刷新角色菜单关系",notes = "批量刷新 角色 菜单关系信息")
|
|
|
|
|
public void refreshBatchSysRoleRef(Long[] roleIds, Long[] ids,String userName) {
|
|
|
|
|
@ApiOperation(value = "刷新角色菜单关系", notes = "批量刷新 角色 菜单关系信息")
|
|
|
|
|
public void refreshBatchSysRoleRef(Long[] roleIds, Long[] ids, String userName) {
|
|
|
|
|
LOGGER.info("系统角色 String[] :{}", roleIds);
|
|
|
|
|
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
|
|
|
|
|
|
|
|
|
|
String roleWhere = CoreHqlPack.packHqlIds("id", roleIds);
|
|
|
|
|
List<SysRole> roleList = roleRDao.findByHqlWhere(roleWhere);
|
|
|
|
|
|
|
|
|
|
if(roleList != null && roleList.size() > 0){
|
|
|
|
|
if (roleList != null && roleList.size() > 0) {
|
|
|
|
|
List<String> moduleListRdd = new ArrayList<>();
|
|
|
|
|
List<String> featuresListRdd = new ArrayList<>(); // 冗余
|
|
|
|
|
List<SysRefRoleMenu> refs = new ArrayList<>(); // 角色权限关系
|
|
|
|
|
|
|
|
|
|
// 删除角色权限关系
|
|
|
|
|
refRoleMenuRDao.deleteByPropertyIn("roleId",roleIds);
|
|
|
|
|
refRoleMenuRDao.deleteByPropertyIn("roleId", roleIds);
|
|
|
|
|
|
|
|
|
|
if(ids != null && ids.length > 0){
|
|
|
|
|
if (ids != null && ids.length > 0) {
|
|
|
|
|
List<SysMenu> list = new ArrayList<>();
|
|
|
|
|
// sqlserver限制最大传参数量
|
|
|
|
|
for (List<Long> idList : ListUtils.partition(Arrays.asList(ids), SQL_SERVER_PARAM_MAX_MUM)) {
|
|
|
|
|
System.out.println("切割大小:"+idList.size());
|
|
|
|
|
System.out.println("切割大小:" + idList.size());
|
|
|
|
|
list.addAll(menuService.findByIdList(idList));
|
|
|
|
|
}
|
|
|
|
|
SysRefRoleMenu ref = null;
|
|
|
|
|
|
|
|
|
|
// 插入角色权限关系
|
|
|
|
|
if(list != null && list.size() > 0){
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
|
for (SysMenu menu : list) {
|
|
|
|
|
for (SysRole role : roleList) {
|
|
|
|
|
ref = new SysRefRoleMenu();
|
|
|
|
@ -148,10 +151,10 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 冗余信息封装
|
|
|
|
|
if(CommonEnumUtil.METHOD_LEVEL.MODULE.getValue() == menu.getMenuType().intValue()){
|
|
|
|
|
if (CommonEnumUtil.METHOD_LEVEL.MODULE.getValue() == menu.getMenuType().intValue()) {
|
|
|
|
|
moduleListRdd.add(menu.getName());
|
|
|
|
|
}
|
|
|
|
|
if(CommonEnumUtil.METHOD_LEVEL.METHOD.getValue() == menu.getMenuType().intValue()){
|
|
|
|
|
if (CommonEnumUtil.METHOD_LEVEL.METHOD.getValue() == menu.getMenuType().intValue()) {
|
|
|
|
|
featuresListRdd.add(menu.getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -165,7 +168,7 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
roleRDao.saveAll(roleList);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
|
|
|
@ -178,22 +181,22 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
@Override
|
|
|
|
|
public void refreshSysRoleRef(Long roleId, Integer softType, List<Long> idList, String userName) {
|
|
|
|
|
SysRole role = roleRDao.getById(roleId);
|
|
|
|
|
ValidatorBean.checkNotNull(role,"不存在的角色信息");
|
|
|
|
|
ValidatorBean.checkNotNull(softType,"不存在的产品信息");
|
|
|
|
|
ValidatorBean.checkNotNull(role, "不存在的角色信息");
|
|
|
|
|
ValidatorBean.checkNotNull(softType, "不存在的产品信息");
|
|
|
|
|
|
|
|
|
|
SysMenu menu = new SysMenu();
|
|
|
|
|
menu.setSoftType(softType);
|
|
|
|
|
List<SysMenu> menuList = menuService.findAllByBean(menu);
|
|
|
|
|
|
|
|
|
|
refRoleMenuRDao.deleteByProperties(new String[]{"roleId","softType"},new Object[]{roleId,softType});
|
|
|
|
|
if(CollectionUtils.isNotEmpty(idList)){
|
|
|
|
|
refRoleMenuRDao.deleteByProperties(new String[]{"roleId", "softType"}, new Object[]{roleId, softType});
|
|
|
|
|
if (CollectionUtils.isNotEmpty(idList)) {
|
|
|
|
|
List<SysRefRoleMenu> refs = new ArrayList<>();
|
|
|
|
|
SysRefRoleMenu ref = null;
|
|
|
|
|
|
|
|
|
|
for (Long id : idList) {
|
|
|
|
|
if(CollectionUtils.isNotEmpty(menuList)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(menuList)) {
|
|
|
|
|
for (SysMenu sysMenu : menuList) {
|
|
|
|
|
if(sysMenu.getId().equals(id)){
|
|
|
|
|
if (sysMenu.getId().equals(id)) {
|
|
|
|
|
ref = new SysRefRoleMenu();
|
|
|
|
|
ref.setRoleId(role.getId());
|
|
|
|
|
ref.setRoleNameRdd(role.getName());
|
|
|
|
@ -210,29 +213,41 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(refs)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(refs)) {
|
|
|
|
|
refRoleMenuRDao.saveAll(refs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "查信角色菜单关系",notes = "查询 ID 查询角色菜单关系")
|
|
|
|
|
@ApiOperation(value = "查信角色菜单关系", notes = "查询 ID 查询角色菜单关系")
|
|
|
|
|
public List<SysRefRoleMenu> findSysRefRoleMenuByRoleId(Long roleId) {
|
|
|
|
|
LOGGER.info("系统角色权限关系 RefRoleMenu find By RoleId");
|
|
|
|
|
return refRoleMenuRDao.findByProperty(
|
|
|
|
|
new String[]{"roleId","isValid"},
|
|
|
|
|
new Object[]{roleId,CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()}
|
|
|
|
|
new String[]{"roleId", "isValid"},
|
|
|
|
|
new Object[]{roleId, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SysRefRoleMenu> findSysRefRoleMenuByRoleIdList(List<Long> idList) {
|
|
|
|
|
if (ObjectUtils.isEmpty(idList)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getInPackList(idList, "roleId", packBean);
|
|
|
|
|
// LOGGER.info("hql {}",packBean.getPackedHql());
|
|
|
|
|
return refRoleMenuRDao.findByHqlWhere(packBean);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SysRefRoleMenu> findSysRefRoleMenuByRoleId(Long roleId, Integer softType) {
|
|
|
|
|
LOGGER.info("系统角色权限关系 RefRoleMenu find By RoleId");
|
|
|
|
|
DdlPackBean ddlPackBean = new DdlPackBean();
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(roleId,"roleId",ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(softType,"softType",ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),"isValid",ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(roleId, "roleId", ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(softType, "softType", ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), "isValid", ddlPackBean);
|
|
|
|
|
|
|
|
|
|
return refRoleMenuRDao.findByHqlWhere(ddlPackBean);
|
|
|
|
|
}
|
|
|
|
@ -261,9 +276,9 @@ public class SysRoleService extends CrudService<SysRole> implements ISysRoleServ
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<SysRole> querySysRole(SysRole role, List<Long> idList, Pager pager) {
|
|
|
|
|
DdlPackBean packBean = CoreHqlPack.packDdlBeanSysRole(role,idList);
|
|
|
|
|
DdlPackBean packBean = CoreHqlPack.packDdlBeanSysRole(role, idList);
|
|
|
|
|
pager = PagerHelper.getPager(pager, roleRDao.findByHqlWhereCount(packBean));
|
|
|
|
|
return new ListPager(roleRDao.findByHqlWherePage(packBean , pager), pager);
|
|
|
|
|
return new ListPager(roleRDao.findByHqlWherePage(packBean, pager), pager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|