hejianhao
2026-08-20 8e2c06d3cf82be192505a02af654cdde9d4723a5
tcm-training-admin-backend/src/main/java/com/tcm/training/admin/live/service/LiveCourseAppService.java
@@ -35,23 +35,27 @@
public class LiveCourseAppService {
    private static final int LIVE_ROOM_PASSWORD_TYPE = 1;
    private static final int PROJECT_INTRODUCTION_PASSWORD_TYPE = 2;
    private final LiveCourseMapper liveCourseMapper;
    private final ExpertMapper expertMapper;
    private final LiveSessionMapper liveSessionMapper;
    private final LiveSessionQuestionMapper liveSessionQuestionMapper;
    private final BCryptPasswordEncoder passwordEncoder;
    private final ProjectIntroductionPasswordService projectIntroductionPasswordService;
    public LiveCourseAppService(LiveCourseMapper liveCourseMapper,
                                ExpertMapper expertMapper,
                                LiveSessionMapper liveSessionMapper,
                                LiveSessionQuestionMapper liveSessionQuestionMapper,
                                BCryptPasswordEncoder passwordEncoder) {
                                BCryptPasswordEncoder passwordEncoder,
                                ProjectIntroductionPasswordService projectIntroductionPasswordService) {
        this.liveCourseMapper = liveCourseMapper;
        this.expertMapper = expertMapper;
        this.liveSessionMapper = liveSessionMapper;
        this.liveSessionQuestionMapper = liveSessionQuestionMapper;
        this.passwordEncoder = passwordEncoder;
        this.projectIntroductionPasswordService = projectIntroductionPasswordService;
    }
    public PageResponse<LiveCourseListItemVO> page(int page, int pageSize, String keyword, Long expertId, Integer status, Integer liveStatus) {
@@ -186,17 +190,22 @@
    }
    public boolean verifyPassword(LiveCoursePasswordVerifyRequest req) {
        if (req.getType() != LIVE_ROOM_PASSWORD_TYPE) {
        if (req.getType() == LIVE_ROOM_PASSWORD_TYPE) {
            // 直播间密码验证
            LiveCourse course = liveCourseMapper.selectOne(new LambdaQueryWrapper<LiveCourse>()
                    .isNotNull(LiveCourse::getPassword)
                    .orderByAsc(LiveCourse::getId)
                    .last("limit 1"));
            return course != null
                    && course.getPassword() != null
                    && !course.getPassword().isEmpty()
                    && passwordEncoder.matches(req.getPassword(), course.getPassword());
        } else if (req.getType() == PROJECT_INTRODUCTION_PASSWORD_TYPE) {
            // 项目介绍密码验证
            return projectIntroductionPasswordService.verifyPassword(req.getPassword());
        } else {
            throw new IllegalArgumentException("不支持的密码类型");
        }
        LiveCourse course = liveCourseMapper.selectOne(new LambdaQueryWrapper<LiveCourse>()
                .isNotNull(LiveCourse::getPassword)
                .orderByAsc(LiveCourse::getId)
                .last("limit 1"));
        return course != null
                && course.getPassword() != null
                && !course.getPassword().isEmpty()
                && passwordEncoder.matches(req.getPassword(), course.getPassword());
    }
    @Transactional