实际上是穿了一个map给 Dao层
int papercount=0;
int readcount=0;
int sharecount=0;
//
List<String> paperIds = new ArrayList<>();
for (ShopPaper shopPaper : shopPapers) {
paperIds.add(shopPaper.getPaperId());
}
HashMap<String, List> map1 = new HashMap<>(); //!!!
map1.put("paperIds",paperIds);
ShopPaperPraise shopPaperPraise = shopPaperService.selectPraiseSum(map1);
papercount=paperIds.size();
readcount=shopPaperPraise.getReadNum();
sharecount=shopPaperPraise.getShareNum();
/**
* 根据电报id集合返回阅读分享的总和
* */
ShopPaperPraise selectPraiseSum(Map map);
foreach collection中的paperIds是穿过来map的key
<!-- select sum(read_num) read_num, sum(share_num) share_num from is_shop_paper_praise where paper_id in('29','22')-->
<select id="selectPraiseSum" parameterType="map" resultType="com.ovopark.shoppaper.model.ShopPaperPraise">
select
sum(read_num) read_num,
sum(share_num) share_num from is_shop_paper_praise
<where>
<foreach collection="paperIds" item="paperId" open="paper_id in(" close=")" separator=",">
#{paperId}
</foreach>
</where>
</select>