UserProfileMapper.xml 5.83 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.unions.dal.IUserProfileDAO">
	<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UserProfile">
		<id column="uid" property="uid" jdbcType="INTEGER" />
		<result column="email" property="email" jdbcType="VARCHAR" />
		<result column="mobile" property="mobile" jdbcType="VARCHAR" />
		<result column="password" property="password" jdbcType="VARCHAR" />
		<result column="user_source" property="userSource" jdbcType="TINYINT" />
		<result column="create_time" property="createTime" jdbcType="INTEGER" />
		<result column="user_channel" property="userChannel" jdbcType="SMALLINT" />
		<result column="status" property="status" jdbcType="TINYINT" />
		<result column="sso_password" property="ssoPassword" jdbcType="VARCHAR" />
	</resultMap>
	<sql id="Base_Column_List">
		uid, email, mobile, password, user_source, create_time, user_channel,
		status, sso_password
	</sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List" />
		from user_profile
		where uid = #{uid,jdbcType=INTEGER}
	</select>
	<select id="selectProfileByEmail" resultMap="BaseResultMap" parameterType="java.lang.String">
		select
		<include refid="Base_Column_List" />
		from user_profile
		where email=#{email} and status=1 limit 1
	</select>
	<select id="selectProfileByMobile" resultMap="BaseResultMap" parameterType="java.lang.String">
		select
		<include refid="Base_Column_List" />
		from user_profile
		where mobile=#{mobile} and status=1 limit 1
	</select>
	<select id="selectProfileByMobileForForeign" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from user_profile
		where mobile=#{mobile1} or mobile=#{mobile2} and status=1 limit 1
	</select>
	<insert id="insert" useGeneratedKeys="true" keyProperty="uid" parameterType="com.yoho.unions.dal.model.UserProfile">
		insert into user_profile (email, mobile,
		password, user_source, create_time,
		user_channel, status)
		values
		(#{email,jdbcType=VARCHAR},
		#{mobile,jdbcType=VARCHAR},
		#{password,jdbcType=VARCHAR}, #{userSource,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER},
		#{userChannel,jdbcType=SMALLINT},
		#{status,jdbcType=TINYINT})
	</insert>
	<insert id="insertSelective" useGeneratedKeys="true" keyProperty="uid" parameterType="com.yoho.unions.dal.model.UserProfile">
		insert into user_profile
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="uid != null">
				uid,
			</if>
			<if test="email != null">
				email,
			</if>
			<if test="mobile != null">
				mobile,
			</if>
			<if test="password != null">
				password,
			</if>
			<if test="userSource != null">
				user_source,
			</if>
			<if test="createTime != null">
				create_time,
			</if>
			<if test="userChannel != null">
				user_channel,
			</if>
			<if test="status != null">
				status,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="uid != null">
				#{uid,jdbcType=INTEGER},
			</if>
			<if test="email != null">
				#{email,jdbcType=VARCHAR},
			</if>
			<if test="mobile != null">
				#{mobile,jdbcType=VARCHAR},
			</if>
			<if test="password != null">
				#{password,jdbcType=VARCHAR},
			</if>
			<if test="userSource != null">
				#{userSource,jdbcType=TINYINT},
			</if>
			<if test="createTime != null">
				#{createTime,jdbcType=INTEGER},
			</if>
			<if test="userChannel != null">
				#{userChannel,jdbcType=SMALLINT},
			</if>
			<if test="status != null">
				#{status,jdbcType=TINYINT},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UserProfile">
		update user_profile
		<set>
			<if test="email != null">
				email = #{email,jdbcType=VARCHAR},
			</if>
			<if test="mobile != null">
				mobile = #{mobile,jdbcType=VARCHAR},
			</if>
			<if test="password != null">
				password = #{password,jdbcType=VARCHAR},
			</if>
			<if test="userSource != null">
				user_source = #{userSource,jdbcType=TINYINT},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=INTEGER},
			</if>
			<if test="userChannel != null">
				user_channel = #{userChannel,jdbcType=SMALLINT},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=TINYINT},
			</if>
			<if test="ssoPassword != null">
				sso_password = #{ssoPassword,jdbcType=VARCHAR},
			</if>
		</set>
		where uid = #{uid,jdbcType=INTEGER}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UserProfile">
		update user_profile
		set email = #{email,jdbcType=VARCHAR},
		mobile = #{mobile,jdbcType=VARCHAR},
		password = #{password,jdbcType=VARCHAR},
		user_source =
		#{userSource,jdbcType=TINYINT},
		create_time = #{createTime,jdbcType=INTEGER},
		user_channel = #{userChannel,jdbcType=SMALLINT},
		status = #{status,jdbcType=TINYINT}
		where uid = #{uid,jdbcType=INTEGER}
	</update>

	<select id="selectProfileByUIds" resultMap="BaseResultMap" parameterType="java.util.List">
		select
		<include refid="Base_Column_List" />
		from user_profile where uid in
		<foreach collection="list" item="item" open="(" close=")" separator=",">
			#{item}
		</foreach>
	</select>


	<select id="selectCountByUidOrMobileOrEmail" resultType="java.lang.Integer">
	 SELECT COUNT(1) from
		user_profile
		where 1=1
		<if test="list!=null and list.size !=0">
			AND uid in
			<foreach collection="list" item="item" open="(" close=")" separator=",">
				#{item}
			</foreach>
		</if>
		<if test="mobile !=null">
			and mobile = #{mobile}
		</if>
		<if test="email !=null">
			and email = #{email}
		</if>
		<if test = "startTime !=null and startTime != 0">
			and create_time &lt;#{startTime}
		</if>
		<if test="endTime !=null and endTime !=0">
			and create_time &gt;#{endTime}
		</if>
	</select>
</mapper>