<?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.ghy.system.mapper.SysDeptConfigMapper">
    <resultMap id="SysDeptConfigResult" type="com.ghy.system.domain.SysDeptConfig">
        <result property="sysDeptConfigId"          column="sys_dept_config_id"/>
        <result property="deptId"                   column="dept_id"/>
        <result property="bannerUrl"                column="banner_url"/>
        <result property="adapayAppId"              column="adapay_app_id"/>
        <result property="adapayApiKey"             column="adapay_api_key"/>
        <result property="adapayMockApiKey"         column="adapay_mock_key"/>
        <result property="adapayRsaPrivateKey"      column="adapay_rsa_private_key"/>
        <result property="adapayMaxRetryTimes"      column="adapay_max_retry_times"/>
        <result property="wxAppId"                  column="wx_app_id"/>
        <result property="wxSecret"                 column="wx_secret"/>
        <result property="servWxAppId"                 column="serv_wx_app_id"/>
        <result property="servWxSecret"                 column="serv_wx_secret"/>
        <result property="takeRate"                 column="take_rate"/>
        <result property="createBy"                 column="create_by"/>
        <result property="createTime"               column="create_time"/>
        <result property="updateBy"                 column="update_by"/>
        <result property="updateTime"               column="update_time"/>
        <result property="remark"                   column="remark"/>
    </resultMap>

    <sql id="selectSysDeptConfig">
        SELECT sys_dept_config_id, dept_id, banner_url, adapay_app_id, adapay_api_key, adapay_mock_key,
               adapay_rsa_private_key, adapay_max_retry_times, wx_app_id, wx_secret, serv_wx_app_id, serv_wx_secret, take_rate,
               create_by, create_time, update_by, update_time, remark
        FROM sys_dept_config
    </sql>

    <select id="selectByDeptId" parameterType="long" resultMap="SysDeptConfigResult">
        <include refid="selectSysDeptConfig"/>
        <where>
            <if test="deptId != null and deptId != 0">
                AND dept_id = #{deptId}
            </if>
        </where>

    </select>

    <select id="selectAllMerchant" resultMap="SysDeptConfigResult">
        <include refid="selectSysDeptConfig"/>
        WHERE adapay_app_id IS NOT NULL
        AND adapay_api_key IS NOT NULL
    </select>

</mapper>