GoodsCoverImageMapper.xml 1.18 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.GoodsCoverImageMapper">
    <resultMap id="GoodsCoverImage" type="com.yoho.search.dal.model.GoodsCoverImage">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="goods_id" property="goodsId" jdbcType="INTEGER"/>
        <result column="cover_1" property="cover_1" jdbcType="VARCHAR"/>
        <result column="cover_2" property="cover_2" jdbcType="VARCHAR"/>
    </resultMap>
    <select id="selectGoodsCoverImage" resultMap="GoodsCoverImage">
        <![CDATA[
    SELECT
    `a`.`id` AS `id`,
    `a`.`goods_id` AS `goods_id`,
    (
    CASE `a`.`gender_cover`
    WHEN 1 THEN
    `a`.`image_url`
    END
    ) AS `cover_1`,
    (
    CASE `a`.`gender_cover`
    WHEN 2 THEN
    `a`.`image_url`
    END
    ) AS `cover_2`
    FROM
    `goods_images` `a`
    where
    (`a`.`gender_cover` <> 0)
     AND goods_id in]]>
        <foreach item="item" index="index" collection="list"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
</mapper>