<?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.bonus.boot.manager.health.dao.CareerdisposDao">
    <insert id="saveInfo">
            insert into pm_base_career_limit(start_date,hospital_id,limit_person,option_id)
        values (#{startDate},#{hospitalId},#{limitPerson},#{optionId})
    </insert>
    <update id="updateLimit">
        update pm_base_career_limit set
                limit_person = #{limitPerson}
        where hospital_id = #{hospital} and start_date = #{startDate} and if_active='1'
    </update>
    <update id="updateInfo">
            update pm_base_career_limit
            <set>
                <if test="time != null">
                    start_date = #{time},
                </if>
                <if test="limitPerson != null">
                    limit_person = #{limitPerson},
                </if>

            </set>
            where id = #{id}
    </update>

    <delete id="delById">
        update pm_base_career_limit set if_active = '0' where id = #{id}
    </delete>


    <select id="getMsgList" resultType="com.bonus.boot.manager.health.entity.PmBaseCareerLimit">
         SELECT
            pbhl.id,
            pbhl.start_date as startDate,
            pbh.hospital as hospital,
           pbhl.limit_person as limitPerson

        FROM
            pm_base_career_limit pbhl
        LEFT JOIN
           pm_base_hospital pbh
         on pbhl.hospital_id =pbh.id
        WHERE
            if_active = '1'

        <if test="phyTime !=null and phyTime !=''">
            and pbhl.start_date  = #{phyTime}
        </if>
        <if test="hospitalId !=null and hospitalId !=''">
            and pbhl.hospital_id  = #{hospitalId}
        </if>

    </select>
    <select id="findByhospid" resultType="java.lang.Integer">
        select count(1)
          from
                pm_base_career_limit
           where
            start_date=#{startDate} and hospital_id =#{hospital} and if_active='1'
    </select>
    <select id="getListById" resultType="com.bonus.boot.manager.health.entity.PmBaseCareerLimit">
        SELECT
            id,
            start_date as time,
            limit_person as limitPerson
        FROM pm_base_career_limit
        where if_active = '1' and id = #{id}
    </select>
</mapper>

