|
@@ -4,6 +4,7 @@ import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.TEACHER_TEMP
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -13,6 +14,8 @@ import javax.annotation.Resource;
|
|
|
|
|
|
import org.redisson.api.RMap;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
@@ -47,6 +50,7 @@ import com.yonge.cooleshow.biz.dal.enums.TeacherTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.StudentStarService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.SysMessageService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TeacherAuthEntryRecordService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TeacherAuthMusicianRecordService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
@@ -67,12 +71,16 @@ import com.yonge.cooleshow.common.enums.UserFirstTimeTypeEnum;
|
|
|
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
|
+import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
|
import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
|
|
|
import com.yonge.toolset.utils.string.ValueUtil;
|
|
|
|
|
|
@Service
|
|
|
public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> implements TeacherService {
|
|
|
+
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TeacherServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private TeacherStyleVideoService teacherStyleVideoService;
|
|
|
@Resource
|
|
@@ -103,6 +111,9 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
|
|
|
@Autowired
|
|
|
private StudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
|
|
|
@Override
|
|
|
public TeacherVo detail(Long userId) {
|
|
@@ -481,6 +492,59 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean updateStyleVideo(Long userId, List<TeacherStyleVideo> styleVideo, String message) {
|
|
|
+
|
|
|
+ Map<Long, TeacherStyleVideo> oldMap = teacherStyleVideoService.list(Wrappers.<TeacherStyleVideo>lambdaQuery()
|
|
|
+ .eq(TeacherStyleVideo::getUserId, userId))
|
|
|
+ .stream().collect(Collectors.toMap(TeacherStyleVideo::getId, o -> o));
|
|
|
+
|
|
|
+ List<TeacherStyleVideo> createList = styleVideo.stream().filter(o -> o.getId() == null)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ createList.forEach(o -> {
|
|
|
+ o.setUserId(userId);
|
|
|
+ });
|
|
|
+
|
|
|
+ List<Long> oldIds = styleVideo.stream().filter(o -> o.getId() != null)
|
|
|
+ .map(TeacherStyleVideo::getId).collect(Collectors.toList());
|
|
|
+ //删除旧视频
|
|
|
+ teacherStyleVideoService.removeByUserIdAndOldIds(userId, oldIds);
|
|
|
+ //保存新视频
|
|
|
+ teacherStyleVideoService.batchAddStyleVideo(createList);
|
|
|
+
|
|
|
+ styleVideo.removeAll(createList);
|
|
|
+
|
|
|
+ //修改视频封面
|
|
|
+ styleVideo.forEach(o -> {
|
|
|
+ TeacherStyleVideo old = oldMap.get(o.getId());
|
|
|
+ if (!o.getCover().equals(old.getCover())) {
|
|
|
+ teacherStyleVideoService.update(Wrappers.<TeacherStyleVideo>lambdaUpdate()
|
|
|
+ .set(TeacherStyleVideo::getCover, o.getCover())
|
|
|
+ .eq(TeacherStyleVideo::getId, o.getId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //发送推送
|
|
|
+ try {
|
|
|
+ // 发送消息
|
|
|
+ SysUser user = userFeignService.queryUserById(userId);
|
|
|
+
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ receivers.put(userId, user.getPhone());
|
|
|
+
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, "系统消息", message, receivers, null,
|
|
|
+ 0, null, ClientEnum.STUDENT.getCode());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("[老师风采修改]发送消息失败--> {}", e.fillInStackTrace());
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public HttpResponseResult<Boolean> addHomeBrowse(Long userId) {
|
|
|
Integer num = baseMapper.addHomeBrowse(userId);
|
|
|
return HttpResponseResult.succeed(num > 0);
|