SubjectController.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.keao.edu.user.controller;
  2. import com.keao.edu.common.controller.BaseController;
  3. import com.keao.edu.common.entity.HttpResponseResult;
  4. import com.keao.edu.common.page.PageInfo;
  5. import com.keao.edu.common.tenant.TenantContextHolder;
  6. import com.keao.edu.user.entity.Subject;
  7. import com.keao.edu.user.page.SubjectQueryInfo;
  8. import com.keao.edu.user.service.SubjectService;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.security.access.prepost.PreAuthorize;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.List;
  16. @RequestMapping("subject")
  17. @Api(tags = "科目服务")
  18. @RestController
  19. public class SubjectController extends BaseController {
  20. @Autowired
  21. private SubjectService subjectService;
  22. @ApiOperation(value = "修改、新增科目")
  23. @PostMapping("/upset")
  24. @PreAuthorize("@pcs.hasPermissions('subject/upset')")
  25. public HttpResponseResult update(@RequestBody Subject subject){
  26. subject.setTenantId(TenantContextHolder.getTenantId());
  27. subjectService.upSetSubject(subject);
  28. return succeed();
  29. }
  30. @ApiOperation(value = "删除科目")
  31. @PostMapping("/del")
  32. @PreAuthorize("@pcs.hasPermissions('subject/del')")
  33. public HttpResponseResult del(@RequestBody Subject subject){
  34. subject.setTenantId(TenantContextHolder.getTenantId());
  35. subject.setDelFlag(true);
  36. subjectService.upSetSubject(subject);
  37. return succeed();
  38. }
  39. @ApiOperation(value = "根据科目编号查询科目")
  40. @GetMapping("/get/{id}")
  41. @PreAuthorize("@pcs.hasPermissions('subject/get')")
  42. public HttpResponseResult<Subject> get(@ApiParam(value = "科目编号", required = true) @PathVariable("id") Integer id){
  43. return succeed(subjectService.get(id));
  44. }
  45. @ApiOperation(value = "分页查询科目列表")
  46. @GetMapping("/queryPage")
  47. @PreAuthorize("@pcs.hasPermissions('subject/queryPage')")
  48. public HttpResponseResult<PageInfo<Subject>> queryPage(SubjectQueryInfo queryInfo){
  49. return succeed(subjectService.queryPage(queryInfo));
  50. }
  51. @ApiOperation(value = "学生端分页查询科目列表")
  52. @GetMapping("/studentQueryPage")
  53. public HttpResponseResult<PageInfo<Subject>> studentQueryPage(SubjectQueryInfo queryInfo){
  54. return succeed(subjectService.queryPage(queryInfo));
  55. }
  56. @ApiOperation(value = "分页查询科目树状列表")
  57. @GetMapping("/queryPageTree")
  58. @PreAuthorize("@pcs.hasPermissions('subject/queryPageTree')")
  59. public HttpResponseResult<PageInfo<Subject>> queryPageTree(SubjectQueryInfo queryInfo){
  60. return succeed(subjectService.queryPageTree(queryInfo));
  61. }
  62. @ApiOperation(value = "获取子集科目列表")
  63. @GetMapping("/findSubSubjects")
  64. @PreAuthorize("@pcs.hasPermissions('subject/findSubSubjects')")
  65. public HttpResponseResult<List<Subject>> findSubSubjects(){
  66. return succeed(subjectService.findSubSubjects(Integer.parseInt(TenantContextHolder.getTenantId())));
  67. }
  68. }