<?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.xhpc.pp.mapper.ServiceFieldMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.pp.domain.ServiceField">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="service_name" property="serviceName" jdbcType="VARCHAR"/>
        <result column="version" property="version" jdbcType="VARCHAR"/>
        <result column="code" property="code" jdbcType="VARCHAR"/>
        <result column="len" property="len" jdbcType="INTEGER"/>
        <result column="seq" property="seq" jdbcType="INTEGER"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="data_type" property="dataType" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        , service_name, version, code, len, seq, remark, data_type
    </sql>

    <select id="querySQL" parameterType="java.util.Map" resultType="java.util.Map">
        ${sql}
    </select>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from service_field
        where id = #{id,jdbcType=BIGINT}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from service_field
        where id = #{id,jdbcType=BIGINT}
    </delete>

    <insert id="insert" parameterType="com.xhpc.pp.domain.ServiceField">
        insert into service_field (id, service_name, version,
                                   code, len, seq,
                                   remark)
        values (#{id,jdbcType=BIGINT}, #{serviceName,jdbcType=VARCHAR}, #{version,jdbcType=VARCHAR},
                #{code,jdbcType=VARCHAR}, #{len,jdbcType=INTEGER}, #{seq,jdbcType=INTEGER},
                #{remark,jdbcType=VARCHAR})
    </insert>

    <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.pp.domain.ServiceField">
        update service_field
        <set>
            <if test="serviceName != null">
                service_name = #{serviceName,jdbcType=VARCHAR},
            </if>
            <if test="version != null">
                version = #{version,jdbcType=VARCHAR},
            </if>
            <if test="code != null">
                code = #{code,jdbcType=VARCHAR},
            </if>
            <if test="len != null">
                len = #{len,jdbcType=INTEGER},
            </if>
            <if test="seq != null">
                seq = #{seq,jdbcType=INTEGER},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>

    <select id="query" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from service_field
        where 1 = 1
        <if test="serviceName != null">
            and service_name = #{serviceName,jdbcType=VARCHAR}
        </if>
        <if test="version != null">
            and version = #{version,jdbcType=VARCHAR}
        </if>
        <if test="code != null">
            and code = #{code,jdbcType=VARCHAR}
        </if>
        order by version asc, service_name asc, seq asc
    </select>
</mapper>
