<?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.AppPetsBreadMapper">
    
    <resultMap type="AppPetsBread" id="AppPetsBreadResult">
        <result property="petBreadId"    column="pet_bread_id"    />
        <result property="petSpeciesId"    column="pet_species_id"    />
        <result property="petsBreadName"    column="pets_bread_name"    />
        <result property="petHealthidId"    column="pet_healthid_id"    />
        <result property="petId"    column="pet_id"    />
        <result property="petsHealthidCertificate"    column="pets_healthid_certificate"    />
        <result property="petsHealthidDeworming"    column="pets_healthid_deworming"    />
        <result property="petsHealthidInfo"    column="pets_healthid_info"    />
        <result property="petsHealthidSterilization"    column="pets_healthid_sterilization"    />
        <result property="petsHealthidVaccine"    column="pets_healthid_vaccine"    />
    </resultMap>

    <sql id="selectAppPetsBreadVo">
        select pet_bread_id, pet_species_id, pets_bread_name, pet_healthid_id, pet_id, pets_healthid_certificate, pets_healthid_deworming, pets_healthid_info, pets_healthid_sterilization, pets_healthid_vaccine from app_pets_bread
    </sql>

    <select id="selectAppPetsBreadList" parameterType="AppPetsBread" resultMap="AppPetsBreadResult">
        <include refid="selectAppPetsBreadVo"/>
        <where>  
            <if test="petSpeciesId != null "> and pet_species_id = #{petSpeciesId}</if>
            <if test="petsBreadName != null  and petsBreadName != ''"> and pets_bread_name like concat('%', #{petsBreadName}, '%')</if>
            <if test="petHealthidId != null "> and pet_healthid_id = #{petHealthidId}</if>
            <if test="petId != null "> and pet_id = #{petId}</if>
            <if test="petsHealthidCertificate != null "> and pets_healthid_certificate = #{petsHealthidCertificate}</if>
            <if test="petsHealthidDeworming != null "> and pets_healthid_deworming = #{petsHealthidDeworming}</if>
            <if test="petsHealthidInfo != null  and petsHealthidInfo != ''"> and pets_healthid_info = #{petsHealthidInfo}</if>
            <if test="petsHealthidSterilization != null "> and pets_healthid_sterilization = #{petsHealthidSterilization}</if>
            <if test="petsHealthidVaccine != null "> and pets_healthid_vaccine = #{petsHealthidVaccine}</if>
        </where>
    </select>
    
    <select id="selectAppPetsBreadByPetBreadId" parameterType="Long" resultMap="AppPetsBreadResult">
        <include refid="selectAppPetsBreadVo"/>
        where pet_bread_id = #{petBreadId}
    </select>
    <select id="getAppPetsBreadList" resultType="com.ruoyi.model.domain.AppPetsBread">
        <include refid="selectAppPetsBreadVo"/>
    </select>

    <insert id="insertAppPetsBread" parameterType="AppPetsBread">
        insert into app_pets_bread
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="petBreadId != null">pet_bread_id,</if>
            <if test="petSpeciesId != null">pet_species_id,</if>
            <if test="petsBreadName != null">pets_bread_name,</if>
            <if test="petHealthidId != null">pet_healthid_id,</if>
            <if test="petId != null">pet_id,</if>
            <if test="petsHealthidCertificate != null">pets_healthid_certificate,</if>
            <if test="petsHealthidDeworming != null">pets_healthid_deworming,</if>
            <if test="petsHealthidInfo != null">pets_healthid_info,</if>
            <if test="petsHealthidSterilization != null">pets_healthid_sterilization,</if>
            <if test="petsHealthidVaccine != null">pets_healthid_vaccine,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="petBreadId != null">#{petBreadId},</if>
            <if test="petSpeciesId != null">#{petSpeciesId},</if>
            <if test="petsBreadName != null">#{petsBreadName},</if>
            <if test="petHealthidId != null">#{petHealthidId},</if>
            <if test="petId != null">#{petId},</if>
            <if test="petsHealthidCertificate != null">#{petsHealthidCertificate},</if>
            <if test="petsHealthidDeworming != null">#{petsHealthidDeworming},</if>
            <if test="petsHealthidInfo != null">#{petsHealthidInfo},</if>
            <if test="petsHealthidSterilization != null">#{petsHealthidSterilization},</if>
            <if test="petsHealthidVaccine != null">#{petsHealthidVaccine},</if>
         </trim>
    </insert>

    <update id="updateAppPetsBread" parameterType="AppPetsBread">
        update app_pets_bread
        <trim prefix="SET" suffixOverrides=",">
            <if test="petSpeciesId != null">pet_species_id = #{petSpeciesId},</if>
            <if test="petsBreadName != null">pets_bread_name = #{petsBreadName},</if>
            <if test="petHealthidId != null">pet_healthid_id = #{petHealthidId},</if>
            <if test="petId != null">pet_id = #{petId},</if>
            <if test="petsHealthidCertificate != null">pets_healthid_certificate = #{petsHealthidCertificate},</if>
            <if test="petsHealthidDeworming != null">pets_healthid_deworming = #{petsHealthidDeworming},</if>
            <if test="petsHealthidInfo != null">pets_healthid_info = #{petsHealthidInfo},</if>
            <if test="petsHealthidSterilization != null">pets_healthid_sterilization = #{petsHealthidSterilization},</if>
            <if test="petsHealthidVaccine != null">pets_healthid_vaccine = #{petsHealthidVaccine},</if>
        </trim>
        where pet_bread_id = #{petBreadId}
    </update>

    <delete id="deleteAppPetsBreadByPetBreadId" parameterType="Long">
        delete from app_pets_bread where pet_bread_id = #{petBreadId}
    </delete>

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