SmartSemesterController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.template.controller;
  2. import com.template.annotation.DESRespondSecret;
  3. import com.template.api.SmartSemesterControllerAPI;
  4. import com.template.common.utils.paramUtils;
  5. import com.template.model.pojo.SmartSemester;
  6. import com.template.model.pojo.SmartIdentity;
  7. import com.template.model.pojo.SmartSemester;
  8. import com.template.model.result.CommonResult;
  9. import com.template.model.result.PageUtils;
  10. import com.template.model.vo.SemesterVo;
  11. import com.template.services.SmartIdentityService;
  12. import com.template.services.SmartSemesterService;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.validation.BindingResult;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import java.util.ArrayList;
  19. import java.util.List;
  20. import java.util.stream.Collectors;
  21. /**
  22. * <p>
  23. * 应用管理 前端控制器
  24. * </p>
  25. *
  26. * @author ceshi
  27. * @since 2024-03-07
  28. */
  29. @RestController
  30. //返回参数加密注解
  31. @DESRespondSecret
  32. public class SmartSemesterController implements SmartSemesterControllerAPI {
  33. @Autowired
  34. private SmartSemesterService smartSemesterService;
  35. /**
  36. * 新增楼栋
  37. *
  38. * @param smartApply 楼栋数据
  39. * @param bindingResult
  40. * @return
  41. */
  42. @Override
  43. @DESRespondSecret(validated = true)
  44. public CommonResult insertSmartSemester(SmartSemester smartApply, BindingResult bindingResult) {
  45. if (bindingResult.hasErrors()) {
  46. String st = paramUtils.getParamError(bindingResult);
  47. return CommonResult.fail(st);
  48. }
  49. int result = smartSemesterService.insertSmartSemester(smartApply);
  50. return result > 0 ? CommonResult.ok("添加成功") : CommonResult.fail("添加失败");
  51. }
  52. /**
  53. * 更新楼栋
  54. *
  55. * @param sa 楼栋数据
  56. * @param bindingResult
  57. * @return
  58. */
  59. @Override
  60. @DESRespondSecret(validated = true)
  61. public CommonResult updateSmartSemesterById(SmartSemester sa, BindingResult bindingResult) {
  62. if (bindingResult.hasErrors()) {
  63. String st = paramUtils.getParamError(bindingResult);
  64. return CommonResult.fail(st);
  65. }
  66. int result = smartSemesterService.updateSmartSemester(sa);
  67. return result > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
  68. }
  69. /**
  70. * 楼栋分页数据查询
  71. *
  72. * @param currentPage 当前页数
  73. * @param pageCount 一页数据条数
  74. * @param name 查询名称
  75. * @return
  76. */
  77. @Override
  78. @DESRespondSecret(validated = true)
  79. public CommonResult queryPageSmartSemesters(int currentPage, int pageCount, String name) {
  80. PageUtils<SmartSemester> result = smartSemesterService.queryPageSmartSemesters(currentPage, pageCount, name);
  81. return CommonResult.ok(result);
  82. }
  83. @Override
  84. @DESRespondSecret(validated = true)
  85. public CommonResult deleteSmartSemesterById(int id) {
  86. SmartSemester data = smartSemesterService.getSmartById(id);
  87. if (data == null) {
  88. return CommonResult.fail("当前数据不存在,删除失败!");
  89. }
  90. int result = smartSemesterService.deleteSmartSemesterById(id);
  91. return result > 0 ? CommonResult.ok("删除成功") : CommonResult.fail("删除失败");
  92. }
  93. }