若依 3.0

This commit is contained in:
RuoYi
2018-10-07 14:16:47 +08:00
parent fed3aa8231
commit e166127c9f
438 changed files with 9987 additions and 3978 deletions

View File

@@ -0,0 +1,118 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService;
/**
* 参数配置 服务层实现
*
* @author ruoyi
*/
@Service
public class SysConfigServiceImpl implements ISysConfigService
{
@Autowired
private SysConfigMapper configMapper;
/**
* 查询参数配置信息
*
* @param configId 参数配置ID
* @return 参数配置信息
*/
@Override
public SysConfig selectConfigById(Long configId)
{
SysConfig config = new SysConfig();
config.setConfigId(configId);
return configMapper.selectConfig(config);
}
/**
* 根据键名查询参数配置信息
*
* @param configName 参数名称
* @return 参数键值
*/
@Override
public String selectConfigByKey(String configKey)
{
SysConfig config = new SysConfig();
config.setConfigKey(configKey);
SysConfig retConfig = configMapper.selectConfig(config);
return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : "";
}
/**
* 查询参数配置列表
*
* @param config 参数配置信息
* @return 参数配置集合
*/
@Override
public List<SysConfig> selectConfigList(SysConfig config)
{
return configMapper.selectConfigList(config);
}
/**
* 新增参数配置
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public int insertConfig(SysConfig config)
{
return configMapper.insertConfig(config);
}
/**
* 修改参数配置
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public int updateConfig(SysConfig config)
{
return configMapper.updateConfig(config);
}
/**
* 批量删除参数配置对象
*
* @param configIds 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteConfigByIds(String ids)
{
return configMapper.deleteConfigByIds(Convert.toStrArray(ids));
}
/**
* 校验参数键名是否唯一
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public String checkConfigKeyUnique(SysConfig config)
{
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
{
return UserConstants.CONFIG_KEY_NOT_UNIQUE;
}
return UserConstants.CONFIG_KEY_UNIQUE;
}
}

View File

@@ -0,0 +1,232 @@
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.service.ISysDeptService;
/**
* 部门管理 服务实现
*
* @author ruoyi
*/
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
@Autowired
private SysDeptMapper deptMapper;
/**
* 查询部门管理数据
*
* @return 部门信息集合
*/
@Override
@DataScope(tableAlias = "d")
public List<SysDept> selectDeptList(SysDept dept)
{
return deptMapper.selectDeptList(dept);
}
/**
* 查询部门管理树
*
* @return 所有部门信息
*/
@Override
public List<Map<String, Object>> selectDeptTree()
{
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<SysDept> deptList = selectDeptList(new SysDept());
trees = getTrees(deptList, false, null);
return trees;
}
/**
* 根据角色ID查询部门数据权限
*
* @param role 角色对象
* @return 部门列表(数据权限)
*/
@Override
public List<Map<String, Object>> roleDeptTreeData(SysRole role)
{
Long roleId = role.getRoleId();
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<SysDept> deptList = selectDeptList(new SysDept());
if (StringUtils.isNotNull(roleId))
{
List<String> roleDeptList = deptMapper.selectRoleDeptTree(roleId);
trees = getTrees(deptList, true, roleDeptList);
}
else
{
trees = getTrees(deptList, false, null);
}
return trees;
}
/**
* 对象转部门树
*
* @param menuList 部门列表
* @param isCheck 是否需要选中
* @param roleDeptList 角色已存在菜单列表
* @return
*/
public List<Map<String, Object>> getTrees(List<SysDept> deptList, boolean isCheck, List<String> roleDeptList)
{
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
for (SysDept dept : deptList)
{
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
{
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put("id", dept.getDeptId());
deptMap.put("pId", dept.getParentId());
deptMap.put("name", dept.getDeptName());
deptMap.put("title", dept.getDeptName());
if (isCheck)
{
deptMap.put("checked", roleDeptList.contains(dept.getDeptId() + dept.getDeptName()));
}
else
{
deptMap.put("checked", false);
}
trees.add(deptMap);
}
}
return trees;
}
/**
* 查询部门人数
*
* @param parentId 部门ID
* @return 结果
*/
@Override
public int selectDeptCount(Long parentId)
{
SysDept dept = new SysDept();
dept.setParentId(parentId);
return deptMapper.selectDeptCount(dept);
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId)
{
int result = deptMapper.checkDeptExistUser(deptId);
return result > 0 ? true : false;
}
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public int deleteDeptById(Long deptId)
{
return deptMapper.deleteDeptById(deptId);
}
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int insertDept(SysDept dept)
{
SysDept info = deptMapper.selectDeptById(dept.getParentId());
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int updateDept(SysDept dept)
{
SysDept info = deptMapper.selectDeptById(dept.getParentId());
String ancestors = info.getAncestors() + "," + dept.getParentId();
dept.setAncestors(ancestors);
updateDeptChildren(dept.getDeptId(), ancestors);
return deptMapper.updateDept(dept);
}
/**
* 修改子元素关系
*
* @param deptId 部门ID
* @param ancestors 元素列表
*/
public void updateDeptChildren(Long deptId, String ancestors)
{
SysDept dept = new SysDept();
dept.setParentId(deptId);
List<SysDept> childrens = deptMapper.selectDeptList(dept);
for (SysDept children : childrens)
{
children.setAncestors(ancestors + "," + dept.getParentId());
}
if (childrens.size() > 0)
{
deptMapper.updateDeptChildren(childrens);
}
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
@Override
public SysDept selectDeptById(Long deptId)
{
return deptMapper.selectDeptById(deptId);
}
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
@Override
public String checkDeptNameUnique(SysDept dept)
{
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
{
return UserConstants.DEPT_NAME_NOT_UNIQUE;
}
return UserConstants.DEPT_NAME_UNIQUE;
}
}

View File

@@ -0,0 +1,118 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.support.Convert;
import com.ruoyi.system.domain.SysDictData;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.service.ISysDictDataService;
/**
* 字典 业务层处理
*
* @author ruoyi
*/
@Service
public class SysDictDataServiceImpl implements ISysDictDataService
{
@Autowired
private SysDictDataMapper dictDataMapper;
/**
* 根据条件分页查询字典数据
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
@Override
public List<SysDictData> selectDictDataList(SysDictData dictData)
{
return dictDataMapper.selectDictDataList(dictData);
}
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public List<SysDictData> selectDictDataByType(String dictType)
{
return dictDataMapper.selectDictDataByType(dictType);
}
/**
* 根据字典类型和字典键值查询字典数据信息
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典标签
*/
@Override
public String selectDictLabel(String dictType, String dictValue)
{
return dictDataMapper.selectDictLabel(dictType, dictValue);
}
/**
* 根据字典数据ID查询信息
*
* @param dictCode 字典数据ID
* @return 字典数据
*/
@Override
public SysDictData selectDictDataById(Long dictCode)
{
return dictDataMapper.selectDictDataById(dictCode);
}
/**
* 通过字典ID删除字典数据信息
*
* @param dictCode 字典数据ID
* @return 结果
*/
@Override
public int deleteDictDataById(Long dictCode)
{
return dictDataMapper.deleteDictDataById(dictCode);
}
/**
* 批量删除字典数据
*
* @param ids 需要删除的数据
* @return 结果
*/
@Override
public int deleteDictDataByIds(String ids)
{
return dictDataMapper.deleteDictDataByIds(Convert.toStrArray(ids));
}
/**
* 新增保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public int insertDictData(SysDictData dictData)
{
return dictDataMapper.insertDictData(dictData);
}
/**
* 修改保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public int updateDictData(SysDictData dictData)
{
return dictDataMapper.updateDictData(dictData);
}
}

View File

@@ -0,0 +1,140 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysDictType;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.mapper.SysDictTypeMapper;
import com.ruoyi.system.service.ISysDictTypeService;
/**
* 字典 业务层处理
*
* @author ruoyi
*/
@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService
{
@Autowired
private SysDictTypeMapper dictTypeMapper;
@Autowired
private SysDictDataMapper dictDataMapper;
/**
* 根据条件分页查询字典类型
*
* @param dictType 字典类型信息
* @return 字典类型集合信息
*/
@Override
public List<SysDictType> selectDictTypeList(SysDictType dictType)
{
return dictTypeMapper.selectDictTypeList(dictType);
}
/**
* 根据所有字典类型
*
* @return 字典类型集合信息
*/
@Override
public List<SysDictType> selectDictTypeAll()
{
return dictTypeMapper.selectDictTypeAll();
}
/**
* 根据字典类型ID查询信息
*
* @param dictId 字典类型ID
* @return 字典类型
*/
@Override
public SysDictType selectDictTypeById(Long dictId)
{
return dictTypeMapper.selectDictTypeById(dictId);
}
/**
* 通过字典ID删除字典信息
*
* @param dictId 字典ID
* @return 结果
*/
@Override
public int deleteDictTypeById(Long dictId)
{
return dictTypeMapper.deleteDictTypeById(dictId);
}
/**
* 批量删除字典类型
*
* @param ids 需要删除的数据
* @return 结果
*/
@Override
public int deleteDictTypeByIds(String ids) throws Exception
{
Long[] dictIds = Convert.toLongArray(ids);
for (Long dictId : dictIds)
{
SysDictType dictType = selectDictTypeById(dictId);
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
{
throw new Exception(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
}
return dictTypeMapper.deleteDictTypeByIds(dictIds);
}
/**
* 新增保存字典类型信息
*
* @param dictType 字典类型信息
* @return 结果
*/
@Override
public int insertDictType(SysDictType dictType)
{
return dictTypeMapper.insertDictType(dictType);
}
/**
* 修改保存字典类型信息
*
* @param dictType 字典类型信息
* @return 结果
*/
@Override
public int updateDictType(SysDictType dictType)
{
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
return dictTypeMapper.updateDictType(dictType);
}
/**
* 校验字典类型称是否唯一
*
* @param dictType 字典类型
* @return 结果
*/
@Override
public String checkDictTypeUnique(SysDictType dict)
{
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
{
return UserConstants.DICT_TYPE_NOT_UNIQUE;
}
return UserConstants.DICT_TYPE_UNIQUE;
}
}

View File

@@ -0,0 +1,66 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.support.Convert;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.mapper.SysLogininforMapper;
import com.ruoyi.system.service.ISysLogininforService;
/**
* 系统访问日志情况信息 服务层处理
*
* @author ruoyi
*/
@Service
public class SysLogininforServiceImpl implements ISysLogininforService
{
@Autowired
private SysLogininforMapper logininforMapper;
/**
* 新增系统登录日志
*
* @param logininfor 访问日志对象
*/
@Override
public void insertLogininfor(SysLogininfor logininfor)
{
logininforMapper.insertLogininfor(logininfor);
}
/**
* 查询系统登录日志集合
*
* @param logininfor 访问日志对象
* @return 登录记录集合
*/
@Override
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor)
{
return logininforMapper.selectLogininforList(logininfor);
}
/**
* 批量删除系统登录日志
*
* @param ids 需要删除的数据
* @return
*/
@Override
public int deleteLogininforByIds(String ids)
{
return logininforMapper.deleteLogininforByIds(Convert.toStrArray(ids));
}
/**
* 清空系统登录日志
*/
@Override
public void cleanLogininfor()
{
logininforMapper.cleanLogininfor();
}
}

View File

@@ -0,0 +1,372 @@
package com.ruoyi.system.service.impl;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.mapper.SysMenuMapper;
import com.ruoyi.system.mapper.SysRoleMenuMapper;
import com.ruoyi.system.service.ISysMenuService;
/**
* 菜单 业务层处理
*
* @author ruoyi
*/
@Service
public class SysMenuServiceImpl implements ISysMenuService
{
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
@Autowired
private SysMenuMapper menuMapper;
@Autowired
private SysRoleMenuMapper roleMenuMapper;
/**
* 根据用户查询菜单
*
* @param userId 用户信息
* @return 菜单列表
*/
@Override
public List<SysMenu> selectMenusByUser(SysUser user)
{
List<SysMenu> menus = new LinkedList<SysMenu>();
// 管理员显示所有菜单信息
if (user.isAdmin())
{
menus = menuMapper.selectMenuNormalAll();
}
else
{
menus = menuMapper.selectMenusByUserId(user.getUserId());
}
return getChildPerms(menus, 0);
}
/**
* 查询菜单集合
*
* @return 所有菜单信息
*/
@Override
public List<SysMenu> selectMenuList(SysMenu menu)
{
return menuMapper.selectMenuList(menu);
}
/**
* 查询菜单集合
*
* @return 所有菜单信息
*/
@Override
public List<SysMenu> selectMenuAll()
{
return menuMapper.selectMenuAll();
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectPermsByUserId(Long userId)
{
List<String> perms = menuMapper.selectPermsByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (String perm : perms)
{
if (StringUtils.isNotEmpty(perm))
{
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
}
}
return permsSet;
}
/**
* 根据角色ID查询菜单
*
* @param role 角色对象
* @return 菜单列表
*/
@Override
public List<Map<String, Object>> roleMenuTreeData(SysRole role)
{
Long roleId = role.getRoleId();
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<SysMenu> menuList = menuMapper.selectMenuAll();
if (StringUtils.isNotNull(roleId))
{
List<String> roleMenuList = menuMapper.selectMenuTree(roleId);
trees = getTrees(menuList, true, roleMenuList, true);
}
else
{
trees = getTrees(menuList, false, null, true);
}
return trees;
}
/**
* 查询所有菜单
*
* @return 菜单列表
*/
@Override
public List<Map<String, Object>> menuTreeData()
{
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<SysMenu> menuList = menuMapper.selectMenuAll();
trees = getTrees(menuList, false, null, false);
return trees;
}
/**
* 查询系统所有权限
*
* @return 权限列表
*/
@Override
public LinkedHashMap<String, String> selectPermsAll()
{
LinkedHashMap<String, String> section = new LinkedHashMap<>();
List<SysMenu> permissions = menuMapper.selectMenuAll();
if (StringUtils.isNotEmpty(permissions))
{
for (SysMenu menu : permissions)
{
section.put(menu.getUrl(), MessageFormat.format(PREMISSION_STRING, menu.getPerms()));
}
}
return section;
}
/**
* 对象转菜单树
*
* @param menuList 菜单列表
* @param isCheck 是否需要选中
* @param roleMenuList 角色已存在菜单列表
* @param permsFlag 是否需要显示权限标识
* @return
*/
public List<Map<String, Object>> getTrees(List<SysMenu> menuList, boolean isCheck, List<String> roleMenuList,
boolean permsFlag)
{
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
for (SysMenu menu : menuList)
{
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put("id", menu.getMenuId());
deptMap.put("pId", menu.getParentId());
deptMap.put("name", transMenuName(menu, roleMenuList, permsFlag));
deptMap.put("title", menu.getMenuName());
if (isCheck)
{
deptMap.put("checked", roleMenuList.contains(menu.getMenuId() + menu.getPerms()));
}
else
{
deptMap.put("checked", false);
}
trees.add(deptMap);
}
return trees;
}
public String transMenuName(SysMenu menu, List<String> roleMenuList, boolean permsFlag)
{
StringBuffer sb = new StringBuffer();
sb.append(menu.getMenuName());
if (permsFlag)
{
sb.append("<font color=\"#888\">&nbsp;&nbsp;&nbsp;" + menu.getPerms() + "</font>");
}
return sb.toString();
}
/**
* 删除菜单管理信息
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public int deleteMenuById(Long menuId)
{
return menuMapper.deleteMenuById(menuId);
}
/**
* 根据菜单ID查询信息
*
* @param menuId 菜单ID
* @return 菜单信息
*/
@Override
public SysMenu selectMenuById(Long menuId)
{
return menuMapper.selectMenuById(menuId);
}
/**
* 查询子菜单数量
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public int selectCountMenuByParentId(Long parentId)
{
return menuMapper.selectCountMenuByParentId(parentId);
}
/**
* 查询菜单使用数量
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public int selectCountRoleMenuByMenuId(Long menuId)
{
return roleMenuMapper.selectCountRoleMenuByMenuId(menuId);
}
/**
* 新增保存菜单信息
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public int insertMenu(SysMenu menu)
{
return menuMapper.insertMenu(menu);
}
/**
* 修改保存菜单信息
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public int updateMenu(SysMenu menu)
{
return menuMapper.updateMenu(menu);
}
/**
* 校验菜单名称是否唯一
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public String checkMenuNameUnique(SysMenu menu)
{
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
{
return UserConstants.MENU_NAME_NOT_UNIQUE;
}
return UserConstants.MENU_NAME_UNIQUE;
}
/**
* 根据父节点的ID获取所有子节点
*
* @param list 分类表
* @param typeId 传入的父节点ID
* @return String
*/
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
{
List<SysMenu> returnList = new ArrayList<SysMenu>();
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
{
SysMenu t = (SysMenu) iterator.next();
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
if (t.getParentId() == parentId)
{
recursionFn(list, t);
returnList.add(t);
}
}
return returnList;
}
/**
* 递归列表
*
* @param list
* @param SysMenu
*/
private void recursionFn(List<SysMenu> list, SysMenu t)
{
// 得到子节点列表
List<SysMenu> childList = getChildList(list, t);
t.setChildren(childList);
for (SysMenu tChild : childList)
{
if (hasChild(list, tChild))
{
// 判断是否有子节点
Iterator<SysMenu> it = childList.iterator();
while (it.hasNext())
{
SysMenu n = (SysMenu) it.next();
recursionFn(list, n);
}
}
}
}
/**
* 得到子节点列表
*/
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
{
List<SysMenu> tlist = new ArrayList<SysMenu>();
Iterator<SysMenu> it = list.iterator();
while (it.hasNext())
{
SysMenu n = (SysMenu) it.next();
if (n.getParentId().longValue() == t.getMenuId().longValue())
{
tlist.add(n);
}
}
return tlist;
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<SysMenu> list, SysMenu t)
{
return getChildList(list, t).size() > 0 ? true : false;
}
}

View File

@@ -0,0 +1,82 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.support.Convert;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.mapper.SysNoticeMapper;
import com.ruoyi.system.service.ISysNoticeService;
/**
* 公告 服务层实现
*
* @author ruoyi
* @date 2018-06-25
*/
@Service
public class SysNoticeServiceImpl implements ISysNoticeService
{
@Autowired
private SysNoticeMapper noticeMapper;
/**
* 查询公告信息
*
* @param noticeId 公告ID
* @return 公告信息
*/
@Override
public SysNotice selectNoticeById(Long noticeId)
{
return noticeMapper.selectNoticeById(noticeId);
}
/**
* 查询公告列表
*
* @param notice 公告信息
* @return 公告集合
*/
@Override
public List<SysNotice> selectNoticeList(SysNotice notice)
{
return noticeMapper.selectNoticeList(notice);
}
/**
* 新增公告
*
* @param notice 公告信息
* @return 结果
*/
@Override
public int insertNotice(SysNotice notice)
{
return noticeMapper.insertNotice(notice);
}
/**
* 修改公告
*
* @param notice 公告信息
* @return 结果
*/
@Override
public int updateNotice(SysNotice notice)
{
return noticeMapper.updateNotice(notice);
}
/**
* 删除公告对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteNoticeByIds(String ids)
{
return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids));
}
}

View File

@@ -0,0 +1,77 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.support.Convert;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.mapper.SysOperLogMapper;
import com.ruoyi.system.service.ISysOperLogService;
/**
* 操作日志 服务层处理
*
* @author ruoyi
*/
@Service
public class SysOperLogServiceImpl implements ISysOperLogService
{
@Autowired
private SysOperLogMapper operLogMapper;
/**
* 新增操作日志
*
* @param operLog 操作日志对象
*/
@Override
public void insertOperlog(SysOperLog operLog)
{
operLogMapper.insertOperlog(operLog);
}
/**
* 查询系统操作日志集合
*
* @param operLog 操作日志对象
* @return 操作日志集合
*/
@Override
public List<SysOperLog> selectOperLogList(SysOperLog operLog)
{
return operLogMapper.selectOperLogList(operLog);
}
/**
* 批量删除系统操作日志
*
* @param ids 需要删除的数据
* @return
*/
@Override
public int deleteOperLogByIds(String ids)
{
return operLogMapper.deleteOperLogByIds(Convert.toStrArray(ids));
}
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
@Override
public SysOperLog selectOperLogById(Long operId)
{
return operLogMapper.selectOperLogById(operId);
}
/**
* 清空操作日志
*/
@Override
public void cleanOperLog()
{
operLogMapper.cleanOperLog();
}
}

View File

@@ -0,0 +1,180 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.ISysPostService;
/**
* 岗位信息 服务层处理
*
* @author ruoyi
*/
@Service
public class SysPostServiceImpl implements ISysPostService
{
@Autowired
private SysPostMapper postMapper;
@Autowired
private SysUserPostMapper userPostMapper;
/**
* 查询岗位信息集合
*
* @param post 岗位信息
* @return 岗位信息集合
*/
@Override
public List<SysPost> selectPostList(SysPost post)
{
return postMapper.selectPostList(post);
}
/**
* 查询所有岗位
*
* @return 岗位列表
*/
@Override
public List<SysPost> selectPostAll()
{
return postMapper.selectPostAll();
}
/**
* 根据用户ID查询岗位
*
* @param userId 用户ID
* @return 岗位列表
*/
@Override
public List<SysPost> selectPostsByUserId(Long userId)
{
List<SysPost> userPosts = postMapper.selectPostsByUserId(userId);
List<SysPost> posts = postMapper.selectPostAll();
for (SysPost post : posts)
{
for (SysPost userRole : userPosts)
{
if (post.getPostId().longValue() == userRole.getPostId().longValue())
{
post.setFlag(true);
break;
}
}
}
return posts;
}
/**
* 通过岗位ID查询岗位信息
*
* @param postId 岗位ID
* @return 角色对象信息
*/
@Override
public SysPost selectPostById(Long postId)
{
return postMapper.selectPostById(postId);
}
/**
* 批量删除岗位信息
*
* @param ids 需要删除的数据ID
* @throws Exception
*/
@Override
public int deletePostByIds(String ids) throws Exception
{
Long[] postIds = Convert.toLongArray(ids);
for (Long postId : postIds)
{
SysPost post = selectPostById(postId);
if (countUserPostById(postId) > 0)
{
throw new Exception(String.format("%1$s已分配,不能删除", post.getPostName()));
}
}
return postMapper.deletePostByIds(postIds);
}
/**
* 新增保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
@Override
public int insertPost(SysPost post)
{
return postMapper.insertPost(post);
}
/**
* 修改保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
@Override
public int updatePost(SysPost post)
{
return postMapper.updatePost(post);
}
/**
* 通过岗位ID查询岗位使用数量
*
* @param postId 岗位ID
* @return 结果
*/
@Override
public int countUserPostById(Long postId)
{
return userPostMapper.countUserPostById(postId);
}
/**
* 校验岗位名称是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostNameUnique(SysPost post)
{
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.POST_NAME_NOT_UNIQUE;
}
return UserConstants.POST_NAME_UNIQUE;
}
/**
* 校验岗位编码是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostCodeUnique(SysPost post)
{
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.POST_CODE_NOT_UNIQUE;
}
return UserConstants.POST_CODE_UNIQUE;
}
}

View File

@@ -0,0 +1,300 @@
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysRoleDept;
import com.ruoyi.system.domain.SysRoleMenu;
import com.ruoyi.system.mapper.SysRoleDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysRoleMenuMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysRoleService;
/**
* 角色 业务层处理
*
* @author ruoyi
*/
@Service
public class SysRoleServiceImpl implements ISysRoleService
{
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysRoleMenuMapper roleMenuMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
@Autowired
private SysRoleDeptMapper roleDeptMapper;
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
@DataScope(tableAlias = "u")
public List<SysRole> selectRoleList(SysRole role)
{
return roleMapper.selectRoleList(role);
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectRoleKeys(Long userId)
{
List<SysRole> perms = roleMapper.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (SysRole perm : perms)
{
if (StringUtils.isNotNull(perms))
{
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 角色列表
*/
@Override
public List<SysRole> selectRolesByUserId(Long userId)
{
List<SysRole> userRoles = roleMapper.selectRolesByUserId(userId);
List<SysRole> roles = selectRoleAll();
for (SysRole role : roles)
{
for (SysRole userRole : userRoles)
{
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
{
role.setFlag(true);
break;
}
}
}
return roles;
}
/**
* 查询所有角色
*
* @return 角色列表
*/
@Override
public List<SysRole> selectRoleAll()
{
return selectRoleList(new SysRole());
}
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public SysRole selectRoleById(Long roleId)
{
return roleMapper.selectRoleById(roleId);
}
/**
* 通过角色ID删除角色
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public boolean deleteRoleById(Long roleId)
{
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
}
/**
* 批量删除角色信息
*
* @param ids 需要删除的数据ID
* @throws Exception
*/
@Override
public int deleteRoleByIds(String ids) throws Exception
{
Long[] roleIds = Convert.toLongArray(ids);
for (Long roleId : roleIds)
{
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0)
{
throw new Exception(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
return roleMapper.deleteRoleByIds(roleIds);
}
/**
* 新增保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int insertRole(SysRole role)
{
// 新增角色信息
roleMapper.insertRole(role);
return insertRoleMenu(role);
}
/**
* 修改保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int updateRole(SysRole role)
{
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
return insertRoleMenu(role);
}
/**
* 修改数据权限信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int updateRule(SysRole role)
{
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
// 新增角色和部门信息(数据权限)
return insertRoleDept(role);
}
/**
* 新增角色菜单信息
*
* @param role 角色对象
*/
public int insertRoleMenu(SysRole role)
{
int rows = 1;
// 新增用户与角色管理
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
for (Long menuId : role.getMenuIds())
{
SysRoleMenu rm = new SysRoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0)
{
rows = roleMenuMapper.batchRoleMenu(list);
}
return rows;
}
/**
* 新增角色部门信息(数据权限)
*
* @param role 角色对象
*/
public int insertRoleDept(SysRole role)
{
int rows = 1;
// 新增角色与部门(数据权限)管理
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
for (Long deptId : role.getDeptIds())
{
SysRoleDept rd = new SysRoleDept();
rd.setRoleId(role.getRoleId());
rd.setDeptId(deptId);
list.add(rd);
}
if (list.size() > 0)
{
rows = roleDeptMapper.batchRoleDept(list);
}
return rows;
}
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleNameUnique(SysRole role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.ROLE_NAME_NOT_UNIQUE;
}
return UserConstants.ROLE_NAME_UNIQUE;
}
/**
* 校验角色权限是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleKeyUnique(SysRole role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.ROLE_KEY_NOT_UNIQUE;
}
return UserConstants.ROLE_KEY_UNIQUE;
}
/**
* 通过角色ID查询角色使用数量
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public int countUserRoleByRoleId(Long roleId)
{
return userRoleMapper.countUserRoleByRoleId(roleId);
}
}

View File

@@ -0,0 +1,107 @@
package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.mapper.SysUserOnlineMapper;
/**
* 在线用户 服务层处理
*
* @author ruoyi
*/
@Component
public class SysUserOnlineServiceImpl
{
@Autowired
private SysUserOnlineMapper userOnlineDao;
/**
* 通过会话序号查询信息
*
* @param sessionId 会话ID
* @return 在线用户信息
*/
public SysUserOnline selectOnlineById(String sessionId)
{
return userOnlineDao.selectOnlineById(sessionId);
}
/**
* 通过会话序号删除信息
*
* @param sessionId 会话ID
* @return 在线用户信息
*/
public void deleteOnlineById(String sessionId)
{
SysUserOnline userOnline = selectOnlineById(sessionId);
if (StringUtils.isNotNull(userOnline))
{
userOnlineDao.deleteOnlineById(sessionId);
}
}
/**
* 通过会话序号删除信息
*
* @param sessions 会话ID集合
* @return 在线用户信息
*/
public void batchDeleteOnline(List<String> sessions)
{
for (String sessionId : sessions)
{
SysUserOnline userOnline = selectOnlineById(sessionId);
if (StringUtils.isNotNull(userOnline))
{
userOnlineDao.deleteOnlineById(sessionId);
}
}
}
/**
* 保存会话信息
*
* @param online 会话信息
*/
public void saveOnline(SysUserOnline online)
{
userOnlineDao.saveOnline(online);
}
/**
* 查询会话集合
*
* @param pageUtilEntity 分页参数
*/
public List<SysUserOnline> selectUserOnlineList(SysUserOnline userOnline)
{
return userOnlineDao.selectUserOnlineList(userOnline);
}
/**
* 强退用户
*
* @param sessionId 会话ID
*/
public void forceLogout(String sessionId)
{
userOnlineDao.deleteOnlineById(sessionId);
}
/**
* 查询会话集合
*
* @param online 会话信息
*/
public List<SysUserOnline> selectOnlineByExpired(Date expiredDate)
{
String lastAccessTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate);
return userOnlineDao.selectOnlineByExpired(lastAccessTime);
}
}

View File

@@ -0,0 +1,347 @@
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.SysUserPost;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysUserService;
/**
* 用户 业务层处理
*
* @author ruoyi
*/
@Service
public class SysUserServiceImpl implements ISysUserService
{
@Autowired
private SysUserMapper userMapper;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysPostMapper postMapper;
@Autowired
private SysUserPostMapper userPostMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
/**
* 根据条件分页查询用户对象
*
* @param user 用户信息
*
* @return 用户信息集合信息
*/
@Override
@DataScope(tableAlias = "u")
public List<SysUser> selectUserList(SysUser user)
{
return userMapper.selectUserList(user);
}
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
@Override
public SysUser selectUserByLoginName(String userName)
{
return userMapper.selectUserByLoginName(userName);
}
/**
* 通过手机号码查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
@Override
public SysUser selectUserByPhoneNumber(String phoneNumber)
{
return userMapper.selectUserByPhoneNumber(phoneNumber);
}
/**
* 通过邮箱查询用户
*
* @param email 邮箱
* @return 用户对象信息
*/
@Override
public SysUser selectUserByEmail(String email)
{
return userMapper.selectUserByEmail(email);
}
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
@Override
public SysUser selectUserById(Long userId)
{
return userMapper.selectUserById(userId);
}
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
@Override
public int deleteUserById(Long userId)
{
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId(userId);
// 删除用户与岗位表
userPostMapper.deleteUserPostByUserId(userId);
return userMapper.deleteUserById(userId);
}
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteUserByIds(String ids) throws Exception
{
Long[] userIds = Convert.toLongArray(ids);
for (Long userId : userIds)
{
if (SysUser.isAdmin(userId))
{
throw new Exception("不允许删除超级管理员用户");
}
}
return userMapper.deleteUserByIds(userIds);
}
/**
* 新增保存用户信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public int insertUser(SysUser user)
{
// 新增用户信息
int rows = userMapper.insertUser(user);
// 新增用户岗位关联
insertUserPost(user);
// 新增用户与角色管理
insertUserRole(user);
return rows;
}
/**
* 修改保存用户信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public int updateUser(SysUser user)
{
Long userId = user.getUserId();
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId(userId);
// 新增用户与角色管理
insertUserRole(user);
// 删除用户与岗位关联
userPostMapper.deleteUserPostByUserId(userId);
// 新增用户与岗位管理
insertUserPost(user);
return userMapper.updateUser(user);
}
/**
* 修改用户个人详细信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public int updateUserInfo(SysUser user)
{
return userMapper.updateUser(user);
}
/**
* 修改用户密码
*
* @param user 用户信息
* @return 结果
*/
@Override
public int resetUserPwd(SysUser user)
{
return updateUserInfo(user);
}
/**
* 新增用户角色信息
*
* @param user 用户对象
*/
public void insertUserRole(SysUser user)
{
// 新增用户与角色管理
List<SysUserRole> list = new ArrayList<SysUserRole>();
for (Long roleId : user.getRoleIds())
{
SysUserRole ur = new SysUserRole();
ur.setUserId(user.getUserId());
ur.setRoleId(roleId);
list.add(ur);
}
if (list.size() > 0)
{
userRoleMapper.batchUserRole(list);
}
}
/**
* 新增用户岗位信息
*
* @param user 用户对象
*/
public void insertUserPost(SysUser user)
{
// 新增用户与岗位管理
List<SysUserPost> list = new ArrayList<SysUserPost>();
for (Long postId : user.getPostIds())
{
SysUserPost up = new SysUserPost();
up.setUserId(user.getUserId());
up.setPostId(postId);
list.add(up);
}
if (list.size() > 0)
{
userPostMapper.batchUserPost(list);
}
}
/**
* 校验用户名称是否唯一
*
* @param loginName 用户名
* @return
*/
@Override
public String checkLoginNameUnique(String loginName)
{
int count = userMapper.checkLoginNameUnique(loginName);
if (count > 0)
{
return UserConstants.USER_NAME_NOT_UNIQUE;
}
return UserConstants.USER_NAME_UNIQUE;
}
/**
* 校验用户名称是否唯一
*
* @param phonenumber 用户名
* @return
*/
@Override
public String checkPhoneUnique(SysUser user)
{
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.USER_PHONE_NOT_UNIQUE;
}
return UserConstants.USER_PHONE_UNIQUE;
}
/**
* 校验email是否唯一
*
* @param email 用户名
* @return
*/
@Override
public String checkEmailUnique(SysUser user)
{
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkEmailUnique(user.getEmail());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.USER_EMAIL_NOT_UNIQUE;
}
return UserConstants.USER_EMAIL_UNIQUE;
}
/**
* 查询用户所属角色组
*
* @param userId 用户ID
* @return 结果
*/
@Override
public String selectUserRoleGroup(Long userId)
{
List<SysRole> list = roleMapper.selectRolesByUserId(userId);
StringBuffer idsStr = new StringBuffer();
for (SysRole role : list)
{
idsStr.append(role.getRoleName()).append(",");
}
if (StringUtils.isNotEmpty(idsStr.toString()))
{
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
}
/**
* 查询用户所属岗位组
*
* @param userId 用户ID
* @return 结果
*/
@Override
public String selectUserPostGroup(Long userId)
{
List<SysPost> list = postMapper.selectPostsByUserId(userId);
StringBuffer idsStr = new StringBuffer();
for (SysPost post : list)
{
idsStr.append(post.getPostName()).append(",");
}
if (StringUtils.isNotEmpty(idsStr.toString()))
{
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
}
}