<?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.izouma.awesomeadmin.dao.TableShouyiYaopinxinxiMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi">
                                    <id column="id" property="id" jdbcType="INTEGER"/>
                                                                        <result column="药品编号" property="药品编号" jdbcType="VARCHAR"/>
                                                            <result column="药品名称" property="药品名称" jdbcType="VARCHAR"/>
                                                            <result column="计量单位" property="计量单位" jdbcType="VARCHAR"/>
                                                            <result column="规格" property="规格" jdbcType="VARCHAR"/>
                                                            <result column="主要成分" property="主要成分" jdbcType="VARCHAR"/>
                                                            <result column="有效成分" property="有效成分" jdbcType="VARCHAR"/>
                                                            <result column="单价" property="单价" jdbcType="DECIMAL"/>
                                                            <result column="生产厂家" property="生产厂家" jdbcType="VARCHAR"/>
                                                            <result column="药品制定部门" property="药品制定部门" jdbcType="VARCHAR"/>
                                                            <result column="FlagColumn" property="flagcolumn" jdbcType="INTEGER"/>
                        </resultMap>
    <sql id="Base_Column_List">
                    ID,                    药品编号,                    药品名称,                    计量单位,                    规格,                    主要成分,                    有效成分,                    单价,                    生产厂家,                    药品制定部门,                    FlagColumn            </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from Table_兽医_药品信息
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from Table_兽医_药品信息
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi"
            useGeneratedKeys="true" keyProperty="id">
        insert into Table_兽医_药品信息
        <trim prefix="(" suffix=")" suffixOverrides=",">
                                                                            <if test="药品编号!= null">
                        药品编号,
                    </if>
                                                                <if test="药品名称!= null">
                        药品名称,
                    </if>
                                                                <if test="计量单位!= null">
                        计量单位,
                    </if>
                                                                <if test="规格!= null">
                        规格,
                    </if>
                                                                <if test="主要成分!= null">
                        主要成分,
                    </if>
                                                                <if test="有效成分!= null">
                        有效成分,
                    </if>
                                                                <if test="单价!= null">
                        单价,
                    </if>
                                                                <if test="生产厂家!= null">
                        生产厂家,
                    </if>
                                                                <if test="药品制定部门!= null">
                        药品制定部门,
                    </if>
                                                                <if test="flagcolumn!= null">
                        FlagColumn,
                    </if>
                                    </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                                                                            <if test="药品编号 != null">
                        #{药品编号,jdbcType=VARCHAR},
                    </if>
                                                                <if test="药品名称 != null">
                        #{药品名称,jdbcType=VARCHAR},
                    </if>
                                                                <if test="计量单位 != null">
                        #{计量单位,jdbcType=VARCHAR},
                    </if>
                                                                <if test="规格 != null">
                        #{规格,jdbcType=VARCHAR},
                    </if>
                                                                <if test="主要成分 != null">
                        #{主要成分,jdbcType=VARCHAR},
                    </if>
                                                                <if test="有效成分 != null">
                        #{有效成分,jdbcType=VARCHAR},
                    </if>
                                                                <if test="单价 != null">
                        #{单价,jdbcType=DECIMAL},
                    </if>
                                                                <if test="生产厂家 != null">
                        #{生产厂家,jdbcType=VARCHAR},
                    </if>
                                                                <if test="药品制定部门 != null">
                        #{药品制定部门,jdbcType=VARCHAR},
                    </if>
                                                                <if test="flagcolumn != null">
                        #{flagcolumn,jdbcType=INTEGER},
                    </if>
                                    </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi">
        update Table_兽医_药品信息
        <set>
                                                                            <if test="药品编号 != null">
                        药品编号= #{药品编号,jdbcType=VARCHAR},
                    </if>
                                                                <if test="药品名称 != null">
                        药品名称= #{药品名称,jdbcType=VARCHAR},
                    </if>
                                                                <if test="计量单位 != null">
                        计量单位= #{计量单位,jdbcType=VARCHAR},
                    </if>
                                                                <if test="规格 != null">
                        规格= #{规格,jdbcType=VARCHAR},
                    </if>
                                                                <if test="主要成分 != null">
                        主要成分= #{主要成分,jdbcType=VARCHAR},
                    </if>
                                                                <if test="有效成分 != null">
                        有效成分= #{有效成分,jdbcType=VARCHAR},
                    </if>
                                                                <if test="单价 != null">
                        单价= #{单价,jdbcType=DECIMAL},
                    </if>
                                                                <if test="生产厂家 != null">
                        生产厂家= #{生产厂家,jdbcType=VARCHAR},
                    </if>
                                                                <if test="药品制定部门 != null">
                        药品制定部门= #{药品制定部门,jdbcType=VARCHAR},
                    </if>
                                                                <if test="flagcolumn != null">
                        FlagColumn= #{flagcolumn,jdbcType=INTEGER},
                    </if>
                                    </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryTableShouyiYaopinxinxiByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi">
        select
        <include refid="Base_Column_List"/>
        from Table_兽医_药品信息
        <where>
            and FlagColumn = 0
                            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                    and  ID = #{record.id}
                </if>
                            <if test="record.药品编号 != null and !&quot;&quot;.equals(record.药品编号)">
                    and  药品编号 = #{record.药品编号}
                </if>
                            <if test="record.药品名称 != null and !&quot;&quot;.equals(record.药品名称)">
                    and  药品名称 = #{record.药品名称}
                </if>
                            <if test="record.计量单位 != null and !&quot;&quot;.equals(record.计量单位)">
                    and  计量单位 = #{record.计量单位}
                </if>
                            <if test="record.规格 != null and !&quot;&quot;.equals(record.规格)">
                    and  规格 = #{record.规格}
                </if>
                            <if test="record.主要成分 != null and !&quot;&quot;.equals(record.主要成分)">
                    and  主要成分 = #{record.主要成分}
                </if>
                            <if test="record.有效成分 != null and !&quot;&quot;.equals(record.有效成分)">
                    and  有效成分 = #{record.有效成分}
                </if>
                            <if test="record.单价 != null and !&quot;&quot;.equals(record.单价)">
                    and  单价 = #{record.单价}
                </if>
                            <if test="record.生产厂家 != null and !&quot;&quot;.equals(record.生产厂家)">
                    and  生产厂家 = #{record.生产厂家}
                </if>
                            <if test="record.药品制定部门 != null and !&quot;&quot;.equals(record.药品制定部门)">
                    and  药品制定部门 = #{record.药品制定部门}
                </if>
                            <if test="record.flagcolumn != null and !&quot;&quot;.equals(record.flagcolumn)">
                    and  FlagColumn = #{record.flagcolumn}
                </if>
            
            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
                                                                                                                    OR  药品编号 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  药品名称 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  计量单位 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  规格 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  主要成分 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  有效成分 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  单价 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  生产厂家 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  药品制定部门 LIKE concat('%',#{record.searchKey},'%')
                                                                                                OR  FlagColumn LIKE concat('%',#{record.searchKey},'%')
                                                            </trim>
            </if>
            <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
                <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
                    <choose>
                        <when test="item.indexOf('like') != -1">
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    concat('%',#{itemDetail},'%')
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </when>
                        <otherwise>
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    #{itemDetail}
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </otherwise>
                    </choose>


                </foreach>


            </if>
        </where>
        order by id desc
    </select>
    <select id="queryAllTableShouyiYaopinxinxi" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi">
        select
        <include refid="Base_Column_List"/>
        from Table_兽医_药品信息
        <where>
            and FlagColumn = 0
                            <if test="id != null and !&quot;&quot;.equals(id)">
                    and  ID = #{id}
                </if>
                            <if test="药品编号 != null and !&quot;&quot;.equals(药品编号)">
                    and  药品编号 = #{药品编号}
                </if>
                            <if test="药品名称 != null and !&quot;&quot;.equals(药品名称)">
                    and  药品名称 = #{药品名称}
                </if>
                            <if test="计量单位 != null and !&quot;&quot;.equals(计量单位)">
                    and  计量单位 = #{计量单位}
                </if>
                            <if test="规格 != null and !&quot;&quot;.equals(规格)">
                    and  规格 = #{规格}
                </if>
                            <if test="主要成分 != null and !&quot;&quot;.equals(主要成分)">
                    and  主要成分 = #{主要成分}
                </if>
                            <if test="有效成分 != null and !&quot;&quot;.equals(有效成分)">
                    and  有效成分 = #{有效成分}
                </if>
                            <if test="单价 != null and !&quot;&quot;.equals(单价)">
                    and  单价 = #{单价}
                </if>
                            <if test="生产厂家 != null and !&quot;&quot;.equals(生产厂家)">
                    and  生产厂家 = #{生产厂家}
                </if>
                            <if test="药品制定部门 != null and !&quot;&quot;.equals(药品制定部门)">
                    and  药品制定部门 = #{药品制定部门}
                </if>
                            <if test="flagcolumn != null and !&quot;&quot;.equals(flagcolumn)">
                    and  FlagColumn = #{flagcolumn}
                </if>
            
            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
                                                                                                                    OR  药品编号 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  药品名称 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  计量单位 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  规格 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  主要成分 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  有效成分 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  单价 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  生产厂家 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  药品制定部门 LIKE concat('%',#{searchKey},'%')
                                                                                                OR  FlagColumn LIKE concat('%',#{searchKey},'%')
                                                            </trim>
            </if>
            <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
                <foreach item="item" index="index" collection="advancedQuery.split('_;')">
                    <choose>
                        <when test="item.indexOf('like') != -1">
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    concat('%',#{itemDetail},'%')
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </when>
                        <otherwise>
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    #{itemDetail}
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </otherwise>
                    </choose>


                </foreach>


            </if>
        </where>
        order by id desc
    </select>
    <select id="queryTableShouyiYaopinxinxi" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi">
        select top 1
        <include refid="Base_Column_List"/>
        from Table_兽医_药品信息
        <where>
            and FlagColumn = 0
                            <if test="id != null and !&quot;&quot;.equals(id)">
                    and ID = #{id}
                </if>
                            <if test="药品编号 != null and !&quot;&quot;.equals(药品编号)">
                    and 药品编号 = #{药品编号}
                </if>
                            <if test="药品名称 != null and !&quot;&quot;.equals(药品名称)">
                    and 药品名称 = #{药品名称}
                </if>
                            <if test="计量单位 != null and !&quot;&quot;.equals(计量单位)">
                    and 计量单位 = #{计量单位}
                </if>
                            <if test="规格 != null and !&quot;&quot;.equals(规格)">
                    and 规格 = #{规格}
                </if>
                            <if test="主要成分 != null and !&quot;&quot;.equals(主要成分)">
                    and 主要成分 = #{主要成分}
                </if>
                            <if test="有效成分 != null and !&quot;&quot;.equals(有效成分)">
                    and 有效成分 = #{有效成分}
                </if>
                            <if test="单价 != null and !&quot;&quot;.equals(单价)">
                    and 单价 = #{单价}
                </if>
                            <if test="生产厂家 != null and !&quot;&quot;.equals(生产厂家)">
                    and 生产厂家 = #{生产厂家}
                </if>
                            <if test="药品制定部门 != null and !&quot;&quot;.equals(药品制定部门)">
                    and 药品制定部门 = #{药品制定部门}
                </if>
                            <if test="flagcolumn != null and !&quot;&quot;.equals(flagcolumn)">
                    and FlagColumn = #{flagcolumn}
                </if>
            
        </where>
    </select>
    <update id="delete">
        UPDATE Table_兽医_药品信息 SET FlagColumn = 1
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TableShouyiYaopinxinxi">
        select
        <include refid="Base_Column_List"/>
        from Table_兽医_药品信息
        <where>
            and FlagColumn = 0
                                                                                                                                                                                                                                                                                                                                        </where>
        order by id desc
    </select>
</mapper>

