foreach标签用法
package cn.onehome.flex.core.dto.req;
import cn.onehome.flex.core.db.entity.Group;
import cn.onehome.flex.core.dto.resp.CommendatoryPageResp;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class CommendatoryReq implements Serializable {
//弹福ID
private Long flexibleId;
// //适用人群
// private List<String> suit;
//分组
private List<Group> group;
}
List<Spu> findSpuByGroupId(CommendatoryReq req);
<select id="findSpuByGroupId" resultMap="spuResultMapper" parameterType="cn.onehome.flex.core.dto.req.CommendatoryReq">
select spu.*
from flexible.spu, flexible.product
where spu.del = 0
and product.del = 0
and spu.product_id = product.id
and product.state = 'RELEASED'
and spu.group_id in
<foreach collection="group" index="index" item="groupItem" open="(" separator="," close=")">
#{groupItem.id}
</foreach>
and product.flexible_id = #{flexibleId}
order by group_sort, id
</select>