<?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.jkcredit.invoice.mapper.manager.ParamMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="baseResultMap" type="com.jkcredit.invoice.model.entity.manager.Param">
        <id column="id" property="id"/>
        <result column="param_name" property="paramName"/>
        <result column="param_value" property="paramValue"/>
        <result column="param_note" property="paramNote"/>
    </resultMap>

    <sql id="paramSql">
		id,
		param_name,
		param_value,
		param_note
	</sql>



    <select id="getParamsPage" resultMap="baseResultMap">
        SELECT
        <include refid="paramSql"/>
        FROM
        t_manager_param
        <where>
            <if test="query.paramName != null and query.paramName != ''">
                and param_name LIKE CONCAT('%',#{query.paramName},'%')
            </if>
            <if test="query.paramValue != null and query.paramValue != ''">
                and param_value = #{query.paramValue}
            </if>
            <if test="query.paramNote != null and query.paramNote != ''">
                and param_note LIKE CONCAT('%',#{query.paramNote},'%')
            </if>
        </where>
    </select>



    <select id="getParamByParamName" resultMap="baseResultMap">
        SELECT
        <include refid="paramSql" />
        FROM
        t_manager_param
        WHERE
        param_name = #{paramName}

    </select>




    <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.manager.Param" >
        insert into t_manager_param (
            param_name,
            param_value,
            param_note
        )
        values ( #{paramName,jdbcType=VARCHAR},#{paramValue,jdbcType=VARCHAR},#{paramNote,jdbcType=VARCHAR}
        )
    </insert>



    <update id="updateParam">
        UPDATE
        t_manager_param
        <set>
            <if test="paramName != null and paramName != ''">
                param_name = #{paramName},
            </if>
            <if test="paramValue != null and paramValue != ''">
                param_value = #{paramValue},
            </if>
            <if test="paramNote != null and paramNote != ''">
                param_note = #{paramNote},
            </if>
        </set>
        WHERE
        id = #{id}
    </update>

</mapper>
