SysUserServicesMapper.xml 10.1 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.glsx.usercenter.mapper.SysUserServicesMapper">
    <resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.user.SysUserServices">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="user_id" jdbcType="INTEGER" property="userId" />
        <result column="service_key" jdbcType="VARCHAR" property="serviceKey" />
        <result column="install_time" jdbcType="INTEGER" property="installTime" />
        <result column="merchant_status" jdbcType="VARCHAR" property="merchantStatus" />
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        id, user_id, service_key, install_time, merchant_status
    </sql>
    <select id="selectByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample" resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        'false' as QUERYID,
        <include refid="Base_Column_List" />
        from sys_user_services
        <if test="_parameter != null">
            <include refid="Example_Where_Clause" />
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from sys_user_services
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from sys_user_services
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample">
        delete from sys_user_services
        <if test="_parameter != null">
            <include refid="Example_Where_Clause" />
        </if>
    </delete>
    <insert id="insert" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into sys_user_services (user_id, service_key, install_time,
        merchant_status)
        values (#{userId,jdbcType=INTEGER}, #{serviceKey,jdbcType=VARCHAR}, #{installTime,jdbcType=INTEGER},
        #{merchantStatus,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into sys_user_services
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">
                user_id,
            </if>
            <if test="serviceKey != null">
                service_key,
            </if>
            <if test="installTime != null">
                install_time,
            </if>
            <if test="merchantStatus != null">
                merchant_status,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">
                #{userId,jdbcType=INTEGER},
            </if>
            <if test="serviceKey != null">
                #{serviceKey,jdbcType=VARCHAR},
            </if>
            <if test="installTime != null">
                #{installTime,jdbcType=INTEGER},
            </if>
            <if test="merchantStatus != null">
                #{merchantStatus,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample" resultType="java.lang.Long">
        select count(*) from sys_user_services
        <if test="_parameter != null">
            <include refid="Example_Where_Clause" />
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update sys_user_services
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.userId != null">
                user_id = #{record.userId,jdbcType=INTEGER},
            </if>
            <if test="record.serviceKey != null">
                service_key = #{record.serviceKey,jdbcType=VARCHAR},
            </if>
            <if test="record.installTime != null">
                install_time = #{record.installTime,jdbcType=INTEGER},
            </if>
            <if test="record.merchantStatus != null">
                merchant_status = #{record.merchantStatus,jdbcType=VARCHAR},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause" />
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update sys_user_services
        set id = #{record.id,jdbcType=INTEGER},
        user_id = #{record.userId,jdbcType=INTEGER},
        service_key = #{record.serviceKey,jdbcType=VARCHAR},
        install_time = #{record.installTime,jdbcType=INTEGER},
        merchant_status = #{record.merchantStatus,jdbcType=VARCHAR}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause" />
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
        update sys_user_services
        <set>
            <if test="userId != null">
                user_id = #{userId,jdbcType=INTEGER},
            </if>
            <if test="serviceKey != null">
                service_key = #{serviceKey,jdbcType=VARCHAR},
            </if>
            <if test="installTime != null">
                install_time = #{installTime,jdbcType=INTEGER},
            </if>
            <if test="merchantStatus != null">
                merchant_status = #{merchantStatus,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
        update sys_user_services
        set user_id = #{userId,jdbcType=INTEGER},
        service_key = #{serviceKey,jdbcType=VARCHAR},
        install_time = #{installTime,jdbcType=INTEGER},
        merchant_status = #{merchantStatus,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>

    <delete id="deleteByUserIdAndServiceId">
        DELETE FROM sys_user_services
        WHERE user_id = #{userId,jdbcType=INTEGER} AND service_key = #{item,jdbcType=VARCHAR}
    </delete>

    <select id="selectByUserId" resultType="com.glsx.usercenter.pojo.user.SysUserServices">
        SELECT
        user_id     userId,
        service_key serviceKey
        FROM sys_user_services
        WHERE user_id = #{userId,jdbcType=INTEGER}
    </select>

</mapper>