<?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.yudao.module.inspection.mapper.InspectionCategoryTemplateMapper">

    <resultMap type="cn.iocoder.yudao.module.inspection.entity.InspectionCategoryTemplate" id="InspectionCategoryTemplateResult">
        <result property="id"    column="id"    />
        <result property="categoryId"    column="category_id"    />
        <result property="skuName"    column="sku_name"    />
        <result property="skuPrice"    column="sku_price"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updater"    column="updater"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectInspectionCategoryTemplateVo">
        select id, category_id, sku_name, sku_price, create_time, creator, updater, update_time from inspection_category_template
    </sql>

    <select id="selectInspectionCategoryTemplateList" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionCategoryTemplate" resultMap="InspectionCategoryTemplateResult">
        <include refid="selectInspectionCategoryTemplateVo"/>
        <where>
            <if test="vo.categoryId != null "> and category_id = #{vo.categoryId}</if>
            <if test="vo.skuName != null  and vo.skuName != ''"> and sku_name like concat('%', #{vo.skuName}, '%')</if>
            <if test="vo.skuPrice != null "> and sku_price = #{vo.skuPrice}</if>
        </where>
    </select>

    <select id="selectInspectionCategoryTemplateById" parameterType="Long" resultMap="InspectionCategoryTemplateResult">
        <include refid="selectInspectionCategoryTemplateVo"/>
        where id = #{id}
    </select>

    <insert id="insertInspectionCategoryTemplate" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionCategoryTemplate">
        insert into inspection_category_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="categoryId != null">category_id,</if>
            <if test="skuName != null">sku_name,</if>
            <if test="skuPrice != null">sku_price,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updater != null">updater,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="categoryId != null">#{categoryId},</if>
            <if test="skuName != null">#{skuName},</if>
            <if test="skuPrice != null">#{skuPrice},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updater != null">#{updater},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateInspectionCategoryTemplate" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionCategoryTemplate">
        update inspection_category_template
        <trim prefix="SET" suffixOverrides=",">
            <if test="categoryId != null">category_id = #{categoryId},</if>
            <if test="skuName != null">sku_name = #{skuName},</if>
            <if test="skuPrice != null">sku_price = #{skuPrice},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updater != null">updater = #{updater},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInspectionCategoryTemplateById" parameterType="Long">
        delete from inspection_category_template where id = #{id}
    </delete>

    <delete id="deleteInspectionCategoryTemplateByIds" parameterType="String">
        delete from inspection_category_template where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteByCategoryId">
        delete from inspection_category_template where category_id = #{id}
    </delete>
</mapper>
