SmartVisitorParentsConfigController.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package com.template.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
  4. import com.template.annotation.DESRespondSecret;
  5. import com.template.api.SmartVisitorParentsConfigControllerAPI;
  6. import com.template.mapper.SmartVisitorParentsConfigMapper;
  7. import com.template.model.pojo.SmartAskForLeaveConfig;
  8. import com.template.model.pojo.SmartDuties;
  9. import com.template.model.pojo.SmartUser;
  10. import com.template.model.pojo.SmartVisitorParentsConfig;
  11. import com.template.model.result.CommonResult;
  12. import com.template.model.result.PageUtils;
  13. import com.template.model.vo.SmartVisitorParentsConfigVo;
  14. import com.template.services.SmartDutiesService;
  15. import com.template.services.SmartUserService;
  16. import com.template.services.SmartVisitorParentsConfigService;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.beans.factory.annotation.Value;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.bind.annotation.RestController;
  22. /**
  23. * <p>
  24. * 前端控制器
  25. * </p>
  26. *
  27. * @author ceshi
  28. * @since 2024-05-29
  29. */
  30. @RestController
  31. @DESRespondSecret
  32. public class SmartVisitorParentsConfigController implements SmartVisitorParentsConfigControllerAPI {
  33. @Autowired
  34. SmartVisitorParentsConfigService smartVisitorParentsConfigService;
  35. @Autowired
  36. SmartUserService smartUserService;
  37. @Autowired
  38. SmartDutiesService smartDutiesService;
  39. @Override
  40. @DESRespondSecret(validated = true)
  41. public CommonResult getClassId(Integer page,Integer size, Integer classId) {
  42. PageUtils<SmartVisitorParentsConfigVo> smartVisitorParentsConfig=smartVisitorParentsConfigService.getClassIdPage(page,size,classId);
  43. return CommonResult.ok(smartVisitorParentsConfig);
  44. }
  45. @Override
  46. @DESRespondSecret(validated = true)
  47. public CommonResult update(SmartVisitorParentsConfig smartVisitorParentsConfig) {
  48. boolean update = smartVisitorParentsConfigService.updateById(smartVisitorParentsConfig);
  49. if (update) {
  50. return CommonResult.ok();
  51. }
  52. return CommonResult.fail();
  53. }
  54. @Override
  55. @DESRespondSecret(validated = true)
  56. public CommonResult getUserId(Integer userId) {
  57. SmartUser smartById = smartUserService.getSmartById(userId);
  58. if (ObjectUtils.isEmpty(smartById)) {
  59. return CommonResult.fail("不存在该用户");
  60. }
  61. // 职务
  62. Integer duties = smartById.getDuties();
  63. SmartDuties smartDuties = smartDutiesService.getSmartById(duties);
  64. if (ObjectUtils.isEmpty(smartDuties)) {
  65. return CommonResult.fail("无职务");
  66. }
  67. String name = smartDuties.getName();
  68. if (!"班主任".equals(name)) {
  69. return CommonResult.fail("无配置权限");
  70. }
  71. Integer schoolClass = smartById.getSchoolClass();
  72. SmartVisitorParentsConfigVo smartVisitorParentsConfigVo=smartVisitorParentsConfigService.getClassId(schoolClass);
  73. return CommonResult.ok(smartVisitorParentsConfigVo);
  74. }
  75. }