commit
faebc3b440
|
@ -0,0 +1,35 @@
|
|||
package com.letoy.edu.controller;
|
||||
|
||||
import com.letoy.edu.service.LessonArrService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(value = "选课管理", tags = "选课管理API")
|
||||
public class LessonArrController {
|
||||
|
||||
@Autowired
|
||||
LessonArrService lessonArrService;
|
||||
|
||||
@PostMapping("/Arr/findAllLessonArr")
|
||||
@ApiOperation(value = "选课管理表查询所有", notes = "选课管理表查询所有")
|
||||
@ApiImplicitParam(value = "",name = "Authorization",paramType = "header", dataType = "String", required=true)
|
||||
private Map<String,Object> findAllLessonArr(){
|
||||
return lessonArrService.findAllLessonArr();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/Arr/findLessonArrByNumberWeek")
|
||||
@ApiOperation(value = "选课管理表根据学号/周查询", notes = "选课管理表根据学号/周查询")
|
||||
@ApiImplicitParam(value = "",name = "Authorization",paramType = "header", dataType = "String", required=true)
|
||||
private Map<String,Object> findLessonArrByNumberWeek(int number, int week){
|
||||
return lessonArrService.findLessonArrByNumberWeek(number,week);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.letoy.edu.dao;
|
||||
|
||||
import com.letoy.edu.entity.LessonArr;
|
||||
import com.letoy.edu.vo.SelectLesson;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface LessonArrMapper {
|
||||
|
||||
List<LessonArr> findAllLessonArr();
|
||||
|
||||
List<SelectLesson> findLessonArrByNumberWeek(@Param("number") int number, @Param("week") int week);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.letoy.edu.entity;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LessonArr {
|
||||
|
||||
private long lessonArrId;
|
||||
private long studentId;
|
||||
private long lessonId;
|
||||
private long scoreId;
|
||||
|
||||
}
|
|
@ -35,5 +35,7 @@ public class LessonInfo {
|
|||
@ApiModelProperty(value = "结束时间", example = "1200", dataType = "int")
|
||||
private long endClass;
|
||||
|
||||
private long day;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.letoy.edu.service.Impl;
|
||||
|
||||
import com.letoy.edu.dao.LessonArrMapper;
|
||||
import com.letoy.edu.entity.LessonArr;
|
||||
import com.letoy.edu.service.LessonArrService;
|
||||
import com.letoy.edu.vo.SelectLesson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LessonArrServiceImpl implements LessonArrService {
|
||||
|
||||
|
||||
@Autowired
|
||||
LessonArrMapper lessonArrMapper;
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> findAllLessonArr() {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
List<LessonArr> allLessonArr = lessonArrMapper.findAllLessonArr();
|
||||
if (allLessonArr.isEmpty()) {
|
||||
hashMap.put("status","1");
|
||||
hashMap.put("msg","查询失败");
|
||||
return hashMap;
|
||||
}
|
||||
hashMap.put("status","0");
|
||||
hashMap.put("msg","查询成功");
|
||||
hashMap.put("data", allLessonArr);
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> findLessonArrByNumberWeek(int number, int week) {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
|
||||
List<SelectLesson> lessonArrByNumberWeek = lessonArrMapper.findLessonArrByNumberWeek(number, week);
|
||||
|
||||
if (lessonArrByNumberWeek.isEmpty()) {
|
||||
hashMap.put("status","1");
|
||||
hashMap.put("msg","查询失败");
|
||||
return hashMap;
|
||||
}
|
||||
hashMap.put("status","0");
|
||||
hashMap.put("msg","查询成功");
|
||||
hashMap.put("data", lessonArrByNumberWeek);
|
||||
return hashMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.letoy.edu.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface LessonArrService {
|
||||
|
||||
HashMap<String,Object> findAllLessonArr();
|
||||
HashMap<String,Object> findLessonArrByNumberWeek(int number, int week);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.letoy.edu.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 简化课程信息类 用于返回课程表
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LessonClean {
|
||||
|
||||
private long lessonId;
|
||||
private long majorId;
|
||||
private long teacherId;
|
||||
private String name;
|
||||
private long type;
|
||||
private String classroom;
|
||||
private long startClass;
|
||||
private long endClass;
|
||||
private long day;
|
||||
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@ public class LessonTimeInfo {
|
|||
private long endWeek;
|
||||
private long startClass;
|
||||
private long endClass;
|
||||
private long day;
|
||||
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
|
@ -38,6 +39,7 @@ public class LessonTimeInfo {
|
|||
this.endWeek = lessonInfo.getEndWeek();
|
||||
this.startClass = lessonInfo.getStartClass();
|
||||
this.endClass = lessonInfo.getEndClass();
|
||||
this.day = lessonInfo.getDay();
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.letoy.edu.vo;
|
||||
|
||||
import com.letoy.edu.entity.LessonInfo;
|
||||
|
||||
import com.letoy.edu.entity.StudentInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 课程选择类
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SelectLesson {
|
||||
|
||||
private long lessonArrId;
|
||||
private long studentId;
|
||||
|
||||
private LessonClean lessonClean;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.letoy.edu.dao.LessonArrMapper">
|
||||
|
||||
<select id="findAllLessonArr" resultType="com.letoy.edu.entity.LessonArr">
|
||||
select lesson_arr_id, student_id, lesson_id, score_id from lesson_arr
|
||||
</select>
|
||||
|
||||
<select id="findLessonArrByNumberWeek" resultMap="lessonMap">
|
||||
select arr.lesson_arr_id,arr.student_id, info.lesson_id, info.major_id, teacher_id, info.name, type, classroom, start_class, end_class, day
|
||||
from lesson_arr arr, lesson_info info, student_info s
|
||||
where s.number=#{number}
|
||||
and s.student_id = arr.student_id
|
||||
and arr.lesson_id = info.lesson_id
|
||||
and start_week <![CDATA[ <= ]]> #{week}
|
||||
and #{week} <![CDATA[ <= ]]> end_week
|
||||
</select>
|
||||
|
||||
<resultMap id="lessonMap" type="com.letoy.edu.vo.SelectLesson">
|
||||
<id property="lessonArrId" column="lesson_arr_id" javaType="java.lang.Integer"/>
|
||||
<result property="studentId" column="student_id" javaType="java.lang.Integer"/>
|
||||
<association property="lessonClean" javaType="com.letoy.edu.vo.LessonClean">
|
||||
<id property="lessonId" column="lesson_id" javaType="java.lang.Integer"/>
|
||||
<result property="majorId" column="major_id" javaType="java.lang.Integer"/>
|
||||
<result property="teacherId" column="teacher_id" javaType="java.lang.Integer"/>
|
||||
<result property="name" column="name" javaType="java.lang.String"/>
|
||||
<result property="type" column="type" javaType="java.lang.Integer"/>
|
||||
<result property="classroom" column="classroom" javaType="java.lang.String"/>
|
||||
<result property="startClass" column="start_class" javaType="java.lang.Integer"/>
|
||||
<result property="endClass" column="end_class" javaType="java.lang.Integer"/>
|
||||
<result property="day" column="day" javaType="java.lang.Integer"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
</mapper>
|
|
@ -0,0 +1,27 @@
|
|||
package com.letoy.edu.dao;
|
||||
|
||||
import com.letoy.edu.entity.LessonArr;
|
||||
import com.letoy.edu.vo.SelectLesson;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class LessonArrMapperTest {
|
||||
|
||||
@Autowired
|
||||
LessonArrMapper lessonArrMapper;
|
||||
|
||||
@Test
|
||||
public void testLessonByNumberWeek(){
|
||||
List<SelectLesson> lessonArrByNumberWeek = lessonArrMapper.findLessonArrByNumberWeek(180809107, 6);
|
||||
System.out.println(lessonArrByNumberWeek);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue