|
@@ -2,17 +2,26 @@ package com.qmth.cqb.base.web;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.cqb.base.dao.CourseRepo;
|
|
import com.qmth.cqb.base.dao.CourseRepo;
|
|
import com.qmth.cqb.base.model.Course;
|
|
import com.qmth.cqb.base.model.Course;
|
|
import com.qmth.cqb.base.service.CourseService;
|
|
import com.qmth.cqb.base.service.CourseService;
|
|
|
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Created by songyue on 16/12/26.
|
|
* Created by songyue on 16/12/26.
|
|
*/
|
|
*/
|
|
@@ -23,83 +32,96 @@ public class CourseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
Gson gson;
|
|
Gson gson;
|
|
-
|
|
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
CourseRepo courseRepo;
|
|
CourseRepo courseRepo;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
CourseService courseService;
|
|
CourseService courseService;
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 获取全部课程
|
|
* 获取全部课程
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="获取全部课程",notes="获取全部课程")
|
|
|
|
|
|
+ @ApiOperation(value = "获取全部课程", notes = "获取全部课程")
|
|
@GetMapping(value = "/course/{curPage}/{pageSize}")
|
|
@GetMapping(value = "/course/{curPage}/{pageSize}")
|
|
- public ResponseEntity getAllCourse(@ModelAttribute Course searchCondition,
|
|
|
|
- @PathVariable int curPage,
|
|
|
|
- @PathVariable int pageSize){
|
|
|
|
- return new ResponseEntity(courseService.findAll(searchCondition,curPage,pageSize),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getAllCourse(@ModelAttribute Course searchCondition, @PathVariable int curPage,
|
|
|
|
+ @PathVariable int pageSize) {
|
|
|
|
+ return new ResponseEntity(courseService.findAll(searchCondition, curPage, pageSize), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更新课程
|
|
* 更新课程
|
|
|
|
+ *
|
|
* @param course
|
|
* @param course
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="更新课程",notes="更新课程")
|
|
|
|
|
|
+ @ApiOperation(value = "更新课程", notes = "更新课程")
|
|
@PutMapping(value = "/course")
|
|
@PutMapping(value = "/course")
|
|
- public ResponseEntity updateCourse(@ModelAttribute Course course){
|
|
|
|
- return new ResponseEntity(courseRepo.save(course),HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity updateCourse(@ModelAttribute Course course) {
|
|
|
|
+ return new ResponseEntity(courseRepo.save(course), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增课程
|
|
* 新增课程
|
|
|
|
+ *
|
|
* @param course
|
|
* @param course
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="新增课程",notes="新增课程")
|
|
|
|
|
|
+ @ApiOperation(value = "新增课程", notes = "新增课程")
|
|
@PostMapping(value = "/course")
|
|
@PostMapping(value = "/course")
|
|
- public ResponseEntity addCourse(@ModelAttribute Course course){
|
|
|
|
- return new ResponseEntity(courseRepo.save(course),HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity addCourse(@ModelAttribute Course course) {
|
|
|
|
+ return new ResponseEntity(courseRepo.save(course), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除课程
|
|
* 删除课程
|
|
|
|
+ *
|
|
* @param coruse_id
|
|
* @param coruse_id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="删除课程",notes="删除课程")
|
|
|
|
|
|
+ @ApiOperation(value = "删除课程", notes = "删除课程")
|
|
@DeleteMapping(value = "/course/{coruse_id}")
|
|
@DeleteMapping(value = "/course/{coruse_id}")
|
|
- public ResponseEntity removeCourse(@PathVariable String coruse_id){
|
|
|
|
|
|
+ public ResponseEntity removeCourse(@PathVariable String coruse_id) {
|
|
courseRepo.delete(coruse_id);
|
|
courseRepo.delete(coruse_id);
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据课程名称或者课程编号获取课程信息
|
|
* 根据课程名称或者课程编号获取课程信息
|
|
|
|
+ *
|
|
* @param keyword
|
|
* @param keyword
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="根据课程名称或者课程编号获取课程信息",notes="根据课程名称或者课程编号获取课程信息")
|
|
|
|
|
|
+ @ApiOperation(value = "根据课程名称或者课程编号获取课程信息", notes = "根据课程名称或者课程编号获取课程信息")
|
|
@GetMapping(value = "/course")
|
|
@GetMapping(value = "/course")
|
|
- public ResponseEntity getCourseByKeyword(@RequestParam String keyword){
|
|
|
|
- return new ResponseEntity(courseService.findCoursesByKeyword(keyword),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getCourseByKeyword(@RequestParam String keyword) {
|
|
|
|
+ return new ResponseEntity(courseService.findCoursesByKeyword(keyword), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据课程编号获取课程信息
|
|
* 根据课程编号获取课程信息
|
|
|
|
+ *
|
|
* @param courseNo
|
|
* @param courseNo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="根据课程编号获取课程信息",notes="根据课程编号获取课程信息")
|
|
|
|
|
|
+ @ApiOperation(value = "根据课程编号获取课程信息", notes = "根据课程编号获取课程信息")
|
|
@GetMapping(value = "/course/{courseNo}")
|
|
@GetMapping(value = "/course/{courseNo}")
|
|
- public ResponseEntity getCourseByNo(@PathVariable String courseNo){
|
|
|
|
- return new ResponseEntity(courseRepo.findByCourseNo(courseNo),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getCourseByNo(@PathVariable String courseNo) {
|
|
|
|
+ return new ResponseEntity(courseRepo.findByCourseNo(courseNo), HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有课程
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation(value = " 查询所有课程", notes = "查询所有课程")
|
|
|
|
+ @GetMapping(value = "/course/allCourses")
|
|
|
|
+ public ResponseEntity getAllCourses() {
|
|
|
|
+ List<Course> courses = courseRepo.findAll();
|
|
|
|
+ return new ResponseEntity(courses, HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|