学生端、教师端实验项目分页

master
pd 4 years ago
parent 3492011da8
commit c761cea942
  1. 5
      src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java
  2. 5
      src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java
  3. 6
      src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java
  4. 21
      src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java
  5. 16
      src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java

@ -23,13 +23,14 @@ public class ExperimentallearningController {
* @return * @return
*/ */
@GetMapping("/queryExperimentallearning") @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(); Response resp = new Response();
if(StringUtils.isEmpty(studentId)){ if(StringUtils.isEmpty(studentId)){
resp.setStatus(300); resp.setStatus(300);
resp.setMessage("学生信息为空"); resp.setMessage("学生信息为空");
}else { }else {
HashMap<String, Object> ret = service.queryProject(studentId,courseId); HashMap<String, Object> ret = service.queryProject(studentId,courseId,pageNo, pageSize);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (status == 200) { if (status == 200) {
resp.setStatus(status); resp.setStatus(status);

@ -25,13 +25,14 @@ public class ProjectAndCourseController {
* @return * @return
*/ */
@GetMapping("/queryProject") @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(); Response resp = new Response();
if(StringUtils.isEmpty(experimentalClassId)){ if(StringUtils.isEmpty(experimentalClassId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("实验班级信息为空"); resp.setErrmessage("实验班级信息为空");
}else { }else {
HashMap<String, Object> ret = service.queryProject(courseId,experimentalClassId); HashMap<String, Object> ret = service.queryProject(courseId,experimentalClassId,pageNo, pageSize);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (status == 200) { if (status == 200) {
resp.setStatus(status); resp.setStatus(status);

@ -28,7 +28,7 @@ public interface TeacherProjectAndCourseMapper {
// "</script>"}) // "</script>"})
@Select("select DISTINCT hpm.projectId,projectName,isOpenProject,isAttendance from hr_project_management hpm left join teacher_project tp on hpm.projectId=tp.projectId " + @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<Project_Management> getBySystemId(@Param("courseId") Integer courseId,@Param("experimentalClassId")Integer experimentalClassId); List<Project_Management> 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}") @Select("select count(*) from hr_course_schedule where courseId=#{courseId}")
Integer getCourseSchedule(Integer 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<Integer> queryProject(Integer courseId); List<Integer> queryProject(Integer courseId);
@Insert({"<script>", @Insert({"<script>",
"insert into teacher_project(courseId,experimentalClassId,projectId) values ", "insert into teacher_project(courseId,experimentalClassId,projectId) values ",
"<foreach collection='projectIds' item='projectId' index='index' separator=','>", "<foreach collection='projectIds' item='projectId' index='index' separator=','>",
"(#{experimentalClassId}, #{courseId}, #{projectId})", "(#{courseId},#{experimentalClassId}, #{projectId})",
"</foreach>", "</foreach>",
"</script>"}) "</script>"})
void addBatchTeachProject(@Param("experimentalClassId") Integer experimentalClassId,@Param("courseId") Integer courseId,@Param("projectIds") List<Integer> projectIds); void addBatchTeachProject(@Param("experimentalClassId") Integer experimentalClassId,@Param("courseId") Integer courseId,@Param("projectIds") List<Integer> projectIds);

@ -5,14 +5,13 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.ExperimentallearningMapper;
import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper; import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -40,10 +39,11 @@ public class ExperimentallearningService {
* @param courseId * @param courseId
* @return * @return
*/ */
public HashMap<String, Object> queryProject(Integer studentId, Integer courseId) { public HashMap<String, Object> queryProject(Integer studentId, Integer courseId,Integer pageNo,Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){ if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){
PageHelper.startPage(pageNo, pageSize);
Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId); Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId);
List<Integer> projectIds = mapper.queryIsAttendance(studentId, courseId); List<Integer> projectIds = mapper.queryIsAttendance(studentId, courseId);
List<Project_Management> projects = mapper.getBycourseId(experimentalClassId,courseId); List<Project_Management> projects = mapper.getBycourseId(experimentalClassId,courseId);
@ -60,7 +60,16 @@ public class ExperimentallearningService {
projects.set(i, project); projects.set(i, project);
} }
} }
resp.put("retvalue", projects);
PageInfo<Project_Management> info=new PageInfo<Project_Management>(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); resp.put("retcode", 200);
}catch(Exception e){ }catch(Exception e){

@ -3,6 +3,9 @@ package com.yipin.liuwanr.service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.mapper.ExperimentallearningMapper;
import com.yipin.liuwanr.vo.CourseAndProjectVo; import com.yipin.liuwanr.vo.CourseAndProjectVo;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -33,12 +36,21 @@ public class ProjectAndCourseService {
* @param courseId * @param courseId
* @return * @return
*/ */
public HashMap<String, Object> queryProject(Integer courseId,Integer experimentalClassId) { public HashMap<String, Object> queryProject(Integer courseId,Integer experimentalClassId,Integer pageNo,Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
PageHelper.startPage(pageNo, pageSize);
List<Project_Management> project=mapper.getBySystemId(courseId,experimentalClassId); List<Project_Management> project=mapper.getBySystemId(courseId,experimentalClassId);
PageInfo<Project_Management> info=new PageInfo<Project_Management>(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("retcode", 200);
resp.put("retvalue", project); resp.put("retvalue", new PageResult(total,project,totalPages));
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);

Loading…
Cancel
Save