|
@@ -1,13 +1,31 @@
|
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
|
|
|
-import cn.com.qmth.examcloud.service.core.entity.Course;
|
|
|
-import cn.com.qmth.examcloud.service.core.service.CourseService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
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.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+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.service.core.entity.Course;
|
|
|
+import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
|
|
|
+import cn.com.qmth.examcloud.service.core.service.CourseService;
|
|
|
|
|
|
/**
|
|
|
* 课程服务API
|
|
@@ -53,4 +71,17 @@ public class CourseApi {
|
|
|
courseRepo.delete(id);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="导入课程",notes = "导入")
|
|
|
+ @PostMapping("/import")
|
|
|
+ public ResponseEntity importCourse(HttpServletRequest request,@RequestParam MultipartFile file){
|
|
|
+ try {
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ List<ExcelError> errors = courseService.importCourse(accessUser.getRootOrgId(),file.getInputStream());
|
|
|
+ return new ResponseEntity(errors,HttpStatus.OK);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|