|
@@ -10,10 +10,12 @@ import java.util.List;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
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.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
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.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
@@ -46,27 +48,34 @@ public class CourseApi {
|
|
@Autowired
|
|
@Autowired
|
|
CourseAssembler courseAssembler;
|
|
CourseAssembler courseAssembler;
|
|
|
|
|
|
- @ApiOperation(value="查询所有课程",notes="enable为查询条件,可为空")
|
|
+ @ApiOperation(value="查询课程分页带查询",notes="分页带查询")
|
|
- @GetMapping
|
|
+ @GetMapping("/all/{curPage}/{pageSize}")
|
|
- public ResponseEntity getAllCourse(@RequestParam Long orgId,@RequestParam(required = false) Boolean enable){
|
|
+ public ResponseEntity getAllOrg(@ModelAttribute Course course, @PathVariable Integer curPage,@PathVariable Integer pageSize){
|
|
- List<Course> list = null;
|
|
+ return new ResponseEntity(courseService.findAlL(course,new PageRequest(curPage - 1,pageSize)), HttpStatus.OK);
|
|
- if(enable!=null){
|
|
|
|
- list = courseRepo.findByOrgIdAndEnable(orgId,enable);
|
|
|
|
- }else{
|
|
|
|
- list = courseRepo.findByOrgId(orgId);
|
|
|
|
- }
|
|
|
|
- return new ResponseEntity(list, HttpStatus.OK);
|
|
|
|
}
|
|
}
|
|
-
|
|
+
|
|
|
|
+ @ApiOperation(value="查询课程不分页带查询",notes = "不分页带查询")
|
|
|
|
+ @GetMapping("/all")
|
|
|
|
+ public ResponseEntity getAllExam(@ModelAttribute Course course){
|
|
|
|
+ return new ResponseEntity(courseService.findAlL(course), HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value="按ID查询课程",notes="ID查询")
|
|
@ApiOperation(value="按ID查询课程",notes="ID查询")
|
|
@GetMapping("/{id}")
|
|
@GetMapping("/{id}")
|
|
public ResponseEntity getCourseById(@PathVariable Long id){
|
|
public ResponseEntity getCourseById(@PathVariable Long id){
|
|
return new ResponseEntity(courseRepo.findOne(id),HttpStatus.OK);
|
|
return new ResponseEntity(courseRepo.findOne(id),HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="按code查询课程",notes="code查询")
|
|
|
|
+ @GetMapping()
|
|
|
|
+ public ResponseEntity getCourseByCode(@RequestParam Long orgId,@RequestParam String code){
|
|
|
|
+ return new ResponseEntity(courseRepo.findByOrgIdAndCode(orgId, code),HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation(value="新增课程",notes="新增")
|
|
@ApiOperation(value="新增课程",notes="新增")
|
|
@PostMapping
|
|
@PostMapping
|
|
public ResponseEntity addCourse(@RequestBody Course course){
|
|
public ResponseEntity addCourse(@RequestBody Course course){
|
|
|
|
+ course.setCreateTime(new Date());
|
|
return new ResponseEntity(courseRepo.save(course),HttpStatus.CREATED);
|
|
return new ResponseEntity(courseRepo.save(course),HttpStatus.CREATED);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -98,9 +107,9 @@ public class CourseApi {
|
|
|
|
|
|
@ApiOperation(value="导出课程",notes = "导出")
|
|
@ApiOperation(value="导出课程",notes = "导出")
|
|
@GetMapping("/export")
|
|
@GetMapping("/export")
|
|
- public void exportCourse(@RequestParam Long orgId,HttpServletResponse response){
|
|
+ public void exportCourse(@ModelAttribute Course orgCriteria,HttpServletResponse response){
|
|
List<CourseDTO> list = new ArrayList<CourseDTO>();
|
|
List<CourseDTO> list = new ArrayList<CourseDTO>();
|
|
- courseRepo.findByOrgId(orgId).forEach(c -> {
|
|
+ courseService.findAlL(orgCriteria).forEach(c -> {
|
|
list.add(courseAssembler.toDTO(c));
|
|
list.add(courseAssembler.toDTO(c));
|
|
});
|
|
});
|
|
ExportUtils.exportEXCEL("课程列表", CourseDTO.class, list, response);
|
|
ExportUtils.exportEXCEL("课程列表", CourseDTO.class, list, response);
|