| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 | 
							- <?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">
 
- <!-- 命名,每一个映射对象不一样
 
- 	namespace:必须与对应的接口全类名一致
 
-  -->
 
- <mapper namespace="com.iamberry.app.mapper.UserMapper">
 
- 	<sql id="userAttribute">
 
- 		id,
 
- 		username,
 
- 		password,
 
- 		token,
 
- 		display_name,
 
- 		display_picture,
 
- 		created_on,
 
- 		ext_open_id,
 
- 		ext_name,
 
- 		ext_type,
 
- 		location,
 
- 		baby_nickname,
 
- 		baby_dob,
 
- 		baby_gender,
 
- 		status_,
 
- 		country_code,
 
- 		is_perfect_user
 
- 	</sql>
 
- 	
 
- 	<resultMap type="User" id="userMap">
 
- 		<id property="id" column="id"/>
 
- 		<result property="username" column="username"/>
 
- 		<result property="password" column="password"/>
 
- 		<result property="token" column="token"/>
 
- 		<result property="display_name" column="display_name"/>
 
- 		<result property="display_picture" column="display_picture"/>
 
- 		<result property="created_on" column="created_on"/>
 
- 		<result property="ext_open_id" column="ext_open_id"/>
 
- 		<result property="ext_name" column="ext_name"/>
 
- 		<result property="ext_type" column="ext_type"/>
 
- 		<result property="location" column="location"/>
 
- 		<result property="baby_nickname" column="baby_nickname"/>
 
- 		<result property="baby_dob" column="baby_dob"/>
 
- 		<result property="baby_gender" column="baby_gender"/>
 
- 		<result property="status_" column="status_"/>
 
- 		<result property="is_perfect_user" column="is_perfect_user"/>
 
- 		<result property="country_code" column="country_code"/>
 
- 	</resultMap>
 
- 	
 
- 	<!-- 根据id查询user所有信息 -->
 
- 	<select id="selectUserById"  parameterType="java.lang.Long" resultMap="userMap">
 
- 		SELECT 
 
- 			<include refid="userAttribute" />
 
- 		FROM USER WHERE ID = #{0}
 
- 	</select>
 
- 	
 
- 	<!-- 根据username查询user所有信息 -->
 
- 	<select id="selectUserByUsername" parameterType="java.lang.String" resultMap="userMap">
 
- 		SELECT <include refid="userAttribute" /> FROM USER WHERE USERNAME = #{0}
 
- 	</select>
 
- 	
 
- 	<!-- 通过ext_open_id查询user所有信息 -->
 
- 	<select id="selectUserByExtOpenId" parameterType="java.lang.String" resultMap="userMap">
 
- 		SELECT <include refid="userAttribute" /> FROM USER WHERE EXT_OPEN_ID = #{0}
 
- 	</select>
 
- 	
 
- 	<!-- 添加用户信息到user表中 -->
 
- 	<insert id="insertUser" parameterType="User" useGeneratedKeys="true" keyProperty="id">
 
- 		INSERT INTO USER 
 
- 		(USERNAME,PASSWORD,TOKEN,DISPLAY_NAME,DISPLAY_PICTURE,CREATED_ON,EXT_OPEN_ID,EXT_NAME,EXT_TYPE,
 
- 		LOCATION,BABY_NICKNAME,BABY_DOB,BABY_GENDER,STATUS_,country_code,is_perfect_user) 
 
- 		VALUES 
 
- 		(#{username},#{password},#{token},#{display_name},#{display_picture},NOW(),#{ext_open_id},#{ext_name},#{ext_type},
 
- 		#{location},#{baby_nickname},#{baby_dob},#{baby_gender},#{status_},#{country_code},#{is_perfect_user})
 
- 	</insert>
 
- 	
 
- 	<!-- 根据id修改user表数据 -->
 
- 	<update id="updateUser" parameterType="User">
 
- 		UPDATE USER 
 
- 		<set>
 
- 			<if test="username != null and username != ''">
 
- 				USERNAME = #{username}, 
 
- 			</if>
 
- 			<if test="password != null and password != ''">
 
- 				PASSWORD = #{password}, 
 
- 			</if>
 
- 			<if test="token != null and token != ''">
 
- 				TOKEN = #{token}, 
 
- 			</if>
 
- 			<if test="display_name != null and display_name != ''">
 
- 				DISPLAY_NAME = #{display_name}, 
 
- 			</if>
 
- 			<if test="display_picture != null and display_picture != ''">
 
- 				DISPLAY_PICTURE = #{display_picture}, 
 
- 			</if>
 
- 			<if test="ext_open_id != null and ext_open_id != ''">
 
- 				EXT_OPEN_ID = #{ext_open_id}, 
 
- 			</if>
 
- 			<if test="ext_name != null and ext_name != ''">
 
- 				EXT_NAME = #{ext_name}, 
 
- 			</if>
 
- 			<if test="ext_type != null and ext_type != ''">
 
- 				EXT_TYPE = #{ext_type}, 
 
- 			</if>
 
- 			<if test="location != null and location != ''">
 
- 				LOCATION = #{location}, 
 
- 			</if>
 
- 			<if test="baby_nickname != null and baby_nickname != ''">
 
- 				BABY_NICKNAME = #{baby_nickname}, 
 
- 			</if>
 
- 			<if test="baby_dob != null and baby_dob != ''">
 
- 				BABY_DOB = #{baby_dob}, 
 
- 			</if>
 
- 			<if test="baby_gender != null and baby_gender != ''">
 
- 				BABY_GENDER = #{baby_gender}, 
 
- 			</if>
 
- 			<if test="status_ != null and status_ != ''">
 
- 				STATUS_ = #{status_} 
 
- 			</if>
 
- 		</set>
 
- 		WHERE 
 
- 			ID = #{id} 
 
- 	</update>
 
- 	
 
- 	<!-- 根据id修改user表的个人头像 -->
 
- 	<update id="updateDisplayPicture">
 
- 		UPDATE USER SET DISPLAY_PICTURE = #{0} WHERE ID = #{1} 
 
- 	</update>
 
- 	
 
- 	<!-- 根据用户名和密码查询用户表信息 -->
 
- 	<select id="validateUser" parameterType="java.lang.String" resultMap="userMap">
 
- 		SELECT <include refid="userAttribute"/> FROM USER WHERE USERNAME=#{0} AND PASSWORD=#{1} 
 
- 	</select>
 
- 	
 
- 	<!-- 通过id修改用户表密码 -->
 
- 	<update id="changePassword">
 
- 		UPDATE USER SET PASSWORD=#{1} WHERE ID=#{0}
 
- 	</update>
 
- 	
 
- 	<!-- 通过token查询user表所有信息 -->
 
- 	<select id="selectUserByToken" parameterType="java.lang.String" resultMap="userMap">
 
- 		SELECT <include refid="userAttribute"/> FROM USER WHERE TOKEN=#{0} 
 
- 	</select>
 
- 	
 
- 	<!-- 根据id修改token值 -->
 
- 	<update id="updateUserToken">
 
- 		UPDATE USER SET TOKEN=#{0} WHERE ID=#{1}
 
- 	</update>
 
- 	
 
- 	<!-- 根据id修改user表的用户名 修改IS_PERFECT_USER字段未已完善状态-->
 
- 	<update id="updateUserName">
 
- 	
 
- 		UPDATE USER SET USERNAME=#{0},IS_PERFECT_USER=2 WHERE ID=#{1}                  
 
- 	</update>
 
- 	
 
- 	<!-- 根据id修改user表的用户名和国家代码 -->
 
- 	<update id="updateUserNameAndCountry">
 
- 		UPDATE USER SET USERNAME=#{0},country_code=#{1},IS_PERFECT_USER=2 WHERE ID=#{2}                  
 
- 	</update>
 
- 	
 
- 	<!-- 通过key_查询sys_config表数据 -->
 
- 	<select id="selectConfig" parameterType="java.lang.String" resultType="String">
 
- 		SELECT VALUE_ FROM SYS_CONFIG WHERE KEY_ = #{0}
 
- 	</select>
 
- 	
 
- 	<!-- USER_AVATOR表中添加数据 -->
 
- 	<insert id="insertUserAvator">
 
- 		INSERT INTO USER_AVATOR (USER_ID, AVATOR) VALUE (#{0}, #{1})
 
- 	</insert>
 
- 	
 
- 	<!-- 通过user_id修改USER_AVATOR表数据 -->
 
- 	<update id="updateUserAvator">
 
- 		UPDATE USER_AVATOR SET AVATOR = #{1} WHERE USER_ID = #{0}
 
- 	</update>
 
- 	
 
- 	<!-- 根据user_id查询USER_AVATOR表数据 -->
 
- 	<select id="selectUserAvator" parameterType="java.lang.Long" resultType="java.lang.String">
 
- 		SELECT avator FROM USER_AVATOR WHERE USER_ID = #{id}
 
- 	</select>
 
- </mapper>
 
 
  |