|
@@ -1,10 +1,13 @@
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
|
+import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
|
|
|
|
+import cn.com.qmth.examcloud.service.core.util.ExportUtils;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -35,6 +38,7 @@ import cn.com.qmth.examcloud.common.util.excel.ExcelError;
|
|
import cn.com.qmth.examcloud.service.core.entity.Org;
|
|
import cn.com.qmth.examcloud.service.core.entity.Org;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
import cn.com.qmth.examcloud.service.core.service.OrgService;
|
|
import cn.com.qmth.examcloud.service.core.service.OrgService;
|
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -153,10 +157,18 @@ public class OrgApi {
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "按父ID导入子机构", notes = "导入子机构")
|
|
@ApiOperation(value = "按父ID导入子机构", notes = "导入子机构")
|
|
- @PostMapping("/{id}/import")
|
|
|
|
- public ResponseEntity importLearnCenter(@PathVariable Long id, @RequestParam MultipartFile file) {
|
|
|
|
|
|
+ @PostMapping("/import")
|
|
|
|
+ public ResponseEntity importLearnCenter(HttpServletRequest request,
|
|
|
|
+ @RequestParam CommonsMultipartFile file) {
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ Long orgId = null;
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ orgId = accessUser.getRootOrgId();
|
|
|
|
+ }else{
|
|
|
|
+ return new ResponseEntity(new ErrorMsg("用户token不存在或已失效"),HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
- List<ExcelError> excelErrors = orgService.importLearnCenter(id, file.getInputStream());
|
|
|
|
|
|
+ List<ExcelError> excelErrors = orgService.importLearnCenter(orgId, file.getInputStream());
|
|
return new ResponseEntity(excelErrors, HttpStatus.OK);
|
|
return new ResponseEntity(excelErrors, HttpStatus.OK);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -164,6 +176,14 @@ public class OrgApi {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation(value="下载导入模板",notes = "下载导入模板")
|
|
|
|
+ @GetMapping("/download")
|
|
|
|
+ public void importFileTemplate(HttpServletResponse response){
|
|
|
|
+ List<Org> list= new ArrayList<Org>();
|
|
|
|
+ list.add(new Org("学习中心", "000001", "张三","13687653477"));
|
|
|
|
+ ExportUtils.exportEXCEL("学习中心导入模板", Org.class, list, response);
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value = "启用机构", notes = "启用")
|
|
@ApiOperation(value = "启用机构", notes = "启用")
|
|
@PutMapping("/enable/{ids}")
|
|
@PutMapping("/enable/{ids}")
|
|
public ResponseEntity enableSchool(@PathVariable String ids) {
|
|
public ResponseEntity enableSchool(@PathVariable String ids) {
|