SmartUserRelationMapper.xml 13.3 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="cn.com.glsx.smart.modules.mapper.SmartUserRelationMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.smart.modules.entity.SmartUserRelation">
        <!--@mbg.generated-->
        <!--@Table smart_user_relation-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="phone" jdbcType="VARCHAR" property="phone"/>
        <result column="password" jdbcType="VARCHAR" property="password"/>
        <result column="channel" jdbcType="TINYINT" property="channel"/>
        <result column="third_id" jdbcType="VARCHAR" property="thirdId"/>
        <result column="source" jdbcType="VARCHAR" property="source"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, `name`, user_id, phone, `password`, channel, third_id, `source`, `status`, remark, create_time
    </sql>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update smart_user_relation
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="`name` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.name,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="phone = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.phone,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="`password` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.password,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="channel = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.channel,jdbcType=TINYINT}
                </foreach>
            </trim>
            <trim prefix="third_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.thirdId,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="`status` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.status,jdbcType=TINYINT}
                </foreach>
            </trim>
            <trim prefix="remark = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update smart_user_relation
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="`name` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.name != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.name,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="phone = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.phone != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.phone,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="`password` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.password != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.password,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="channel = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.channel != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.channel,jdbcType=TINYINT}
                    </if>
                </foreach>
            </trim>
            <trim prefix="third_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.thirdId != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.thirdId,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="`status` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.status != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.status,jdbcType=TINYINT}
                    </if>
                </foreach>
            </trim>
            <trim prefix="remark = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.remark != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.createTime != null">
                        when id = #{item.id,jdbcType=BIGINT} then
                        #{item.createTime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_user_relation
        (`name`, phone, `password`, channel, third_id, `status`, remark, create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.name,jdbcType=VARCHAR}, #{item.phone,jdbcType=VARCHAR},
            #{item.password,jdbcType=VARCHAR},
            #{item.channel,jdbcType=TINYINT}, #{item.thirdId,jdbcType=VARCHAR},
            #{item.status,jdbcType=TINYINT},
            #{item.remark,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP})
        </foreach>
    </insert>
    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
            parameterType="cn.com.glsx.smart.modules.entity.SmartUserRelation" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_user_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            `name`,
            phone,
            `password`,
            channel,
            third_id,
            `status`,
            remark,
            create_time,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            #{name,jdbcType=VARCHAR},
            #{phone,jdbcType=VARCHAR},
            #{password,jdbcType=VARCHAR},
            #{channel,jdbcType=TINYINT},
            #{thirdId,jdbcType=VARCHAR},
            #{status,jdbcType=TINYINT},
            #{remark,jdbcType=VARCHAR},
            #{createTime,jdbcType=TIMESTAMP},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            `name` = #{name,jdbcType=VARCHAR},
            phone = #{phone,jdbcType=VARCHAR},
            `password` = #{password,jdbcType=VARCHAR},
            channel = #{channel,jdbcType=TINYINT},
            third_id = #{thirdId,jdbcType=VARCHAR},
            `status` = #{status,jdbcType=TINYINT},
            remark = #{remark,jdbcType=VARCHAR},
            create_time = #{createTime,jdbcType=TIMESTAMP},
        </trim>
    </insert>
    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="cn.com.glsx.smart.modules.entity.SmartUserRelation" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_user_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="name != null and name != ''">
                `name`,
            </if>
            <if test="phone != null and phone != ''">
                phone,
            </if>
            <if test="password != null and password != ''">
                `password`,
            </if>
            <if test="channel != null">
                channel,
            </if>
            <if test="thirdId != null and thirdId != ''">
                third_id,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="remark != null and remark != ''">
                remark,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="name != null and name != ''">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="phone != null and phone != ''">
                #{phone,jdbcType=VARCHAR},
            </if>
            <if test="password != null and password != ''">
                #{password,jdbcType=VARCHAR},
            </if>
            <if test="channel != null">
                #{channel,jdbcType=TINYINT},
            </if>
            <if test="thirdId != null and thirdId != ''">
                #{thirdId,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=TINYINT},
            </if>
            <if test="remark != null and remark != ''">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            <if test="name != null and name != ''">
                `name` = #{name,jdbcType=VARCHAR},
            </if>
            <if test="phone != null and phone != ''">
                phone = #{phone,jdbcType=VARCHAR},
            </if>
            <if test="password != null and password != ''">
                `password` = #{password,jdbcType=VARCHAR},
            </if>
            <if test="channel != null">
                channel = #{channel,jdbcType=TINYINT},
            </if>
            <if test="thirdId != null and thirdId != ''">
                third_id = #{thirdId,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=TINYINT},
            </if>
            <if test="remark != null and remark != ''">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <select id="getSingle" parameterType="cn.com.glsx.smart.modules.entity.SmartUserRelation" resultMap="BaseResultMap">
        select
            <include refid="Base_Column_List" />
        from smart_user_relation
        where 1 = 1
        <if test="id != null">
            and id = #{id,jdbcType=BIGINT}
        </if>
        <if test="userId != null">
            and user_id = #{userId,jdbcType=BIGINT}
        </if>
        <if test="phone != null and phone != ''">
            and phone = #{phone,jdbcType=VARCHAR}
        </if>
        <if test="channel != null">
            and channel = #{channel,jdbcType=TINYINT}
        </if>
        limit 1
  </select>
</mapper>