<?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.ym.mec.biz.dal.dao.HfMerchantConfigDao">

	<resultMap type="com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig"
		id="HfMerchantConfig">
		<result column="id_" property="id" />
		<result column="app_id_" property="appId" />
		<result column="mer_key_" property="merKey" />
		<result column="api_key_" property="apiKey" />
		<result column="mock_api_key_" property="mockApiKey" />
		<result column="rsa_private_key_" property="rsaPrivateKey" />
		<result column="rsa_public_key_" property="rsaPublicKey" />
		<result column="expend_params_" property="expendParams" />
		<result column="wx_app_id_" property="wxAppId" />
		<result column="wx_app_secret_" property="wxAppSecret" />
		<result column="platform_payee_member_id_" property="platformPayeeMemberId" />
		<result column="create_time_" property="createTime" />
		<result column="update_time_" property="updateTime" />
		<result column="tenant_id_" property="tenantId" />
	</resultMap>

	<!-- 根据主键查询一条记录 -->
	<select id="get" resultMap="HfMerchantConfig">
		SELECT * FROM
		hf_merchant_config WHERE id_ = #{id}
	</select>

	<!-- 全查询 -->
	<select id="findAll" resultMap="HfMerchantConfig">
		SELECT * FROM hf_merchant_config ORDER
		BY id_
	</select>

	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig"
		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
			AS ID FROM DUAL </selectKey> -->
		INSERT INTO hf_merchant_config
		(id_,app_id_,mer_key_,api_key_,mock_api_key_,rsa_private_key_,rsa_public_key_,expend_params_,wx_app_id_,wx_app_secret_,create_time_,update_time_,tenant_id_,platform_payee_member_id_)
		VALUES(#{id},#{appId},#{merKey},#{apiKey},#{mockApiKey},#{rsaPrivateKey},#{rsaPublicKey},#{expendParams},#{wxAppId},#{wxAppSecret},#{createTime},#{updateTime},#{tenantId},#{platformPayeeMemberId})
	</insert>

	<!-- 根据主键查询一条记录 -->
	<update id="update" parameterType="com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig">
		UPDATE hf_merchant_config
		<set>
			<if test="apiKey != null">
				api_key_ = #{apiKey},
			</if>
			<if test="appId != null">
				app_id_ = #{appId},
			</if>
			<if test="rsaPublicKey != null">
				rsa_public_key_ = #{rsaPublicKey},
			</if>
			<if test="mockApiKey != null">
				mock_api_key_ = #{mockApiKey},
			</if>
			<if test="expendParams != null">
				expend_params_ = #{expendParams},
			</if>
			<if test="id != null">
				id_ = #{id},
			</if>
			<if test="tenantId != null">
				tenant_id_ = #{tenantId},
			</if>
			<if test="updateTime != null">
				update_time_ = #{updateTime},
			</if>
			<if test="merKey != null">
				mer_key_ = #{merKey},
			</if>
			<if test="rsaPrivateKey != null">
				rsa_private_key_ = #{rsaPrivateKey},
			</if>
			<if test="platformPayeeMemberId != null">
				platform_payee_member_id_ = #{platformPayeeMemberId},
			</if>
			<if test="createTime != null">
				create_time_ = #{createTime},
			</if>
			<if test="wxAppId != null">
				wx_app_id_ = #{wxAppId},
			</if>
			<if test="wxAppSecret != null">
				wx_app_secret_ = #{wxAppSecret},
			</if>
		</set>
		WHERE id_ = #{id}
	</update>

	<!-- 根据主键删除一条记录 -->
	<delete id="delete">
		DELETE FROM hf_merchant_config WHERE id_ = #{id}
	</delete>

	<!-- 分页查询 -->
	<select id="queryPage" resultMap="HfMerchantConfig" parameterType="map">
		SELECT * FROM hf_merchant_config
        <include refid="queryPageSql"/>
		ORDER BY id_
		<include refid="global.limit" />
	</select>

	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM hf_merchant_config
        <include refid="queryPageSql"/>
	</select>
	
	<select id="queryByTenantId" resultMap="HfMerchantConfig">
		SELECT * FROM hf_merchant_config where tenant_id_ = #{tenantId}
	</select>

    <sql id="queryPageSql">
        <where>
            <if test="tenantId != null">
                AND tenant_id_ = #{tenantId}
            </if>
        </where>
    </sql>

</mapper>
