<?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.saye.hospitalgd.mapper.OperatorMapper">

    <select id="findAllOperator" parameterType="HashMap" resultType="HashMap">
        select hisoper_id, HisOperCode,user_name,modify_time
        from his_operator
        <where>
            is_active = 1
            <if test="likeFiled!=null and likeFiled!=''">
                and (HisOperCode like concat('%',concat(#{likeFiled},'%'))
                or user_name like concat('%',concat(#{likeFiled},'%'))
                )
            </if>
        </where>

    </select>

    <select id="findAllOperatorByCode" parameterType="HashMap" resultType="HashMap">
        select hisoper_id, HisOperCode, user_name, modify_time
        from his_operator
        where HisOperCode = #{hisOperCode}
    </select>

    <select id="findMilitaryOperators" parameterType="HashMap" resultType="HashMap">
        select HisOperCode
        from his_operator
        where is_active = 1 and user_name = '军保支付'
    </select>

    <insert id="addOperator" parameterType="HashMap">
        insert into his_operator(HisOperCode, user_name, is_active, modify_time)
        values (#{hisOperCode}, #{userName}, #{is_active}, #{modify_time})
    </insert>

    <update id="updateOperatorByCode" parameterType="HashMap">
        update his_operator
        set
        <if test="userName!=null and userName!=''">
            user_name=#{userName},
        </if>
        <if test="hisOperCode!=null and hisOperCode!=''">
            HisOperCode=#{hisOperCode},
        </if>
        <if test="is_active!=null and is_active!=''">
            is_active=#{is_active},
        </if>
        modify_time=#{modify_time}
        where hisoper_id=#{hisoperId}
    </update>

</mapper>