package com.template.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.template.annotation.DESRespondSecret; import com.template.api.SmartVisitorParentsConfigControllerAPI; import com.template.mapper.SmartVisitorParentsConfigMapper; import com.template.model.pojo.SmartAskForLeaveConfig; import com.template.model.pojo.SmartDuties; import com.template.model.pojo.SmartUser; import com.template.model.pojo.SmartVisitorParentsConfig; import com.template.model.result.CommonResult; import com.template.model.result.PageUtils; import com.template.model.vo.SmartVisitorParentsConfigVo; import com.template.services.SmartDutiesService; import com.template.services.SmartUserService; import com.template.services.SmartVisitorParentsConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** *

* 前端控制器 *

* * @author ceshi * @since 2024-05-29 */ @RestController @DESRespondSecret public class SmartVisitorParentsConfigController implements SmartVisitorParentsConfigControllerAPI { @Autowired SmartVisitorParentsConfigService smartVisitorParentsConfigService; @Autowired SmartUserService smartUserService; @Autowired SmartDutiesService smartDutiesService; @Override @DESRespondSecret(validated = true) public CommonResult getClassId(Integer page,Integer size, Integer classId) { PageUtils smartVisitorParentsConfig=smartVisitorParentsConfigService.getClassIdPage(page,size,classId); return CommonResult.ok(smartVisitorParentsConfig); } @Override @DESRespondSecret(validated = true) public CommonResult update(SmartVisitorParentsConfig smartVisitorParentsConfig) { boolean update = smartVisitorParentsConfigService.updateById(smartVisitorParentsConfig); if (update) { return CommonResult.ok(); } return CommonResult.fail(); } @Override @DESRespondSecret(validated = true) public CommonResult getUserId(Integer userId) { SmartUser smartById = smartUserService.getSmartById(userId); if (ObjectUtils.isEmpty(smartById)) { return CommonResult.fail("不存在该用户"); } // 职务 Integer duties = smartById.getDuties(); SmartDuties smartDuties = smartDutiesService.getSmartById(duties); if (ObjectUtils.isEmpty(smartDuties)) { return CommonResult.fail("无职务"); } String name = smartDuties.getName(); if (!"班主任".equals(name)) { return CommonResult.fail("无配置权限"); } Integer schoolClass = smartById.getSchoolClass(); SmartVisitorParentsConfigVo smartVisitorParentsConfigVo=smartVisitorParentsConfigService.getClassId(schoolClass); return CommonResult.ok(smartVisitorParentsConfigVo); } }