diff --git a/src/main/java/com/yipin/liuwanr/controller/StudentController.java b/src/main/java/com/yipin/liuwanr/controller/StudentController.java index 8d6eae3..5d82eeb 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StudentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StudentController.java @@ -122,19 +122,19 @@ public class StudentController { /** * 根据professionalIds(专业id)查询所有学生 * @param schoolId 必须 - * @param professionalIds + * @param professionalId * @param pageNo * @param pageSize * @return */ @GetMapping("queryStudent/byProfessionalIds") - Response queryStudentByProfessionalIds(@RequestParam Integer schoolId,@RequestParam Integer professionalIds,Integer pageNo,Integer pageSize){ + Response queryStudentByProfessionalIds(@RequestParam Integer schoolId,@RequestParam Integer professionalId,Integer pageNo,Integer pageSize){ Response resp = new Response(); if (schoolId == null){ resp.setMessage(300); resp.setErrmessage("学校id为空,查询失败!"); }else{ - HashMap ret = studentService.queryStudentByProfessionalIds(professionalIds, pageNo, pageSize, schoolId); + HashMap ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId); QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue"); } return resp; diff --git a/src/main/java/com/yipin/liuwanr/helper/QueryStudentUtils.java b/src/main/java/com/yipin/liuwanr/helper/QueryStudentUtils.java new file mode 100644 index 0000000..a5bdfc6 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/helper/QueryStudentUtils.java @@ -0,0 +1,28 @@ +package com.yipin.liuwanr.helper; + +import com.yipin.liuwanr.entity.Response; + +import java.util.HashMap; +import java.util.List; + +public class QueryStudentUtils { + /** + * Controller.queryStudent之共性api + * @param resp + * @param hashMap + * @param retcode + * @param retvalue + */ + public static void queryStudentByIds(Response resp,HashMap hashMap,String retcode,String retvalue){ + + int status = (int)hashMap.get(retcode); + if (status==200){ + resp.setStatus(status); + resp.setMessage(hashMap.get(retvalue)); + }else{ + resp.setStatus(status); + resp.setMessage(hashMap.get(retvalue.toString())); + } + + } +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java index 7c3828f..d327a1b 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java @@ -19,15 +19,15 @@ public interface StudentMapper { void addStudent(Student student); //通过专业id查询所有学生信息 - @Select("SELECT studentName,studentNumber,professionalName,gradeId,classId,roleId,loginNumber,lastLoginTime from student WHERE professionalId = #{professionalIds} and schoolId = #{schoolId}") - List queryStudentByProfessionalIds(Integer professionalIds, Integer schoolId); + @Select("SELECT u.logInNumber,u.userName,u.lastLoginTime,o.roleId, o.gradeId, o.classId, o.professionalId FROM hr_user_info u,hr_organization_relationship o WHERE u.userId = o.userId AND o.roleId = 4 AND o.professionalId = #{professionalId} AND o.schoolId = #{schoolId}") + List queryStudentByProfessionalIds(Integer professionalId, Integer schoolId); //通过年级id查询所有学生信息 - @Select("SELECT studentName,studentNumber,professionalName,gradeId,classId,roleId,loginNumber,lastLoginTime from student WHERE gradeId = #{gradeId} and schoolId = #{schoolId}") + @Select("SELECT u.logInNumber,u.userName,u.lastLoginTime,o.roleId, o.gradeId, o.classId, o.professionalId FROM hr_user_info u,hr_organization_relationship o WHERE u.userId = o.userId AND o.roleId = 4 AND o.gradeId = #{gradeId} AND o.schoolId = #{schoolId}") List queryStudentByGradeIds(Integer gradeId, Integer schoolId); //通过班级id查询所有学生信息 - @Select("SELECT studentName,studentNumber,professionalName,gradeId,classId,roleId,loginNumber,lastLoginTime from student WHERE classId = #{classId} and schoolId = #{schoolId}") + @Select("SELECT u.logInNumber,u.userName,u.lastLoginTime,o.roleId, o.gradeId, o.classId, o.professionalId FROM hr_user_info u,hr_organization_relationship o WHERE u.userId = o.userId AND o.roleId = 4 AND o.classId = #{classId} AND o.schoolId = #{schoolId}") List queryStudentByClassIds(Integer classId, Integer schoolId); @Select("select s.studentId,studentName from experimental_class_student ecs left join student s on ecs.studentId=s.studentId where ecs.experimentalClassId=#{experimentalClassId} ") diff --git a/src/main/java/com/yipin/liuwanr/service/StudentService.java b/src/main/java/com/yipin/liuwanr/service/StudentService.java index 468c61a..666fb61 100644 --- a/src/main/java/com/yipin/liuwanr/service/StudentService.java +++ b/src/main/java/com/yipin/liuwanr/service/StudentService.java @@ -53,12 +53,12 @@ public class StudentService { return resp; } - public HashMap queryStudentByProfessionalIds(Integer professionalIds,Integer pageNo, Integer pageSize ,Integer schoolId){ + public HashMap queryStudentByProfessionalIds(Integer professionalId,Integer pageNo, Integer pageSize ,Integer schoolId){ HashMap resp = new HashMap(); try { if (pageNo != null && pageSize != null) { PageHelper.startPage(pageNo, pageSize); - List list = studentMapper.queryStudentByProfessionalIds(professionalIds,schoolId); + List list = studentMapper.queryStudentByProfessionalIds(professionalId,schoolId); PageInfo info = new PageInfo(list); int total1 = (int) info.getTotal(); int totalPages; @@ -71,7 +71,7 @@ public class StudentService { resp.put("retcode", 200); }else{ - List list = studentMapper.queryStudentByProfessionalIds(professionalIds,schoolId); + List list = studentMapper.queryStudentByProfessionalIds(professionalId,schoolId); resp.put("retcode",200); resp.put("retvalue",list); }