重构学生查询接口(转移目标数据表)

master
mzh820631607 4 years ago
parent 07fa2ca51a
commit 2ab6f46adf
  1. 6
      src/main/java/com/yipin/liuwanr/controller/StudentController.java
  2. 28
      src/main/java/com/yipin/liuwanr/helper/QueryStudentUtils.java
  3. 8
      src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java
  4. 6
      src/main/java/com/yipin/liuwanr/service/StudentService.java

@ -122,19 +122,19 @@ public class StudentController {
/** /**
* 根据professionalIds专业id查询所有学生 * 根据professionalIds专业id查询所有学生
* @param schoolId 必须 * @param schoolId 必须
* @param professionalIds * @param professionalId
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
* @return * @return
*/ */
@GetMapping("queryStudent/byProfessionalIds") @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(); Response resp = new Response();
if (schoolId == null){ if (schoolId == null){
resp.setMessage(300); resp.setMessage(300);
resp.setErrmessage("学校id为空,查询失败!"); resp.setErrmessage("学校id为空,查询失败!");
}else{ }else{
HashMap<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalIds, pageNo, pageSize, schoolId); HashMap<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue"); QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue");
} }
return resp; return resp;

@ -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<String, Object> 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()));
}
}
}

@ -19,15 +19,15 @@ public interface StudentMapper {
void addStudent(Student student); void addStudent(Student student);
//通过专业id查询所有学生信息 //通过专业id查询所有学生信息
@Select("SELECT studentName,studentNumber,professionalName,gradeId,classId,roleId,loginNumber,lastLoginTime from student WHERE professionalId = #{professionalIds} 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.professionalId = #{professionalId} AND o.schoolId = #{schoolId}")
List<Student> queryStudentByProfessionalIds(Integer professionalIds, Integer schoolId); List<Student> queryStudentByProfessionalIds(Integer professionalId, Integer schoolId);
//通过年级id查询所有学生信息 //通过年级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<Student> queryStudentByGradeIds(Integer gradeId, Integer schoolId); List<Student> queryStudentByGradeIds(Integer gradeId, Integer schoolId);
//通过班级id查询所有学生信息 //通过班级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<Student> queryStudentByClassIds(Integer classId, Integer schoolId); List<Student> 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} ") @Select("select s.studentId,studentName from experimental_class_student ecs left join student s on ecs.studentId=s.studentId where ecs.experimentalClassId=#{experimentalClassId} ")

@ -53,12 +53,12 @@ public class StudentService {
return resp; return resp;
} }
public HashMap<String, Object> queryStudentByProfessionalIds(Integer professionalIds,Integer pageNo, Integer pageSize ,Integer schoolId){ public HashMap<String, Object> queryStudentByProfessionalIds(Integer professionalId,Integer pageNo, Integer pageSize ,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
if (pageNo != null && pageSize != null) { if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize); PageHelper.startPage(pageNo, pageSize);
List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalIds,schoolId); List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalId,schoolId);
PageInfo<Student> info = new PageInfo<Student>(list); PageInfo<Student> info = new PageInfo<Student>(list);
int total1 = (int) info.getTotal(); int total1 = (int) info.getTotal();
int totalPages; int totalPages;
@ -71,7 +71,7 @@ public class StudentService {
resp.put("retcode", 200); resp.put("retcode", 200);
}else{ }else{
List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalIds,schoolId); List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalId,schoolId);
resp.put("retcode",200); resp.put("retcode",200);
resp.put("retvalue",list); resp.put("retvalue",list);
} }

Loading…
Cancel
Save