<?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.ycl.jxkg.mapper.UserMapper">
|
<resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.User">
|
<id column="id" jdbcType="INTEGER" property="id"/>
|
<result column="user_uuid" jdbcType="VARCHAR" property="userUuid"/>
|
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
|
<result column="password" jdbcType="VARCHAR" property="password"/>
|
<result column="real_name" jdbcType="VARCHAR" property="realName"/>
|
<result column="age" jdbcType="INTEGER" property="age"/>
|
<result column="sex" jdbcType="INTEGER" property="sex"/>
|
<result column="birth_day" jdbcType="TIMESTAMP" property="birthDay"/>
|
<result column="user_level" jdbcType="INTEGER" property="userLevel"/>
|
<result column="phone" jdbcType="VARCHAR" property="phone"/>
|
<result column="role" jdbcType="INTEGER" property="role"/>
|
<result column="status" jdbcType="INTEGER" property="status"/>
|
<result column="image_path" jdbcType="VARCHAR" property="imagePath"/>
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
|
<result column="last_active_time" jdbcType="TIMESTAMP" property="lastActiveTime"/>
|
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
<result column="wx_open_id" jdbcType="VARCHAR" property="wxOpenId"/>
|
</resultMap>
|
<sql id="Base_Column_List">
|
id
|
, user_uuid, user_name, password, real_name, age, sex, birth_day, user_level, phone,
|
role, status, image_path, create_time, modify_time, last_active_time, deleted, wx_open_id
|
</sql>
|
|
|
<select id="getAllUser" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user where deleted=0
|
</select>
|
|
<select id="getUserById" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user
|
where id=#{value}
|
</select>
|
|
<select id="getUserByUserName" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user
|
where deleted=0 and user_name=#{value} limit 1
|
</select>
|
|
<select id="getUserByUserNamePwd" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user
|
where deleted=0 and user_name=#{username} and password=#{pwd} limit 1
|
</select>
|
|
<select id="getUserByUuid" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user
|
where deleted=0 and user_uuid=#{value,jdbcType=VARCHAR}
|
</select>
|
|
|
<select id="userPageList" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM t_user
|
<where>
|
and deleted=0
|
<if test="name != null and name != ''">
|
and real_name like concat('%',#{name},'%')
|
</if>
|
</where>
|
ORDER BY id
|
<if test="offset != null and limit != null ">
|
<bind name="patternAdd" value="limit*offset"/>
|
limit #{limit} OFFSET #{offset}
|
</if>
|
</select>
|
|
|
<select id="userPageCount" resultType="java.lang.Integer">
|
select count(*) from t_user
|
<where>
|
and deleted=0
|
<if test="name != null and name != ''">
|
and real_name like concat('%', #{name}, '%')
|
</if>
|
</where>
|
</select>
|
|
|
<select id="userPage" resultMap="BaseResultMap" parameterType="com.ycl.jxkg.domain.vo.admin.user.UserPageRequestVO">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM t_user
|
<where>
|
and deleted=0
|
<if test="userName != null and userName != ''">
|
and user_name like concat('%',#{userName},'%')
|
</if>
|
<if test="role != null ">
|
and role= #{role}
|
</if>
|
</where>
|
</select>
|
|
|
<insert id="insertUser" parameterType="com.ycl.jxkg.domain.entity.User"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into t_user
|
(user_uuid, user_name, password, real_name, age, last_active_time)
|
values (#{userUuid,jdbcType=VARCHAR}, #{userName}, #{password}, #{realName}, #{age}, #{lastActiveTime})
|
</insert>
|
|
<insert id="insertUsers" parameterType="java.util.List"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into t_user
|
(user_uuid,user_name,password,real_name,age,last_active_time)
|
values
|
<foreach collection="list" item="item" index="index"
|
separator=",">
|
(#{item.userUuid},#{item.userName},#{item.password},#{item.realName},#{item.age},
|
#{item.lastActiveTime})
|
</foreach>
|
</insert>
|
|
|
<update id="updateUser" parameterType="com.ycl.jxkg.domain.entity.User">
|
update t_user
|
<set>
|
<if test="realName != null">real_name = #{realName},</if>
|
<if test="age != null">age = #{age},</if>
|
<if test="lastActiveTime != null">last_active_time = #{lastActiveTime},</if>
|
</set>
|
where id = #{id}
|
</update>
|
|
|
<update id="updateUsersAge">
|
update t_user set age = #{age} where id in
|
<foreach item="id" collection="idslist" open="(" separator=","
|
close=")">
|
#{id}
|
</foreach>
|
</update>
|
|
|
<delete id="deleteUsersByIds">
|
delete from t_user where id in
|
<foreach item="id" collection="list" open="(" separator=","
|
close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<select id="selectAllCount" resultType="java.lang.Integer">
|
SELECT count(*)
|
from t_user
|
where deleted = 0
|
</select>
|
|
|
<select id="selectByUserName" resultType="com.ycl.jxkg.domain.other.KeyValue">
|
SELECT id as value,user_name as name
|
from t_user
|
where deleted=0
|
and user_name like concat('%'
|
, #{value}
|
, '%')
|
limit 5
|
</select>
|
|
|
<select id="selectByIds" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user
|
where id in
|
<foreach item="id" collection="list" open="(" separator=","
|
close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
|
<select id="selectByWxOpenId" parameterType="java.lang.String" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from t_user
|
where deleted=0 and wx_open_id = #{wxOpenId}
|
limit 1
|
</select>
|
|
<select id="classesStudent" resultType="com.ycl.jxkg.domain.vo.StudentVO">
|
SELECT tu.id,
|
tu.real_name,
|
tu.phone
|
FROM t_user tu
|
INNER JOIN t_classes_user tcu ON tu.id = tcu.user_id
|
WHERE tcu.classes_id = #{classesId}
|
ORDER BY tcu.create_time
|
</select>
|
|
</mapper>
|