614bfcdf 康伟

Merge remote-tracking branch 'origin/master'

2 个父辈 2ee112db d6c17a6f
......@@ -13,15 +13,14 @@ import com.skua.core.context.BaseContextHandler;
import com.skua.core.entity.SysPermissionDataRule;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.entity.SysPermission;
import com.skua.modules.system.entity.SysRole;
import com.skua.modules.system.entity.SysRolePermission;
import com.skua.modules.system.model.TreeModel;
import com.skua.modules.system.service.ISysPermissionDataRuleService;
import com.skua.modules.system.service.ISysPermissionService;
import com.skua.modules.system.service.ISysRolePermissionService;
import com.skua.modules.system.service.ISysRoleService;
import com.skua.modules.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
......@@ -51,6 +50,9 @@ public class SysRoleController {
private ISysRoleService sysRoleService;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
private ISysPermissionDataRuleService sysPermissionDataRuleService;
@Autowired
......@@ -75,9 +77,14 @@ public class SysRoleController {
Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
Page<SysRole> page = new Page<SysRole>(pageNo, pageSize);
// if(!BaseContextHandler.getUserId().equals("admin")){
// queryWrapper.notLike("role_code","admin");
// }
if(StringUtils.isNotEmpty(BaseContextHandler.getDeparts())){
SysDepart sysDepart = sysDepartService.getById(BaseContextHandler.getDeparts());
if(sysDepart!=null){
if(!"A01".equals(sysDepart.getOrgCode())){
queryWrapper.notLike("role_type","group");
}
}
}
IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
......@@ -195,6 +202,14 @@ public class SysRoleController {
if(!BaseContextHandler.getUserLoginName().equals("admin")){
queryWrapper.notLike("role_code","admin");
}
if(StringUtils.isNotEmpty(BaseContextHandler.getDeparts())){
SysDepart sysDepart = sysDepartService.getById(BaseContextHandler.getDeparts());
if(sysDepart!=null){
if(!"A01".equals(sysDepart.getOrgCode())){
queryWrapper.notLike("role_type","group");
}
}
}
queryWrapper.orderByDesc("create_time");
List<SysRole> list = sysRoleService.list(queryWrapper);
if(list==null||list.size()<=0) {
......
......@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import com.skua.core.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -44,6 +45,13 @@ public class SysRole implements Serializable {
private String roleCode;
/**
* 角色编码
*/
@Excel(name="角色类型",width=15)
@Dict(dicCode = "role_type")
private String roleType;
/**
* 所属机构
*/
/*@Excel(name="所属机构",width=15)*/
......
......@@ -34,10 +34,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
*
* @param
* @param page
* @param orgCode
* @param roleId
* @return
*/
IPage<SysUser> getUserByRoleId(Page page,@Param("roleId") String roleId, @Param("username") String username);
IPage<SysUser> getUserByRoleId(Page page,@Param("roleId") String roleId,
@Param("username") String username,@Param("departId") String departId);
/**
* 根据用户名设置部门ID
......@@ -74,4 +75,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
List<SysUser> getUserByUserIds(@Param("userIds") String userIds);
List<SysUser> operationUserList(@Param("departId") String departId);
String queryDepartIdsByUserId(@Param("userId") String userId);
}
......
......@@ -17,11 +17,33 @@
<!-- 根据角色Id查询 -->
<select id="getUserByRoleId" resultType="com.skua.modules.system.entity.SysUser">
select * from sys_user where del_flag = '0' and is_system_user = '0'
and id in (select user_id from sys_user_role where role_id=#{roleId})
<if test="username!=null and username!=''">
and (username like concat('%',#{username},'%') or realname like concat('%',#{username},'%'))
</if>
SELECT
u.*
FROM
sys_user u
LEFT JOIN sys_user_depart d ON u.id = d.user_id
WHERE
u.del_flag = '0'
AND u.is_system_user = '0'
AND u.id IN ( SELECT user_id FROM sys_user_role WHERE role_id = #{roleId} )
<if test="username!=null and username!=''">
AND (u.username LIKE CONCAT('%',#{username},'%') or u.realname LIKE CONCAT('%',#{username},'%'))
</if>
<if test="departId!=null and departId!=''">
AND d.dep_id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="queryDepartIdsByUserId" resultType="java.lang.String">
SELECT
CONCAT( dep_id, ',', dep_ids ) AS departs
FROM
sys_user_depart
WHERE
user_id = #{userId}
</select>
<!-- 修改用户部门code -->
......
......@@ -114,6 +114,7 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
}
}
}
@Override
public List<String> queryDepartIdsOfUserId(String userId) {
List<String> departByUserId = baseMapper.getDepartByUserId(userId);
......
......@@ -14,6 +14,7 @@ import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.system.entity.*;
import com.skua.modules.system.mapper.*;
import com.skua.modules.system.service.ISysUserDepartService;
import com.skua.modules.system.service.ISysUserService;
import com.skua.modules.system.vo.SysUserVO;
import com.skua.modules.websocket.WebSocket;
......@@ -24,6 +25,7 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
......@@ -136,8 +138,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// SysUser user = userMapper.getUserByName(username);
// info.setSysUserCode(user.getUsername());
// info.setSysUserName(user.getRealname());
LoginUser user = sysBaseAPI.getUserByName(username);
if (user != null) {
info.setSysUserCode(user.getUsername());
......@@ -170,11 +170,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return userMapper.getUserByDepId(page, departId, username);
}
// 根据角色Id查询
@Override
public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username) {
return userMapper.getUserByRoleId(page, roleId, username);
String departIds = userMapper.queryDepartIdsByUserId(BaseContextHandler.getUserId());
return userMapper.getUserByRoleId(page, roleId, username, departIds);
}
//获取登录人所属集团
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!