<?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.tofly.feesapi.common.mapper.CommonMapper">
    <select id="queryForPage" resultType="map">
        ${sql}
    </select>

    <select id="query" resultType="java.util.HashMap">
        ${sql}
    </select>

    <select id="procedureCmd" statementType="CALLABLE" parameterType="java.util.Map" resultType="java.util.HashMap">
        ${sql}
    </select>

    <!--此定义主要用于返回Object-->
    <resultMap id="mapCus" type="java.util.HashMap">
    </resultMap>

    <!--通过角色ID获取用户信息-->
    <select id="getUserListByRoleId" resultType="java.util.HashMap">
        SELECT ID as "code", REAL_NAME as "name"
        FROM TF_SMPN_USER_X
        WHERE ID IN (SELECT USER_ID FROM TF_SMPN_USERROLE_X
        <where>
            <if test="userRoleEnum!=null">
                ROLE_ID = #{userRoleEnum}
            </if>
        </where>
        )
    </select>

    <!--通过PZID值获取配置信息-->
    <select id="getConfigValueByPZID" resultType="String">
        select value from TF_YWYS_SYS_CONFIG
        <where>
            <if test="pzid!=null and pzid!=''">
                pzid = #{pzid}
            </if>
        </where>
    </select>

    <!--获取当前的财务日期-->
    <select id="getBillMonthByCompanyBranch" resultType="String">
        select bill_year_month as cwrq
        from tf_ywys_sys_gdcsb
        where gd_flag = '0'
        <if test="companyBranch!=null and companyBranch!=''">
            and company_Branch=#{companyBranch}
        </if>
    </select>

    <!--通过用户ID获取用户信息-->
    <select id="getUserInfoByUserId" resultType="com.tofly.feesapi.common.model.SystemUserInfo">
        SELECT id, username, phone, avatar, department_id as departmentId, real_name as realName
        FROM TF_SMPN_USER_X
        WHERE username = #{userId}
    </select>

    <!--通过用户ID获取用户信息-->
    <select id="getCwrq" resultType="String">
        select cwrq as cwrq
        from sys_gdcsb
        where gd_flag = '0'
        <if test="ssgs!=null and ssgs!=''">
            and ssgs=#{ssgs}
        </if>
    </select>

    <!--通过角色ID获取用户信息-->
    <select id="getAllOperater" resultType="java.util.HashMap">
        select ID as "code", REAL_NAME as "name" from tf_smpn_user_x where (job !='抄表外包人员' or job is null ) and department_id='77'
    </select>
</mapper>
