From c761cea94200530069ea4f61ce6c083a3f482957 Mon Sep 17 00:00:00 2001 From: pd <2776455882@qq.com> Date: Thu, 6 Aug 2020 16:44:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AB=AF=E3=80=81=E6=95=99?= =?UTF-8?q?=E5=B8=88=E7=AB=AF=E5=AE=9E=E9=AA=8C=E9=A1=B9=E7=9B=AE=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExperimentallearningController.java | 5 +++-- .../ProjectAndCourseController.java | 5 +++-- .../mapper/TeacherProjectAndCourseMapper.java | 6 +++--- .../service/ExperimentallearningService.java | 21 +++++++++++++------ .../service/ProjectAndCourseService.java | 16 ++++++++++++-- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java index abdde49..0cc52ce 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java @@ -23,13 +23,14 @@ public class ExperimentallearningController { * @return */ @GetMapping("/queryExperimentallearning") - Response queryExperimentallearning(@RequestParam Integer studentId,@RequestParam Integer courseId) { + Response queryExperimentallearning(@RequestParam Integer studentId,@RequestParam Integer courseId, + @RequestParam Integer pageNo,@RequestParam Integer pageSize) { Response resp = new Response(); if(StringUtils.isEmpty(studentId)){ resp.setStatus(300); resp.setMessage("学生信息为空"); }else { - HashMap ret = service.queryProject(studentId,courseId); + HashMap ret = service.queryProject(studentId,courseId,pageNo, pageSize); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java index 76b244a..e48f01c 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java @@ -25,13 +25,14 @@ public class ProjectAndCourseController { * @return */ @GetMapping("/queryProject") - Response queryProject(@RequestParam Integer courseId,@RequestParam Integer experimentalClassId) { + Response queryProject(@RequestParam Integer courseId,@RequestParam Integer experimentalClassId, + @RequestParam Integer pageNo,@RequestParam Integer pageSize) { Response resp = new Response(); if(StringUtils.isEmpty(experimentalClassId)){ resp.setStatus(300); resp.setErrmessage("实验班级信息为空"); }else { - HashMap ret = service.queryProject(courseId,experimentalClassId); + HashMap ret = service.queryProject(courseId,experimentalClassId,pageNo, pageSize); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java b/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java index 6df5f43..0a09f51 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java @@ -28,7 +28,7 @@ public interface TeacherProjectAndCourseMapper { // ""}) @Select("select DISTINCT hpm.projectId,projectName,isOpenProject,isAttendance from hr_project_management hpm left join teacher_project tp on hpm.projectId=tp.projectId " + - " where tp.courseId=#{courseId} and tp.experimentalClassId=#{experimentalClassId}") + " where hpm.isdel=0 and tp.courseId=#{courseId} and tp.experimentalClassId=#{experimentalClassId}") List getBySystemId(@Param("courseId") Integer courseId,@Param("experimentalClassId")Integer experimentalClassId); @@ -47,13 +47,13 @@ public interface TeacherProjectAndCourseMapper { @Select("select count(*) from hr_course_schedule where courseId=#{courseId}") Integer getCourseSchedule(Integer courseId); - @Select("select DISTINCT tc.projectId from hr_course_tc tc left join hr_project_management pm on tc.projectId=pm.projectId where tc.courseId=#{courseId} and pm.projectPermissions=0 ") + @Select("select DISTINCT tc.projectId from hr_course_tc tc left join hr_project_management pm on tc.projectId=pm.projectId where pm.isdel=0 and tc.courseId=#{courseId} and pm.projectPermissions=0 ") List queryProject(Integer courseId); @Insert({""}) void addBatchTeachProject(@Param("experimentalClassId") Integer experimentalClassId,@Param("courseId") Integer courseId,@Param("projectIds") List projectIds); diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java index e8d80cd..0f4cc11 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java @@ -5,14 +5,13 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; -import com.yipin.liuwanr.entity.UserM; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.yipin.liuwanr.entity.*; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.yipin.liuwanr.entity.Assesment; -import com.yipin.liuwanr.entity.Attendance; -import com.yipin.liuwanr.entity.Project_Management; import com.yipin.liuwanr.mapper.ExperimentallearningMapper; import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper; import org.springframework.util.StringUtils; @@ -40,10 +39,11 @@ public class ExperimentallearningService { * @param courseId * @return */ - public HashMap queryProject(Integer studentId, Integer courseId) { + public HashMap queryProject(Integer studentId, Integer courseId,Integer pageNo,Integer pageSize) { HashMap resp = new HashMap(); try { if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){ + PageHelper.startPage(pageNo, pageSize); Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId); List projectIds = mapper.queryIsAttendance(studentId, courseId); List projects = mapper.getBycourseId(experimentalClassId,courseId); @@ -60,7 +60,16 @@ public class ExperimentallearningService { projects.set(i, project); } } - resp.put("retvalue", projects); + + PageInfo info=new PageInfo(projects); + int total1 = (int) info.getTotal(); + int totalPages; + totalPages = total1 / pageSize; + if (total1 % pageSize != 0){ + totalPages ++; + } + long total = total1; + resp.put("retvalue", new PageResult(total,projects,totalPages)); } resp.put("retcode", 200); }catch(Exception e){ diff --git a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java index 2e74202..4977124 100644 --- a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java +++ b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java @@ -3,6 +3,9 @@ package com.yipin.liuwanr.service; import java.util.HashMap; import java.util.List; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.yipin.liuwanr.entity.PageResult; import com.yipin.liuwanr.mapper.ExperimentallearningMapper; import com.yipin.liuwanr.vo.CourseAndProjectVo; import org.jboss.logging.Logger; @@ -33,12 +36,21 @@ public class ProjectAndCourseService { * @param courseId * @return */ - public HashMap queryProject(Integer courseId,Integer experimentalClassId) { + public HashMap queryProject(Integer courseId,Integer experimentalClassId,Integer pageNo,Integer pageSize) { HashMap resp = new HashMap(); try { + PageHelper.startPage(pageNo, pageSize); List project=mapper.getBySystemId(courseId,experimentalClassId); + PageInfo info=new PageInfo(project); + int total1 = (int) info.getTotal(); + int totalPages; + totalPages = total1 / pageSize; + if (total1 % pageSize != 0){ + totalPages ++; + } + long total = total1; resp.put("retcode", 200); - resp.put("retvalue", project); + resp.put("retvalue", new PageResult(total,project,totalPages)); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500);