|
@@ -24,9 +24,8 @@ 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.commons.CommonsMultipartFile;
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
-import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.core.basic.dao.SpecialtyRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.SpecialtyRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Specialty;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Specialty;
|
|
@@ -38,174 +37,151 @@ import io.swagger.annotations.ApiOperation;
|
|
/**
|
|
/**
|
|
* @Description: 专业服务API
|
|
* @Description: 专业服务API
|
|
* @author weiwenhai
|
|
* @author weiwenhai
|
|
- * @Date 2017年8月7号
|
|
|
|
|
|
+ * @Date 2017年8月7号
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("${$rmp.ctr.basic}/specialty")
|
|
@RequestMapping("${$rmp.ctr.basic}/specialty")
|
|
-public class SpecialtyController extends ControllerSupport{
|
|
|
|
|
|
+public class SpecialtyController extends ControllerSupport {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
SpecialtyService specialtyService;
|
|
SpecialtyService specialtyService;
|
|
-
|
|
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
SpecialtyRepo specialtyRepo;
|
|
SpecialtyRepo specialtyRepo;
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 带分页查询
|
|
* 带分页查询
|
|
|
|
+ *
|
|
* @param specialty
|
|
* @param specialty
|
|
* @param curPage
|
|
* @param curPage
|
|
* @param pageSize
|
|
* @param pageSize
|
|
* @param request
|
|
* @param request
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="查询专业带分页", notes="查询专业带分页")
|
|
|
|
|
|
+ @ApiOperation(value = "查询专业带分页", notes = "查询专业带分页")
|
|
@GetMapping("/all/{curPage}/{pageSize}")
|
|
@GetMapping("/all/{curPage}/{pageSize}")
|
|
public ResponseEntity getAllOrg(@ModelAttribute Specialty specialty,
|
|
public ResponseEntity getAllOrg(@ModelAttribute Specialty specialty,
|
|
- @RequestParam(required = false ) Long courseId,
|
|
|
|
- @PathVariable Integer curPage,
|
|
|
|
- @PathVariable Integer pageSize,
|
|
|
|
- HttpServletRequest request){
|
|
|
|
|
|
+ @RequestParam(required = false) Long courseId, @PathVariable Integer curPage,
|
|
|
|
+ @PathVariable Integer pageSize, HttpServletRequest request) {
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
- if(accessUser != null){
|
|
|
|
|
|
+ if (accessUser != null) {
|
|
specialty.setOrgId(accessUser.getRootOrgId());
|
|
specialty.setOrgId(accessUser.getRootOrgId());
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
}
|
|
}
|
|
- return new ResponseEntity(specialtyService.findAll(specialty,courseId, new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(specialtyService.findAll(specialty, courseId,
|
|
|
|
+ new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 按code查询专业
|
|
* 按code查询专业
|
|
|
|
+ *
|
|
* @param orgId
|
|
* @param orgId
|
|
* @param code
|
|
* @param code
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="按code查询专业",notes="按code查询专业")
|
|
|
|
|
|
+ @ApiOperation(value = "按code查询专业", notes = "按code查询专业")
|
|
@GetMapping
|
|
@GetMapping
|
|
- public ResponseEntity getAll(@RequestParam Long orgId, @RequestParam String code){
|
|
|
|
- return new ResponseEntity(specialtyRepo.findByOrgIdAndCode(orgId,code),HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getAll(@RequestParam Long orgId, @RequestParam String code) {
|
|
|
|
+ return new ResponseEntity(specialtyRepo.findByOrgIdAndCode(orgId, code), HttpStatus.OK);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询专业不带分页
|
|
* 查询专业不带分页
|
|
|
|
+ *
|
|
* @param specialty
|
|
* @param specialty
|
|
* @param request
|
|
* @param request
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="查询专业不带分页",notes="查询专业不带分页")
|
|
|
|
|
|
+ @ApiOperation(value = "查询专业不带分页", notes = "查询专业不带分页")
|
|
@GetMapping("/all")
|
|
@GetMapping("/all")
|
|
- public ResponseEntity getAll(@ModelAttribute Specialty specialty,HttpServletRequest request){
|
|
|
|
|
|
+ public ResponseEntity getAll(@ModelAttribute Specialty specialty, HttpServletRequest request) {
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
- if(accessUser != null){
|
|
|
|
|
|
+ if (accessUser != null) {
|
|
specialty.setOrgId(accessUser.getRootOrgId());
|
|
specialty.setOrgId(accessUser.getRootOrgId());
|
|
}
|
|
}
|
|
specialty.setEnable(true);
|
|
specialty.setEnable(true);
|
|
- return new ResponseEntity(specialtyService.findAll(specialty),HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(specialtyService.findAll(specialty), HttpStatus.OK);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新增专业
|
|
* 新增专业
|
|
|
|
+ *
|
|
* @param specialty
|
|
* @param specialty
|
|
* @param request
|
|
* @param request
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="新增专业", notes="新增专业")
|
|
|
|
|
|
+ @ApiOperation(value = "新增专业", notes = "新增专业")
|
|
@PostMapping("/addSpecialty")
|
|
@PostMapping("/addSpecialty")
|
|
- public ResponseEntity addSpecialty(@RequestBody Specialty specialty,HttpServletRequest request){
|
|
|
|
|
|
+ public void addSpecialty(@RequestBody Specialty specialty, HttpServletRequest request) {
|
|
specialty.setCreateTime(new Date());
|
|
specialty.setCreateTime(new Date());
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
- if(accessUser != null){
|
|
|
|
- specialty.setOrgId(accessUser.getRootOrgId());
|
|
|
|
- }else {
|
|
|
|
- return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
|
|
- }
|
|
|
|
- try{
|
|
|
|
- specialtyService.save(specialty);
|
|
|
|
- return new ResponseEntity(HttpStatus.CREATED);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
|
|
+ User accessUser = getAccessUser();
|
|
|
|
+ specialty.setOrgId(accessUser.getRootOrgId());
|
|
|
|
+ specialtyService.save(specialty);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新专业
|
|
* 更新专业
|
|
|
|
+ *
|
|
* @param specialty
|
|
* @param specialty
|
|
* @param request
|
|
* @param request
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="更新专业",notes="更新专业")
|
|
|
|
|
|
+ @ApiOperation(value = "更新专业", notes = "更新专业")
|
|
@PutMapping("/updateSpecialty")
|
|
@PutMapping("/updateSpecialty")
|
|
- public ResponseEntity updateSpecialty(@RequestBody Specialty specialty,HttpServletRequest request){
|
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
- if(accessUser != null){
|
|
|
|
- specialty.setOrgId(accessUser.getRootOrgId());
|
|
|
|
- }else {
|
|
|
|
- return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
|
|
- }
|
|
|
|
- try{
|
|
|
|
- specialtyService.updateSpecialty(specialty);
|
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
|
|
+ public void updateSpecialty(@RequestBody Specialty specialty, HttpServletRequest request) {
|
|
|
|
+ User accessUser = getAccessUser();
|
|
|
|
+ specialty.setOrgId(accessUser.getRootOrgId());
|
|
|
|
+ specialtyService.updateSpecialty(specialty);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据ID删除专业
|
|
* 根据ID删除专业
|
|
|
|
+ *
|
|
* @param ids
|
|
* @param ids
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="根据ID删除专业",notes="根据ID删除专业")
|
|
|
|
|
|
+ @ApiOperation(value = "根据ID删除专业", notes = "根据ID删除专业")
|
|
@DeleteMapping("/{ids}")
|
|
@DeleteMapping("/{ids}")
|
|
- public ResponseEntity deleteSpecialtyIds(@PathVariable String ids){
|
|
|
|
|
|
+ public ResponseEntity deleteSpecialtyIds(@PathVariable String ids) {
|
|
specialtyService.deleteSpecialty(ids);
|
|
specialtyService.deleteSpecialty(ids);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
-
|
|
|
|
- @ApiOperation(value="根据ID删除专业",notes="根据ID删除专业")
|
|
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "根据ID删除专业", notes = "根据ID删除专业")
|
|
@DeleteMapping("/delete/{id}")
|
|
@DeleteMapping("/delete/{id}")
|
|
- public ResponseEntity deleteSpecialtyId(@PathVariable String id){
|
|
|
|
|
|
+ public ResponseEntity deleteSpecialtyId(@PathVariable String id) {
|
|
specialtyRepo.delete(Long.parseLong(id));
|
|
specialtyRepo.delete(Long.parseLong(id));
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="下载导入模板",notes = "下载导入模板")
|
|
|
|
|
|
+ @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
@GetMapping("/download")
|
|
@GetMapping("/download")
|
|
- public void importFileTemplate(HttpServletResponse response){
|
|
|
|
- List<SpecialtyDto> list= new ArrayList<SpecialtyDto>();
|
|
|
|
|
|
+ public void importFileTemplate(HttpServletResponse response) {
|
|
|
|
+ List<SpecialtyDto> list = new ArrayList<SpecialtyDto>();
|
|
ExportService.exportEXCEL("专业导入模板", SpecialtyDto.class, list, response);
|
|
ExportService.exportEXCEL("专业导入模板", SpecialtyDto.class, list, response);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="导入",notes = "导入")
|
|
|
|
|
|
+ @ApiOperation(value = "导入", notes = "导入")
|
|
@PostMapping("/import")
|
|
@PostMapping("/import")
|
|
- public ResponseEntity importCourse(HttpServletRequest request,
|
|
|
|
- @RequestParam CommonsMultipartFile file){
|
|
|
|
|
|
+ public List<ExcelError> importCourse(HttpServletRequest request,
|
|
|
|
+ @RequestParam CommonsMultipartFile file) throws IOException {
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
- 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);
|
|
|
|
- }
|
|
|
|
|
|
+ Long orgId = accessUser.getRootOrgId();
|
|
|
|
+
|
|
|
|
+ List<ExcelError> errors = specialtyService.importSpecialty(orgId, file.getInputStream());
|
|
|
|
+ return errors;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 导出专业
|
|
* 导出专业
|
|
|
|
+ *
|
|
* @param specialty
|
|
* @param specialty
|
|
* @param response
|
|
* @param response
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="导出专业", notes="导出专业")
|
|
|
|
|
|
+ @ApiOperation(value = "导出专业", notes = "导出专业")
|
|
@GetMapping("/export")
|
|
@GetMapping("/export")
|
|
- public void exportSpecialty(@ModelAttribute Specialty specialty,HttpServletResponse response){
|
|
|
|
|
|
+ public void exportSpecialty(@ModelAttribute Specialty specialty, HttpServletResponse response) {
|
|
List<SpecialtyDto> list = new ArrayList<SpecialtyDto>();
|
|
List<SpecialtyDto> list = new ArrayList<SpecialtyDto>();
|
|
specialtyService.findAll(specialty).forEach(c -> {
|
|
specialtyService.findAll(specialty).forEach(c -> {
|
|
list.add(new SpecialtyDto(c));
|
|
list.add(new SpecialtyDto(c));
|