MetaConfigMapper.xml 3.01 KB
<?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.yoho.order.dal.MetaConfigMapper">
    <resultMap id="BaseResultMap" type="com.yoho.order.model.MetaConfig">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="code" jdbcType="VARCHAR" property="code" />
        <result column="title" jdbcType="VARCHAR" property="title" />
        <result column="create_time" jdbcType="INTEGER" property="createTime" />
        <result column="desc" jdbcType="VARCHAR" property="desc" />
        <result column="value" property="value" jdbcType="VARCHAR" />
    </resultMap>


    <sql id="Base_Column_List">
        id, code, title,`desc`, create_time
    </sql>

    <select id="selectByPrimaryKey" parameterType="int" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>,`value`
        from meta_config
        where id = #{id}
        limit 1
    </select>

    <select id="countByCondition" parameterType="com.yoho.order.model.MetaConfigReq" resultType="int">
        select count(1)
        from meta_config
        <where>
            1 = 1
            <if test="code != null and code != ''">
                and code like concat('%',#{code,jdbcType=VARCHAR},'%')
            </if>
            <if test="title != null and title != ''">
                and title like concat('%', #{title,jdbcType=VARCHAR},'%')
            </if>
        </where>
    </select>

    <select id="listByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.MetaConfigReq">
        select
        <include refid="Base_Column_List"/>
        from meta_config
        <where>
            1 = 1
            <if test="code != null and code != ''">
                and code like concat('%',#{code,jdbcType=VARCHAR},'%')
            </if>
            <if test="title != null and title != ''">
                and title like concat('%', #{title,jdbcType=VARCHAR},'%')
            </if>
        </where>
        order by id asc
        limit #{start},#{size}
    </select>

    <select id="selectByCode" parameterType="string" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>,`value`
        from meta_config
        where code = #{code,jdbcType=VARCHAR}
        limit 1
    </select>

    <update id="updateByPrimaryKey" parameterType="com.yoho.order.model.MetaConfig">
        update meta_config
        <set>
            <if test="code != null and code != ''">
                code = #{code,jdbcType=VARCHAR},
            </if>
            <if test="title != null and title != ''">
                title = #{title,jdbcType=VARCHAR},
            </if>
            <if test="desc != null and desc != ''">
                `desc` = #{desc,jdbcType=VARCHAR},
            </if>
            <if test="value != null and value != ''">
                `value` = #{value,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>