ソースを参照

Merge branch 'feature/0721-tenant' into develop

haonan 1 年間 前
コミット
537f32a2c5

+ 37 - 27
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -543,16 +543,23 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void addStudent(StudentWrapper.Student student) {
+        // 更新头像
+        if (StringUtils.isEmpty(student.getAvatar())) {
+            String avatar;
+            if (student.getGender().equals(1)) {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_BOY);
+            } else {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_GIRL);
+            }
+            student.setAvatar(avatar);
+        }
         SysUser sysUser = employeeDao.querySysUserByPhone(student.getPhone());
         if (sysUser == null) {
             sysUser = new SysUser();
             sysUser.setUserType(ClientEnum.STUDENT.getCode());
             sysUser.setGender(student.getGender());
             //设置默认头像
-            if (StringUtil.isEmpty(sysUser.getAvatar())) {
-                String defaultHeard = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD);
-                sysUser.setAvatar(defaultHeard);
-            }
+            sysUser.setAvatar(student.getAvatar());
 
             sysUser.setUsername(student.getName());
             sysUser.setPhone(student.getPhone());
@@ -573,20 +580,6 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 
         student.setId(sysUser.getId());
         Long tenantId = student.getTenantId();
-        // 更新头像
-        if (StringUtils.isEmpty(student.getAvatar())) {
-            String avatar;
-            if (tenantId != -1L) {
-                if (student.getGender().equals(1)) {
-                    avatar = sysConfigService.findConfigValue(SysConfigConstant.TENANT_STUDENT_BOY_AVATAR);
-                } else {
-                    avatar = sysConfigService.findConfigValue(SysConfigConstant.TENANT_STUDENT_GIRL_AVATAR);
-                }
-            } else {
-                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD);
-            }
-            student.setAvatar(avatar);
-        }
         this.save(student);
 
         // 加好友
@@ -607,10 +600,14 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         if (student == null) {
             throw new BizException("学生信息不存在");
         }
-        String avatar = student.getAvatar();
+        String avatar = studentInfo.getAvatar();
         if (StringUtils.isEmpty(avatar)) {
-            avatar = sysConfigService.findConfigValue(SysConfigConstant.TENANT_STUDENT_AVATAR);
-            student.setAvatar(avatar);
+            if (studentInfo.getGender().equals(1)) {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_BOY);
+            } else {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_GIRL);
+            }
+            studentInfo.setAvatar(avatar);
         }
         // 解绑
 //        if (Boolean.FALSE.equals(studentInfo.getBindTenant())) {
@@ -639,23 +636,29 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         }
         com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = sysUserMapper.selectById(studentInfo.getId());
         sysUser.setGender(studentInfo.getGender());
+        sysUser.setAvatar(student.getAvatar());
         sysUserMapper.updateById(sysUser);
         return true;
     }
 
     private Boolean createStudent(StudentWrapper.Student studentInfo) {
+        String avatar = studentInfo.getAvatar();
+        if (StringUtils.isEmpty(avatar)) {
+            if (studentInfo.getGender().equals(1)) {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_BOY);
+            } else {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_GIRL);
+            }
+            studentInfo.setAvatar(avatar);
+        }
         com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo);
         Student student = new Student();
         student.setUserId(sysUser.getId());
         student.setTenantId(studentInfo.getTenantId());
         student.setSubjectId(studentInfo.getSubjectId());
+        student.setAvatar(studentInfo.getAvatar());
         student.setCreateTime(new Date());
         student.setLockFlag(UserLockFlag.NORMAL);
-        String avatar = studentInfo.getAvatar();
-        if (StringUtils.isEmpty(avatar)) {
-            avatar = sysConfigService.findConfigValue(SysConfigConstant.TENANT_STUDENT_AVATAR);
-            student.setAvatar(avatar);
-        }
 
         save(student);
         return true;
@@ -688,7 +691,14 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
                     com.yonge.cooleshow.biz.dal.entity.SysUser.class);
             sysUser.setPhone(studentInfo.getPhone());
             if (StringUtils.isEmpty(studentInfo.getAvatar())) {
-                sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
+                //设置默认头像
+                String avatar;
+                if (studentInfo.getGender().equals(1)) {
+                    avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_BOY);
+                } else {
+                    avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_GIRL);
+                }
+                sysUser.setAvatar(avatar);
             } else {
                 sysUser.setAvatar(studentInfo.getAvatar());
             }

+ 23 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java

@@ -11,7 +11,9 @@ import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
+import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumPurchaseMapper;
+import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumRefMapper;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
@@ -76,6 +78,13 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     @Autowired
     private UserTenantAlbumRecordService userTenantAlbumRecordService;
 
+
+    @Autowired
+    private TenantAlbumRefMapper tenantAlbumRefMapper;
+
+    @Autowired
+    private TenantAlbumMapper tenantAlbumMapper;
+
 	/**
      * 查询详情
      * @param id 详情ID
@@ -274,11 +283,18 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         TenantInfo tenantInfo = tenantInfoService.detail(detail.getTenantId());
         if (tenantInfo != null) {
             album.setTenantName(tenantInfo.getName());
-            QueryWrapper<TenantAlbumPurchase> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().eq(TenantAlbumPurchase::getTenantId, detail.getTenantId());
-            Integer count = tenantAlbumPurchaseMapper.selectCount(queryWrapper);
-            if (count > 0) {
-                album.setTenantAlbumStatus(1);
+            QueryWrapper<TenantAlbumRef> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(TenantAlbumRef::getTenantId, detail.getTenantId());
+            List<TenantAlbumRef> albumRefs = tenantAlbumRefMapper.selectList(queryWrapper);
+            if (!albumRefs.isEmpty()) {
+                List<Long> albIds = albumRefs.stream().map(TenantAlbumRef::getTenantAlbumId).distinct().collect(Collectors.toList());
+                QueryWrapper<TenantAlbum> query = new QueryWrapper<>();
+                query.lambda().in(TenantAlbum::getId, albIds)
+                        .eq(TenantAlbum::getStatus,true);
+                Integer count = tenantAlbumMapper.selectCount(query);
+                if (count > 0) {
+                    album.setTenantAlbumStatus(1);
+                }
             }
             UserTenantAlbumRecord record =
                     userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(),
@@ -291,10 +307,11 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
                 album.setTenantAlbumStartTime(record.getStartTime());
                 album.setTenantAlbumEndTime(record.getEndTime());
             }
-
         }
 
 
+
+
         //查询是否已经购买专辑
         Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId,sysUser.getId());
 

+ 6 - 5
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenStudentController.java

@@ -148,14 +148,15 @@ public class OpenStudentController extends BaseController {
         // 配置头像
         String avatar = student.getAvatar();
         if (StringUtils.isEmpty(avatar)) {
-            if (StringUtils.isEmpty(avatar)) {
-                avatar = sysConfigService.findConfigValue(SysConfigConstant.TENANT_STUDENT_AVATAR);
-                student.setAvatar(avatar);
+            if (student.getGender().equals(1)) {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_BOY);
+            } else {
+                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_GIRL);
             }
             student.setAvatar(avatar);
         }
 
-        Student studentInfo = JSON.parseObject(JSON.toJSONString(student), Student.class);
+        StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
         studentInfo.setTenantId(tenantInfo.getId());
 
         // 加好友
@@ -167,7 +168,7 @@ public class OpenStudentController extends BaseController {
             teacherList.forEach(next -> imUserFriendService.saveUserFriend(next.getUserId(),
                     new HashSet<>(ImmutableList.of(sysUser.getId()))));
         }
-        studentService.saveOrUpdate(studentInfo);
+        studentService.save(studentInfo);
         return succeed();
     }
 }