diff --git a/httpTest/Student.http b/httpTest/Student.http index 57407659..edc2a604 100644 --- a/httpTest/Student.http +++ b/httpTest/Student.http @@ -3,3 +3,8 @@ POST {{baseURL}}/jlw/student/list.json Content-Type: application/x-www-form-urlencoded Cookie: JSESSIONID={{session}} + +### +GET {{baseURL}}/jlw/student/getValues.json?universitySystemId=1569331621092564992 +Cookie: JSESSIONID={{session}} + diff --git a/httpTest/http-client.private.env.json b/httpTest/http-client.private.env.json index 5113c33c..b1eea78d 100644 --- a/httpTest/http-client.private.env.json +++ b/httpTest/http-client.private.env.json @@ -1,6 +1,6 @@ { "dev": { "baseURL": "http://localhost:9090/server/", - "session": "A8152C92D7491D57327FF765D2B6780C" + "session": "7375560290D5B4F661672990339E8898" } } \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java b/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java index f9efff41..b2576671 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java @@ -17,6 +17,8 @@ import java.util.Map; */ @SqlResource("jlw.student") public interface StudentDao extends BaseMapper{ + public PageQuery queryByConditionQuery(PageQuery query); + public PageQuery queryByCondition(PageQuery query); public PageQuery queryByCondition2Student(PageQuery query); @Update diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java index 867f3018..0e9836a2 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java @@ -654,7 +654,9 @@ public class StudentService extends CoreBaseService{ } public List getValuesByQuery (StudentQuery studentQuery){ - return studentDao.getValuesByQuery(studentQuery); + List valuesByQuery = studentDao.getValuesByQuery(studentQuery); + queryListAfter(valuesByQuery); + return valuesByQuery; } //大赛任务一答卷 @@ -778,6 +780,12 @@ public class StudentService extends CoreBaseService{ return JsonResult.success(); } + public PageQueryqueryByConditionQuery(PageQuery query){ + PageQuery ret = studentDao.queryByConditionQuery(query); + queryListAfter(ret.getList()); + return ret; + } + //大赛任务二答卷 线程处理 private class TaskCallableForCT2Q implements Callable { CompetitionTaskSecondQuestionStepQuery condition; diff --git a/web/src/main/java/com/ibeetl/jlw/web/StudentController.java b/web/src/main/java/com/ibeetl/jlw/web/StudentController.java index de15ebc2..1dfd985f 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/StudentController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/StudentController.java @@ -2180,6 +2180,19 @@ public class StudentController{ } + @PostMapping(API + "/getPageList.do") + @ResponseBody + public JsonResult getPageList(StudentQuery condition, @SCoreUser CoreUser coreUser){ + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + PageQuery page = condition.getPageQuery(); + studentService.queryByConditionQuery(page); + return JsonResult.success(page); + } + } + + @PostMapping(MODEL + "/delete.json") @Function("student.delete") @ResponseBody @@ -2190,6 +2203,20 @@ public class StudentController{ return JsonResult.success(); } + /** + * 教师端-开课添加学生时候的列表 + * 通过专业ID查询,学生列表 + * + * @param universitySystemId + * @return + */ + @GetMapping(MODEL + "/studentListByUniversitySystemId.json") + @Function("teacher.query") + @ResponseBody + public JsonResult studentListByUniversitySystemId(Long universitySystemId) { + return JsonResult.success(studentListByUniversitySystemId(universitySystemId)); + } + //学生登录日志 @PostMapping(MODEL + "/logList.json") diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/StudentQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/StudentQuery.java index 154caf53..e3cfb51d 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/StudentQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/StudentQuery.java @@ -47,6 +47,9 @@ public class StudentQuery extends PageParam { private Long universitiesCollegesId; + // 专业ID + private Long universitySystemId; + private String className; private String universitiesCollegesName; @@ -169,6 +172,14 @@ public class StudentQuery extends PageParam { this.orderByRand = orderByRand; } + public Long getUniversitySystemId() { + return universitySystemId; + } + + public void setUniversitySystemId(Long universitySystemId) { + this.universitySystemId = universitySystemId; + } + public static class StudentTemp{ //临时学生类 private Long studentsId; diff --git a/web/src/main/resources/sql/jlw/student.md b/web/src/main/resources/sql/jlw/student.md index 49ae5253..da8bed0a 100644 --- a/web/src/main/resources/sql/jlw/student.md +++ b/web/src/main/resources/sql/jlw/student.md @@ -152,8 +152,75 @@ queryByCondition @} @} ORDER BY t.add_time DESC - - + +queryByConditionQuery +=== +* 没有权限的查询 + + select + @pageTag(){ + t.* + @} + from student t + LEFT JOIN school_class a ON a.class_id = t.class_id + LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id + where 1=1 + @if(!isEmpty(studentId)){ + and t.student_id =#studentId# + @} + @if(!isEmpty(universitiesCollegesId)){ + and b.universities_colleges_id =#universitiesCollegesId# + @} + @if(!isEmpty(universitySystemId)){ + and a.university_system_id =#universitySystemId# + @} + @if(!isEmpty(classId)){ + and t.class_id =#classId# + @} + @if(!isEmpty(classIds)){ + and find_in_set(t.class_id ,#classIds#) + @} + @if(!isEmpty(className)){ + and a.class_name like #'%'+className+'%'# + @} + @if(!isEmpty(universitiesCollegesName)){ + and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# + @} + @if(!isEmpty(studentName)){ + and t.student_name like #'%'+studentName+'%'# + @} + @if(!isEmpty(studentSn)){ + and t.student_sn =#studentSn# + @} + @if(!isEmpty(studentMobile)){ + and t.student_mobile =#studentMobile# + @} + @if(!isEmpty(studentEmail)){ + and t.student_email =#studentEmail# + @} + @if(!isEmpty(studentStatus)){ + and t.student_status =#studentStatus# + @} + @if(!isEmpty(studentStatuses)){ + and find_in_set(t.student_status,#studentStatuses#) + @} + @if(!isEmpty(studentPassword)){ + and t.student_password =#studentPassword# + @} + @if(!isEmpty(addTime)){ + and t.add_time =#addTime# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(orderByRand)){ + ORDER BY RAND() + @} + + queryByCondition2Student === * 根据不为空的参数进行分页查询 @@ -739,6 +806,9 @@ getValuesByQuery @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} + @if(!isEmpty(universitySystemId)){ + and a.university_system_id =#universitySystemId# + @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} diff --git a/web/src/test/java/com/ibeetl/jlw/web/StudentControllerTest.java b/web/src/test/java/com/ibeetl/jlw/web/StudentControllerTest.java new file mode 100644 index 00000000..4abb8cb1 --- /dev/null +++ b/web/src/test/java/com/ibeetl/jlw/web/StudentControllerTest.java @@ -0,0 +1,44 @@ +package com.ibeetl.jlw.web; + +import base.BaseTest; +import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.RequestBuilder; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +import java.nio.charset.Charset; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +/** + *

+ * + *

+ * + * @author mlx + * @date 2022/10/24 + * @modified + */ +class StudentControllerTest extends BaseTest { + + private static final String MODEL = "/jlw/student"; + private static final String API = "/api/student"; + + + @Test + void getPageList() throws Exception { + //构造请求参数 + RequestBuilder rb = MockMvcRequestBuilders.post(API + "/getPageList.do") + .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + .param("universitySystemId", "1569331621092564992"); + + //发送请求,验证返回结果 + String result = mvc.perform(rb) + .andExpect(status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0")) + .andReturn().getResponse().getContentAsString(Charset.defaultCharset()); + + System.out.println(result); + } +} \ No newline at end of file