Merge remote-tracking branch 'origin/master'

master
zhiyong.ning 4 years ago
commit a3141cca39
  1. 109
      src/main/java/com/yipin/liuwanr/controller/StudentController.java
  2. 28
      src/main/java/com/yipin/liuwanr/helper/QueryStudentUtils.java
  3. 19
      src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java
  4. 80
      src/main/java/com/yipin/liuwanr/service/StudentService.java

@ -3,6 +3,7 @@ package com.yipin.liuwanr.controller;
import com.yipin.liuwanr.entity.Response;
import com.yipin.liuwanr.entity.Student;
import com.yipin.liuwanr.entity.UserM;
import com.yipin.liuwanr.helper.QueryStudentUtils;
import com.yipin.liuwanr.helper.RedisHelper;
import com.yipin.liuwanr.service.StudentService;
import com.yipin.liuwanr.service.UserService;
@ -34,7 +35,6 @@ public class StudentController {
/**
* 批量导入学生
* @param file
* @param classId
* @return
*/
@PostMapping("/readStudent")
@ -94,44 +94,8 @@ public class StudentController {
}
return resp;
}
/**
* 查询学生
*/
@GetMapping("/queryStudent")
Response queryStudent(@RequestParam Integer schoolId,String searchContent,Integer pageNo,Integer pageSize,String professionalIds,String gradeIds,String classIds) {
Response resp = new Response();
Student student = new Student();
if (schoolId==null){
resp.setStatus(300);
resp.setErrmessage("学校id为空,查询失败!");
}else{
if (searchContent!=null&&searchContent!="") {
student.setSearchContent(searchContent);
}
if (professionalIds!=null&&professionalIds!="") {
student.setProfessionalIds(professionalIds);
}
if (gradeIds!=null&&gradeIds!="") {
student.setGradeIds(gradeIds);
}
if (classIds!=null&&classIds!="") {
student.setClassIds(classIds);
}
student.setSchoolId(schoolId);
HashMap<String, Object> ret = studentService.queryStudent(student,pageNo,pageSize);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
}
return resp;
}
/**
* 查询学生详情
*/
@ -150,11 +114,74 @@ public class StudentController {
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
}
}
return resp;
}
/**
* 根据professionalIds专业id查询所有学生
* @param schoolId 必须
* @param professionalId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("queryStudent/byProfessionalIds")
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<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue");
}
return resp;
}
/**
* 根据年级id查询所有学生信息
* @param schoolId
* @param gradeId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("queryStudent/byGradeId")
Response queryStudentByGradeId(@RequestParam Integer schoolId, @RequestParam Integer gradeId, Integer pageNo, Integer pageSize){
Response resp = new Response();
if (schoolId == null){
resp.setMessage(300);
resp.setErrmessage("学校id为空,查询失败!");
}else {
HashMap<String, Object> ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue");
}
return resp;
}
/**
* 根据班级id查询所有学生信息
* @param schoolId
* @param classId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("queryStudent/byClassIds")
Response queryStudentByClassIds(@RequestParam Integer schoolId,@RequestParam Integer classId,Integer pageNo,Integer pageSize){
Response resp = new Response();
if (schoolId == null){
resp.setMessage(300);
resp.setErrmessage("学校id为空,查询失败!");
}else {
HashMap<String, Object> ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue");
}
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()));
}
}
}

@ -18,14 +18,17 @@ public interface StudentMapper {
+ "VALUES(#{studentName},#{studentNumber},#{phone},#{email},#{roleId},#{schoolId},#{professionalId},#{gradeId},#{classId},0,#{uniqueIdentificationAccount})")
void addStudent(Student student);
//查询学生
@Select({ "<script>",
"SELECT stu.stuProfessionalArchitectureName,g.gradeName,cla.className,t.loginNumber,t.lastLoginTime,t.uniqueIdentificationAccount,t.studentId,t.studentName,t.studentNumber,t.phone,t.email,t.roleId,t.schoolId,t.professionalId,t.gradeId,t.classId,t.experimentalClassId,(SELECT GROUP_CONCAT(c.experimentalClassName) FROM experimental_class_ning c WHERE FIND_IN_SET(c.experimentalClassId,t.experimentalClassId)) AS experimentName FROM student t,class cla,grade g,stu_professional_architecture stu WHERE t.isdel =0 and t.classId = cla.classId and t.gradeId = g.gradeId and t.professionalId = stu.stuProfessionalArchitectureId and t.schoolId=#{schoolId}",
" <if test='searchContent!=null'> and t.studentName like CONCAT('%',#{searchContent},'%') or t.studentNumber like CONCAT('%',#{searchContent},'%')</if>",
" <if test='professionalIds!=null'> and FIND_IN_SET(t.professionalId,#{professionalIds})</if>",
" <if test='gradeIds!=null'> and FIND_IN_SET(t.gradeId,#{gradeIds}) </if>",
" <if test='classIds!=null'> and FIND_IN_SET(t.classId,#{classIds})</if>", "</script> " })
List<Student> queryStudent(Student student);
//通过专业id查询所有学生信息
@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 professionalId, Integer schoolId);
//通过年级id查询所有学生信息
@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);
//通过班级id查询所有学生信息
@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);
@Select("select s.studentId,studentName from experimental_class_student ecs left join student s on ecs.studentId=s.studentId where ecs.experimentalClassId=#{experimentalClassId} ")
List<Student> getByStudents(Integer experimentalClassId);

@ -53,12 +53,12 @@ public class StudentService {
return resp;
}
public HashMap<String, Object> queryStudent(Student student, Integer pageNo, Integer pageSize) {
public HashMap<String, Object> queryStudentByProfessionalIds(Integer professionalId,Integer pageNo, Integer pageSize ,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize);
List<Student> list = studentMapper.queryStudent(student);
List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalId,schoolId);
PageInfo<Student> info = new PageInfo<Student>(list);
int total1 = (int) info.getTotal();
int totalPages;
@ -69,19 +69,83 @@ public class StudentService {
long total = total1;
resp.put("retvalue", new PageResult(total, list, totalPages));
resp.put("retcode", 200);
} else {
List<Student> list = studentMapper.queryStudent(student);
resp.put("retvalue", list);
}else{
List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalId,schoolId);
resp.put("retcode",200);
resp.put("retvalue",list);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
resp.put("retcode",500);
resp.put("retvalue","Inquiry Failed");
return resp;
}
return resp;
}
public HashMap<String, Object> queryStudentByGradeIds(Integer gradeId,Integer pageNo, Integer pageSize ,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize);
List<Student> list = studentMapper.queryStudentByProfessionalIds(gradeId,schoolId);
PageInfo<Student> info = new PageInfo<Student>(list);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0) {
totalPages++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, list, totalPages));
resp.put("retcode", 200);
}else{
List<Student> list = studentMapper.queryStudentByGradeIds(gradeId,schoolId);
resp.put("retcode",200);
resp.put("retvalue",list);
}
} catch (RuntimeException e) {
}catch (RuntimeException e){
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
resp.put("retcode",500);
resp.put("retvalue","Inquiry Failed");
return resp;
}
return resp;
// List<Student> list = studentMapper.queryStudentByProfessionalIds(professionalIds,schoolId);
}
public HashMap<String, Object> queryStudentByClassIds(Integer classId,Integer pageNo, Integer pageSize ,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize);
List<Student> list = studentMapper.queryStudentByClassIds(classId,schoolId);
PageInfo<Student> info = new PageInfo<Student>(list);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0) {
totalPages++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, list, totalPages));
resp.put("retcode", 200);
}else{
List<Student> list = studentMapper.queryStudentByClassIds(classId,schoolId);
resp.put("retcode",200);
resp.put("retvalue",list);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
resp.put("retcode",500);
resp.put("retvalue","Inquiry Failed");
return resp;
}
return resp;
}
public HashMap<String, Object> deleteStudent(Integer studentId,String phone) {
HashMap<String, Object> resp = new HashMap<String, Object>();

Loading…
Cancel
Save