#update
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
package com.maibu.domain;
|
||||
|
||||
import com.maibu.annotation.Excel;
|
||||
import com.maibu.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 岗位表 sys_post
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@ApiModel(value = "SysPost", description = "岗位表 sys_post")
|
||||
public class SysPost extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 岗位序号 */
|
||||
@ApiModelProperty("岗位序号")
|
||||
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long postId;
|
||||
|
||||
/** 岗位编码 */
|
||||
@ApiModelProperty("岗位编码")
|
||||
@Excel(name = "岗位编码")
|
||||
private String postCode;
|
||||
|
||||
/** 岗位名称 */
|
||||
@ApiModelProperty("岗位名称")
|
||||
@Excel(name = "岗位名称")
|
||||
private String postName;
|
||||
|
||||
/** 岗位排序 */
|
||||
@ApiModelProperty("岗位排序")
|
||||
@Excel(name = "岗位排序")
|
||||
private Integer postSort;
|
||||
|
||||
/** 状态(0正常 1停用) */
|
||||
@ApiModelProperty("状态(0正常 1停用)")
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/** 用户是否存在此岗位标识 默认不存在 */
|
||||
private boolean flag = false;
|
||||
|
||||
public Long getPostId()
|
||||
{
|
||||
return postId;
|
||||
}
|
||||
|
||||
public void setPostId(Long postId)
|
||||
{
|
||||
this.postId = postId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "岗位编码不能为空")
|
||||
@Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
|
||||
public String getPostCode()
|
||||
{
|
||||
return postCode;
|
||||
}
|
||||
|
||||
public void setPostCode(String postCode)
|
||||
{
|
||||
this.postCode = postCode;
|
||||
}
|
||||
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
|
||||
public String getPostName()
|
||||
{
|
||||
return postName;
|
||||
}
|
||||
|
||||
public void setPostName(String postName)
|
||||
{
|
||||
this.postName = postName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getPostSort()
|
||||
{
|
||||
return postSort;
|
||||
}
|
||||
|
||||
public void setPostSort(Integer postSort)
|
||||
{
|
||||
this.postSort = postSort;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isFlag()
|
||||
{
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag)
|
||||
{
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("postId", getPostId())
|
||||
.append("postCode", getPostCode())
|
||||
.append("postName", getPostName())
|
||||
.append("postSort", getPostSort())
|
||||
.append("status", getStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.maibu.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用户和岗位关联 sys_user_post
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@ApiModel(value = "SysUserPost", description = "用户和岗位关联 sys_user_post")
|
||||
public class SysUserPost
|
||||
{
|
||||
/** 用户ID */
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long userId;
|
||||
|
||||
/** 岗位ID */
|
||||
@ApiModelProperty("岗位ID")
|
||||
private Long postId;
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getPostId()
|
||||
{
|
||||
return postId;
|
||||
}
|
||||
|
||||
public void setPostId(Long postId)
|
||||
{
|
||||
this.postId = postId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("postId", getPostId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.maibu.enums;
|
||||
|
||||
public enum Language {
|
||||
ZH_CN("zh-CN"),
|
||||
EN("en-US"),
|
||||
DEFAULT("default");
|
||||
|
||||
private String value;
|
||||
|
||||
Language(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String matches(String language) {
|
||||
if(language.equals("zh")){
|
||||
return Language.ZH_CN.value;
|
||||
}else {
|
||||
return Language.EN.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.maibu.mapper;
|
||||
|
||||
|
||||
import com.maibu.domain.SysPost;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysPostMapper
|
||||
{
|
||||
/**
|
||||
* 查询岗位数据集合
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 岗位数据集合
|
||||
*/
|
||||
public List<SysPost> selectPostList(SysPost post);
|
||||
|
||||
/**
|
||||
* 查询所有岗位
|
||||
*
|
||||
* @return 岗位列表
|
||||
*/
|
||||
public List<SysPost> selectPostAll();
|
||||
|
||||
/**
|
||||
* 通过岗位ID查询岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public SysPost selectPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取岗位选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中岗位ID列表
|
||||
*/
|
||||
public List<Long> selectPostListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询用户所属岗位组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
public List<SysPost> selectPostsByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 删除岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostById(Long postId);
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
*
|
||||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostByIds(Long[] postIds);
|
||||
|
||||
/**
|
||||
* 修改岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePost(SysPost post);
|
||||
|
||||
/**
|
||||
* 新增岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPost(SysPost post);
|
||||
|
||||
/**
|
||||
* 校验岗位名称
|
||||
*
|
||||
* @param postName 岗位名称
|
||||
* @return 结果
|
||||
*/
|
||||
public SysPost checkPostNameUnique(String postName);
|
||||
|
||||
/**
|
||||
* 校验岗位编码
|
||||
*
|
||||
* @param postCode 岗位编码
|
||||
* @return 结果
|
||||
*/
|
||||
public SysPost checkPostCodeUnique(String postCode);
|
||||
}
|
||||
@@ -7,14 +7,13 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色与菜单关联表 数据层
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysRoleMenuMapper
|
||||
{
|
||||
public interface SysRoleMenuMapper {
|
||||
/**
|
||||
* 查询菜单使用数量
|
||||
*
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -22,7 +21,7 @@ public interface SysRoleMenuMapper
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色和菜单关联
|
||||
*
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -30,7 +29,7 @@ public interface SysRoleMenuMapper
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单关联信息
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -38,7 +37,7 @@ public interface SysRoleMenuMapper
|
||||
|
||||
/**
|
||||
* 批量新增角色菜单信息
|
||||
*
|
||||
*
|
||||
* @param roleMenuList 角色菜单列表
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -49,4 +48,13 @@ public interface SysRoleMenuMapper
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
List<SysRoleMenu> selectRoleMenuList(Long roleId);
|
||||
|
||||
|
||||
/**
|
||||
* 当前menu是否绑定到当前角色
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkMenuRole(Long menuId, Long roleId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.maibu.mapper;
|
||||
|
||||
import com.maibu.core.domain.entity.SysUser;
|
||||
import com.maibu.mybatis.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysUserMapper {
|
||||
public interface SysUserMapper extends BaseMapperX<SysUser> {
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@@ -198,4 +199,11 @@ public interface SysUserMapper {
|
||||
*/
|
||||
List<SysUser> selectByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据机构id获取当前机构所有非管理用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> selectByRoleId(Long roleId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.maibu.mapper;
|
||||
|
||||
|
||||
import com.maibu.domain.SysUserPost;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户与岗位关联表 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysUserPostMapper
|
||||
{
|
||||
/**
|
||||
* 通过用户ID删除用户和岗位关联
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserPostByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过岗位ID查询岗位使用数量
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 批量删除用户和岗位关联
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserPost(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量新增用户岗位信息
|
||||
*
|
||||
* @param userPostList 用户角色列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchUserPost(List<SysUserPost> userPostList);
|
||||
}
|
||||
@@ -113,6 +113,7 @@ public interface ISysMenuService
|
||||
*/
|
||||
public boolean checkMenuExistRole(Long menuId);
|
||||
|
||||
|
||||
/**
|
||||
* 新增保存菜单信息
|
||||
*
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.maibu.service;
|
||||
|
||||
|
||||
import com.maibu.domain.SysPost;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysPostService
|
||||
{
|
||||
/**
|
||||
* 查询岗位信息集合
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 岗位列表
|
||||
*/
|
||||
public List<SysPost> selectPostList(SysPost post);
|
||||
|
||||
/**
|
||||
* 查询所有岗位
|
||||
*
|
||||
* @return 岗位列表
|
||||
*/
|
||||
public List<SysPost> selectPostAll();
|
||||
|
||||
/**
|
||||
* 通过岗位ID查询岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public SysPost selectPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取岗位选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中岗位ID列表
|
||||
*/
|
||||
public List<Long> selectPostListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 校验岗位名称
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkPostNameUnique(SysPost post);
|
||||
|
||||
/**
|
||||
* 校验岗位编码
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkPostCodeUnique(SysPost post);
|
||||
|
||||
/**
|
||||
* 通过岗位ID查询岗位使用数量
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 删除岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostById(Long postId);
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
*
|
||||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostByIds(Long[] postIds);
|
||||
|
||||
/**
|
||||
* 新增保存岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPost(SysPost post);
|
||||
|
||||
/**
|
||||
* 修改保存岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePost(SysPost post);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public interface ISysRoleService
|
||||
*/
|
||||
public List<SysRole> selectRoleList(SysRole role);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色列表
|
||||
*
|
||||
|
||||
@@ -60,13 +60,6 @@ public interface ISysUserService
|
||||
*/
|
||||
public String selectUserRoleGroup(String userName);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户所属岗位组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
public String selectUserPostGroup(String userName);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
@@ -255,4 +248,6 @@ public interface ISysUserService
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> selectByDeptId();
|
||||
|
||||
List<SysUser> selectByRoleId(Long id);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.maibu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.maibu.core.domain.AjaxResult;
|
||||
import com.maibu.core.domain.entity.SysOrg;
|
||||
import com.maibu.core.domain.entity.SysUser;
|
||||
import com.maibu.mapper.SysOrgMapper;
|
||||
import com.maibu.mapper.SysUserMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +23,20 @@ public class SysOrgService {
|
||||
@Autowired
|
||||
private SysOrgMapper sysOrgMapper;
|
||||
|
||||
@Autowired
|
||||
private SysSiteService sysSiteService;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
|
||||
public List<SysOrg> list(SysOrg org) {
|
||||
if (org != null && org.getUserId() != null) {
|
||||
SysUser sysUser = sysUserMapper.selectUserById(org.getUserId());
|
||||
if(sysUser!=null){
|
||||
org.setId(sysUser.getOrgId());
|
||||
}
|
||||
}
|
||||
LambdaQueryWrapper<SysOrg> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (org != null && !StringUtils.isEmpty(org.getOrgCode())) {
|
||||
queryWrapper.eq(SysOrg::getOrgCode, org.getOrgCode());
|
||||
@@ -29,6 +44,9 @@ public class SysOrgService {
|
||||
if (org != null && !StringUtils.isEmpty(org.getOrgName())) {
|
||||
queryWrapper.like(SysOrg::getOrgName, org.getOrgName());
|
||||
}
|
||||
if (org != null && org.getId()!=null) {
|
||||
queryWrapper.eq(SysOrg::getId, org.getId());
|
||||
}
|
||||
return sysOrgMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@@ -36,8 +54,12 @@ public class SysOrgService {
|
||||
return sysOrgMapper.saveOrUpdate(org);
|
||||
}
|
||||
|
||||
public int delete(Long id) {
|
||||
return sysOrgMapper.updateById(id);
|
||||
public AjaxResult delete(Long id) {
|
||||
// todo 查询是否有管理的site
|
||||
if (sysSiteService.checkExistSite(id)) {
|
||||
return AjaxResult.error("组织下有场站请先删除!");
|
||||
}
|
||||
return AjaxResult.success(sysOrgMapper.deleteById(id));
|
||||
}
|
||||
|
||||
public SysOrg selectById(Long id) {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.maibu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.maibu.core.domain.entity.SysOrg;
|
||||
import com.maibu.core.domain.entity.SysSite;
|
||||
import com.maibu.core.redis.RedisCache;
|
||||
import com.maibu.mapper.SysOrgMapper;
|
||||
import com.maibu.exception.ServiceException;
|
||||
import com.maibu.mapper.SysRegionMapper;
|
||||
import com.maibu.mapper.SysSiteMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,6 +20,9 @@ public class SysSiteService {
|
||||
@Autowired
|
||||
private SysSiteMapper sysSiteMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRegionService sysRegionService;
|
||||
|
||||
|
||||
public List<SysSite> list(SysSite site) {
|
||||
LambdaQueryWrapper<SysSite> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -32,8 +36,21 @@ public class SysSiteService {
|
||||
return sysSiteMapper.saveOrUpdate(org);
|
||||
}
|
||||
|
||||
public int delete(Long id) {
|
||||
return sysSiteMapper.deleteById(id);
|
||||
@Transactional
|
||||
public int delete(List<Long> ids) {
|
||||
sysRegionService.deleteAll(ids);
|
||||
return sysSiteMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
|
||||
public boolean checkExistSite(Long id) {
|
||||
List<SysSite> sysSites = selectByOrgId(id);
|
||||
if (CollectionUtils.isEmpty(sysSites)) {
|
||||
return false;
|
||||
} else {
|
||||
long count = sysSites.stream().filter(x -> x.getDelFlag() != null && !x.getDelFlag()).count();
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public SysSite selectById(Long id) {
|
||||
|
||||
@@ -33,8 +33,7 @@ import static com.maibu.utils.SecurityUtils.getLoginUser;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl implements ISysMenuService
|
||||
{
|
||||
public class SysMenuServiceImpl implements ISysMenuService {
|
||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||
|
||||
@Resource
|
||||
@@ -56,8 +55,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList(Long userId)
|
||||
{
|
||||
public List<SysMenu> selectMenuList(Long userId) {
|
||||
return selectMenuList(new SysMenu(), userId);
|
||||
}
|
||||
|
||||
@@ -68,17 +66,15 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
||||
{
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId) {
|
||||
|
||||
//todo 重写
|
||||
menu.setLanguage(SecurityUtils.getLanguage());
|
||||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
if (SysUser.isAdmin(userId)) {
|
||||
menuList = menuMapper.selectMenuList(menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
menu.getParams().put("userId", userId);
|
||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||
}
|
||||
@@ -92,14 +88,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId)
|
||||
{
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(perm))
|
||||
{
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
@@ -113,14 +106,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId)
|
||||
{
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByRoleId(roleId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(perm))
|
||||
{
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
@@ -135,15 +125,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId, String language)
|
||||
{
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId, String language) {
|
||||
List<SysMenu> menus = null;
|
||||
if (SecurityUtils.isAdmin(userId))
|
||||
{
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menus = menuMapper.selectMenuTreeAll(language);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
menus = menuMapper.selectMenuTreeByUserId(userId, language);
|
||||
}
|
||||
return getChildPerms(menus, 0);
|
||||
@@ -156,8 +142,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectMenuListByRoleId(Long roleId)
|
||||
{
|
||||
public List<Long> selectMenuListByRoleId(Long roleId) {
|
||||
SysRole role = roleMapper.selectRoleById(roleId);
|
||||
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
||||
}
|
||||
@@ -169,11 +154,9 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 路由列表
|
||||
*/
|
||||
@Override
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus)
|
||||
{
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus) {
|
||||
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||
for (SysMenu menu : menus)
|
||||
{
|
||||
for (SysMenu menu : menus) {
|
||||
RouterVo router = new RouterVo();
|
||||
router.setHidden("1".equals(menu.getVisible()));
|
||||
router.setName(getRouteName(menu));
|
||||
@@ -182,14 +165,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
router.setQuery(menu.getQuery());
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
List<SysMenu> cMenus = menu.getChildren();
|
||||
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
||||
{
|
||||
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
||||
router.setAlwaysShow(true);
|
||||
router.setRedirect("noRedirect");
|
||||
router.setChildren(buildMenus(cMenus));
|
||||
}
|
||||
else if (isMenuFrame(menu))
|
||||
{
|
||||
} else if (isMenuFrame(menu)) {
|
||||
router.setMeta(null);
|
||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
RouterVo children = new RouterVo();
|
||||
@@ -200,9 +180,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
children.setQuery(menu.getQuery());
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
}
|
||||
else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
||||
{
|
||||
} else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
router.setPath("/");
|
||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
@@ -227,22 +205,18 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
|
||||
{
|
||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
||||
{
|
||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
|
||||
SysMenu menu = (SysMenu) iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(menu.getParentId()))
|
||||
{
|
||||
if (!tempList.contains(menu.getParentId())) {
|
||||
recursionFn(menus, menu);
|
||||
returnList.add(menu);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
if (returnList.isEmpty()) {
|
||||
returnList = menus;
|
||||
}
|
||||
return returnList;
|
||||
@@ -255,8 +229,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
|
||||
{
|
||||
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) {
|
||||
List<SysMenu> menuTrees = buildMenuTree(menus);
|
||||
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
@@ -268,8 +241,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 菜单信息
|
||||
*/
|
||||
@Override
|
||||
public SysMenu selectMenuById(Long menuId)
|
||||
{
|
||||
public SysMenu selectMenuById(Long menuId) {
|
||||
return menuMapper.selectMenuById(menuId, SecurityUtils.getLanguage());
|
||||
}
|
||||
|
||||
@@ -280,8 +252,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId)
|
||||
{
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
int result = menuMapper.hasChildByMenuId(menuId);
|
||||
return result > 0;
|
||||
}
|
||||
@@ -293,12 +264,12 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuExistRole(Long menuId)
|
||||
{
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
int result = roleMenuMapper.checkMenuExistRole(menuId);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增保存菜单信息
|
||||
*
|
||||
@@ -306,8 +277,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMenu(SysMenu menu)
|
||||
{
|
||||
public int insertMenu(SysMenu menu) {
|
||||
return menuMapper.insertMenu(menu);
|
||||
}
|
||||
|
||||
@@ -318,8 +288,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMenu(SysMenu menu)
|
||||
{
|
||||
public int updateMenu(SysMenu menu) {
|
||||
return menuMapper.updateMenu(menu);
|
||||
}
|
||||
|
||||
@@ -330,8 +299,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMenuById(Long menuId)
|
||||
{
|
||||
public int deleteMenuById(Long menuId) {
|
||||
return menuMapper.deleteMenuById(menuId);
|
||||
}
|
||||
|
||||
@@ -342,13 +310,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkMenuNameUnique(SysMenu menu)
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -365,18 +331,14 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
|
||||
@Override
|
||||
public List<SysMenu> deptRoleMenuTreeselect(Long deptId, Long roleId) {
|
||||
//todo
|
||||
LoginUser loginUser = getLoginUser();
|
||||
Long userDeptId = loginUser.getDeptId();
|
||||
Long deptUserId = loginUser.getUser().getDept().getDeptUserId();
|
||||
// Long deptUserId = loginUser.getUser().getDept().getDeptUserId();
|
||||
SysRole sysRole = roleMapper.selectRoleById(roleId);
|
||||
// List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectRoleByUserId(sysDept.getDeptUserId());
|
||||
// SysUserRole sysUserRole = sysUserRoleList.stream().filter(s -> roleId.equals(s.getRoleId())).findAny().orElse(null);
|
||||
// if (ObjectUtil.isNotNull(sysUserRole)) {
|
||||
// return menuMapper.selectMenuList(new SysMenu());
|
||||
// if (!deptId.equals(userDeptId) && "manager".equals(sysRole.getRoleKey())) {
|
||||
// return this.selectMenuList(deptUserId);
|
||||
// }
|
||||
if (!deptId.equals(userDeptId) && "manager".equals(sysRole.getRoleKey())) {
|
||||
return this.selectMenuList(deptUserId);
|
||||
}
|
||||
SysDept sysDept = sysDeptMapper.selectDeptById(deptId);
|
||||
if (ObjectUtil.isNull(sysDept) && null == sysDept.getDeptUserId()) {
|
||||
return new ArrayList<>();
|
||||
@@ -390,12 +352,10 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param menu 菜单信息
|
||||
* @return 路由名称
|
||||
*/
|
||||
public String getRouteName(SysMenu menu)
|
||||
{
|
||||
public String getRouteName(SysMenu menu) {
|
||||
String routerName = StringUtils.capitalize(menu.getPath());
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (isMenuFrame(menu))
|
||||
{
|
||||
if (isMenuFrame(menu)) {
|
||||
routerName = StringUtils.EMPTY;
|
||||
}
|
||||
return routerName;
|
||||
@@ -407,23 +367,19 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param menu 菜单信息
|
||||
* @return 路由地址
|
||||
*/
|
||||
public String getRouterPath(SysMenu menu)
|
||||
{
|
||||
public String getRouterPath(SysMenu menu) {
|
||||
String routerPath = menu.getPath();
|
||||
// 内链打开外网方式
|
||||
if (menu.getParentId().intValue() != 0 && isInnerLink(menu))
|
||||
{
|
||||
if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||
routerPath = innerLinkReplaceEach(routerPath);
|
||||
}
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
||||
&& UserConstants.NO_FRAME.equals(menu.getIsFrame()))
|
||||
{
|
||||
&& UserConstants.NO_FRAME.equals(menu.getIsFrame())) {
|
||||
routerPath = "/" + menu.getPath();
|
||||
}
|
||||
// 非外链并且是一级目录(类型为菜单)
|
||||
else if (isMenuFrame(menu))
|
||||
{
|
||||
else if (isMenuFrame(menu)) {
|
||||
routerPath = "/";
|
||||
}
|
||||
return routerPath;
|
||||
@@ -435,19 +391,13 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param menu 菜单信息
|
||||
* @return 组件信息
|
||||
*/
|
||||
public String getComponent(SysMenu menu)
|
||||
{
|
||||
public String getComponent(SysMenu menu) {
|
||||
String component = UserConstants.LAYOUT;
|
||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu))
|
||||
{
|
||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
|
||||
component = menu.getComponent();
|
||||
}
|
||||
else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu))
|
||||
{
|
||||
} else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||
component = UserConstants.INNER_LINK;
|
||||
}
|
||||
else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
|
||||
{
|
||||
} else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) {
|
||||
component = UserConstants.PARENT_VIEW;
|
||||
}
|
||||
return component;
|
||||
@@ -459,8 +409,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isMenuFrame(SysMenu menu)
|
||||
{
|
||||
public boolean isMenuFrame(SysMenu menu) {
|
||||
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
||||
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
||||
}
|
||||
@@ -471,8 +420,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isInnerLink(SysMenu menu)
|
||||
{
|
||||
public boolean isInnerLink(SysMenu menu) {
|
||||
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath());
|
||||
}
|
||||
|
||||
@@ -482,8 +430,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isParentView(SysMenu menu)
|
||||
{
|
||||
public boolean isParentView(SysMenu menu) {
|
||||
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
||||
}
|
||||
|
||||
@@ -494,15 +441,12 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param parentId 传入的父节点ID
|
||||
* @return String
|
||||
*/
|
||||
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
|
||||
{
|
||||
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
|
||||
{
|
||||
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
|
||||
SysMenu t = (SysMenu) iterator.next();
|
||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||
if (t.getParentId() == parentId)
|
||||
{
|
||||
if (t.getParentId() == parentId) {
|
||||
recursionFn(list, t);
|
||||
returnList.add(t);
|
||||
}
|
||||
@@ -516,15 +460,12 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param list 分类表
|
||||
* @param t 子节点
|
||||
*/
|
||||
private void recursionFn(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
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))
|
||||
{
|
||||
for (SysMenu tChild : childList) {
|
||||
if (hasChild(list, tChild)) {
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
@@ -533,15 +474,12 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
|
||||
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
||||
Iterator<SysMenu> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
while (it.hasNext()) {
|
||||
SysMenu n = (SysMenu) it.next();
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue())
|
||||
{
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
@@ -551,8 +489,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
private boolean hasChild(List<SysMenu> list, SysMenu t) {
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
|
||||
@@ -561,10 +498,10 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
*
|
||||
* @return 替换后的内链域名
|
||||
*/
|
||||
public String innerLinkReplaceEach(String path)
|
||||
{
|
||||
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." },
|
||||
new String[] { "", "", "", "/" });
|
||||
public String innerLinkReplaceEach(String path) {
|
||||
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, "."},
|
||||
new String[]{"", "", "", "/"});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
package com.maibu.service.impl;
|
||||
|
||||
import com.maibu.constant.UserConstants;
|
||||
import com.maibu.domain.SysPost;
|
||||
import com.maibu.exception.ServiceException;
|
||||
import com.maibu.mapper.SysPostMapper;
|
||||
import com.maibu.mapper.SysUserPostMapper;
|
||||
import com.maibu.service.ISysPostService;
|
||||
import com.maibu.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位信息 服务层处理
|
||||
*
|
||||
* @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 postId 岗位ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysPost selectPostById(Long postId)
|
||||
{
|
||||
return postMapper.selectPostById(postId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取岗位选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中岗位ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectPostListByUserId(Long userId)
|
||||
{
|
||||
return postMapper.selectPostListByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验岗位名称是否唯一
|
||||
*
|
||||
* @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.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.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.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过岗位ID查询岗位使用数量
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int countUserPostById(Long postId)
|
||||
{
|
||||
return userPostMapper.countUserPostById(postId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostById(Long postId)
|
||||
{
|
||||
return postMapper.deletePostById(postId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
*
|
||||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] postIds)
|
||||
{
|
||||
for (Long postId : postIds)
|
||||
{
|
||||
SysPost post = selectPostById(postId);
|
||||
if (countUserPostById(postId) > 0)
|
||||
{
|
||||
throw new ServiceException(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);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.maibu.service.ISysRoleService;
|
||||
import com.maibu.utils.SecurityUtils;
|
||||
import com.maibu.utils.StringUtils;
|
||||
import com.maibu.utils.spring.SpringUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -23,6 +22,7 @@ import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.maibu.core.domain.entity.SysUser;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
@@ -37,8 +37,7 @@ import static com.maibu.utils.SecurityUtils.getLoginUser;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl implements ISysRoleService
|
||||
{
|
||||
public class SysRoleServiceImpl implements ISysRoleService {
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@@ -54,77 +53,28 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
@Resource
|
||||
private SysDeptMapper sysDeptMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysRole> selectRoleList(SysRole role)
|
||||
{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
Long userDeptId = loginUser.getDeptId();
|
||||
Long deptId;
|
||||
if (null != role.getDeptId()) {
|
||||
deptId = role.getDeptId();
|
||||
} else {
|
||||
deptId = loginUser.getDeptId();
|
||||
}
|
||||
List<SysDept> sysDeptList;
|
||||
SysDept sysDept = new SysDept();
|
||||
sysDept.setDeptId(deptId);
|
||||
if (null != role.getShowChild() && role.getShowChild()) {
|
||||
sysDeptList = sysDeptMapper.listDeptAndChild(sysDept);
|
||||
} else {
|
||||
sysDeptList = sysDeptMapper.selectDeptList(sysDept);
|
||||
}
|
||||
// List<SysDept> sysDeptList = new ArrayList<>();
|
||||
// if (null != role.getDeptIds()) {
|
||||
// sysDeptList = sysDeptMapper.selectDeptByIds(Arrays.asList(role.getDeptIds()));
|
||||
// } else {
|
||||
// LoginUser loginUser = getLoginUser();
|
||||
// Long deptId = loginUser.getDeptId();
|
||||
// if (null != deptId) {
|
||||
// SysDept sysDept = new SysDept();
|
||||
// sysDept.setDeptId(deptId);
|
||||
// sysDeptList = sysDeptMapper.selectDeptList(sysDept);
|
||||
// }
|
||||
// }
|
||||
if (CollectionUtils.isNotEmpty(sysDeptList)) {
|
||||
Map<Long, String> deptMap = sysDeptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
||||
List<Long> deptIdList = sysDeptList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
||||
List<SysRoleDept> sysRoleDeptList = roleDeptMapper.selectRoleDeptByDeptIds(deptIdList);
|
||||
Map<Long, Long> roleDeptMap = sysRoleDeptList.stream().collect(Collectors.toMap(SysRoleDept::getRoleId, SysRoleDept::getDeptId));
|
||||
if (CollectionUtils.isEmpty(sysRoleDeptList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Long> roleIdList = sysRoleDeptList.stream().map(SysRoleDept::getRoleId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(roleIdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<SysRole> sysRoleList = roleMapper.selectRoleByIds(roleIdList, role.getRoleName(), role.getStatus());
|
||||
for (SysRole sysRole : sysRoleList) {
|
||||
Long deptId1 = roleDeptMap.get(sysRole.getRoleId());
|
||||
String deptName = deptMap.get(deptId1);
|
||||
sysRole.setDeptId(deptId1);
|
||||
sysRole.setDeptName(deptName);
|
||||
// if (userDeptId.equals(deptId1) && "manager".equals(sysRole.getRoleKey())) {
|
||||
// sysRole.setCanEditRole(false);
|
||||
// } else {
|
||||
// sysRole.setCanEditRole(true);
|
||||
// }
|
||||
sysRole.setCanEditRole(!(userDeptId.equals(deptId1) && "manager".equals(sysRole.getRoleKey()) && !SecurityUtils.isAdmin(userId)));
|
||||
sysRole.setManager("manager".equals(sysRole.getRoleKey()));
|
||||
}
|
||||
return sysRoleList;
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
public List<SysRole> selectRoleList(SysRole role) {
|
||||
List<SysRole> list = roleMapper.selectRoleAll();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(x -> {
|
||||
if (!StringUtils.isEmpty(x.getMenuList())) {
|
||||
String[] l = x.getMenuList().split(",");
|
||||
Long[] result = Arrays.stream(l)
|
||||
.filter(s -> s != null && !s.isEmpty())
|
||||
.map(Long::valueOf)
|
||||
.toArray(Long[]::new);
|
||||
x.setMenuIds(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
@@ -133,16 +83,12 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@Cacheable(cacheNames = "role", key = "#root.methodName + ':' + #userId", unless = "#result == null or #result.size() == 0")
|
||||
@Override
|
||||
public List<SysRole> selectRolesByUserId(Long userId)
|
||||
{
|
||||
public List<SysRole> selectRolesByUserId(Long userId) {
|
||||
List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
|
||||
List<SysRole> roles = selectRoleAll();
|
||||
for (SysRole role : roles)
|
||||
{
|
||||
for (SysRole userRole : userRoles)
|
||||
{
|
||||
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
|
||||
{
|
||||
for (SysRole role : roles) {
|
||||
for (SysRole userRole : userRoles) {
|
||||
if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {
|
||||
role.setFlag(true);
|
||||
break;
|
||||
}
|
||||
@@ -159,14 +105,11 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@Cacheable(cacheNames = "role", key = "#root.methodName + ':' + #userId", unless = "#result == null or #result.size() == 0")
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(Long userId)
|
||||
{
|
||||
public Set<String> selectRolePermissionByUserId(Long userId) {
|
||||
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (SysRole perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotNull(perm))
|
||||
{
|
||||
for (SysRole perm : perms) {
|
||||
if (StringUtils.isNotNull(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
||||
}
|
||||
}
|
||||
@@ -179,8 +122,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRoleAll()
|
||||
{
|
||||
public List<SysRole> selectRoleAll() {
|
||||
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
|
||||
}
|
||||
|
||||
@@ -191,8 +133,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectRoleListByUserId(Long userId)
|
||||
{
|
||||
public List<Long> selectRoleListByUserId(Long userId) {
|
||||
return roleMapper.selectRoleListByUserId(userId);
|
||||
}
|
||||
|
||||
@@ -204,16 +145,8 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@Cacheable(cacheNames = "role", key = "#root.methodName + ':' + #roleId", unless = "#result == null")
|
||||
@Override
|
||||
public SysRole selectRoleById(Long roleId)
|
||||
{
|
||||
SysRole sysRole = roleMapper.selectRoleById(roleId);
|
||||
if (ObjectUtil.isNotNull(sysRole)) {
|
||||
SysRoleDept sysRoleDept = roleDeptMapper.selectByRoleId(sysRole.getRoleId());
|
||||
if (ObjectUtil.isNotNull(sysRoleDept)) {
|
||||
sysRole.setDeptId(sysRoleDept.getDeptId());
|
||||
}
|
||||
}
|
||||
return sysRole;
|
||||
public SysRole selectRoleById(Long roleId) {
|
||||
return roleMapper.selectRoleById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,12 +156,10 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkRoleNameUnique(SysRole role)
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -241,12 +172,10 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkRoleKeyUnique(SysRole role)
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -258,10 +187,8 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param role 角色信息
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleAllowed(SysRole role)
|
||||
{
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
|
||||
{
|
||||
public void checkRoleAllowed(SysRole role) {
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员角色");
|
||||
}
|
||||
}
|
||||
@@ -272,15 +199,12 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(Long roleId)
|
||||
{
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
||||
{
|
||||
public void checkRoleDataScope(Long roleId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
if (StringUtils.isEmpty(roles))
|
||||
{
|
||||
if (StringUtils.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
}
|
||||
}
|
||||
@@ -294,8 +218,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@Cacheable(cacheNames = "role", key = "#root.methodName + ':' + #roleId", unless = "#result == null")
|
||||
@Override
|
||||
public int countUserRoleByRoleId(Long roleId)
|
||||
{
|
||||
public int countUserRoleByRoleId(Long roleId) {
|
||||
return userRoleMapper.countUserRoleByRoleId(roleId);
|
||||
}
|
||||
|
||||
@@ -307,19 +230,18 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertRole(SysRole role)
|
||||
{
|
||||
public int insertRole(SysRole role) {
|
||||
// 新增角色信息
|
||||
roleMapper.insertRole(role);
|
||||
// 绑定部门角色
|
||||
List<SysRoleDept> sysRoleDeptList = new ArrayList<>();
|
||||
SysRoleDept sysRoleDept = new SysRoleDept();
|
||||
sysRoleDept.setDeptId(role.getDeptId());
|
||||
sysRoleDept.setRoleId(role.getRoleId());
|
||||
sysRoleDeptList.add(sysRoleDept);
|
||||
if (CollectionUtils.isNotEmpty(sysRoleDeptList)) {
|
||||
roleDeptMapper.batchRoleDept(sysRoleDeptList);
|
||||
}
|
||||
// // 绑定部门角色
|
||||
// List<SysRoleDept> sysRoleDeptList = new ArrayList<>();
|
||||
// SysRoleDept sysRoleDept = new SysRoleDept();
|
||||
// sysRoleDept.setDeptId(role.getDeptId());
|
||||
// sysRoleDept.setRoleId(role.getRoleId());
|
||||
// sysRoleDeptList.add(sysRoleDept);
|
||||
// if (CollectionUtils.isNotEmpty(sysRoleDeptList)) {
|
||||
// roleDeptMapper.batchRoleDept(sysRoleDeptList);
|
||||
// }
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
@@ -334,8 +256,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
})
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRole(SysRole role)
|
||||
{
|
||||
public int updateRole(SysRole role) {
|
||||
// 修改角色信息
|
||||
roleMapper.updateRole(role);
|
||||
// 删除角色与菜单关联
|
||||
@@ -353,8 +274,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
@CacheEvict(cacheNames = "role", key = "'selectRoleById:' + #role.roleId", condition = "#result != null"),
|
||||
})
|
||||
@Override
|
||||
public int updateRoleStatus(SysRole role)
|
||||
{
|
||||
public int updateRoleStatus(SysRole role) {
|
||||
return roleMapper.updateRole(role);
|
||||
}
|
||||
|
||||
@@ -366,8 +286,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int authDataScope(SysRole role)
|
||||
{
|
||||
public int authDataScope(SysRole role) {
|
||||
// 修改角色信息
|
||||
roleMapper.updateRole(role);
|
||||
// 删除角色与部门关联
|
||||
@@ -381,20 +300,17 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleMenu(SysRole role)
|
||||
{
|
||||
public int insertRoleMenu(SysRole role) {
|
||||
int rows = 1;
|
||||
// 新增用户与角色管理
|
||||
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
|
||||
for (Long menuId : role.getMenuIds())
|
||||
{
|
||||
for (Long menuId : role.getMenuIds()) {
|
||||
SysRoleMenu rm = new SysRoleMenu();
|
||||
rm.setRoleId(role.getRoleId());
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
if (list.size() > 0) {
|
||||
rows = roleMenuMapper.batchRoleMenu(list);
|
||||
}
|
||||
return rows;
|
||||
@@ -405,20 +321,17 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleDept(SysRole role)
|
||||
{
|
||||
public int insertRoleDept(SysRole role) {
|
||||
int rows = 1;
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
|
||||
for (Long deptId : role.getDeptIds())
|
||||
{
|
||||
for (Long deptId : role.getDeptIds()) {
|
||||
SysRoleDept rd = new SysRoleDept();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
if (list.size() > 0) {
|
||||
rows = roleDeptMapper.batchRoleDept(list);
|
||||
}
|
||||
return rows;
|
||||
@@ -433,8 +346,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
@CacheEvict(cacheNames = "role", allEntries = true)
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteRoleById(Long roleId)
|
||||
{
|
||||
public int deleteRoleById(Long roleId) {
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
|
||||
// 删除角色与部门关联
|
||||
@@ -451,13 +363,11 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
@CacheEvict(cacheNames = "role", allEntries = true)
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteRoleByIds(Long[] roleIds)
|
||||
{
|
||||
for (Long roleId : roleIds)
|
||||
{
|
||||
public int deleteRoleByIds(Long[] roleIds) {
|
||||
for (Long roleId : roleIds) {
|
||||
checkRoleAllowed(new SysRole(roleId));
|
||||
checkRoleDataScope(roleId);
|
||||
SysRole role = selectRoleById(roleId);
|
||||
// SysRole role = selectRoleById(roleId);
|
||||
//if (countUserRoleByRoleId(roleId) > 0)
|
||||
//{
|
||||
// throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
@@ -466,7 +376,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenu(roleIds);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDept(roleIds);
|
||||
// roleDeptMapper.deleteRoleDept(roleIds);
|
||||
return roleMapper.deleteRoleByIds(roleIds);
|
||||
}
|
||||
|
||||
@@ -478,8 +388,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@CacheEvict(cacheNames = "role", allEntries = true)
|
||||
@Override
|
||||
public int deleteAuthUser(SysUserRole userRole)
|
||||
{
|
||||
public int deleteAuthUser(SysUserRole userRole) {
|
||||
return userRoleMapper.deleteUserRoleInfo(userRole);
|
||||
}
|
||||
|
||||
@@ -492,8 +401,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*/
|
||||
@CacheEvict(cacheNames = "role", allEntries = true)
|
||||
@Override
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds)
|
||||
{
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds) {
|
||||
return userRoleMapper.deleteUserRoleInfos(roleId, userIds);
|
||||
}
|
||||
|
||||
@@ -505,12 +413,10 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds)
|
||||
{
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
for (Long userId : userIds)
|
||||
{
|
||||
for (Long userId : userIds) {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
|
||||
@@ -87,10 +87,11 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
|
||||
sysUserOnline.setBrowser(user.getBrowser());
|
||||
sysUserOnline.setOs(user.getOs());
|
||||
sysUserOnline.setLoginTime(user.getLoginTime());
|
||||
if (StringUtils.isNotNull(user.getUser().getDept()))
|
||||
{
|
||||
sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
|
||||
}
|
||||
//TODO 设置组织?
|
||||
// if (StringUtils.isNotNull(user.getUser().getDept()))
|
||||
// {
|
||||
// sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
|
||||
// }
|
||||
return sysUserOnline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@ package com.maibu.service.impl;
|
||||
|
||||
import com.maibu.annotation.DataScope;
|
||||
import com.maibu.constant.UserConstants;
|
||||
import com.maibu.core.domain.entity.SysDept;
|
||||
import com.maibu.core.domain.entity.SysRole;
|
||||
import com.maibu.core.domain.entity.SysUser;
|
||||
import com.maibu.domain.SysPost;
|
||||
import com.maibu.domain.SysUserPost;
|
||||
import com.maibu.domain.SysUserRole;
|
||||
import com.maibu.enums.SocialPlatformType;
|
||||
import com.maibu.exception.ServiceException;
|
||||
@@ -39,8 +36,7 @@ import java.util.stream.Collectors;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
public class SysUserServiceImpl implements ISysUserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
@@ -49,14 +45,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysPostMapper postMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserPostMapper userPostMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
@@ -71,23 +63,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectUserList(SysUser user) {
|
||||
List<SysUser> sysUserList = userMapper.selectUserList(user);
|
||||
for (SysUser sysUser : sysUserList) {
|
||||
// 根据用户查询角色
|
||||
List<SysRole> sysRoles = roleMapper.selectRolePermissionByUserId(sysUser.getUserId());
|
||||
if (!sysRoles.isEmpty()){
|
||||
String result = sysRoles.stream()
|
||||
.map(SysRole::getRoleName) // 方法引用,等价于 role -> role.getRoleName()
|
||||
.collect(Collectors.joining(", ")); // 指定分隔符
|
||||
sysUser.setRoles(sysRoles);
|
||||
sysUser.setRoleNames(result);
|
||||
}
|
||||
SysDept dept = sysUser.getDept();
|
||||
sysUser.setManager(sysUser.getUserId().equals(dept.getDeptUserId()));
|
||||
}
|
||||
// for (SysUser sysUser : sysUserList) {
|
||||
// // 根据用户查询角色
|
||||
// List<SysRole> sysRoles = roleMapper.selectRolePermissionByUserId(sysUser.getUserId());
|
||||
// if (!sysRoles.isEmpty()) {
|
||||
// String result = sysRoles.stream()
|
||||
// .map(SysRole::getRoleName) // 方法引用,等价于 role -> role.getRoleName()
|
||||
// .collect(Collectors.joining(", ")); // 指定分隔符
|
||||
// sysUser.setRoles(sysRoles);
|
||||
// sysUser.setRoleNames(result);
|
||||
// }
|
||||
//// SysDept dept = sysUser.getDept();
|
||||
//// sysUser.setManager(sysUser.getUserId().equals(dept.getDeptUserId()));
|
||||
// }
|
||||
return sysUserList;
|
||||
}
|
||||
|
||||
@@ -99,8 +89,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectAllocatedList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectAllocatedList(SysUser user) {
|
||||
return userMapper.selectAllocatedList(user);
|
||||
}
|
||||
|
||||
@@ -112,8 +101,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUnallocatedList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||
user.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
|
||||
return userMapper.selectUnallocatedList(user);
|
||||
}
|
||||
@@ -126,8 +114,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Cacheable(cacheNames = "sysUser", key = "#root.methodName + ':' + #userName", unless = "#result == null")
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName)
|
||||
{
|
||||
public SysUser selectUserByUserName(String userName) {
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
@@ -139,8 +126,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Cacheable(cacheNames = "sysUser", key = "#root.methodName + ':' + #userId", unless = "#result == null")
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId)
|
||||
{
|
||||
public SysUser selectUserById(Long userId) {
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
@@ -152,34 +138,14 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Cacheable(cacheNames = "sysUser", key = "#root.methodName + ':' + #userName", unless = "#result == null")
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userName)
|
||||
{
|
||||
public String selectUserRoleGroup(String userName) {
|
||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||
if (CollectionUtils.isEmpty(list))
|
||||
{
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户所属岗位组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Cacheable(cacheNames = "sysUser", key = "#root.methodName + ':' + #userName", unless = "#result == null")
|
||||
@Override
|
||||
public String selectUserPostGroup(String userName)
|
||||
{
|
||||
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
||||
if (CollectionUtils.isEmpty(list))
|
||||
{
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
@@ -187,12 +153,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkUserNameUnique(SysUser user)
|
||||
{
|
||||
public String checkUserNameUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -205,12 +169,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkPhoneUnique(SysUser user)
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -223,12 +185,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkEmailUnique(SysUser user)
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -240,10 +200,8 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||
{
|
||||
public void checkUserAllowed(SysUser user) {
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
@@ -254,15 +212,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId)
|
||||
{
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
||||
{
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
if (StringUtils.isEmpty(users))
|
||||
{
|
||||
if (StringUtils.isEmpty(users)) {
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
@@ -281,12 +236,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
})
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertUser(SysUser user)
|
||||
{
|
||||
public int insertUser(SysUser user) {
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
return rows;
|
||||
@@ -299,8 +253,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUser user)
|
||||
{
|
||||
public boolean registerUser(SysUser user) {
|
||||
return userMapper.insertUser(user) > 0;
|
||||
}
|
||||
|
||||
@@ -317,17 +270,16 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
})
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateUser(SysUser user)
|
||||
{
|
||||
public int updateUser(SysUser user) {
|
||||
Long userId = user.getUserId();
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user);
|
||||
// insertUserPost(user);
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@@ -339,8 +291,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void insertUserAuth(Long userId, Long[] roleIds)
|
||||
{
|
||||
public void insertUserAuth(Long userId, Long[] roleIds) {
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
insertUserRole(userId, roleIds);
|
||||
}
|
||||
@@ -352,8 +303,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(SysUser user)
|
||||
{
|
||||
public int updateUserStatus(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@@ -364,8 +314,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserProfile(SysUser user)
|
||||
{
|
||||
public int updateUserProfile(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@@ -377,8 +326,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userName, String avatar)
|
||||
{
|
||||
public boolean updateUserAvatar(String userName, String avatar) {
|
||||
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||
}
|
||||
|
||||
@@ -389,8 +337,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetPwd(SysUser user)
|
||||
{
|
||||
public int resetPwd(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@@ -402,8 +349,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(String userName, String password)
|
||||
{
|
||||
public int resetUserPwd(String userName, String password) {
|
||||
return userMapper.resetUserPwd(userName, password);
|
||||
}
|
||||
|
||||
@@ -412,8 +358,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserRole(SysUser user)
|
||||
{
|
||||
public void insertUserRole(SysUser user) {
|
||||
this.insertUserRole(user.getUserId(), user.getRoleIds());
|
||||
}
|
||||
|
||||
@@ -422,22 +367,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserPost(SysUser user)
|
||||
{
|
||||
Long[] posts = user.getPostIds();
|
||||
if (StringUtils.isNotEmpty(posts))
|
||||
{
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
||||
for (Long postId : posts)
|
||||
{
|
||||
SysUserPost up = new SysUserPost();
|
||||
up.setUserId(user.getUserId());
|
||||
up.setPostId(postId);
|
||||
list.add(up);
|
||||
}
|
||||
userPostMapper.batchUserPost(list);
|
||||
}
|
||||
public void insertUserPost(SysUser user) {
|
||||
// Long[] posts = user.getPostIds();
|
||||
// if (StringUtils.isNotEmpty(posts))
|
||||
// {
|
||||
// // 新增用户与岗位管理
|
||||
// List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
||||
// for (Long postId : posts)
|
||||
// {
|
||||
// SysUserPost up = new SysUserPost();
|
||||
// up.setUserId(user.getUserId());
|
||||
// up.setPostId(postId);
|
||||
// list.add(up);
|
||||
// }
|
||||
// userPostMapper.batchUserPost(list);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,14 +390,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
public void insertUserRole(Long userId, Long[] roleIds)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(roleIds))
|
||||
{
|
||||
public void insertUserRole(Long userId, Long[] roleIds) {
|
||||
if (StringUtils.isNotEmpty(roleIds)) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>(roleIds.length);
|
||||
for (Long roleId : roleIds)
|
||||
{
|
||||
for (Long roleId : roleIds) {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
@@ -472,14 +413,13 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@CacheEvict(cacheNames = "sysUser", allEntries = true)
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteUserById(Long userId)
|
||||
{
|
||||
public int deleteUserById(Long userId) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 删除用户与岗位表
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 删除用户与微信绑定,因为引入iot-service模块会产生循环依赖,所以先写在这个mapper里
|
||||
userMapper.deleteBySysUserIdAndSourceClient(userId, SocialPlatformType.listWechatPlatform);
|
||||
// userMapper.deleteBySysUserIdAndSourceClient(userId, SocialPlatformType.listWechatPlatform);
|
||||
return userMapper.deleteUserById(userId);
|
||||
}
|
||||
|
||||
@@ -492,19 +432,17 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@CacheEvict(cacheNames = "sysUser", allEntries = true)
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteUserByIds(Long[] userIds)
|
||||
{
|
||||
for (Long userId : userIds)
|
||||
{
|
||||
public int deleteUserByIds(Long[] userIds) {
|
||||
for (Long userId : userIds) {
|
||||
checkUserAllowed(new SysUser(userId));
|
||||
checkUserDataScope(userId);
|
||||
}
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRole(userIds);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPost(userIds);
|
||||
// userPostMapper.deleteUserPost(userIds);
|
||||
// 删除用户与微信关联,因为引入iot-service模块会产生循环依赖,所以先写在这个mapper里
|
||||
userMapper.deleteBySysUserIdsAndSourceClient(userIds, SocialPlatformType.listWechatPlatform);
|
||||
// userMapper.deleteBySysUserIdsAndSourceClient(userIds, SocialPlatformType.listWechatPlatform);
|
||||
return userMapper.deleteUserByIds(userIds);
|
||||
}
|
||||
|
||||
@@ -517,10 +455,8 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
|
||||
{
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||
{
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||
throw new ServiceException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
@@ -528,23 +464,18 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
||||
for (SysUser user : userList)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (SysUser user : userList) {
|
||||
try {
|
||||
// 验证是否存在这个用户
|
||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||
if (StringUtils.isNull(u))
|
||||
{
|
||||
if (StringUtils.isNull(u)) {
|
||||
BeanValidators.validateWithException(validator, user);
|
||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
||||
user.setCreateBy(operName);
|
||||
this.insertUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
||||
}
|
||||
else if (isUpdateSupport)
|
||||
{
|
||||
} else if (isUpdateSupport) {
|
||||
BeanValidators.validateWithException(validator, user);
|
||||
checkUserAllowed(user);
|
||||
checkUserDataScope(user.getUserId());
|
||||
@@ -552,28 +483,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
this.updateUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
log.error(msg, e);
|
||||
}
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
@@ -614,7 +538,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> selectAllSubUser(Long deptId){
|
||||
public List<SysUser> selectAllSubUser(Long deptId) {
|
||||
return userMapper.selectAllSubUser(deptId);
|
||||
}
|
||||
|
||||
@@ -624,7 +548,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SysUser getDeptUserByUserId(Long userId){
|
||||
public SysUser getDeptUserByUserId(Long userId) {
|
||||
return userMapper.getDeptUserByUserId(userId);
|
||||
}
|
||||
|
||||
@@ -632,14 +556,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
public List<SysUser> listTerminal(SysUser user) {
|
||||
return userMapper.listTerminal(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据机构id获取当前机构所有非管理用户
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> selectByDeptId(){
|
||||
public List<SysUser> selectByDeptId() {
|
||||
Long deptId = SecurityUtils.getDeptId();
|
||||
return userMapper.selectByDeptId(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectByRoleId(Long roleId) {
|
||||
return userMapper.selectByRoleId(roleId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.maibu.mapper.SysPostMapper">
|
||||
|
||||
<resultMap type="SysPost" id="SysPostResult">
|
||||
<id property="postId" column="post_id" />
|
||||
<result property="postCode" column="post_code" />
|
||||
<result property="postName" column="post_name" />
|
||||
<result property="postSort" column="post_sort" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostVo">
|
||||
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
|
||||
from sys_post
|
||||
</sql>
|
||||
|
||||
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
<where>
|
||||
<if test="postCode != null and postCode != ''">
|
||||
AND post_code like concat('%', #{postCode}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="postName != null and postName != ''">
|
||||
AND post_name like concat('%', #{postName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPostAll" resultMap="SysPostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
where post_id = #{postId}
|
||||
</select>
|
||||
|
||||
<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
|
||||
select p.post_id
|
||||
from sys_post p
|
||||
left join sys_user_post up on up.post_id = p.post_id
|
||||
left join sys_user u on u.user_id = up.user_id
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
|
||||
select p.post_id, p.post_name, p.post_code
|
||||
from sys_post p
|
||||
left join sys_user_post up on up.post_id = p.post_id
|
||||
left join sys_user u on u.user_id = up.user_id
|
||||
where u.user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
where post_name=#{postName} limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
where post_code=#{postCode} limit 1
|
||||
</select>
|
||||
|
||||
<update id="updatePost" parameterType="SysPost">
|
||||
update sys_post
|
||||
<set>
|
||||
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
|
||||
<if test="postName != null and postName != ''">post_name = #{postName},</if>
|
||||
<if test="postSort != null">post_sort = #{postSort},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where post_id = #{postId}
|
||||
</update>
|
||||
|
||||
<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
|
||||
insert into sys_post(
|
||||
<if test="postId != null and postId != 0">post_id,</if>
|
||||
<if test="postCode != null and postCode != ''">post_code,</if>
|
||||
<if test="postName != null and postName != ''">post_name,</if>
|
||||
<if test="postSort != null">post_sort,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="postId != null and postId != 0">#{postId},</if>
|
||||
<if test="postCode != null and postCode != ''">#{postCode},</if>
|
||||
<if test="postName != null and postName != ''">#{postName},</if>
|
||||
<if test="postSort != null">#{postSort},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deletePostById" parameterType="Long">
|
||||
delete from sys_post where post_id = #{postId}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostByIds" parameterType="Long">
|
||||
delete from sys_post where post_id in
|
||||
<foreach collection="array" item="postId" open="(" separator="," close=")">
|
||||
#{postId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -19,20 +19,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="menuList" column="menu_list" />
|
||||
<result property="siteAccess" column="site_access" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||
r.status, r.del_flag, r.create_time, r.remark
|
||||
r.status, r.del_flag, r.create_time, r.remark,r.site_access
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.del_flag = '0'
|
||||
SELECT
|
||||
r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.menu_check_strictly,
|
||||
r.dept_check_strictly,
|
||||
r.status,
|
||||
r.del_flag,
|
||||
r.create_time,
|
||||
r.remark,
|
||||
r.site_access
|
||||
GROUP_CONCAT(srm.menu_id) AS menu_list
|
||||
FROM sys_role r
|
||||
LEFT JOIN sys_user_role ur ON ur.role_id = r.role_id
|
||||
LEFT JOIN sys_user u ON u.user_id = ur.user_id
|
||||
LEFT JOIN sys_role_menu srm ON srm.role_id = r.role_id
|
||||
|
||||
where r.del_flag = 0
|
||||
<if test="roleId != null and roleId != 0">
|
||||
AND r.role_id = #{roleId}
|
||||
</if>
|
||||
@@ -51,18 +70,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
GROUP BY r.role_id
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
||||
WHERE r.del_flag = 0 and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleAll" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
SELECT
|
||||
r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.menu_check_strictly,
|
||||
r.dept_check_strictly,
|
||||
r.status,
|
||||
r.del_flag,
|
||||
r.create_time,
|
||||
r.remark,
|
||||
r.site_access,
|
||||
GROUP_CONCAT(srm.menu_id) AS menu_list
|
||||
FROM sys_role r
|
||||
LEFT JOIN sys_user_role ur ON ur.role_id = r.role_id
|
||||
LEFT JOIN sys_user u ON u.user_id = ur.user_id
|
||||
LEFT JOIN sys_role_menu srm ON srm.role_id = r.role_id
|
||||
where r.del_flag = 0
|
||||
GROUP BY r.role_id
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
|
||||
@@ -80,17 +118,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and u.user_name = #{userName}
|
||||
WHERE r.del_flag = 0 and u.user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.role_name=#{roleName} and r.del_flag = '0' limit 1
|
||||
where r.role_name=#{roleName} and r.del_flag = 0 limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
|
||||
where r.role_key=#{roleKey} and r.del_flag = 0 limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectRoleByIds" resultMap="SysRoleResult">
|
||||
@@ -118,6 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="siteAccess != null and siteAccess != ''">site_access,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
@@ -130,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="siteAccess != null and siteAccess != ''">#{siteAccess},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
@@ -146,6 +186,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="siteAccess != null">site_access = #{siteAccess},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
@@ -153,11 +194,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</update>
|
||||
|
||||
<delete id="deleteRoleById" parameterType="Long">
|
||||
update sys_role set del_flag = '2' where role_id = #{roleId}
|
||||
update sys_role set del_flag = 1 where role_id = #{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRoleByIds" parameterType="Long">
|
||||
update sys_role set del_flag = '2' where role_id in
|
||||
update sys_role set del_flag = 1 where role_id in
|
||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
|
||||
@@ -25,11 +25,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<delete id="deleteRoleMenu" parameterType="Long">
|
||||
delete from sys_role_menu where role_id in
|
||||
<foreach collection="array" item="ids" index="roleId" open="(" separator="," close=")">
|
||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
<insert id="batchRoleMenu">
|
||||
insert into sys_role_menu(role_id, menu_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
<resultMap type="com.maibu.core.domain.entity.SysUser" id="SysUserResult">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="orgId" column="org_id"/>
|
||||
<result property="siteId" column="site_id"/>
|
||||
<result property="roleId" column="role_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="nickName" column="nick_name"/>
|
||||
<result property="email" column="email"/>
|
||||
@@ -29,22 +31,9 @@
|
||||
<result property="openId" column="open_id"/>
|
||||
<result property="displayPassword" column="display_password"/>
|
||||
<result property="aiChatNum" column="ai_chat_num"/>
|
||||
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult"/>
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="deptResult" type="SysDept">
|
||||
<id property="deptId" column="dept_id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="ancestors" column="ancestors"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="leader" column="leader"/>
|
||||
<result property="status" column="dept_status"/>
|
||||
<result property="deptUserId" column="dept_user_id"/>
|
||||
<result property="deptUserName" column="dept_user_name"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="RoleResult" type="SysRole">
|
||||
<id property="roleId" column="role_id"/>
|
||||
<result property="roleName" column="role_name"/>
|
||||
@@ -55,26 +44,21 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.ai_chat_num,u.display_password,u.open_id,u.session_id,u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber,
|
||||
select u.ai_chat_num,u.display_password,u.open_id,u.session_id,u.user_id, u.dept_id,u.org_id,u.site_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber,
|
||||
u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
d.dept_user_id,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
|
||||
(select su.user_name from sys_user su where su.user_id = d.dept_user_id) as dept_user_name,
|
||||
ap.language,ap.time_zone
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
left join app_preferences ap on u.user_id = ap.user_id
|
||||
</sql>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
||||
select u.user_id, u.dept_id,u.org_id,u.site_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
||||
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_name, d.leader, d.dept_user_id, r.role_id, r.role_key
|
||||
r.role_id, r.role_key
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0'
|
||||
@@ -90,27 +74,18 @@
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
<if test="orgId != null and orgId != 0">
|
||||
AND u.org_id = #{orgId}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
|
||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
ancestors) ))
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
|
||||
AND u.dept_id = #{deptId}
|
||||
<if test="siteId != null and siteId != 0">
|
||||
AND u.site_id = #{siteId}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
||||
@@ -121,17 +96,14 @@
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
||||
and u.dept_id = #{deptId}
|
||||
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
|
||||
ur.role_id = #{roleId})
|
||||
<if test="userName != null and userName != ''">
|
||||
@@ -141,7 +113,6 @@
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
@@ -151,7 +122,7 @@
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
where u.user_id = #{userId} and u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectUserByOpenId" parameterType="String" resultMap="SysUserResult">
|
||||
@@ -180,6 +151,8 @@
|
||||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="orgId != null">org_id,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
@@ -198,6 +171,8 @@
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="orgId != null and orgId != ''">#{orgId},</if>
|
||||
<if test="siteId != null and siteId != ''">#{siteId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
@@ -220,6 +195,8 @@
|
||||
update sys_user
|
||||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="orgId != null and orgId != 0">org_id = #{orgId},</if>
|
||||
<if test="siteId != null and siteId != 0">site_id = #{siteId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
@@ -298,6 +275,8 @@
|
||||
SELECT
|
||||
u.user_id,
|
||||
u.dept_id,
|
||||
u.site_id,
|
||||
u.org_id,
|
||||
u.nick_name,
|
||||
u.user_name,
|
||||
u.email,
|
||||
@@ -327,6 +306,8 @@
|
||||
SELECT
|
||||
u.user_id,
|
||||
u.dept_id,
|
||||
u.site_id,
|
||||
u.org_id,
|
||||
u.nick_name,
|
||||
u.user_name
|
||||
FROM
|
||||
@@ -343,7 +324,7 @@
|
||||
</select>
|
||||
|
||||
<select id="listTerminal" resultType="com.maibu.core.domain.entity.SysUser">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
||||
select u.user_id, u.dept_id,u.site_id,u.org_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
||||
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_name, d.leader, d.dept_user_id, r.role_id, r.role_key
|
||||
from sys_user u
|
||||
@@ -351,7 +332,6 @@
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0'
|
||||
and isnull(u.dept_id)
|
||||
<if test="userId != null and userId != 0">
|
||||
AND u.user_id = #{userId}
|
||||
</if>
|
||||
@@ -379,4 +359,11 @@
|
||||
where u.dept_id = #{deptId}
|
||||
and u.user_id != d.dept_user_id
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectByRoleId" parameterType="Long" resultMap="SysUserResult">
|
||||
select u.user_id,u.user_name,u.nick_name from
|
||||
sys_user u inner join sys_user_role sur on u.user_id = sur.user_id
|
||||
where sur.role_id = #{roleId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.maibu.mapper.SysUserPostMapper">
|
||||
|
||||
<resultMap type="SysUserPost" id="SysUserPostResult">
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="postId" column="post_id" />
|
||||
</resultMap>
|
||||
|
||||
<delete id="deleteUserPostByUserId" parameterType="Long">
|
||||
delete from sys_user_post where user_id=#{userId}
|
||||
</delete>
|
||||
|
||||
<select id="countUserPostById" resultType="Integer">
|
||||
select count(1) from sys_user_post where post_id=#{postId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteUserPost" parameterType="Long">
|
||||
delete from sys_user_post where user_id in
|
||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchUserPost">
|
||||
insert into sys_user_post(user_id, post_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.userId},#{item.postId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user