All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mapper.shop.StoreGoodsAttributeMapper.xml Maven / Gradle / Ivy

The newest version!
<?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.jblv.shop.mapper.StoreGoodsAttributeMapper">
    
    <resultMap type="StoreGoodsAttribute" id="StoreGoodsAttributeResult">
        <result property="attrId"    column="attr_id"    />
        <result property="attrName"    column="attr_name"    />
        <result property="typeId"    column="type_id"    />
        <result property="attrIndex"    column="attr_index"    />
        <result property="attrType"    column="attr_type"    />
        <result property="attrInputType"    column="attr_input_type"    />
        <result property="attrValues"    column="attr_values"    />
        <result property="sort"    column="sort"    />
    </resultMap>

    <sql id="selectStoreGoodsAttributeVo">
        select attr_id, attr_name, type_id, attr_index, attr_type, attr_input_type, attr_values, sort from store_goods_attribute
    </sql>

    <select id="selectStoreGoodsAttributeList" parameterType="StoreGoodsAttribute" resultMap="StoreGoodsAttributeResult">
        <include refid="selectStoreGoodsAttributeVo"/>
        <where>
            <if test="typeId != null  and typeId != ''"> and type_id = #{typeId}</if>
            <if test="attrName != null  and attrName != ''"> and attr_name like concat('%', #{attrName}, '%')</if>
        </where>
    </select>
    
    <select id="selectStoreGoodsAttributeById" parameterType="Long" resultMap="StoreGoodsAttributeResult">
        <include refid="selectStoreGoodsAttributeVo"/>
        where attr_id = #{attrId}
    </select>
        
    <insert id="insertStoreGoodsAttribute" parameterType="StoreGoodsAttribute" useGeneratedKeys="true" keyProperty="attrId">
        insert into store_goods_attribute
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="attrName != null  and attrName != ''">attr_name,</if>
            <if test="typeId != null ">type_id,</if>
            <if test="attrIndex != null ">attr_index,</if>
            <if test="attrType != null ">attr_type,</if>
            <if test="attrInputType != null ">attr_input_type,</if>
            <if test="attrValues != null  and attrValues != ''">attr_values,</if>
            <if test="sort != null ">sort,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="attrName != null  and attrName != ''">#{attrName},</if>
            <if test="typeId != null ">#{typeId},</if>
            <if test="attrIndex != null ">#{attrIndex},</if>
            <if test="attrType != null ">#{attrType},</if>
            <if test="attrInputType != null ">#{attrInputType},</if>
            <if test="attrValues != null  and attrValues != ''">#{attrValues},</if>
            <if test="sort != null ">#{sort},</if>
         </trim>
    </insert>

    <update id="updateStoreGoodsAttribute" parameterType="StoreGoodsAttribute">
        update store_goods_attribute
        <trim prefix="SET" suffixOverrides=",">
            <if test="attrName != null  and attrName != ''">attr_name = #{attrName},</if>
            <if test="typeId != null ">type_id = #{typeId},</if>
            <if test="attrIndex != null ">attr_index = #{attrIndex},</if>
            <if test="attrType != null ">attr_type = #{attrType},</if>
            <if test="attrInputType != null ">attr_input_type = #{attrInputType},</if>
            <if test="attrValues != null  and attrValues != ''">attr_values = #{attrValues},</if>
            <if test="sort != null ">sort = #{sort},</if>
        </trim>
        where attr_id = #{attrId}
    </update>

    <delete id="deleteStoreGoodsAttributeById" parameterType="Long">
        delete from store_goods_attribute where attr_id = #{attrId}
    </delete>

    <delete id="deleteStoreGoodsAttributeByIds" parameterType="String">
        delete from store_goods_attribute where attr_id in 
        <foreach item="attrId" collection="array" open="(" separator="," close=")">
            #{attrId}
        </foreach>
    </delete>
    
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy