package com.xjrsoft.module.textbook.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.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.xjrsoft.common.model.result.RT; import com.xjrsoft.common.page.ConventPage; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.common.utils.VoToColumnUtil; import com.xjrsoft.module.textbook.dto.*; import com.xjrsoft.module.textbook.entity.TextbookStudentClaim; import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService; import com.xjrsoft.module.textbook.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import java.util.Date; import java.util.List; /** * @title: 学生教材认领记录 * @Author szs * @Date: 2023-12-26 * @Version 1.0 */ @RestController @RequestMapping("/textbook" + "/textbookStudentClaim") @Api(value = "/textbook" + "/textbookStudentClaim",tags = "学生教材认领记录代码") @AllArgsConstructor public class TextbookStudentClaimController { private final ITextbookStudentClaimService textbookStudentClaimService; @GetMapping(value = "/head-tea-look-class-book-semester") @ApiOperation(value="班主任查看班级教材学期页面") @SaCheckPermission("textbookstudentclaim:detail") public RT> headTeaLookClassBookSemester(){ return RT.ok(textbookStudentClaimService.headTeaLookClassBookSemester()); } @GetMapping(value = "/head-tea-look-class-book") @ApiOperation(value="班主任查看班级教材页面") @SaCheckPermission("textbookstudentclaim:detail") public RT headTeaLookClassBook(@Valid HeadTeaLookClassBookDto dto){ return RT.ok(textbookStudentClaimService.headTeaLookClassBook(dto)); } @GetMapping(value = "/page") @ApiOperation(value="学生教材认领记录列表(分页)") @SaCheckPermission("textbookstudentclaim:detail") public RT> page(@Valid TextbookStudentClaimPageDto dto){ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper .orderByDesc(TextbookStudentClaim::getId) .select(TextbookStudentClaim.class,x -> VoToColumnUtil.fieldsToColumns(TextbookStudentClaimPageVo.class).contains(x.getProperty())) .eq(dto.getStudentUserId() != null, TextbookStudentClaim::getStudentUserId, dto.getStudentUserId()) .eq(TextbookStudentClaim::getIsClaim, 1) ; IPage page = textbookStudentClaimService.page(ConventPage.getPage(dto), queryWrapper); PageOutput pageOutput = ConventPage.getPageOutput(page, TextbookStudentClaimPageVo.class); return RT.ok(pageOutput); } @GetMapping(value = "/student-confirm-list") @ApiOperation(value="学生教材领取确定页面") @SaCheckPermission("textbookstudentclaim:detail") public RT studentConfirmList(@Valid TextbookClaimStudentConfirmDto dto){ TextbookClaimStudentConfirmVo textbookClaimStudentConfirmVo = textbookStudentClaimService.getStudentConfirmList(dto); return RT.ok(textbookClaimStudentConfirmVo); } @GetMapping(value = "/student-semester-list") @ApiOperation(value="学生教材领取学期页面") @SaCheckPermission("textbookstudentclaim:detail") public RT> studentSemesterList(){ List textbookStudentSemesterVoList = textbookStudentClaimService.getStudentSemesterList(); return RT.ok(textbookStudentSemesterVoList); } @GetMapping(value = "/teacher-check-byClass-list") @ApiOperation(value="教师教材领取按班级查看页面") @SaCheckPermission("textbookstudentclaim:detail") public RT> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){ IPage page = textbookStudentClaimService.getTeacherCheckByclassList(dto); PageOutput pageOutput = ConventPage.getPageOutput(page, TeacherCheckByclassVo.class); return RT.ok(pageOutput); } // @GetMapping(value = "/teacher-check-byClass-list") // @ApiOperation(value="班主任为学生教材领取按班级查看页面") // @SaCheckPermission("textbookstudentclaim:detail") // public RT> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){ // IPage page = textbookStudentClaimService.getTeacherCheckByclassList(dto); // PageOutput pageOutput = ConventPage.getPageOutput(page, TeacherCheckByclassVo.class); // return RT.ok(pageOutput); // } @GetMapping(value = "/teacher-check-byStu-list") @ApiOperation(value="教师教材领取按学生查看页面") @SaCheckPermission("textbookstudentclaim:detail") public RT> teacherCheckByStuList(@Valid TeacherCheckByStuDto dto){ IPage page = textbookStudentClaimService.getTeacherCheckByStuList(dto); PageOutput pageOutput = ConventPage.getPageOutput(page, TeacherCheckByStuVo.class); return RT.ok(pageOutput); } @GetMapping(value = "/teacher-check-stu-claim-list") @ApiOperation(value="教师查看一本教材的学生领取情况页面") @SaCheckPermission("textbookstudentclaim:detail") public RT> teacherCheckStuClaimList(@Valid TeacherCheckStuClaimDto dto){ List teacherCheckStuClaimList = textbookStudentClaimService.getTeacherCheckStuClaimList(dto); return RT.ok(teacherCheckStuClaimList); } @GetMapping(value = "/teacher-get-stu-noClaim-list") @ApiOperation(value="班主任获取班上某个学生没有认领的教材记录") @SaCheckPermission("textbookstudentclaim:detail") public RT> teacherGetStuNoClaimList(@RequestParam Long studentUserId){ List textbookClaimVOList = textbookStudentClaimService.getTeacherGetStuNoClaimList(studentUserId); return RT.ok(textbookClaimVOList); } @GetMapping(value = "/info") @ApiOperation(value="根据id查询学生教材认领记录信息") @SaCheckPermission("textbookstudentclaim:detail") public RT info(@RequestParam Long id){ TextbookStudentClaim textbookStudentClaim = textbookStudentClaimService.getById(id); if (textbookStudentClaim == null) { return RT.error("找不到此数据!"); } return RT.ok(BeanUtil.toBean(textbookStudentClaim, TextbookStudentClaimVo.class)); } @PostMapping @ApiOperation(value = "新增学生教材认领记录") @SaCheckPermission("textbookstudentclaim:add") public RT add(@Valid @RequestBody AddTextbookStudentClaimDto dto){ TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class); boolean isSuccess = textbookStudentClaimService.save(textbookStudentClaim); return RT.ok(isSuccess); } @PutMapping @ApiOperation(value = "修改学生教材认领记录") @SaCheckPermission("textbookstudentclaim:edit") public RT update(@Valid @RequestBody UpdateTextbookStudentClaimDto dto){ TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class); return RT.ok(textbookStudentClaimService.updateById(textbookStudentClaim)); } @PutMapping("/confirm") @ApiOperation(value = "学生自己确认已经领取") @SaCheckPermission("textbookstudentclaim:edit") public RT confirm(@Valid @RequestBody List textbookStudentClaimIds){ return RT.ok(textbookStudentClaimService.updateByIds(textbookStudentClaimIds)); } @PutMapping("/teacher-confirm") @ApiOperation(value = "教师帮助学生确认已经领取") @SaCheckPermission("textbookstudentclaim:edit") public RT teacherConfirm(@Valid @RequestBody List teacherConfirmDtoList){ for (TeacherConfirmDto dto : teacherConfirmDtoList) { TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class); textbookStudentClaim.setId(dto.getTextbookStudentClaimId()); textbookStudentClaim.setIsClaim(1); textbookStudentClaim.setRemark(dto.getRemark()); textbookStudentClaim.setModifyUserId(StpUtil.getLoginIdAsLong()); textbookStudentClaim.setModifyDate(new Date()); textbookStudentClaimService.updateById(textbookStudentClaim); } return RT.ok(true); } @DeleteMapping @ApiOperation(value = "删除学生教材认领记录") @SaCheckPermission("textbookstudentclaim:delete") public RT delete(@Valid @RequestBody List ids){ return RT.ok(textbookStudentClaimService.removeBatchByIds(ids)); } }