|
@@ -3,10 +3,9 @@ package cn.com.qmth.examcloud.service.core.api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-
|
|
|
|
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;
|
|
@@ -21,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
|
import cn.com.qmth.examcloud.common.util.excel.ExcelError;
|
|
import cn.com.qmth.examcloud.common.util.excel.ExcelError;
|
|
import cn.com.qmth.examcloud.service.core.entity.Course;
|
|
import cn.com.qmth.examcloud.service.core.entity.Course;
|
|
import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
|
|
@@ -41,16 +39,22 @@ public class CourseApi {
|
|
@Autowired
|
|
@Autowired
|
|
CourseService courseService;
|
|
CourseService courseService;
|
|
|
|
|
|
- @ApiOperation(value="查询所有课程")
|
|
|
|
|
|
+ @ApiOperation(value="查询所有课程",notes="enable为查询条件,可为空")
|
|
@GetMapping
|
|
@GetMapping
|
|
- public ResponseEntity getAllCourse(){
|
|
|
|
- return new ResponseEntity(courseRepo.findAll(), HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getAllCourse(@RequestParam Long orgId,@RequestParam(required = false) Boolean enable){
|
|
|
|
+ List<Course> list = null;
|
|
|
|
+ if(enable!=null){
|
|
|
|
+ list = courseRepo.findByOrgIdAndEnable(orgId,enable);
|
|
|
|
+ }else{
|
|
|
|
+ list = courseRepo.findByOrgId(orgId);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity(list, 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.findById(id),HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(courseRepo.findOne(id),HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value="新增课程",notes="新增")
|
|
@ApiOperation(value="新增课程",notes="新增")
|
|
@@ -62,6 +66,7 @@ public class CourseApi {
|
|
@ApiOperation(value="更新课程",notes="更新")
|
|
@ApiOperation(value="更新课程",notes="更新")
|
|
@PutMapping
|
|
@PutMapping
|
|
public ResponseEntity updateCourse(@RequestBody Course course){
|
|
public ResponseEntity updateCourse(@RequestBody Course course){
|
|
|
|
+ course.setUpdateTime(new Date());
|
|
return new ResponseEntity(courseRepo.save(course),HttpStatus.OK);
|
|
return new ResponseEntity(courseRepo.save(course),HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -74,10 +79,9 @@ public class CourseApi {
|
|
|
|
|
|
@ApiOperation(value="导入课程",notes = "导入")
|
|
@ApiOperation(value="导入课程",notes = "导入")
|
|
@PostMapping("/import")
|
|
@PostMapping("/import")
|
|
- public ResponseEntity importCourse(HttpServletRequest request,@RequestParam MultipartFile file){
|
|
|
|
|
|
+ public ResponseEntity importCourse(@RequestParam Long orgId,@RequestParam MultipartFile file){
|
|
try {
|
|
try {
|
|
- AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
- List<ExcelError> errors = courseService.importCourse(accessUser.getRootOrgId(),file.getInputStream());
|
|
|
|
|
|
+ List<ExcelError> errors = courseService.importCourse(orgId,file.getInputStream());
|
|
return new ResponseEntity(errors,HttpStatus.OK);
|
|
return new ResponseEntity(errors,HttpStatus.OK);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|