system和auth 初步构建
This commit is contained in:
194
schoolNewsServ/system/src/main/resources/mapper/UserMapper.xml
Normal file
194
schoolNewsServ/system/src/main/resources/mapper/UserMapper.xml
Normal file
@@ -0,0 +1,194 @@
|
||||
<?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="org.xyzh.system.mapper.UserMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.user.TbSysUser">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="username" property="username" jdbcType="VARCHAR"/>
|
||||
<result column="password" property="password" jdbcType="VARCHAR"/>
|
||||
<result column="email" property="email" jdbcType="VARCHAR"/>
|
||||
<result column="phone" property="phone" jdbcType="VARCHAR"/>
|
||||
<result column="wechat_id" property="wechatID" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="Boolean"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, username, password, email, phone, wechat_id,
|
||||
create_time, update_time, delete_time, deleted, status
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="username != null and username != ''">
|
||||
AND username LIKE CONCAT('%', #{username}, '%')
|
||||
</if>
|
||||
<if test="email != null and email != ''">
|
||||
AND email LIKE CONCAT('%', #{email}, '%')
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
AND phone = #{phone}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据用户名查询用户 -->
|
||||
<select id="selectByUsername" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
WHERE deleted = 0
|
||||
AND username = #{username}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据邮箱查询用户 -->
|
||||
<select id="selectByEmail" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
WHERE deleted = 0
|
||||
AND email = #{email}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号查询用户 -->
|
||||
<select id="selectByPhone" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
WHERE deleted = 0
|
||||
AND phone = #{phone}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据过滤条件查询用户 -->
|
||||
<select id="selectByFilter" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.username != null and filter.username != ''">
|
||||
AND username = #{filter.username}
|
||||
</if>
|
||||
<if test="filter.email != null and filter.email != ''">
|
||||
AND email = #{filter.email}
|
||||
</if>
|
||||
<if test="filter.phone != null and filter.phone != ''">
|
||||
AND phone = #{filter.phone}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND status = #{filter.status}
|
||||
</if>
|
||||
<if test="filter.wechatID != null and filter.wechatID != ''">
|
||||
AND wechat_id = #{filter.wechatID}
|
||||
</if>
|
||||
</where>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 查询用户列表 -->
|
||||
<select id="selectUserList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
<include refid="Where_Clause"/>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 批量删除用户(逻辑删除) -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE tb_sys_user
|
||||
SET deleted = 1,
|
||||
delete_time = NOW(),
|
||||
updater = #{updater}
|
||||
WHERE deleted = 0
|
||||
AND id IN
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 插入用户 -->
|
||||
<insert id="insert" parameterType="org.xyzh.common.dto.user.TbSysUser">
|
||||
INSERT INTO tb_sys_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="username != null">username,</if>
|
||||
<if test="password != null">password,</if>
|
||||
<if test="email != null">email,</if>
|
||||
<if test="phone != null">phone,</if>
|
||||
<if test="avatar != null">avatar,</if>
|
||||
<if test="nickname != null">nickname,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="birthday != null">birthday,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="lastLoginTime != null">last_login_time,</if>
|
||||
<if test="lastLoginIp != null">last_login_ip,</if>
|
||||
<if test="creator != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
deleted
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="username != null">#{username},</if>
|
||||
<if test="password != null">#{password},</if>
|
||||
<if test="email != null">#{email},</if>
|
||||
<if test="phone != null">#{phone},</if>
|
||||
<if test="avatar != null">#{avatar},</if>
|
||||
<if test="nickname != null">#{nickname},</if>
|
||||
<if test="gender != null">#{gender},</if>
|
||||
<if test="birthday != null">#{birthday},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="lastLoginTime != null">#{lastLoginTime},</if>
|
||||
<if test="lastLoginIp != null">#{lastLoginIp},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.user.TbSysUser">
|
||||
UPDATE tb_sys_user
|
||||
<set>
|
||||
<if test="username != null">username = #{username},</if>
|
||||
<if test="password != null">password = #{password},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="avatar != null">avatar = #{avatar},</if>
|
||||
<if test="nickname != null">nickname = #{nickname},</if>
|
||||
<if test="gender != null">gender = #{gender},</if>
|
||||
<if test="birthday != null">birthday = #{birthday},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
|
||||
<if test="lastLoginIp != null">last_login_ip = #{lastLoginIp},</if>
|
||||
<if test="updater != null">updater = #{updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除(逻辑删除) -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_sys_user
|
||||
SET deleted = 1,
|
||||
delete_time = NOW()
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user