<?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="singleMoney"    column="single_money"    />
        <result property="singleOrderPay"    column="single_order_pay"    />
        <result property="singleOrderNoPay"    column="single_order_no_pay"    />
        <result property="areaMoney"    column="area_money"    />
        <result property="areaOrderPay"    column="area_order_pay"    />
        <result property="areaOrderNoPay"    column="area_order_no_pay"    />
        <result property="cityMoney"    column="city_money"    />
        <result property="cityOrderPay"    column="city_order_pay"    />
        <result property="cityOrderNoPay"    column="city_order_no_pay"    />
        <result property="workerRate"    column="worker_rate"    />
        <result property="phone"    column="phone"    />
        <result property="plainOutTime"    column="plain_out_time"    />
        <result property="goOutTime"    column="go_out_time"    />
        <result property="goingOutTime"    column="going_out_time"    />
        <result property="goingOutTimeRate"    column="going_out_time_rate"    />
        <result property="goldenServer"    column="golden_server"    />
        <result property="monthRent"    column="month_rent"    />
        <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, single_money, single_order_pay, single_order_no_pay, area_money,
               area_order_pay, area_order_no_pay, city_money, city_order_pay, city_order_no_pay, worker_rate, phone,
               plain_out_time, go_out_time, going_out_time, going_out_time_rate, golden_server, month_rent, 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 dept_id = #{deptId}
    </select>

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

    <select id="selectSysDeptConfigBySysDeptConfigId" parameterType="Long" resultMap="SysDeptConfigResult">
        <include refid="selectSysDeptConfig"/>
        where sys_dept_config_id = #{sysDeptConfigId}
    </select>

    <select id="selectSysDeptConfigList" parameterType="com.ghy.system.domain.SysDeptConfig" resultMap="SysDeptConfigResult">
        <include refid="selectSysDeptConfig"/>
        <where>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
        </where>
    </select>

    <insert id="insertSysDeptConfig" parameterType="com.ghy.system.domain.SysDeptConfig" useGeneratedKeys="true" keyProperty="sysDeptConfigId">
        insert into sys_dept_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="bannerUrl != null">banner_url,</if>
            <if test="singleMoney != null">single_money,</if>
            <if test="singleOrderPay != null">single_order_pay,</if>
            <if test="singleOrderNoPay != null">single_order_no_pay,</if>
            <if test="areaMoney != null">area_money,</if>
            <if test="areaOrderPay != null">area_order_pay,</if>
            <if test="areaOrderNoPay != null">area_order_no_pay,</if>
            <if test="cityMoney != null">city_money,</if>
            <if test="cityOrderPay != null">city_order_pay,</if>
            <if test="cityOrderNoPay != null">city_order_no_pay,</if>
            <if test="workerRate != null">worker_rate,</if>
            <if test="phone != null">phone,</if>
            <if test="plainOutTime != null">plain_out_time,</if>
            <if test="goOutTime != null">go_out_time,</if>
            <if test="goingOutTime != null">going_out_time,</if>
            <if test="goingOutTimeRate != null">going_out_time_rate,</if>
            <if test="goldenServer != null">golden_server,</if>
            <if test="monthRent != null">month_rent,</if>
            <if test="adapayAppId != null">adapay_app_id,</if>
            <if test="adapayApiKey != null">adapay_api_key,</if>
            <if test="adapayMockApiKey != null">adapay_mock_key,</if>
            <if test="adapayRsaPrivateKey != null">adapay_rsa_private_key,</if>
            <if test="adapayMaxRetryTimes != null">adapay_max_retry_times,</if>
            <if test="wxAppId != null">wx_app_id,</if>
            <if test="wxSecret != null">wx_secret,</if>
            <if test="servWxAppId != null">serv_wx_app_id,</if>
            <if test="servWxSecret != null">serv_wx_secret,</if>
            <if test="takeRate != null">take_rate,</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>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="bannerUrl != null">#{bannerUrl},</if>
            <if test="singleMoney != null">#{singleMoney},</if>
            <if test="singleOrderPay != null">#{singleOrderPay},</if>
            <if test="singleOrderNoPay != null">#{singleOrderNoPay},</if>
            <if test="areaMoney != null">#{areaMoney},</if>
            <if test="areaOrderPay != null">#{areaOrderPay},</if>
            <if test="areaOrderNoPay != null">#{areaOrderNoPay},</if>
            <if test="cityMoney != null">#{cityMoney},</if>
            <if test="cityOrderPay != null">#{cityOrderPay},</if>
            <if test="cityOrderNoPay != null">#{cityOrderNoPay},</if>
            <if test="workerRate != null">#{workerRate},</if>
            <if test="phone != null">#{phone},</if>
            <if test="plainOutTime != null">#{plainOutTime},</if>
            <if test="goOutTime != null">#{goOutTime},</if>
            <if test="goingOutTime != null">#{goingOutTime},</if>
            <if test="goingOutTimeRate != null">#{goingOutTimeRate},</if>
            <if test="goldenServer != null">#{goldenServer},</if>
            <if test="monthRent != null">#{monthRent},</if>
            <if test="adapayAppId != null">#{adapayAppId},</if>
            <if test="adapayApiKey != null">#{adapayApiKey},</if>
            <if test="adapayMockApiKey != null">#{adapayMockApiKey},</if>
            <if test="adapayRsaPrivateKey != null">#{adapayRsaPrivateKey},</if>
            <if test="adapayMaxRetryTimes != null">#{adapayMaxRetryTimes},</if>
            <if test="wxAppId != null">#{wxAppId},</if>
            <if test="wxSecret != null">#{wxSecret},</if>
            <if test="servWxAppId != null">#{servWxAppId},</if>
            <if test="servWxSecret != null">#{servWxSecret},</if>
            <if test="takeRate != null">#{takeRate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateSysDeptConfig" parameterType="com.ghy.system.domain.SysDeptConfig">
        update sys_dept_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="bannerUrl != null">banner_url = #{bannerUrl},</if>
            <if test="singleMoney != null">single_money = #{singleMoney},</if>
            <if test="singleOrderPay != null">single_order_pay = #{singleOrderPay},</if>
            <if test="singleOrderNoPay != null">single_order_no_pay = #{singleOrderNoPay},</if>
            <if test="areaMoney != null">area_money = #{areaMoney},</if>
            <if test="areaOrderPay != null">area_order_pay = #{areaOrderPay},</if>
            <if test="areaOrderNoPay != null">area_order_no_pay = #{areaOrderNoPay},</if>
            <if test="cityMoney != null">city_money = #{cityMoney},</if>
            <if test="cityOrderPay != null">city_order_pay = #{cityOrderPay},</if>
            <if test="cityOrderNoPay != null">city_order_no_pay = #{cityOrderNoPay},</if>
            <if test="workerRate != null">worker_rate = #{workerRate},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="plainOutTime != null">plain_out_time = #{plainOutTime},</if>
            <if test="goOutTime != null">go_out_time = #{goOutTime},</if>
            <if test="goingOutTime != null">going_out_time = #{goingOutTime},</if>
            <if test="goingOutTimeRate != null">going_out_time_rate = #{goingOutTimeRate},</if>
            <if test="goldenServer != null">golden_server = #{goldenServer},</if>
            <if test="monthRent != null">month_rent = #{monthRent},</if>
            <if test="adapayAppId != null">adapay_app_id = #{adapayAppId},</if>
            <if test="adapayApiKey != null">adapay_api_key = #{adapayApiKey},</if>
            <if test="adapayMockApiKey != null">adapay_mock_key = #{adapayMockApiKey},</if>
            <if test="adapayRsaPrivateKey != null">adapay_rsa_private_key = #{adapayRsaPrivateKey},</if>
            <if test="adapayMaxRetryTimes != null">adapay_max_retry_times = #{adapayMaxRetryTimes},</if>
            <if test="wxAppId != null">wx_app_id = #{wxAppId},</if>
            <if test="wxSecret != null">wx_secret = #{wxSecret},</if>
            <if test="servWxAppId != null">serv_wx_app_id = #{servWxAppId},</if>
            <if test="servWxSecret != null">serv_wx_secret = #{servWxSecret},</if>
            <if test="takeRate != null">take_rate = #{takeRate},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where sys_dept_config_id = #{sysDeptConfigId}
    </update>

    <delete id="deleteSysDeptConfigBySysDeptConfigId" parameterType="Long">
        delete from sys_dept_config where sys_dept_config_id = #{sysDeptConfigId}
    </delete>

    <delete id="deleteSysDeptConfigBySysDeptConfigIds" parameterType="String">
        delete from sys_dept_config where sys_dept_config_id in
        <foreach item="sysDeptConfigId" collection="array" open="(" separator="," close=")">
            #{sysDeptConfigId}
        </foreach>
    </delete>

</mapper>