<?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.ruoyi.asset.mapper.TbAssetCategoryMapper">
    
    <resultMap type="TbAssetCategory" id="TbAssetCategoryResult">
        <result property="id"    column="id"    />
        <result property="number"    column="number"    />
        <result property="name"    column="name"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTbAssetCategoryVo">
        select id, number, name, remark from tb_asset_category
    </sql>

    <select id="selectTbAssetCategoryList" parameterType="TbAssetCategory" resultMap="TbAssetCategoryResult">
        <include refid="selectTbAssetCategoryVo"/>
        <where>  
            <if test="number != null  and number != ''"> and number = #{number}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>
    
    <select id="selectTbAssetCategoryById" parameterType="Long" resultMap="TbAssetCategoryResult">
        <include refid="selectTbAssetCategoryVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTbAssetCategory" parameterType="TbAssetCategory" useGeneratedKeys="true" keyProperty="id">
        insert into tb_asset_category
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="number != null and number != ''">number,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="number != null and number != ''">#{number},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTbAssetCategory" parameterType="TbAssetCategory">
        update tb_asset_category
        <trim prefix="SET" suffixOverrides=",">
            <if test="number != null and number != ''">number = #{number},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTbAssetCategoryById" parameterType="Long">
        delete from tb_asset_category where id = #{id}
    </delete>

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