超管能看到所有项目

master
jiakun.lin 4 years ago
parent 0bbfd18c70
commit 7b05b57bd2
  1. 6
      src/main/java/com/yipin/liuwanr/mapper/ProjectManagementMapper.java
  2. 22
      src/main/java/com/yipin/liuwanr/service/ProjectManagementService.java

@ -40,7 +40,7 @@ public interface ProjectManagementMapper {
@Select({"<script>", @Select({"<script>",
// "select projectId,projectName,projectPermissions,founder,creationTime,state,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0", // "select projectId,projectName,projectPermissions,founder,creationTime,state,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0",
"select * from hr_project_management where 1 = 1",// (roleId NOT LIKE '%3%' AND isdel = 0)", "select * from hr_project_management where 1 = 1",// (roleId NOT LIKE '%3%' AND isdel = 0)",
" <if test='userId==null'>AND roleId NOT LIKE '%3%' AND isdel = 0</if>", " <if test='userId==null'>AND founder NOT LIKE '4' AND isdel = 0</if>",
" <if test='userId!=null'>AND ((FIND_IN_SET(1,founder) AND isdel = 0) OR ( isdel = 0 AND userId = #{userId} ))</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的 " <if test='userId!=null'>AND ((FIND_IN_SET(1,founder) AND isdel = 0) OR ( isdel = 0 AND userId = #{userId} ))</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
" <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>", " <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>",
" <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统 " <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统
@ -373,8 +373,8 @@ public interface ProjectManagementMapper {
* @param userId * @param userId
* @return * @return
*/ */
@Select("SELECT accountRole FROM user WHERE userId=#{userId}") @Select("SELECT roleId FROM hr_user_info WHERE userId=#{userId}")
Integer queryRoleId(Integer userId); String queryRoleId(Integer userId);
/** /**
* 查询项目名称 * 查询项目名称

@ -39,16 +39,16 @@ public class ProjectManagementService {
public HashMap<String, Object> queryRole(Integer userId) { public HashMap<String, Object> queryRole(Integer userId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
Integer roleId = mapper.queryRoleId(userId); String roleId = mapper.queryRoleId(userId);
if (null != roleId) { if (null != roleId) {
//角色为教师 //角色为教师
if (roleId == 3) { if ("14".equals(roleId)) {
resp.put("retvalue", 1); resp.put("retvalue", 1);
} }
//角色为管理员 //角色为管理员
else if (roleId == 1 || roleId == 2) { else if ("13".equals(roleId) || "13,14".equals(roleId)) {
resp.put("retvalue", 0); resp.put("retvalue", 0);
} else if (roleId == 4) { } else if ("4".equals(roleId)) {
resp.put("retcode", 300); resp.put("retcode", 300);
resp.put("retvalue", "Role does not meet the requirements"); resp.put("retvalue", "Role does not meet the requirements");
return resp; return resp;
@ -78,16 +78,16 @@ public class ProjectManagementService {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
//获取用户的角色信息 //获取用户的角色信息
Integer roleId = mapper.queryRoleId(vo.getUserId()); String roleId = mapper.queryRoleId(vo.getUserId());
if (null != roleId) { if (null != roleId) {
//角色不对(学生没有权限) //角色不对(学生没有权限)
if (roleId == 4) { if ("4".equals(roleId)) {
resp.put("retcode", 300); resp.put("retcode", 300);
resp.put("retvalue", "抱歉,您的权限不能访问该地址!"); resp.put("retvalue", "抱歉,您的权限不能访问该地址!");
return resp; return resp;
} }
//角色等于管理员或者超级管理员 //角色等于管理员或者超级管理员
else if (roleId == 1 ) { else if ("1".equals(roleId)) {
vo.setUserId(null); vo.setUserId(null);
} }
} }
@ -115,16 +115,16 @@ public class ProjectManagementService {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
//获取用户的角色信息 //获取用户的角色信息
Integer roleId = mapper.queryRoleId(vo.getUserId()); String roleId = mapper.queryRoleId(vo.getUserId());
if (null != roleId) { if (null != roleId) {
//角色不对(学生没有权限) //角色不对(学生没有权限)
if (roleId == 4) { if ("4".equals(roleId)) {
resp.put("retcode", 300); resp.put("retcode", 300);
resp.put("retvalue", "抱歉,您的权限不能访问该地址!"); resp.put("retvalue", "抱歉,您的权限不能访问该地址!");
return resp; return resp;
} }
//角色等于管理员或者超级管理员 //角色等于超级管理员
else if (roleId == 1 ) { else if ("1".equals(roleId)) {
vo.setUserId(null); vo.setUserId(null);
} }
} }

Loading…
Cancel
Save