|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -12,8 +13,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+import cn.com.qmth.examcloud.common.util.excel.ExcelError;
|
|
|
+import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
@@ -23,17 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
-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.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
@@ -43,6 +34,7 @@ import cn.com.qmth.examcloud.service.core.entity.Specialty;
|
|
|
import cn.com.qmth.examcloud.service.core.repo.SpecialtyRepo;
|
|
|
import cn.com.qmth.examcloud.service.core.service.SpecialtyService;
|
|
|
import cn.com.qmth.examcloud.service.core.util.ExportUtils;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
/**
|
|
|
* @Description: 专业服务API
|
|
@@ -81,6 +73,18 @@ public class SpecialtyApi {
|
|
|
}
|
|
|
return new ResponseEntity(specialtyService.findAll(specialty, new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按code查询专业
|
|
|
+ * @param orgId
|
|
|
+ * @param code
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="按code查询专业",notes="按code查询专业")
|
|
|
+ @GetMapping
|
|
|
+ public ResponseEntity getAll(@RequestParam Long orgId, @RequestParam String code){
|
|
|
+ return new ResponseEntity(specialtyRepo.findByOrgIdAndCode(orgId,code),HttpStatus.OK);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询专业不带分页
|
|
@@ -166,6 +170,33 @@ public class SpecialtyApi {
|
|
|
specialtyRepo.delete(Long.parseLong(id));
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="下载导入模板",notes = "下载导入模板")
|
|
|
+ @GetMapping("/download")
|
|
|
+ public void importFileTemplate(HttpServletResponse response){
|
|
|
+ List<SpecialtyDTO> list= new ArrayList<SpecialtyDTO>();
|
|
|
+ ExportUtils.exportEXCEL("专业导入模板", SpecialtyDTO.class, list, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="导入",notes = "导入")
|
|
|
+ @PostMapping("/import")
|
|
|
+ public ResponseEntity importCourse(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 {
|
|
|
+ List<ExcelError> errors = specialtyService.importSpecialty(orgId,file.getInputStream());
|
|
|
+ return new ResponseEntity(errors,HttpStatus.OK);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 导出专业
|