<?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.system.FinanceUserMapper">

    <!-- 查询财务人员列表 -->
    <select id="findFinanceUserPageList" parameterType="HashMap" resultType="com.saye.hospitalgd.model.FinanceUser">
        SELECT 
            id,
            name,
            wechat_name as wechatName,
            phone,
            open_id as openId,
            is_active as isActive,
            create_time as createTime,
            modify_time as modifyTime,
            remark
        FROM finance_user
        <where>
            <if test="name != null and name != ''">
                AND name LIKE CONCAT('%', #{name}, '%')
            </if>
            <if test="wechatName != null and wechatName != ''">
                AND wechat_name LIKE CONCAT('%', #{wechatName}, '%')
            </if>
            <if test="phone != null and phone != ''">
                AND phone LIKE CONCAT('%', #{phone}, '%')
            </if>
            <if test="isActive != null and isActive != ''">
                AND is_active = #{isActive}
            </if>
        </where>
        ORDER BY create_time DESC
    </select>

    <!-- 添加财务人员 -->
    <insert id="addFinanceUser" parameterType="com.saye.hospitalgd.model.FinanceUser">
        INSERT INTO finance_user (
            id,
            name,
            wechat_name,
            phone,
            open_id,
            is_active,
            create_time,
            modify_time,
            remark
        ) VALUES (
            #{id},
            #{name},
            #{wechatName},
            #{phone},
            #{openId},
            #{isActive},
            #{createTime},
            #{modifyTime},
            #{remark}
        )
    </insert>

    <!-- 修改财务人员 -->
    <update id="updateFinanceUser" parameterType="com.saye.hospitalgd.model.FinanceUser">
        UPDATE finance_user SET
            name = #{name},
            wechat_name = #{wechatName},
            phone = #{phone},
            open_id = #{openId},
            is_active = #{isActive},
            modify_time = #{modifyTime},
            remark = #{remark}
        WHERE id = #{id}
    </update>

    <!-- 删除财务人员 -->
    <delete id="deleteFinanceUser" parameterType="String">
        DELETE FROM finance_user WHERE id = #{id}
    </delete>

    <!-- 根据ID查询财务人员 -->
    <select id="findFinanceUserById" parameterType="String" resultType="com.saye.hospitalgd.model.FinanceUser">
        SELECT 
            id,
            name,
            wechat_name as wechatName,
            phone,
            open_id as openId,
            is_active as isActive,
            create_time as createTime,
            modify_time as modifyTime,
            remark
        FROM finance_user
        WHERE id = #{id}
    </select>

    <!-- 获取所有启用的财务人员 -->
    <select id="findActiveFinanceUsers" resultType="com.saye.hospitalgd.model.FinanceUser">
        SELECT 
            id,
            name,
            wechat_name as wechatName,
            phone,
            open_id as openId,
            is_active as isActive,
            create_time as createTime,
            modify_time as modifyTime,
            remark
        FROM finance_user
        WHERE is_active = '1'
        ORDER BY create_time DESC
    </select>

</mapper>





















