Commit 9dcd39be authored by wujipeng's avatar wujipeng
Browse files

根据学生id查询最近的一场考试

parent 0e26d1b5
......@@ -4,6 +4,7 @@ import com.platform.business.model.dto.ExamDTO;
import com.platform.business.model.vo.ExamStudentVO;
import com.platform.business.model.vo.ExamVO;
import com.platform.business.service.ExamService;
import com.platform.business.service.ExamStudentService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
......@@ -17,6 +18,8 @@ public class ExamController extends BaseController {
@Resource
private ExamService examService;
@Resource
private ExamStudentService examStudentService;
@PostMapping("/page")
public TableDataInfo page(@RequestBody ExamDTO examDTO) {
......@@ -53,4 +56,9 @@ public class ExamController extends BaseController {
return getDataTable(examService.classExamScore(examDTO));
}
@ApiOperation(value = "根据学生id查询最近的一场考试")
@GetMapping("/student/recent/{studentId}")
public Result<ExamStudentVO> recent(@PathVariable String studentId) {
return Result.data(examStudentService.recent(studentId));
}
}
......@@ -19,4 +19,8 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudentEntity> {
List<ExamStudentVO> queryOneselfTeacher(@Param("userId")String userId);
ExamStudentVO recent(@Param("studentId") String studentId);
List<ExamStudentVO> theSameEvent(@Param("examId") Integer examId);
}
......@@ -22,4 +22,6 @@ public interface ExamStudentService extends IService<ExamStudentEntity> {
List<ExamStudentVO> queryOneselfTeacher(String userId);
ExamStudentVO recent(String studentId);
}
......@@ -33,4 +33,12 @@ public class ExamStaudentServiceImpl extends ServiceImpl<ExamStudentMapper, Exam
return baseMapper.queryOneselfTeacher(userId);
}
@Override
public ExamStudentVO recent(String studentId) {
ExamStudentVO examStudentVO = baseMapper.recent(studentId);
//获取同一场考试的学生
List<ExamStudentVO> data = baseMapper.theSameEvent(examStudentVO.getExamId());
examStudentVO.setData(data);
return examStudentVO;
}
}
......@@ -70,4 +70,29 @@
e.chief_id = #{userId} or e.invigilation_id like concat('%',#{userId},'%')
);
</select>
<select id="recent" resultType="com.platform.business.model.vo.ExamStudentVO">
select u.level as lev,
e.type,
e.name as examName,
es.start_time as startTime,
es.duration,
e.forbid,
e.chief_id as chiefId,
e.invigilation_id as invigilationId,
es.exam_id as examId,
c.name as className
from exam_student es
left join exam e on es.exam_id = e.id
left join user u on es.student_id = u.id
left join class c on e.class_id = c.id
where u.id = #{studentId}
order by es.start_time desc
limit 1
</select>
<select id="theSameEvent" resultType="com.platform.business.model.vo.ExamStudentVO">
select es.student_id as studentId, u.nick_name as studentName
from exam_student es
left join user u on es.student_id = u.id
where es.exam_id = #{examId}
</select>
</mapper>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment