Browse Source

默认头像

liujc 1 year ago
parent
commit
7429169823

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/UserMusicServiceImpl.java

@@ -57,6 +57,9 @@ public class UserMusicServiceImpl extends ServiceImpl<UserMusicMapper, UserMusic
     @Autowired
     private TeacherService teacherService;
 
+    @Autowired
+    private SysConfigService sysConfigService;
+
     /**
      * 查询详情
      * @param id 详情ID
@@ -252,6 +255,7 @@ public class UserMusicServiceImpl extends ServiceImpl<UserMusicMapper, UserMusic
             .map(UserMusicWrapper.UserMusic::getUserId).collect(Collectors.toList());
         Map<Integer, Student> studentMap = studentService.getMapByIds(studentIds.stream().map(Long::intValue).collect(Collectors.toList()));
 
+        SysConfig userAvatar = sysConfigService.findByParamName(SysConfigService.USER_DEFAULT_AVATAR);
         // 老师ID集合
         List<Long> teacherIds = records.stream().filter(o -> o.getClientType() == ClientEnum.TEACHER)
             .map(UserMusicWrapper.UserMusic::getUserId).collect(Collectors.toList());
@@ -277,6 +281,9 @@ public class UserMusicServiceImpl extends ServiceImpl<UserMusicMapper, UserMusic
                     record.setSubjectId(teacher.getSubjectId());
                 }
             }
+            if (StringUtil.isEmpty(record.getAvatar())) {
+                record.setAvatar(userAvatar.getParanValue());
+            }
         }
 
         // 声部ID集合

+ 8 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/UserMusicStarServiceImpl.java

@@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.entity.Student;
-import com.ym.mec.biz.dal.entity.Subject;
-import com.ym.mec.biz.dal.entity.Teacher;
-import com.ym.mec.biz.dal.entity.UserMusicStar;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.mapper.UserMusicMapper;
 import com.ym.mec.biz.dal.mapper.UserMusicStarMapper;
@@ -49,6 +46,9 @@ public class UserMusicStarServiceImpl extends ServiceImpl<UserMusicStarMapper, U
     private SysUserService sysUserService;
     @Autowired
     private TeacherService teacherService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
 	/**
      * 查询详情
      * @param id 详情ID
@@ -95,6 +95,7 @@ public class UserMusicStarServiceImpl extends ServiceImpl<UserMusicStarMapper, U
         studentIds = records.stream().filter(o ->o.getClientType() == ClientEnum.TEACHER)
             .map(UserMusicStarWrapper.UserMusicStar::getUserId).map(Long::intValue).collect(Collectors.toList());
 
+        SysConfig userAvatar = sysConfigService.findByParamName(SysConfigService.USER_DEFAULT_AVATAR);
         Map<Integer, Teacher> teacherMap = teacherService.getMapByIds(studentIds);
         for (UserMusicStarWrapper.UserMusicStar userMusicStar : userMusicStars) {
             if (userMusicStar.getClientType() == ClientEnum.STUDENT) {
@@ -114,6 +115,9 @@ public class UserMusicStarServiceImpl extends ServiceImpl<UserMusicStarMapper, U
                 userMusicStar.setUserName(sysUser.getUsername());
                 userMusicStar.setUserAvatar(sysUser.getAvatar());
             }
+            if (StringUtil.isEmpty(userMusicStar.getUserAvatar())) {
+                userMusicStar.setUserAvatar(userAvatar.getParanValue());
+            }
         }
 
         // 声部ID集合