ExamLocationController.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.ExamLocation;
  7. import com.keao.edu.user.page.ExamLocationQueryInfo;
  8. import com.keao.edu.user.service.ExamLocationService;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiImplicitParam;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.Date;
  16. import java.util.List;
  17. /**
  18. * @Author Joburgess
  19. * @Date 2020.06.16
  20. */
  21. @RestController
  22. @RequestMapping("examLocation")
  23. @Api(tags = "线下考点服务")
  24. public class ExamLocationController extends BaseController {
  25. @Autowired
  26. private ExamLocationService examLocationService;
  27. @ApiOperation("分页查询")
  28. @GetMapping(value = "/list")
  29. public HttpResponseResult<PageInfo<ExamLocation>> getList(ExamLocationQueryInfo queryInfo) {
  30. if(StringUtils.isBlank(queryInfo.getSearch())){
  31. queryInfo.setSearch(null);
  32. }
  33. return succeed(examLocationService.queryPage(queryInfo));
  34. }
  35. @ApiOperation("获取所在机构所有考点")
  36. @GetMapping(value = "/getTenantAllLocations")
  37. public HttpResponseResult<List<ExamLocation>> getTenantAllLocations(){
  38. return succeed(examLocationService.getTenantAllLocations(TenantContextHolder.getTenantId()));
  39. }
  40. @ApiOperation("查询考点详情")
  41. @ApiImplicitParam(name = "id", value = "机构ID", required = true, dataType = "Integer", paramType = "path")
  42. @GetMapping(value = "/query")
  43. public HttpResponseResult<ExamLocation> query(Integer id) {
  44. return succeed(examLocationService.get(id));
  45. }
  46. @ApiOperation("新增考点")
  47. @PostMapping(value = "/add")
  48. public HttpResponseResult add(@RequestBody ExamLocation examLocation) {
  49. examLocation.setTenantId(TenantContextHolder.getTenantId());
  50. examLocation.setIsAvailable(true);
  51. examLocationService.insert(examLocation);
  52. return succeed();
  53. }
  54. @ApiOperation("更新考点")
  55. @PostMapping(value = "/update")
  56. public HttpResponseResult update(@RequestBody ExamLocation examLocation) {
  57. examLocation.setUpdateTime(new Date());
  58. examLocationService.update(examLocation);
  59. return succeed();
  60. }
  61. @ApiOperation("删除考点")
  62. @PostMapping(value = "/del")
  63. public HttpResponseResult add(Integer id) {
  64. return succeed(examLocationService.delete(id));
  65. }
  66. }