package com.xjrsoft.module.student.controller; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xjrsoft.common.annotation.XjrLog; import com.xjrsoft.common.enums.ArchivesStatusEnum; import com.xjrsoft.common.model.result.RT; import com.xjrsoft.common.page.ConventPage; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.module.base.entity.WhitelistManagement; import com.xjrsoft.module.base.service.IWhitelistManagementService; import com.xjrsoft.module.student.dto.BaseStudentInfoDetailDto; import com.xjrsoft.module.student.dto.BaseStudentInfoPageDto; import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto; import com.xjrsoft.module.student.dto.UpdateBaseStudentInfoDto; import com.xjrsoft.module.student.entity.BaseStudentUser; import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService; import com.xjrsoft.module.student.service.IStudentManagerService; import com.xjrsoft.module.student.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; /** * @title: 学生职务设置 * @Author dzx * @Date: 2023-11-13 * @Version 1.0 */ @RestController @RequestMapping("/student" + "/basestudentinfo") @Api(value = "/student" + "/basestudentinfo", tags = "学生信息修改管理") @AllArgsConstructor public class BaseStudentInfoController { private final IStudentManagerService studentManagerService; private final IBaseStudentSchoolRollService baseStudentSchoolRollService; private final IWhitelistManagementService whitelistService; @GetMapping(value = "/mobile-page") @ApiOperation(value = "学生列表(分页)") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "学生列表(分页)") public RT> mobilePage(@Valid BaseStudentInfoPageDto dto) { Page mobilePage = baseStudentSchoolRollService.getMobilePage(new Page<>(dto.getLimit(), dto.getSize()), dto); for (BaseStudentInfoPageVo record : mobilePage.getRecords()) { BaseStudentUser user = studentManagerService.getById(record.getId()); record.setAvatar(user.getAvatar()); } PageOutput pageOutput = ConventPage.getPageOutput(mobilePage, BaseStudentInfoPageVo.class); return RT.ok(pageOutput); } @GetMapping(value = "/mobile-page-statistics") @ApiOperation(value = "学生列表人数统计") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "学生列表人数统计", saveResponseData = true) public RT mobilePageStatistics(@Valid BaseStudentInfoPageDto dto) { BaseStudentInfoPageDataVo result = baseStudentSchoolRollService.getMobilePageStatistics(dto); return RT.ok(result); } @GetMapping(value = "/mobile-class-statistics") @ApiOperation(value = "班级统计(移动端)") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "班级统计(移动端)", saveResponseData = true) public RT mobileClassStatistics(@Valid BaseStudentInfoPageDto dto) { MobileClassStatisticsVo result = baseStudentSchoolRollService.getMobileClassStatistics(dto); return RT.ok(result); } @PutMapping @ApiOperation(value = "修改学生信息") @SaCheckPermission("basestudentpost:edit") @XjrLog(value = "修改学生信息", saveResponseData = true) public RT update(@Valid @RequestBody UpdateBaseStudentInfoDto dto) { return RT.ok(baseStudentSchoolRollService.updateInfo(dto)); } @GetMapping(value = "/info") @ApiOperation(value = "根据id查询详情信息") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "根据id查询详情信息", saveResponseData = true) public RT info(@RequestParam Long id) { BaseStudentInfoDetailDto dto = new BaseStudentInfoDetailDto(); dto.setId(id); BaseStudentInfoDetailVo detailVo = baseStudentSchoolRollService.getInfoById(dto); BaseStudentUser baseStudentUser = studentManagerService.getByIdDeep(id); detailVo.setStudentId(baseStudentUser.getBaseStudentList().get(0).getStudentId()); if (detailVo == null) { return RT.error("找不到此数据!"); } return RT.ok(BeanUtil.toBean(detailVo, BaseStudentInfoDetailVo.class)); } @GetMapping(value = "/studentinfoByKeyWord") @ApiOperation(value = "根据姓名或者身份证号查询详情信息") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "根据姓名或者身份证号查询详情信息") public RT> info(@Valid BaseStudentSimpleInfoDto dto) { dto.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode()); List infos = baseStudentSchoolRollService.getInfosByParam(dto); return RT.ok(infos); } @GetMapping(value = "/studentinfoByKeyWordNotReading") @ApiOperation(value = "根据姓名或者身份证号查询不在读学生详情信息") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "根据姓名或者身份证号查询不在读学生详情信息") public RT> studentinfoByKeyWordNotReading(@Valid BaseStudentSimpleInfoDto dto) { dto.setFindNewStudent(0); dto.setIsNotReading(1); List infos = baseStudentSchoolRollService.getInfosByParam(dto); return RT.ok(infos); } @GetMapping(value = "/getWhitelistInfo") @ApiOperation(value = "根据userId查询白名单信息(不传默认查询登录者)") @SaCheckPermission("basestudentpost:detail") @XjrLog(value = "根据userId查询白名单信息(不传默认查询登录者)", saveResponseData = true) public RT getWhitelistInfo(Long userId) { if (userId == null) { userId = StpUtil.getLoginIdAsLong(); } WhitelistManagement one = whitelistService.getOne( new QueryWrapper().lambda() .eq(WhitelistManagement::getUserId, userId) ); WhitelistInfoVo whitelistInfoVo = new WhitelistInfoVo(); whitelistInfoVo.setWhitelistStatus(0); if (one != null) { whitelistInfoVo.setWhitelistStatus(1); if (one.getIsTemporary() == 1) { whitelistInfoVo.setEndTime(one.getEndTime()); } whitelistInfoVo.setIsTemporary(one.getIsTemporary()); } return RT.ok(whitelistInfoVo); } }