All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mybatis.mapper.p_app_user.xml Maven / Gradle / Ivy

<?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">

<!-- Automatic generated on 2020-08-18 10:59:40 by CrudCodeGenerator wirtten by Gerald Chen -->

<mapper namespace="com.github.javaclub.base.mapper.AppUserDAO">

	<resultMap type="com.github.javaclub.base.domain.AppUserDO" id="wxUserMap">
        <result property="id" column="id" />
        <result property="mobile" column="mobile" />
        <result property="openId" column="open_id" />
        <result property="referUserId" column="refer_user_id" />
        <result property="nickname" column="nickname" />
        <result property="name" column="name" />
        <result property="extraId" column="extra_id" />
        <result property="extraName" column="extra_name" />
        <result property="gender" column="gender" />
        <result property="status" column="status" />
        <result property="userAvatar" column="user_avatar" />
        <result property="gmtModify" column="gmt_modified" />
        <result property="gmtCreate" column="gmt_create" />
        <result property="deleteFlag" column="delete_flag" />
        <result property="locationIp" column="location_ip" />
        <result property="attributes" column="attributes" />
        <result property="version" column="version" />

    </resultMap>
    
    <sql id="AllColumns">
		id,
		mobile,
		open_id,
		refer_user_id,
		nickname,
		name,
		extra_id,
		extra_name,
		gender,
		status,
		user_avatar,
		gmt_modified,
		gmt_create,
		delete_flag,
		location_ip,
		attributes, 
		version
    </sql>
    
    <sql id="InfoManageSet">
        <set>
			<if test="mobile != null">mobile=#{mobile},</if>
			<if test="openId != null">open_id=#{openId},</if>
			<if test="referUserId != null">refer_user_id=#{referUserId},</if>
			<if test="nickname != null">nickname=#{nickname},</if>
			<if test="name != null">name=#{name},</if>
			<if test="extraId != null">extra_id=#{extraId},</if>
			<if test="extraName != null">extra_name=#{extraName},</if>
			<if test="gender != null">gender=#{gender},</if>
			<if test="status != null">status=#{status},</if>
			<if test="userAvatar != null">user_avatar=#{userAvatar},</if>
			<if test="deleteFlag != null">delete_flag=#{deleteFlag},</if>
			<if test="locationIp != null">location_ip=#{locationIp},</if>
			<if test="attributes != null">attributes=#{attributes},</if>
			<if test="version != null">version=#{version},</if>

        </set>
    </sql>
    
    <sql id="Where_QueryCondition">
        <where>
			<if test="id != null">
			    id = #{id} 
			</if>
			<if test="nicknameLike != null">
            		AND nickname LIKE CONCAT('%', #{nicknameLike}, '%') 
     		</if>
     		<if test="mobile != null">
			    AND mobile = #{mobile} 
     		</if>
     		<if test="openId != null">
			    AND open_id = #{openId} 
     		</if>
     		<if test="extraId != null">
			    AND extra_id = #{extraId} 
     		</if>
     		<if test="extraName != null">
            		AND extra_name LIKE CONCAT('%', #{extraName}, '%') 
     		</if>
     		<if test="queryExtra != null and queryExtra == true">
     		 <![CDATA[
			    AND extra_id > 0 
			 ]]>
     		</if>
     		<if test="queryExtra != null and queryExtra == false">
     		 <![CDATA[
			    AND extra_id = 0 
			 ]]>
     		</if>
	        
	        <if test="minId != null">
	            <![CDATA[
	            AND id >= #{minId} 
	        	]]>
	        </if>
	        <if test="maxId != null">
	            <![CDATA[
	            AND id <= #{maxId} 
	        	]]>
	        </if>
	        <if test="ids != null and ids.size() > 0">
	            AND id IN
	            <foreach item="id" index="index" collection="ids"
	                     open="(" separator="," close=")">
	                #{id}
	            </foreach>
	        </if>
	        
	        <if test="gmtCreateRange != null and gmtCreateRange.start != null">
	            <![CDATA[
	            AND gmt_create >= #{gmtCreateRange.start} 
	        	]]>
	        </if>
	        <if test="gmtCreateRange != null and gmtCreateRange.end != null">
	            <![CDATA[
	            AND gmt_create <= #{gmtCreateRange.end} 
	        	]]>
	        </if>
	        <if test="gmtModifyRange != null and gmtModifyRange.start != null">
	            <![CDATA[
	            AND gmt_modified >= #{gmtModifyRange.start} 
	        	]]>
	        </if>
	        <if test="gmtModifyRange != null and gmtModifyRange.end != null">
	            <![CDATA[
	            AND gmt_modified <= #{gmtModifyRange.end} 
	        	]]>
	        </if>
        </where>
    </sql>
    
    
    <sql id="OrderBy">
        <choose>
	        <when test="orderByList != null and orderByList.size() > 0">
	            <foreach item="orderby" index="index" collection="orderByList" open="" separator="," close="">
                	${orderby.key} ${orderby.value}
            	</foreach>
	        </when>
	        <otherwise>
	            gmt_create DESC 
	        </otherwise>
        </choose>
    </sql>
    
    <select id="getById" resultMap="wxUserMap">
	    	SELECT  
	    		<include refid="AllColumns" /> 
	    	FROM p_app_user WHERE id = #{id} LIMIT 1
    </select>
    
    <select id="getByOpenId" resultMap="wxUserMap">
	    	SELECT  
	    		<include refid="AllColumns" /> 
	    	FROM p_app_user WHERE open_id = #{openId} LIMIT 1
    </select>
    
    <select id="getByMobile" resultMap="wxUserMap">
	    	SELECT  
	    		<include refid="AllColumns" /> 
	    	FROM p_app_user WHERE mobile = #{mobile} LIMIT 1
    </select>
    
    <select id="queryList" parameterType="com.github.javaclub.base.domain.query.AppUserQuery" resultMap="wxUserMap">
	    	SELECT  
	    		<include refid="AllColumns" />
	    	FROM p_app_user  
	    		<include refid="Where_QueryCondition" />
	    	ORDER BY 
	    		<include refid="OrderBy" /> 
	    LIMIT #{start}, #{limit}
    </select>
    
    <select id="count" parameterType="com.github.javaclub.base.domain.query.AppUserQuery" resultType="java.lang.Integer">
	    	SELECT count(id) 
	    	FROM p_app_user  
	    	<include refid="Where_QueryCondition" />
    </select>
    
    <insert id="insert" parameterType="com.github.javaclub.base.domain.AppUserDO" useGeneratedKeys="true" keyProperty="id">
        INSERT p_app_user 
        <include refid="InfoManageSet" />
    </insert>
    
    <insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> 
	    INSERT INTO p_app_user(mobile,open_id,refer_user_id,name,extra_id,extra_name,gender,status,user_avatar,gmt_modified,gmt_create,delete_flag,location_ip,attributes,version)
	    VALUES 
	    <foreach collection="list" item="obj" index="index" separator=",">  
	       (#{obj.mobile},#{obj.openId},#{obj.referUserId},#{obj.name},#{obj.extraId},#{obj.extraName},#{obj.gender},#{obj.status},#{obj.userAvatar},now(),now(),#{obj.deleteFlag},#{obj.locationIp},#{obj.attributes},#{obj.version})
	    </foreach>  
    </insert>

    <update id="update" parameterType="com.github.javaclub.base.domain.AppUserDO">
        UPDATE p_app_user 
        <include refid="InfoManageSet" />
        WHERE id = #{id}
    </update>
    
    <update id="setNickName" parameterType="com.github.javaclub.base.domain.AppUserDO">
        UPDATE p_app_user SET nickname = #{nickname} WHERE id = #{id}
    </update>
    
    <update id="setUserStatus">
        UPDATE p_app_user SET status = #{status} WHERE id = #{id}
    </update>
    
    <update id="updateUserMobile">
        UPDATE p_app_user SET mobile = #{mobile} WHERE id = #{userId}
    </update>
    
    <update id="unauthorizedMobile">
        UPDATE p_app_user SET mobile = NULL WHERE id = #{userId}
    </update>
    
    <update id="bindExtra">
        UPDATE p_app_user SET extra_id = #{extraId}, extra_name = #{extraName} WHERE id = #{userId}
    </update>
    
    <update id="unbindExtra">
        UPDATE p_app_user SET extra_id = 0, extra_name = NULL WHERE id = #{userId}
    </update>
    
    <update id="updateUsernickAndUserAvatar">
        UPDATE p_app_user SET version = version + 1
        <if test="nickname != null">
	        <![CDATA[
	            , nickname = #{nickname}
	        	]]>
	    </if>
	    <if test="userAvatar != null">
	        <![CDATA[
	            , user_avatar = #{userAvatar} 
	        	]]>
	    </if>
        WHERE id = #{id} 
        <if test="version != null">
	        <![CDATA[
	            AND version = #{version} 
	        	]]>
	    </if>
    </update>
    
    <update id="updateAttributes">
    		<choose>
	        <when test="version != null">
	        		UPDATE p_app_user SET attributes = #{attributes}, version = version + 1 WHERE id = #{id} AND version = #{version}
	        </when>
	        <otherwise>
	        		UPDATE p_app_user SET attributes = #{attributes} WHERE id = #{id} 
	        </otherwise>
        </choose>
    </update>
    
    <delete id="deleteById">
    		DELETE FROM p_app_user WHERE id = #{id}
    </delete>

	
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy