Selaa lähdekoodia

解决相册数量查询问题

zc 2 kuukautta sitten
vanhempi
commit
610fc886f2

+ 15 - 1
alien-entity/src/main/java/shop/alien/mapper/StoreOfficialAlbumMapper.java

@@ -27,6 +27,20 @@ public interface StoreOfficialAlbumMapper extends BaseMapper<StoreOfficialAlbum>
             "order by b2.img_sort LIMIT 1) where a.delete_flag = '0' and  a.store_id = #{storeId}")
     List<StoreOfficialAlbumVo> getStoreOfficialAlbumList(@Param("storeId") Integer storeId);
 
-    @Select("select si.business_id as id ,count(*) as img_count from store_img si where si.delete_flag = '0' and si.store_id = #{storeId} group by si.business_id ")
+    @Select("select " +
+            " soa.id," +
+            " (" +
+            "        SELECT COUNT(*) " +
+            "        FROM store_img b2 " +
+            "        WHERE b2.business_id = soa.id " +
+            "            AND b2.img_type IN ('2', '4') " +
+            "            AND b2.delete_flag = 0 " +
+            "            AND b2.store_id = #{storeId} " +
+            "    ) as imgCount " +
+            " from" +
+            " store_official_album soa\n" +
+            " where " +
+            " soa.store_id = #{storeId} " +
+            " and soa.delete_flag = 0")
     List<StoreOfficialAlbum> getStoreOfficialAlbumImgCount(@Param("storeId") Integer storeId);
 }