Merge branch 'master' of http://git.estsh.com/i3-IMPP/i3plus-core
commit
d590bd7591
@ -0,0 +1,201 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
|
||||||
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||||
|
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.RefRoleMenu;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.repository.RefRoleMenuRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.repository.SysMenuRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.repository.SysRoleRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
||||||
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 系统角色业务接口实现
|
||||||
|
* @Reference :
|
||||||
|
* @Author : wei.peng
|
||||||
|
* @Date : 2018-10-22 16:58:43.779
|
||||||
|
* @Modify :
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class SysRoleService implements ISysRoleService {
|
||||||
|
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(SysRoleService.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleRepository sysRoleRDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysMenuRepository sysMenuRDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RefRoleMenuRepository refRoleMenuRDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSysRole(SysRole sysRole) {
|
||||||
|
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
||||||
|
sysRoleRDao.update(sysRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSysRoleStatus(String id, int status, SessionUser user) {
|
||||||
|
LOGGER.info("系统角色 SYS_MENU id:{} status:{} user:{}", id,status,user);
|
||||||
|
SysRole role = sysRoleRDao.getById(Long.parseLong(id));
|
||||||
|
role.setRoleStatusId(status);
|
||||||
|
role.setModifyUser(user.getUserName());
|
||||||
|
sysRoleRDao.update(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSysRoleStatusByIds(String[] ids, int status, SessionUser user) {
|
||||||
|
LOGGER.info("系统功能 SYS_MENU ids:{} status:{} user:{}", ids, status, user);
|
||||||
|
StringBuffer where = new StringBuffer();
|
||||||
|
|
||||||
|
HqlPack.getInPack(String.join(",", ids), "id", where);
|
||||||
|
sysRoleRDao.updateByHqlWhere(where.toString(), "roleStatusId", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteSysRoleById(String id) {
|
||||||
|
LOGGER.info("系统角色 SYS_ROLE Key:{}", id);
|
||||||
|
sysRoleRDao.deleteById(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysRole insertSysRole(SysRole sysRole) {
|
||||||
|
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
||||||
|
return sysRoleRDao.insert(sysRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshSysRoleRef(String roleId,String[] ids,SessionUser user) {
|
||||||
|
LOGGER.info("系统角色 SYS_ROLE :{}", roleId);
|
||||||
|
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
|
||||||
|
|
||||||
|
SysRole role = sysRoleRDao.getById(Long.parseLong(roleId));
|
||||||
|
|
||||||
|
if(role != null){
|
||||||
|
String where = CoreHqlPack.packHqlIds("id", ids);
|
||||||
|
List<SysMenu> list = sysMenuRDao.findByHqlWhere(where);
|
||||||
|
|
||||||
|
// 删除角色权限关系
|
||||||
|
refRoleMenuRDao.deleteByProperties("roleId",role.getId());
|
||||||
|
|
||||||
|
if(list != null && list.size() > 0){
|
||||||
|
List<RefRoleMenu> refs = new ArrayList<>(list.size());
|
||||||
|
for (SysMenu menu : list) {
|
||||||
|
RefRoleMenu ref = new RefRoleMenu(menu.getId(), menu.getName(), role.getId(), role.getName());
|
||||||
|
ConvertBean.modelInitialize(ref, user);
|
||||||
|
refs.add(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入角色权限关系
|
||||||
|
refRoleMenuRDao.saveAll(refs);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
throw ImppExceptionBuilder.newInstance()
|
||||||
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
||||||
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
||||||
|
.setErrorDetail("角色信息不存在")
|
||||||
|
.setErrorSolution("请重新输入")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshBatchSysRoleRef(String[] roleIds, String[] ids,SessionUser user) {
|
||||||
|
LOGGER.info("系统角色 String[] :{}", roleIds);
|
||||||
|
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
|
||||||
|
|
||||||
|
String roleWhere = CoreHqlPack.packHqlIds("id", ids);
|
||||||
|
List<SysRole> roleList = sysRoleRDao.findByHql(roleWhere);
|
||||||
|
|
||||||
|
if(roleList != null && roleList.size() > 0){
|
||||||
|
String menuWhere = CoreHqlPack.packHqlIds("id", ids);
|
||||||
|
List<SysMenu> list = sysMenuRDao.findByHqlWhere(menuWhere);
|
||||||
|
|
||||||
|
// 封装需要删除的IDS
|
||||||
|
Long[] rids = new Long[roleList.size()];
|
||||||
|
for (int i = 0; i < roleList.size(); i++) {
|
||||||
|
rids[i] = roleList.get(i).getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除角色权限关系
|
||||||
|
refRoleMenuRDao.deleteByIds(rids);
|
||||||
|
|
||||||
|
// 插入角色权限关系
|
||||||
|
if(list != null && list.size() > 0){
|
||||||
|
List<RefRoleMenu> refs = new ArrayList<>(list.size());
|
||||||
|
for (SysMenu menu : list) {
|
||||||
|
for (SysRole role : roleList) {
|
||||||
|
RefRoleMenu ref = new RefRoleMenu(menu.getId(), menu.getName(), role.getId(), role.getName());
|
||||||
|
ConvertBean.modelInitialize(ref, user);
|
||||||
|
refs.add(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入角色权限关系
|
||||||
|
refRoleMenuRDao.saveAll(refs);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
throw ImppExceptionBuilder.newInstance()
|
||||||
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
||||||
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
||||||
|
.setErrorDetail("角色信息不存在")
|
||||||
|
.setErrorSolution("请重新输入")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RefRoleMenu> findRefRoleMenuByRoleId(String roleId) {
|
||||||
|
LOGGER.info("系统角色权限关系 RefRoleMenu find By RoleId");
|
||||||
|
return refRoleMenuRDao.findByProperty("roleId",roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysRole> findSysRoleAll() {
|
||||||
|
LOGGER.info("系统角色 SYS_ROLE find All");
|
||||||
|
return sysRoleRDao.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysRole getSysRoleById(String id) {
|
||||||
|
LOGGER.info("系统角色 SYS_ROLE find id:{}", id);
|
||||||
|
return sysRoleRDao.getOne(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListPager<SysRole> querySysRole(SysRole role, Pager pager) {
|
||||||
|
LOGGER.info("系统角色 SysRole find role :{} page :{}", role, pager);
|
||||||
|
|
||||||
|
if (role == null) {
|
||||||
|
//不传入实体对象,查询所有
|
||||||
|
int count = sysRoleRDao.listCount();
|
||||||
|
pager = PagerHelper.getPager(pager, count);
|
||||||
|
return new ListPager(sysRoleRDao.listPager(pager), pager);
|
||||||
|
} else {
|
||||||
|
//生成hql查询语句
|
||||||
|
String hqlPack = CoreHqlPack.packHqlSysRole(role);
|
||||||
|
pager = PagerHelper.getPager(pager, sysRoleRDao.findByHqlWhereCount(hqlPack));
|
||||||
|
return new ListPager(sysRoleRDao.findByHqlWherePage(hqlPack + role.orderBy(), pager), pager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,102 +0,0 @@
|
|||||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
|
||||||
|
|
||||||
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
|
|
||||||
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.SessionUser;
|
|
||||||
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
|
|
||||||
import cn.estsh.i3plus.pojo.platform.repository.SysRoleRepository;
|
|
||||||
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 org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description : 系统角色业务接口实现
|
|
||||||
* @Reference :
|
|
||||||
* @Author : wei.peng
|
|
||||||
* @Date : 2018-10-22 16:58:43.779
|
|
||||||
* @Modify :
|
|
||||||
**/
|
|
||||||
@Service
|
|
||||||
public class SysRoleServiceImpl implements ISysRoleService {
|
|
||||||
|
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(SysRoleServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysRoleRepository sysRoleRDao;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSysRole(SysRole sysRole) {
|
|
||||||
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
|
||||||
sysRoleRDao.update(sysRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSysRoleStatus(String id, int status, SessionUser user) {
|
|
||||||
LOGGER.info("系统角色 SYS_MENU id:{} status:{} user:{}", id,status,user);
|
|
||||||
SysRole role = sysRoleRDao.getById(Long.parseLong(id));
|
|
||||||
role.setRoleStatusId(status);
|
|
||||||
role.setModifyUser(user.getUserName());
|
|
||||||
sysRoleRDao.update(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSysRoleStatusByIds(String[] ids, int status, SessionUser user) {
|
|
||||||
LOGGER.info("系统功能 SYS_MENU ids:{} status:{} user:{}", ids, status, user);
|
|
||||||
StringBuffer where = new StringBuffer();
|
|
||||||
|
|
||||||
HqlPack.getInPack(String.join(",", ids), "id", where);
|
|
||||||
sysRoleRDao.updateByHqlWhere(where.toString(), "roleStatusId", status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteSysRoleById(String id) {
|
|
||||||
LOGGER.info("系统角色 SYS_ROLE Key:{}", id);
|
|
||||||
sysRoleRDao.deleteById(Long.parseLong(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SysRole insertSysRole(SysRole sysRole) {
|
|
||||||
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
|
||||||
return sysRoleRDao.insert(sysRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SysRole> findSysRoleAll() {
|
|
||||||
LOGGER.info("系统角色 SYS_ROLE find All");
|
|
||||||
return sysRoleRDao.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SysRole getSysRoleById(String id) {
|
|
||||||
LOGGER.info("系统角色 SYS_ROLE find id:{}", id);
|
|
||||||
return sysRoleRDao.getOne(Long.parseLong(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListPager<SysRole> querySysRole(SysRole role, Pager pager) {
|
|
||||||
LOGGER.info("系统角色 SysRole find role :{} page :{}", role, pager);
|
|
||||||
|
|
||||||
if (role == null) {
|
|
||||||
//不传入实体对象,查询所有
|
|
||||||
int count = sysRoleRDao.listCount();
|
|
||||||
pager = PagerHelper.getPager(pager, count);
|
|
||||||
return new ListPager(sysRoleRDao.listPager(pager), pager);
|
|
||||||
} else {
|
|
||||||
//生成hql查询语句
|
|
||||||
String hqlPack = CoreHqlPack.packHqlSysRole(role);
|
|
||||||
pager = PagerHelper.getPager(pager, sysRoleRDao.findByHqlWhereCount(hqlPack));
|
|
||||||
return new ListPager(sysRoleRDao.findByHqlWherePage(hqlPack + role.orderBy(), pager), pager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue