AdminDepartmentApiController.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package com.goafanti.admin.controller;
  2. import javax.annotation.Resource;
  3. import org.springframework.stereotype.Controller;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import com.goafanti.admin.service.DepartmentService;
  7. import com.goafanti.common.bo.Result;
  8. import com.goafanti.common.constant.ErrorConstants;
  9. import com.goafanti.common.controller.CertifyApiController;
  10. import com.goafanti.common.model.WorkingHours;
  11. import com.goafanti.common.utils.StringUtils;
  12. @Controller
  13. @RequestMapping(value = "/api/admin/department")
  14. public class AdminDepartmentApiController extends CertifyApiController {
  15. @Resource
  16. private DepartmentService departmentService;
  17. /**
  18. * 新增工作时间
  19. */
  20. @RequestMapping(value = "/workingHours/add", method = RequestMethod.POST)
  21. public Result add(WorkingHours in) {
  22. Result res = new Result();
  23. if (in.getType()==null||StringUtils.isBlank(in.getName())||
  24. StringUtils.isBlank(in.getStart())||StringUtils.isBlank(in.getRestStart())||
  25. StringUtils.isBlank(in.getEnd())||StringUtils.isBlank(in.getRestEnd())) {
  26. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  27. return res;
  28. }
  29. if (departmentService.checkWorkingHoursType(in.getType())) {
  30. res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "", "分类"));
  31. return res;
  32. }
  33. res.setData(departmentService.addWorkingHours(in));
  34. return res;
  35. }
  36. /**
  37. * 删除工作时间
  38. */
  39. @RequestMapping(value = "/workingHours/delete", method = RequestMethod.POST)
  40. public Result delete(Integer id) {
  41. Result res = new Result();
  42. if (id==null) {
  43. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  44. return res;
  45. }
  46. if (departmentService.checkDepWorkingHouresType(id)) {
  47. res.getError().add(buildError( "已分配无法删除!。", "已分配无法删除!"));
  48. return res;
  49. }
  50. res.setData(departmentService.deleteWorkingHours(id));
  51. return res;
  52. }
  53. /**
  54. * 工作时间列表
  55. */
  56. @RequestMapping(value = "/workingHours/list", method = RequestMethod.GET)
  57. public Result list() {
  58. Result res = new Result();
  59. res.setData(departmentService.selectWorkingHours());
  60. return res;
  61. }
  62. /**
  63. * 工作时间列表
  64. */
  65. @RequestMapping(value = "/workingHours/get", method = RequestMethod.GET)
  66. public Result get(String depId) {
  67. Result res = new Result();
  68. if (depId==null) {
  69. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  70. return res;
  71. }
  72. res.setData(departmentService.getWorkingHours(depId));
  73. return res;
  74. }
  75. /**
  76. * 工作时间列表
  77. */
  78. @RequestMapping(value = "/selectAllDep", method = RequestMethod.GET)
  79. public Result selectAllDep() {
  80. Result res = new Result();
  81. res.setData(departmentService.selectAllDep());
  82. return res;
  83. }
  84. }