StudentReportPlanControllerTest.java 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.stp.StpUtil;
  3. import cn.hutool.core.bean.BeanUtil;
  4. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  5. import com.xjrsoft.common.model.result.RT;
  6. import com.xjrsoft.common.utils.LocalDateTimeUtil;
  7. import com.xjrsoft.common.utils.VoToColumnUtil;
  8. import com.xjrsoft.module.banding.entity.BandingTask;
  9. import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
  10. import com.xjrsoft.module.student.dto.UpdateStudentReportPlanDto;
  11. import com.xjrsoft.module.student.entity.EnrollmentPlan;
  12. import com.xjrsoft.module.student.entity.StudentReportPlan;
  13. import com.xjrsoft.module.student.service.IEnrollmentPlanService;
  14. import com.xjrsoft.module.student.service.IStudentReportPlanService;
  15. import com.xjrsoft.module.student.vo.StudentReportPlanVo;
  16. import org.junit.jupiter.api.AfterEach;
  17. import org.junit.jupiter.api.BeforeEach;
  18. import org.junit.jupiter.api.Test;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.boot.test.context.SpringBootTest;
  21. import java.time.LocalDateTime;
  22. import java.util.Date;
  23. import static org.junit.jupiter.api.Assertions.*;
  24. @SpringBootTest
  25. class StudentReportPlanControllerTest {
  26. @BeforeEach
  27. void setUp() {
  28. // 模拟用户登录
  29. StpUtil.login(1000000000000000000L); // 假设用户ID为1
  30. }
  31. @AfterEach
  32. void tearDown() {
  33. // 清理会话
  34. StpUtil.logout();
  35. }
  36. @Autowired
  37. private IEnrollmentPlanService enrollmentPlanService;
  38. @Autowired
  39. private IStudentReportPlanService studentReportPlanService;
  40. @Autowired
  41. private IBandingTaskClassStudentService taskClassStudentService;
  42. @Test
  43. void newStudentPlan() {
  44. EnrollmentPlan enrollmentPlan = enrollmentPlanService.getById(1897950348853186562L);
  45. StudentReportPlan plan = studentReportPlanService.getOne(
  46. new MPJLambdaWrapper<StudentReportPlan>()
  47. .select(StudentReportPlan::getId)
  48. .select(StudentReportPlan.class, x -> VoToColumnUtil.fieldsToColumns(StudentReportPlan.class).contains(x.getProperty()))
  49. .innerJoin(BandingTask.class, BandingTask::getId, StudentReportPlan::getBandingTaskId)
  50. .eq(BandingTask::getEnrollType, enrollmentPlan.getEnrollType())
  51. .eq(BandingTask::getGradeId, enrollmentPlan.getGradeId())
  52. .eq(StudentReportPlan::getCategory, 3)
  53. );
  54. System.out.println("kdjfiajf");
  55. }
  56. @Test
  57. void update() {
  58. UpdateStudentReportPlanDto dto = new UpdateStudentReportPlanDto();
  59. dto.setId(1917442536876085249L);
  60. dto.setSemesterId(1868532124600545280L);
  61. dto.setName("2025级null新生报到");
  62. StudentReportPlan reportPlan = studentReportPlanService.getById(dto.getId());
  63. BeanUtil.copyProperties(dto, reportPlan);
  64. if((reportPlan.getCategory() == 2 || reportPlan.getCategory() == 3) && LocalDateTimeUtil.isDateTimeInRange(LocalDateTime.now(), reportPlan.getStartTime(), reportPlan.getEndTime())){
  65. reportPlan.setStatus(1);
  66. }
  67. if(reportPlan.getCategory() == 3){
  68. taskClassStudentService.syncStudentData(reportPlan);
  69. }
  70. System.out.println("kdjfiajf");
  71. }
  72. }