瀏覽代碼

Merge branch 'online_dev_20230606'

liujc 1 年之前
父節點
當前提交
6d7d775b8c

+ 1 - 0
.gitignore

@@ -62,3 +62,4 @@ target
 **/logback-spring.xml
 **/AuditLogInterceptor.java
 /toolset/audit-log/src/main/java/com/yonge/toolset/log/interceptor/AuditLogInterceptor.java
+/log/

+ 61 - 41
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -2,12 +2,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 
 import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.TEACHER_TEMP_LIVE_ROOM;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -85,9 +80,9 @@ 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);
-	
+
+    private final static Logger log = LoggerFactory.getLogger(TeacherServiceImpl.class);
+
     @Autowired
     private TeacherStyleVideoService teacherStyleVideoService;
     @Resource
@@ -147,6 +142,31 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     @Override
     public IPage<TeacherVo> selectPage(IPage<TeacherVo> page, TeacherSearch search) {
         List<TeacherVo> teacherVos = baseMapper.selectPage(page, search);
+
+        if (CollectionUtils.isEmpty(teacherVos)) {
+            return page.setRecords(teacherVos);
+        }
+        //设置声部
+        List<Long> subjectIds = teacherVos.stream().filter(o -> o.getSubjectId() != null).flatMap(o -> Arrays.stream(o.getSubjectId().split(","))).map(Long::parseLong).collect(Collectors.toList());
+        List<Subject> subjects = subjectService.findBySubjectByIdList(subjectIds);
+
+        Map<Long, String> subjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, Subject::getName));
+
+        for (TeacherVo teacherVo : teacherVos) {
+            if (null == teacherVo.getSubjectId()) {
+                continue;
+            }
+
+            String subjectNames = Arrays.stream(teacherVo.getSubjectId().split(",")).map(Long::parseLong).map(o -> {
+                String subjectName = subjectMap.get(o);
+                if (!StringUtil.isEmpty(subjectName)) {
+                    return subjectName;
+                }
+                return null;
+            }).filter(Objects::nonNull).collect(Collectors.joining(","));
+            teacherVo.setSubjectName(subjectNames);
+        }
+
         return page.setRecords(teacherVos);
     }
 
@@ -520,11 +540,11 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-	public boolean updateStyleVideo(Long userId, List<TeacherStyleVideo> styleVideo, String message) {
-    	
-    	if(styleVideo == null){
-    		styleVideo = new ArrayList<TeacherStyleVideo>();
-    	}
+    public boolean updateStyleVideo(Long userId, List<TeacherStyleVideo> styleVideo, String message) {
+
+        if(styleVideo == null){
+            styleVideo = new ArrayList<TeacherStyleVideo>();
+        }
         //修改老师信息
         
         List<TeacherStyleVideo> teacherStyleVideoList = teacherStyleVideoService.list(Wrappers.<TeacherStyleVideo>lambdaQuery()
@@ -545,9 +565,9 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
                 .map(TeacherStyleVideo::getId).collect(Collectors.toList());
         
         for(TeacherStyleVideo tv : teacherStyleVideoList){
-        	if(tv.getAuthStatus() == AuthStatusEnum.DOING){
-        		oldIds.add(tv.getId());
-        	}
+            if(tv.getAuthStatus() == AuthStatusEnum.DOING){
+                oldIds.add(tv.getId());
+            }
         }
         //删除旧视频
         teacherStyleVideoService.removeByUserIdAndOldIds(userId, oldIds);
@@ -575,17 +595,17 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
             Map<Long, String> receivers = new HashMap<>();
             receivers.put(userId, user.getPhone());
 
-			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.CUSTOME_MESSAGE_PUSH, receivers, null, 0,
-					null, ClientEnum.TEACHER.getCode(), message);
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.CUSTOME_MESSAGE_PUSH, receivers, null, 0,
+                    null, ClientEnum.TEACHER.getCode(), message);
 
         } catch (Exception e) {
             log.error("[老师风采修改]发送消息失败--> {}", e.fillInStackTrace());
         }
 
-		return true;
-	}
+        return true;
+    }
 
-	@Override
+    @Override
     public HttpResponseResult<Boolean> addHomeBrowse(Long userId) {
         Integer num = baseMapper.addHomeBrowse(userId);
         return HttpResponseResult.succeed(num > 0);
@@ -667,29 +687,29 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     }
 
     @Override
-	public List<HotTeacherVo> queryHotTeacherList(Long userId) {
-    	List<Long> watchTeacherIdList = new ArrayList<Long>();
-    	
-    	List<StudentStar> studentStarList = studentStarDao.queryByStudentId(userId);
-    	if(studentStarList != null && studentStarList.size() > 0){
-    		watchTeacherIdList = studentStarList.stream().map(StudentStar :: getTeacherId).collect(Collectors.toList());
-    	}
-    	
-    	Student student = studentService.getById(userId);
+    public List<HotTeacherVo> queryHotTeacherList(Long userId) {
+        List<Long> watchTeacherIdList = new ArrayList<Long>();
+
+        List<StudentStar> studentStarList = studentStarDao.queryByStudentId(userId);
+        if(studentStarList != null && studentStarList.size() > 0){
+            watchTeacherIdList = studentStarList.stream().map(StudentStar :: getTeacherId).collect(Collectors.toList());
+        }
+
+        Student student = studentService.getById(userId);
         Long subjectId = null;
         if (student.getSubjectId()!= null) {
             subjectId = Long.parseLong(student.getSubjectId());
         }
-    	
-    	List<HotTeacherVo> hotTeacherList = baseMapper.queryHotTeacherList(subjectId);
-    	for(HotTeacherVo vo : hotTeacherList){
-    		if(watchTeacherIdList.contains(vo.getUserId())){
-    			vo.setWatch(true);
-    		}
-    	}
-    	
-		return hotTeacherList;
-	}
+
+        List<HotTeacherVo> hotTeacherList = baseMapper.queryHotTeacherList(subjectId);
+        for(HotTeacherVo vo : hotTeacherList){
+            if(watchTeacherIdList.contains(vo.getUserId())){
+                vo.setWatch(true);
+            }
+        }
+
+        return hotTeacherList;
+    }
 
     private void setTagTime(TeacherTagEnum teacherTagEnum, TeacherVo teacherVo) {
         if (teacherTagEnum.equals(TeacherTagEnum.LIVE)) {