<?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.pill.mapper.PillExpiryWarningMapper">

    <resultMap id="PillExpiryWarningResult" type="com.ruoyi.pill.domain.PillExpiryWarning">
        <result property="warningId"    column="warning_id"    />
        <result property="drugId"    column="drug_id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="productionDate"    column="production_date"    />
        <result property="validityPeriod"    column="validity_period"    />
        <result property="purchaseId"    column="purchase_id"    />
        <result property="stock"    column="stock"    />
        <result property="createTime"    column="create_time"    />
        <result property="drugName" column="drug_name"/>
        <result property="factoryName" column="factory_name"/>
        <result property="purchaseTime" column="purchase_time"/>
        <result property="daysToExpire" column="days_to_expire"/>
    </resultMap>

    <sql id="BaseSelectSql">
        select
            pe.warning_id,
            pe.drug_id,
            pe.factory_id,
            pe.production_date,
            pe.validity_period,
            pe.purchase_id,
            pd.num as stock,
            pe.create_time,
            pd.drug_name,
            pf.factory_name,
            pp.purchase_time,
            datediff(date_add(pe.production_date, interval pe.validity_period day), curdate()) as days_to_expire
        from pill_expiry_warning pe
                 LEFT JOIN pill_drug pd ON pe.drug_id = pd.drug_id
                 LEFT JOIN pill_factory pf ON pe.factory_id = pf.factory_id
                 LEFT JOIN pill_purchase pp ON pe.purchase_id = pp.purchase_id
    </sql>

    <select id="selectPillExpiryWarningList" parameterType="com.ruoyi.pill.domain.PillExpiryWarning" resultMap="PillExpiryWarningResult">
        <include refid="BaseSelectSql"/>
        <where>
            <if test="drugId != null "> and pe.drug_id = #{drugId}</if>
            <if test="factoryId != null "> and pe.factory_id = #{factoryId}</if>
            <if test="productionDate != null "> and pe.production_date = #{productionDate}</if>
            <if test="validityPeriod != null "> and pe.validity_period = #{validityPeriod}</if>
            <if test="purchaseId != null "> and pe.purchase_id = #{purchaseId}</if>
        </where>
    </select>

    <select id="selectPillExpiryWarningByWarningId" parameterType="Long" resultMap="PillExpiryWarningResult">
        <include refid="BaseSelectSql"/>
        where pe.warning_id = #{warningId}
    </select>

    <insert id="insertPillExpiryWarning" parameterType="com.ruoyi.pill.domain.PillExpiryWarning" useGeneratedKeys="true" keyProperty="warningId">
        insert into pill_expiry_warning
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="drugId != null">drug_id,</if>
            <if test="factoryId != null">factory_id,</if>
            <if test="productionDate != null">production_date,</if>
            <if test="validityPeriod != null">validity_period,</if>
            <if test="purchaseId != null">purchase_id,</if>
            <if test="stock != null">stock,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="drugId != null">#{drugId},</if>
            <if test="factoryId != null">#{factoryId},</if>
            <if test="productionDate != null">#{productionDate},</if>
            <if test="validityPeriod != null">#{validityPeriod},</if>
            <if test="purchaseId != null">#{purchaseId},</if>
            <if test="stock != null">#{stock},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updatePillExpiryWarning" parameterType="com.ruoyi.pill.domain.PillExpiryWarning">
        update pill_expiry_warning
        <set>
            <if test="drugId != null">drug_id = #{drugId},</if>
            <if test="factoryId != null">factory_id = #{factoryId},</if>
            <if test="productionDate != null">production_date = #{productionDate},</if>
            <if test="validityPeriod != null">validity_period = #{validityPeriod},</if>
            <if test="purchaseId != null">purchase_id = #{purchaseId},</if>
            <if test="stock != null">stock = #{stock},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </set>
        where warning_id = #{warningId}
    </update>

    <delete id="deletePillExpiryWarningByWarningId" parameterType="Long">
        delete from pill_expiry_warning where warning_id = #{warningId}
    </delete>

    <delete id="deletePillExpiryWarningByWarningIds" parameterType="Long[]">
        delete from pill_expiry_warning where warning_id in
        <foreach item="warningId" collection="array" open="(" separator="," close=")">
            #{warningId}
        </foreach>
    </delete>
</mapper>
看看代码哪里出现问题，前端下拉框显示无数据