<?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.model.mapper.AppPetTypeMapper">
    
    <resultMap type="AppPetType" id="AppPetTypeResult">
        <result property="petTypeId"    column="pet_type_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="petTypeImage"    column="pet_type_image"    />
        <result property="petTypeName"    column="pet_type_name"    />
        <result property="reamk"    column="reamk"    />
    </resultMap>

    <sql id="selectAppPetTypeVo">
        select pet_type_id, del_flag, pet_type_image, pet_type_name, reamk from app_pet_type
    </sql>

    <select id="selectAppPetTypeList" parameterType="AppPetType" resultMap="AppPetTypeResult">
        <include refid="selectAppPetTypeVo"/>
        <where>  
            <if test="petTypeImage != null  and petTypeImage != ''"> and pet_type_image = #{petTypeImage}</if>
            <if test="petTypeName != null  and petTypeName != ''"> and pet_type_name like concat('%', #{petTypeName}, '%')</if>
            <if test="reamk != null  and reamk != ''"> and reamk = #{reamk}</if>
        </where>
    </select>
    
    <select id="selectAppPetTypeByPetTypeId" parameterType="Long" resultMap="AppPetTypeResult">
        <include refid="selectAppPetTypeVo"/>
        where pet_type_id = #{petTypeId}
    </select>
    <select id="getAppPetTypeList" resultType="com.ruoyi.model.domain.AppPetType">
        <include refid="selectAppPetTypeVo"/>
    </select>

    <insert id="insertAppPetType" parameterType="AppPetType">
        insert into app_pet_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="petTypeId != null">pet_type_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="petTypeImage != null">pet_type_image,</if>
            <if test="petTypeName != null">pet_type_name,</if>
            <if test="reamk != null">reamk,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="petTypeId != null">#{petTypeId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="petTypeImage != null">#{petTypeImage},</if>
            <if test="petTypeName != null">#{petTypeName},</if>
            <if test="reamk != null">#{reamk},</if>
         </trim>
    </insert>

    <update id="updateAppPetType" parameterType="AppPetType">
        update app_pet_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="petTypeImage != null">pet_type_image = #{petTypeImage},</if>
            <if test="petTypeName != null">pet_type_name = #{petTypeName},</if>
            <if test="reamk != null">reamk = #{reamk},</if>
        </trim>
        where pet_type_id = #{petTypeId}
    </update>

    <delete id="deleteAppPetTypeByPetTypeId" parameterType="Long">
        delete from app_pet_type where pet_type_id = #{petTypeId}
    </delete>

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