ProductAttrMapper.xml 3.0 KB
Newer Older
YunaiV's avatar
YunaiV committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?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="cn.iocoder.mall.product.dao.ProductAttrMapper">

    <sql id="FIELDS">
        id, name, status, create_time
    </sql>

    <!--<select id="selectList" resultType="ProductCategoryDO">-->
        <!--SELECT-->
        <!--<include refid="FIELDS" />-->
        <!--FROM product_category-->
        <!--WHERE deleted = 0-->
    <!--</select>-->

    <select id="selectById" parameterType="Integer" resultType="ProductAttrDO">
        SELECT
            <include refid="FIELDS" />
        FROM product_attr
        WHERE id = #{id}
        AND deleted = 0
    </select>

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
    <select id="selectByName" parameterType="String" resultType="ProductAttrDO">
        SELECT
            <include refid="FIELDS" />
        FROM product_attr
        WHERE name = #{name}
        AND deleted = 0
        LIMIT 1
    </select>

    <insert id="insert" parameterType="ProductAttrDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
        INSERT INTO product_attr (
          name, status, create_time, deleted
        ) VALUES (
          #{name}, #{status}, #{createTime}, #{deleted}
        )
    </insert>
YunaiV's avatar
YunaiV committed
40

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    <update id="update" parameterType="ProductAttrDO">
        UPDATE product_attr
        <set>
            <if test="name != null">
                name = #{name},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="deleted != null">
                deleted = #{deleted}
            </if>
        </set>
        WHERE id = #{id}
    </update>
YunaiV's avatar
YunaiV committed
56 57 58 59 60 61 62 63 64 65 66 67

    <select id="selectListByIds" resultType="ProductAttrDO">
        SELECT
            <include refid="FIELDS" />
        FROM product_attr
        WHERE id IN
            <foreach item="id" collection="ids" separator="," open="(" close=")" index="">
                #{id}
            </foreach>
        AND deleted = 0
    </select>

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    <select id="selectListByNameLike" resultType="ProductAttrDO">
        SELECT
            <include refid="FIELDS" />
        FROM product_attr
        <where>
            <if test="name != null">
                name LIKE "%"#{name}"%"
            </if>
            AND deleted = 0
        </where>
        LIMIT #{offset}, #{limit}
    </select>

    <select id="selectCountByNameLike" resultType="Integer">
        SELECT
            COUNT(1)
        FROM product_attr
        <where>
            <if test="name != null">
                name LIKE "%"#{name}"%"
            </if>
            AND deleted = 0
        </where>
    </select>

    <select id="selectListByStatus" parameterType="Integer" resultType="ProductAttrDO">
        SELECT
            <include refid="FIELDS" />
        FROM product_attr
        <where>
            <if test="status != null">
                status = #{status}
            </if>
            AND deleted = 0
        </where>
    </select>

YunaiV's avatar
YunaiV committed
105
</mapper>