<?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.xinelu.manage.mapper.scheduleplan.SchedulePlanMapper">

    <resultMap id="BaseResultMap" type="com.xinelu.manage.domain.scheduleplan.SchedulePlan">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="hospitalId" column="hospital_id" jdbcType="BIGINT"/>
            <result property="hospitalName" column="hospital_name" jdbcType="VARCHAR"/>
            <result property="departmentId" column="department_id" jdbcType="BIGINT"/>
            <result property="departmentName" column="department_name" jdbcType="VARCHAR"/>
            <result property="scheduleId" column="schedule_id" jdbcType="BIGINT"/>
            <result property="scheduleName" column="schedule_name" jdbcType="VARCHAR"/>
            <result property="doctorId" column="doctor_id" jdbcType="BIGINT"/>
            <result property="doctorName" column="doctor_name" jdbcType="VARCHAR"/>
            <result property="scheduleStartDate" column="schedule_start_date" jdbcType="DATE"/>
            <result property="scheduleEndDate" column="schedule_end_date" jdbcType="DATE"/>
            <result property="minutesPerPatient" column="minutes_per_patient" jdbcType="INTEGER"/>
            <result property="patientsPerDay" column="patients_per_day" jdbcType="INTEGER"/>
            <result property="scheduleAddress" column="schedule_address" jdbcType="VARCHAR"/>
            <result property="status" column="status" jdbcType="CHAR"/>
            <result property="delFlag" column="del_flag" jdbcType="CHAR"/>
            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,hospital_id,hospital_name,
        department_id,department_name,schedule_id,
        schedule_name,doctor_id,doctor_name,
        schedule_start_date,schedule_end_date,minutes_per_patient,
        patients_per_day,schedule_address,status,
        del_flag,create_by,create_time,
        update_by,update_time
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from schedule_plan
        where  id = #{id,jdbcType=BIGINT} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from schedule_plan
        where  id = #{id,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.manage.domain.scheduleplan.SchedulePlan" useGeneratedKeys="true">
        insert into schedule_plan
        ( id,hospital_id,hospital_name
        ,department_id,department_name,schedule_id
        ,schedule_name,doctor_id,doctor_name
        ,schedule_start_date,schedule_end_date,minutes_per_patient
        ,patients_per_day,schedule_address,status
        ,del_flag,create_by,create_time
        ,update_by,update_time)
        values (#{id,jdbcType=BIGINT},#{hospitalId,jdbcType=BIGINT},#{hospitalName,jdbcType=VARCHAR}
        ,#{departmentId,jdbcType=BIGINT},#{departmentName,jdbcType=VARCHAR},#{scheduleId,jdbcType=BIGINT}
        ,#{scheduleName,jdbcType=VARCHAR},#{doctorId,jdbcType=BIGINT},#{doctorName,jdbcType=VARCHAR}
        ,#{scheduleStartDate,jdbcType=DATE},#{scheduleEndDate,jdbcType=DATE},#{minutesPerPatient,jdbcType=INTEGER}
        ,#{patientsPerDay,jdbcType=INTEGER},#{scheduleAddress,jdbcType=VARCHAR},#{status,jdbcType=CHAR}
        ,#{delFlag,jdbcType=CHAR},#{createBy,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}
        ,#{updateBy,jdbcType=VARCHAR},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xinelu.manage.domain.scheduleplan.SchedulePlan" useGeneratedKeys="true">
        insert into schedule_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="hospitalId != null">hospital_id,</if>
                <if test="hospitalName != null">hospital_name,</if>
                <if test="departmentId != null">department_id,</if>
                <if test="departmentName != null">department_name,</if>
                <if test="scheduleId != null">schedule_id,</if>
                <if test="scheduleName != null">schedule_name,</if>
                <if test="doctorId != null">doctor_id,</if>
                <if test="doctorName != null">doctor_name,</if>
                <if test="scheduleStartDate != null">schedule_start_date,</if>
                <if test="scheduleEndDate != null">schedule_end_date,</if>
                <if test="minutesPerPatient != null">minutes_per_patient,</if>
                <if test="patientsPerDay != null">patients_per_day,</if>
                <if test="scheduleAddress != null">schedule_address,</if>
                <if test="status != null">status,</if>
                <if test="delFlag != null">del_flag,</if>
                <if test="createBy != null">create_by,</if>
                <if test="createTime != null">create_time,</if>
                <if test="updateBy != null">update_by,</if>
                <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="hospitalId != null">#{hospitalId,jdbcType=BIGINT},</if>
                <if test="hospitalName != null">#{hospitalName,jdbcType=VARCHAR},</if>
                <if test="departmentId != null">#{departmentId,jdbcType=BIGINT},</if>
                <if test="departmentName != null">#{departmentName,jdbcType=VARCHAR},</if>
                <if test="scheduleId != null">#{scheduleId,jdbcType=BIGINT},</if>
                <if test="scheduleName != null">#{scheduleName,jdbcType=VARCHAR},</if>
                <if test="doctorId != null">#{doctorId,jdbcType=BIGINT},</if>
                <if test="doctorName != null">#{doctorName,jdbcType=VARCHAR},</if>
                <if test="scheduleStartDate != null">#{scheduleStartDate,jdbcType=DATE},</if>
                <if test="scheduleEndDate != null">#{scheduleEndDate,jdbcType=DATE},</if>
                <if test="minutesPerPatient != null">#{minutesPerPatient,jdbcType=INTEGER},</if>
                <if test="patientsPerDay != null">#{patientsPerDay,jdbcType=INTEGER},</if>
                <if test="scheduleAddress != null">#{scheduleAddress,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=CHAR},</if>
                <if test="delFlag != null">#{delFlag,jdbcType=CHAR},</if>
                <if test="createBy != null">#{createBy,jdbcType=VARCHAR},</if>
                <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
                <if test="updateBy != null">#{updateBy,jdbcType=VARCHAR},</if>
                <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xinelu.manage.domain.scheduleplan.SchedulePlan">
        update schedule_plan
        <set>
                <if test="hospitalId != null">
                    hospital_id = #{hospitalId,jdbcType=BIGINT},
                </if>
                <if test="hospitalName != null">
                    hospital_name = #{hospitalName,jdbcType=VARCHAR},
                </if>
                <if test="departmentId != null">
                    department_id = #{departmentId,jdbcType=BIGINT},
                </if>
                <if test="departmentName != null">
                    department_name = #{departmentName,jdbcType=VARCHAR},
                </if>
                <if test="scheduleId != null">
                    schedule_id = #{scheduleId,jdbcType=BIGINT},
                </if>
                <if test="scheduleName != null">
                    schedule_name = #{scheduleName,jdbcType=VARCHAR},
                </if>
                <if test="doctorId != null">
                    doctor_id = #{doctorId,jdbcType=BIGINT},
                </if>
                <if test="doctorName != null">
                    doctor_name = #{doctorName,jdbcType=VARCHAR},
                </if>
                <if test="scheduleStartDate != null">
                    schedule_start_date = #{scheduleStartDate,jdbcType=DATE},
                </if>
                <if test="scheduleEndDate != null">
                    schedule_end_date = #{scheduleEndDate,jdbcType=DATE},
                </if>
                <if test="minutesPerPatient != null">
                    minutes_per_patient = #{minutesPerPatient,jdbcType=INTEGER},
                </if>
                <if test="patientsPerDay != null">
                    patients_per_day = #{patientsPerDay,jdbcType=INTEGER},
                </if>
                <if test="scheduleAddress != null">
                    schedule_address = #{scheduleAddress,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=CHAR},
                </if>
                <if test="delFlag != null">
                    del_flag = #{delFlag,jdbcType=CHAR},
                </if>
                <if test="createBy != null">
                    create_by = #{createBy,jdbcType=VARCHAR},
                </if>
                <if test="createTime != null">
                    create_time = #{createTime,jdbcType=TIMESTAMP},
                </if>
                <if test="updateBy != null">
                    update_by = #{updateBy,jdbcType=VARCHAR},
                </if>
                <if test="updateTime != null">
                    update_time = #{updateTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xinelu.manage.domain.scheduleplan.SchedulePlan">
        update schedule_plan
        set 
            hospital_id =  #{hospitalId,jdbcType=BIGINT},
            hospital_name =  #{hospitalName,jdbcType=VARCHAR},
            department_id =  #{departmentId,jdbcType=BIGINT},
            department_name =  #{departmentName,jdbcType=VARCHAR},
            schedule_id =  #{scheduleId,jdbcType=BIGINT},
            schedule_name =  #{scheduleName,jdbcType=VARCHAR},
            doctor_id =  #{doctorId,jdbcType=BIGINT},
            doctor_name =  #{doctorName,jdbcType=VARCHAR},
            schedule_start_date =  #{scheduleStartDate,jdbcType=DATE},
            schedule_end_date =  #{scheduleEndDate,jdbcType=DATE},
            minutes_per_patient =  #{minutesPerPatient,jdbcType=INTEGER},
            patients_per_day =  #{patientsPerDay,jdbcType=INTEGER},
            schedule_address =  #{scheduleAddress,jdbcType=VARCHAR},
            status =  #{status,jdbcType=CHAR},
            del_flag =  #{delFlag,jdbcType=CHAR},
            create_by =  #{createBy,jdbcType=VARCHAR},
            create_time =  #{createTime,jdbcType=TIMESTAMP},
            update_by =  #{updateBy,jdbcType=VARCHAR},
            update_time =  #{updateTime,jdbcType=TIMESTAMP}
        where   id = #{id,jdbcType=BIGINT} 
    </update>
	<select id="getList" parameterType="com.xinelu.manage.domain.scheduleplan.SchedulePlan" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from schedule_plan
		<where>
			del_flag = '0'
			<if test="hospitalId != null">
				and hospital_id = #{hospitalId,jdbcType=BIGINT}
			</if>
			<if test="departmentId != null">
				and department_id = #{departmentId,jdbcType=BIGINT}
			</if>
			<if test="scheduleId != null">
				and schedule_id = #{scheduleId,jdbcType=BIGINT}
			</if>
			<if test="doctorId != null">
				and doctor_id = #{doctorId,jdbcType=BIGINT}
			</if>
		</where>
	</select>
</mapper>
