Explorar el Código

fix 机构专辑分页

haonan hace 1 año
padre
commit
a61f8aa24c

+ 1 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumMusicMapper.java

@@ -4,8 +4,6 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
-import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
@@ -26,7 +24,7 @@ public interface TenantAlbumMusicMapper extends BaseMapper<TenantAlbumMusic> {
 	 */
 	List<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> selectPage(@Param("page") IPage<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> page, @Param("param") TenantAlbumMusicWrapper.StudentMusicSheetQuery param);
 
-	List<Long> selectMusicSheetIds(@Param("albumIds") List<Long> albumIds, @Param("subjectType") String s, @Param("type") String type, @Param("level") String level);
+	List<Long> selectMusicSheetIds(@Param("albumId") String albumId, @Param("subjectType") String s, @Param("type") String type, @Param("level") String level);
 
     /**
      * 获取机构专辑曲目ID集合

+ 19 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumMusicServiceImpl.java

@@ -9,6 +9,7 @@ import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.toolset.base.exception.BizException;
+import jodd.util.StringUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +50,11 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
     @Autowired
     private SysUserMapper sysUserMapper;
 
+
+    @Autowired
+    private TenantAlbumMusicService tenantAlbumMusicService;
+
+
     /**
      * 查询详情
      * @param id 详情ID
@@ -68,16 +74,25 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
      */
     @Override
     public IPage<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> selectPage(IPage<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> page, TenantAlbumMusicWrapper.StudentTenantAlbumMusicQuery query) {
-        List<Long> albumIds = query.getAlbumIds();
-        if (CollectionUtils.isEmpty(albumIds)){
-            throw new BizException("该机构未绑定相关专辑");
+
+        String albumId = query.getAlbumId();
+        if (StringUtil.isEmpty(albumId)){
+            Long tenantId = query.getTenantId();
+            //查询机构专辑Id
+            List<TenantAlbumMusic> list = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantId, tenantId).list();
+            if (CollectionUtils.isNotEmpty(list)){
+                TenantAlbumMusic albumMusic = list.get(0);
+                 albumId = albumMusic.getTenantAlbumId().toString();
+            } else {
+                throw new BizException("该机构未绑定相关专辑");
+            }
         }
         SubjectTypeEnum subjectType = query.getSubjectType();
         String s = subjectType.toString();
         String type = query.getType();
         String level = query.getLevel();
 
-        List<Long> musicSheetIds = tenantAlbumMusicMapper.selectMusicSheetIds(albumIds, s, type, level);
+        List<Long> musicSheetIds = tenantAlbumMusicMapper.selectMusicSheetIds(albumId, s, type, level);
 
         TenantAlbumMusicWrapper.StudentMusicSheetQuery musicSheetQuery = new TenantAlbumMusicWrapper.StudentMusicSheetQuery();
         musicSheetQuery.setMusicSheetIds(musicSheetIds);

+ 9 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumMusicWrapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.biz.dal.entity.MusicTag;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -138,8 +139,8 @@ public class TenantAlbumMusicWrapper {
         @ApiModelProperty("关键字匹配")
         private String keyword;
 
-        @ApiModelProperty(value = "专辑id集合")
-        private List<Long> albumIds;
+        /*@ApiModelProperty(value = "专辑id集合")
+        private List<Long> albumIds;*/
 
         @ApiModelProperty("声部分类(ENSEMBLE, MUSIC, SUBJECT)")
         private SubjectTypeEnum subjectType;
@@ -156,6 +157,12 @@ public class TenantAlbumMusicWrapper {
         @ApiModelProperty("标签")
         private Long musicTagId;
 
+        @ApiModelProperty("端类型")
+        private ClientEnum clientType;
+
+        @ApiModelProperty("机构id")
+        private Long tenantId;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }

+ 2 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml

@@ -60,11 +60,8 @@
             <if test="subjectType != null and subjectType != ''">
               and  t.subject_type_ = #{subjectType}
             </if>
-            <if test="albumIds != null and albumIds.size != 0">
-              and  t.tenant_album_id_ in
-                <foreach collection="albumIds" item="item" separator="," open="(" close=")">
-                #{item}
-            </foreach>
+            <if test="albumId != null and albumId != ''">
+              and  t.tenant_album_id_ = #{albumId}
             </if>
         </where>
 

+ 3 - 0
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/TenantAlbumSheetController.java

@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -80,6 +81,8 @@ public class TenantAlbumSheetController extends BaseController {
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
+        query.setTenantId(Optional.ofNullable(user.getTenantId()).orElse(-1L));
+        query.setClientType(ClientEnum.TENANT_STUDENT);
         IPage<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> page = tenantAlbumMusicService.selectPage(QueryInfo.getPage(query), query);
         return succeed((PageUtil.pageInfo(page)));
     }

+ 5 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TenantAlbumSheetController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
@@ -19,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Optional;
+
 /**
  * 专辑表 web 控制层
  * @author yzp
@@ -46,6 +49,8 @@ public class TenantAlbumSheetController extends BaseController {
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
+        query.setTenantId(Optional.ofNullable(user.getTenantId()).orElse(-1L));
+        query.setClientType(ClientEnum.TEACHER);
         IPage<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> page = tenantAlbumMusicService.selectPage(QueryInfo.getPage(query), query);
         return succeed((PageUtil.pageInfo(page)));
     }

+ 5 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantAlbumSheetController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
@@ -19,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Optional;
+
 /**
  * 专辑表 web 控制层
  * @author yzp
@@ -60,6 +63,8 @@ public class TenantAlbumSheetController extends BaseController {
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
+        query.setTenantId(Optional.ofNullable(user.getTenantId()).orElse(-1L));
+        query.setClientType(ClientEnum.TENANT);
         IPage<TenantAlbumMusicWrapper.StudentTenantAlbumMusic> page = tenantAlbumMusicService.selectPage(QueryInfo.getPage(query), query);
         return succeed((PageUtil.pageInfo(page)));
     }