package com.xjrsoft.module.student.controller; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.bean.BeanUtil; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.xjrsoft.common.model.result.RT; import com.xjrsoft.common.utils.LocalDateTimeUtil; import com.xjrsoft.common.utils.VoToColumnUtil; import com.xjrsoft.module.banding.entity.BandingTask; import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService; import com.xjrsoft.module.student.dto.UpdateStudentReportPlanDto; import com.xjrsoft.module.student.entity.EnrollmentPlan; import com.xjrsoft.module.student.entity.StudentReportPlan; import com.xjrsoft.module.student.service.IEnrollmentPlanService; import com.xjrsoft.module.student.service.IStudentReportPlanService; import com.xjrsoft.module.student.vo.StudentReportPlanVo; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.time.LocalDateTime; import java.util.Date; import static org.junit.jupiter.api.Assertions.*; @SpringBootTest class StudentReportPlanControllerTest { @BeforeEach void setUp() { // 模拟用户登录 StpUtil.login(1000000000000000000L); // 假设用户ID为1 } @AfterEach void tearDown() { // 清理会话 StpUtil.logout(); } @Autowired private IEnrollmentPlanService enrollmentPlanService; @Autowired private IStudentReportPlanService studentReportPlanService; @Autowired private IBandingTaskClassStudentService taskClassStudentService; @Test void newStudentPlan() { EnrollmentPlan enrollmentPlan = enrollmentPlanService.getById(1897950348853186562L); StudentReportPlan plan = studentReportPlanService.getOne( new MPJLambdaWrapper() .select(StudentReportPlan::getId) .select(StudentReportPlan.class, x -> VoToColumnUtil.fieldsToColumns(StudentReportPlan.class).contains(x.getProperty())) .innerJoin(BandingTask.class, BandingTask::getId, StudentReportPlan::getBandingTaskId) .eq(BandingTask::getEnrollType, enrollmentPlan.getEnrollType()) .eq(BandingTask::getGradeId, enrollmentPlan.getGradeId()) .eq(StudentReportPlan::getCategory, 3) ); System.out.println("kdjfiajf"); } @Test void update() { UpdateStudentReportPlanDto dto = new UpdateStudentReportPlanDto(); dto.setId(1917442536876085249L); dto.setSemesterId(1868532124600545280L); dto.setName("2025级null新生报到"); StudentReportPlan reportPlan = studentReportPlanService.getById(dto.getId()); BeanUtil.copyProperties(dto, reportPlan); if((reportPlan.getCategory() == 2 || reportPlan.getCategory() == 3) && LocalDateTimeUtil.isDateTimeInRange(LocalDateTime.now(), reportPlan.getStartTime(), reportPlan.getEndTime())){ reportPlan.setStatus(1); } if(reportPlan.getCategory() == 3){ taskClassStudentService.syncStudentData(reportPlan); } System.out.println("kdjfiajf"); } }