| | |
| | | package com.tcm.training.admin.live.service; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | |
| | | @Transactional |
| | | public void updatePassword(Long id, LiveCoursePasswordRequest req) { |
| | | String password = req.getPassword(); |
| | | if (StrUtil.isNotBlank(password)) { |
| | | if (password.length() != 6) { |
| | | throw new IllegalArgumentException("直播间密码必须是6个字符"); |
| | | } |
| | | } |
| | | LiveCourse course = liveCourseMapper.selectById(id); |
| | | if (course == null) { |
| | | throw new IllegalArgumentException("课程不存在"); |
| | | } |
| | | if (StrUtil.isNotBlank(password)) { |
| | | course.setPassword(passwordEncoder.encode(req.getPassword())); |
| | | } else { |
| | | course.setPassword(null); |
| | | } |
| | | liveCourseMapper.updateById(course); |
| | | } |
| | | |