Browse Source

1.机构专辑分类查询排序调整、修改调整

yuanliang 1 year ago
parent
commit
7d690b5a5a

+ 8 - 10
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumCategoryServiceImpl.java

@@ -156,8 +156,8 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
         List<Long> newUpdateIds = values.stream().map(TenantAlbumCategoryDetail::getId).filter(Objects::nonNull)
                 .collect(Collectors.toList());
 
-        List<TenantAlbumCategoryDetail> removeDetailIdList =
-                detailList.stream().filter(next -> !newUpdateIds.contains(next.getId())).collect(Collectors.toList());
+        List<Long> removeDetailIdList = detailList.stream().map(TenantAlbumCategoryDetail::getId)
+                .filter(next -> !newUpdateIds.contains(next)).collect(Collectors.toList());
         if (!removeDetailIdList.isEmpty()) {
             // 校验删除的分类值是否被使用,如果有使用,则提示
             TenantAlbumCategory albumCategory = this.getById(tenantAlbumCategory.getId());
@@ -171,16 +171,14 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
             if (useCount > 0) {
                 checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), removeDetailIdList);
             }
+            tenantAlbumCategoryDetailService.removeByIds(removeDetailIdList);
         }
-
-        tenantAlbumCategoryDetailService.lambdaUpdate()
-                .eq(TenantAlbumCategoryDetail::getTenantAlbumCategoryId, tenantAlbumCategory.getId())
-                .remove();
-        this.updateById(JSON.parseObject(tenantAlbumCategory.jsonString(), TenantAlbumCategory.class));
         if (!values.isEmpty()) {
             values.forEach(next -> next.setTenantAlbumCategoryId(tenantAlbumCategory.getId()));
-            tenantAlbumCategoryDetailService.saveBatch(values);
+            tenantAlbumCategoryDetailService.saveOrUpdateBatch(values);
         }
+
+        this.updateById(JSON.parseObject(tenantAlbumCategory.jsonString(), TenantAlbumCategory.class));
         return true;
     }
 
@@ -214,11 +212,11 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
      * 校验专辑分类中的值是否有被应用
      */
     private void checkTenantAlbumCategoryDetailUsed(ETenantAlbumCategoryType categoryType,
-                                                    List<TenantAlbumCategoryDetail> list) {
+                                                    List<Long> list) {
         if (list.isEmpty()) {
             return;
         }
-        List<String> idStrList = list.stream().map(next -> next.getId().toString()).collect(Collectors.toList());
+        List<String> idStrList = list.stream().map(Object::toString).collect(Collectors.toList());
         QueryWrapper<TenantAlbumMusic> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda()
                 .in(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType),

+ 1 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumCategoryMapper.xml

@@ -29,6 +29,7 @@
                 AND t.category_type_ = #{param.categoryType}
             </if>
         </where>
+        ORDER BY t.id_ DESC
 
     </select>
 

+ 1 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantGroupMapper.xml

@@ -30,6 +30,7 @@
                 t.admin_id_ = #{param.adminId}
             </if>
         </where>
+        ORDER BY t.id_ ASC
     </select>
 
 </mapper>