| | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | public boolean verifyPassword(LiveCoursePasswordVerifyRequest req) { |
| | | if (req.getType() != LIVE_ROOM_PASSWORD_TYPE) { |
| | | throw new IllegalArgumentException("不支持的密码类型"); |
| | | } |
| | | if (req.getType() == LIVE_ROOM_PASSWORD_TYPE) { |
| | | // 直播间密码验证 |
| | | LiveCourse course = liveCourseMapper.selectOne(new LambdaQueryWrapper<LiveCourse>() |
| | | .isNotNull(LiveCourse::getPassword) |
| | | .orderByAsc(LiveCourse::getId) |
| | |
| | | && 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("不支持的密码类型"); |
| | | } |
| | | } |
| | | |
| | | @Transactional |