列表排序

master
mzh820631607 4 years ago
parent 2f156cf27a
commit 1b530b1d24
  1. 47
      src/main/java/com/yipin/liuwanr/mapper/ProjectManagementMapper.java
  2. 5
      src/main/java/com/yipin/liuwanr/mapper/ScoreIndexMapper.java
  3. 65
      src/main/java/com/yipin/liuwanr/service/ProjectManagementService.java

@ -46,17 +46,33 @@ public interface ProjectManagementMapper {
* " ORDER BY creationTime desc", * " ORDER BY creationTime desc",
*/ */
@Select({"<script>", @Select({"<script>",
// "select projectId,projectName,projectPermissions,founder,creationTime,state,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0", "select * from hr_project_management where isdel = 0",
"select * from hr_project_management where (roleId NOT LIKE '%3%' AND isdel = 0)", " <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>",
" <if test='userId!=null'>OR ( isdel = 0 AND userId = #{userId} )</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的 " <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统
" <if test='founder==null'> and founder in (1,2)</if>",//教师选择创建人为系统
" <if test='state!=null'> and state=#{state}</if>",
" <if test='systemId!=null'> and systemId=#{systemId}</if>",
" <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>" +
"<if test='founder==null or founder==3'> or ( isdel = 0 AND userId = #{userId} " +
" <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>",//教师选择创建人为系统
" <if test='state!=null'> and state=#{state}</if>", " <if test='state!=null'> and state=#{state}</if>",
" <if test='systemId!=null'> and systemId=#{systemId}</if>", " <if test='systemId!=null'> and systemId=#{systemId}</if>",
" <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>", " <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>",
") </if>" +
" ORDER BY creationTime desc", " ORDER BY creationTime desc",
"</script>"}) "</script>"})
List<ProjectManagement> queryManagements(ProjectManagement management); List<ProjectManagement> queryManagements(ProjectManagement management);
@Select({"<script>",
"select * from hr_project_management where isdel = 0 AND userId = #{userId}",
" <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>",
" <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统
" <if test='state!=null'> and state=#{state}</if>",
" <if test='systemId!=null'> and systemId=#{systemId}</if>",
" <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>",
" ORDER BY creationTime desc",
"</script>"})
List<ProjectManagement> queryUserManagements(ProjectManagement vo);
// @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 isdel=0", // "select * from hr_project_management where isdel=0",
@ -76,11 +92,19 @@ public interface ProjectManagementMapper {
@Select({"<script>", @Select({"<script>",
"select * from hr_project_management where (roleId NOT LIKE '%3%' AND isdel = 0 AND projectPermissions != 0)", "select * from hr_project_management where (roleId NOT LIKE '%3%' AND isdel = 0 AND projectPermissions != 0)",
" <if test='userId!=null'>OR ( isdel = 0 AND projectPermissions != 0 AND userId = #{userId} )</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
" <if test='systemId!=null'> and systemId=#{systemId}</if>", " <if test='systemId!=null'> and systemId=#{systemId}</if>",
" ORDER BY creationTime desc", " ORDER BY creationTime desc",
"</script>"}) "</script>"})
List<ProjectManagement> queryManagementsExportTest(ProjectManagement management); List<ProjectManagement> queryManagementsExportTest(ProjectManagement management);
@Select({"<script>",
"select * from hr_project_management where isdel = 0 AND projectPermissions != 0 AND state = 1",
" <if test='systemId!=null'> and systemId=#{systemId}</if>" +
"<if test ='userId!=null'> or( isdel = 0 AND projectPermissions != 0 AND userId = #{userId} AND state = 1" +
"<if test='systemId!=null'> and systemId=#{systemId}</if>" +
")</if>",
" ORDER BY creationTime desc",
"</script>"})
List<ProjectManagement> queryManagementsExport(ProjectManagement management);
/** /**
@ -216,7 +240,7 @@ public interface ProjectManagementMapper {
* @return * @return
*/ */
@Select({"<script>", @Select({"<script>",
"select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and judgmentPointsId in", "select judgmentPointsId,judgmentPointsName,experimentalRequirements,userId from hr_judgment_points where isdel=0 and judgmentPointsId in",
"<foreach collection='point' item='po' open='(' separator=',' close=')'>" + "#{po} " + "</foreach> ", "<foreach collection='point' item='po' open='(' separator=',' close=')'>" + "#{po} " + "</foreach> ",
"</script>"}) "</script>"})
List<Judgment_Points> getByjudgmentPointsIds(@Param("point") List<Integer> point); List<Judgment_Points> getByjudgmentPointsIds(@Param("point") List<Integer> point);
@ -228,7 +252,7 @@ public interface ProjectManagementMapper {
* @param projectId * @param projectId
* @return * @return
*/ */
@Select("select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") @Select("select judgmentPointsId,judgmentPointsName,experimentalRequirements ,userId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0")
List<Judgment_Points> getByProjectId(Integer projectId); List<Judgment_Points> getByProjectId(Integer projectId);
@ -315,6 +339,16 @@ public interface ProjectManagementMapper {
@Select("SELECT accountRole FROM user WHERE userId=#{userId}") @Select("SELECT accountRole FROM user WHERE userId=#{userId}")
Integer queryRoleId(Integer userId); Integer queryRoleId(Integer userId);
/**
* 查询用户角色
*
* @param userId
* @return
*/
@Select("SELECT roleId FROM hr_user_info WHERE userId=#{userId}")
String queryRoleIds(Integer userId);
@Select("SELECT id FROM tms_experimental_teaching WHERE project_id =#{projectId}") @Select("SELECT id FROM tms_experimental_teaching WHERE project_id =#{projectId}")
List<Integer> queryproject(Integer projectId); List<Integer> queryproject(Integer projectId);
@ -325,4 +359,5 @@ public interface ProjectManagementMapper {
"where projectId=#{projectId}" "where projectId=#{projectId}"
+ "</script>") + "</script>")
void daleteManegement(Integer id); void daleteManegement(Integer id);
} }

@ -46,7 +46,7 @@ public interface ScoreIndexMapper {
* 根据判分点id和项目id查询具体分数 * 根据判分点id和项目id查询具体分数
* @return * @return
*/ */
@Select("select score from hr_score_index where isdel=0 and judgmentPointsId=#{judgmentPointsId} and projectId=#{projectId} and userId=#{userId}") @Select("select score from hr_score_index where isdel=0 and judgmentPointsId=#{judgmentPointsId} and projectId=#{projectId} and userId=#{userId} ORDER BY score DESC LIMIT 1")
Integer getbyJudgmentPointsIdScore(@Param("judgmentPointsId")Integer judgmentPointsId,@Param("projectId") Integer projectId,@Param("userId") Integer userId); Integer getbyJudgmentPointsIdScore(@Param("judgmentPointsId")Integer judgmentPointsId,@Param("projectId") Integer projectId,@Param("userId") Integer userId);
/** /**
@ -57,7 +57,8 @@ public interface ScoreIndexMapper {
*/ */
@Select({"<script>", @Select({"<script>",
"select score,judgmentPointsId from hr_score_index where isdel=0 and userId=#{userId} and projectId=#{projectId} and judgmentPointsId in", "select score,judgmentPointsId from hr_score_index where isdel=0 and userId=#{userId} and projectId=#{projectId} and judgmentPointsId in",
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" + "#{id} " + "</foreach> ", "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" + "#{id} " + "</foreach> " +
"GROUP BY scoreindexId",
"</script>"}) "</script>"})
List<ScoreIndex> queryScore(@Param("ids")List<Integer> judgmentPointsId,@Param("projectId")Integer projectId,@Param("userId") Integer userId); List<ScoreIndex> queryScore(@Param("ids")List<Integer> judgmentPointsId,@Param("projectId")Integer projectId,@Param("userId") Integer userId);
} }

@ -77,23 +77,18 @@ public class ProjectManagementService {
public HashMap<String, Object> queryManagements(ProjectManagement vo, Integer pageNo, Integer pageSize) { public HashMap<String, Object> queryManagements(ProjectManagement vo, Integer pageNo, Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
//获取用户的角色信息
Integer roleId = mapper.queryRoleId(vo.getUserId());
if (null != roleId) {
//角色不对(学生没有权限)
if (roleId == 4) {
resp.put("retcode", 300);
resp.put("retvalue", "抱歉,您的权限不能访问该地址!");
return resp;
}
//角色等于管理员或者超级管理员
else if (roleId == 1 ) {
vo.setUserId(null);
}
}
PageHelper.startPage(pageNo, pageSize); PageHelper.startPage(pageNo, pageSize);
//条件查询 //条件查询
List<ProjectManagement> list = mapper.queryManagementsExportTest(vo); List<ProjectManagement> list = mapper.queryManagementsExport(vo);
// //获取用户的角色信息
// String roleId = mapper.queryRoleIds(vo.getUserId());
// if (null != roleId) {
// if (roleId.contains("3")) {
// vo.setUserId(null);
// List<ProjectManagement> projectManagements = mapper.queryManagementsExport(vo);
// list.addAll(projectManagements);
// }
// }
PageInfo<ProjectManagement> info = new PageInfo<ProjectManagement>(list); PageInfo<ProjectManagement> info = new PageInfo<ProjectManagement>(list);
resp.put("retvalue", new PageResult(info.getTotal(), list)); resp.put("retvalue", new PageResult(info.getTotal(), list));
resp.put("retcode", 200); resp.put("retcode", 200);
@ -115,21 +110,25 @@ 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.queryRoleIds(vo.getUserId());
if (null != roleId) { // if (null != roleId) {
//角色不对(学生没有权限) // //角色不对(学生没有权限)
if (roleId == 4) { // if (roleId.contains("4")) {
resp.put("retcode", 300); // resp.put("retcode", 300);
resp.put("retvalue", "抱歉,您的权限不能访问该地址!"); // resp.put("retvalue", "抱歉,您的权限不能访问该地址!");
return resp; // return resp;
} // }
//角色等于管理员或者超级管理员 // //角色等于管理员或者超级管理员
else if (roleId == 1 ) { // else if (roleId.contains("1")) {
vo.setUserId(null); // vo.setUserId(null);
} // }
} // }
//条件查询 //条件查询
List<ProjectManagement> list = mapper.queryManagements(vo); List<ProjectManagement> list = mapper.queryManagements(vo);
// if (vo.getFounder()==null||vo.getFounder()==3){
// List<ProjectManagement> list2 = mapper.queryUserManagements(vo);
// list.addAll(list2);
// }
resp.put("retvalue",list); resp.put("retvalue",list);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (Exception e) { } catch (Exception e) {
@ -469,6 +468,14 @@ public class ProjectManagementService {
public HashMap<String, Object> insertProjectManagement(ProjectManagement pro, List<Judgment_Points> points, List<Integer> roles) { public HashMap<String, Object> insertProjectManagement(ProjectManagement pro, List<Judgment_Points> points, List<Integer> roles) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
//只允许一个Founder
// if (pro.getFounder()==1){//超管
// pro.setFounder(1);
// }else if (pro.getFounder()==2){//管理员
// pro.setFounder(2);
// }else if (pro.getFounder()==3){//老师
// pro.setFounder(3);
// }
// 添加项目信息 // 添加项目信息
mapper.insertProjectManagement(pro); mapper.insertProjectManagement(pro);
// 取出添加的项目信息的id // 取出添加的项目信息的id
@ -536,7 +543,7 @@ public class ProjectManagementService {
try{ try{
Integer count = mapper.getByprojectName(projectName); Integer count = mapper.getByprojectName(projectName);
if(count>=1){ if(count>=1){
resp.put("retcode", 300); resp.put("retcode", 201);
resp.put("retvalue", "该项目名称已存在"); resp.put("retvalue", "该项目名称已存在");
}else{ }else{
resp.put("retcode", 200); resp.put("retcode", 200);

Loading…
Cancel
Save