Commit 711d31cc authored by muhong's avatar muhong

修改 查询sql

parent d99392f1
...@@ -5,7 +5,6 @@ import com.wwdz.ch.db.domain.FavoritesItemsRelation; ...@@ -5,7 +5,6 @@ import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import com.wwdz.ch.db.dto.FavoritesItemsDto; import com.wwdz.ch.db.dto.FavoritesItemsDto;
import java.util.List; import java.util.List;
import java.util.Map;
public interface FavoritesItemsRelationDao { public interface FavoritesItemsRelationDao {
/** /**
...@@ -131,13 +130,6 @@ public interface FavoritesItemsRelationDao { ...@@ -131,13 +130,6 @@ public interface FavoritesItemsRelationDao {
*/ */
long countByUserId(Long userId); long countByUserId(Long userId);
/**
* 通过藏品id分组统计记录数量最多的20条记录
*
* @return
*/
List<Map<String, Object>> findItemIdByCount();
/** /**
* 连表查询获取藏品的图片 * 连表查询获取藏品的图片
* *
......
...@@ -150,11 +150,6 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -150,11 +150,6 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
return favoritesItemsRelationMapper.countByExample(example); return favoritesItemsRelationMapper.countByExample(example);
} }
@Override
public List<Map<String, Object>> findItemIdByCount() {
return favoritesItemsRelationMapper.selectItemIdByCount();
}
@Override @Override
public List<FavoritesItemsDto> queryItemImages(Long favoritesId, List<Long> onlyOneselfItemIds) { public List<FavoritesItemsDto> queryItemImages(Long favoritesId, List<Long> onlyOneselfItemIds) {
FavoritesRequestDto favoritesRequestDto = new FavoritesRequestDto(); FavoritesRequestDto favoritesRequestDto = new FavoritesRequestDto();
......
...@@ -54,7 +54,5 @@ public interface FavoritesItemsRelationMapper { ...@@ -54,7 +54,5 @@ public interface FavoritesItemsRelationMapper {
int updateByExample(@Param("record") FavoritesItemsRelation record, @Param("example") FavoritesItemsRelationExample example); int updateByExample(@Param("record") FavoritesItemsRelation record, @Param("example") FavoritesItemsRelationExample example);
List<Map<String, Object>> selectItemIdByCount();
List<FavoritesItemsDto> selectItemImages(FavoritesRequestDto dto); List<FavoritesItemsDto> selectItemImages(FavoritesRequestDto dto);
} }
\ No newline at end of file
...@@ -262,18 +262,17 @@ ...@@ -262,18 +262,17 @@
</if> </if>
limit 1 limit 1
</select> </select>
<select id="selectItemIdByCount" resultType="java.util.Map">
select item_id,count(*) from favorites_items_relation group by item_id order by count(*) limit 20
</select>
<select id="selectItemImages" parameterType="com.wwdz.ch.db.dto.request.FavoritesRequestDto" resultMap="ItemResultMap"> <select id="selectItemImages" parameterType="com.wwdz.ch.db.dto.request.FavoritesRequestDto" resultMap="ItemResultMap">
select a.item_id,a.add_time,b.images,b.top_image select a.item_id,a.add_time,b.images,b.top_image
from favorites_items_relation a left join item b on a.item_id = b.id from favorites_items_relation a left join item b on a.item_id = b.id
where a.favorites_id = ${id} where a.favorites_id = #{id}
<if test="itemIds != null and itemIds.size() &gt; 0">
and a.item_id not in and a.item_id not in
<foreach item="item" index="index" collection="itemIds" <foreach item="item" index="index" collection="itemIds"
open="(" separator="," close=")"> open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if>
order by a.add_time desc order by a.add_time desc
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -719,6 +719,6 @@ ...@@ -719,6 +719,6 @@
limit 1 limit 1
</select> </select>
<select id="selectOnlyOneselfItems" parameterType="java.lang.Long" resultType="java.lang.Long"> <select id="selectOnlyOneselfItems" parameterType="java.lang.Long" resultType="java.lang.Long">
select a.id from item a join user_items_relation b on a.id = b.item_id where a.source_type = 2 and a.view_permission = 1 and b.user_id != ${userId} select a.id from item a join user_items_relation b on a.id = b.item_id where a.source_type = 2 and a.view_permission = 1 and b.user_id != #{userId}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment