main主干首次提交,包含用户认证模块
This commit is contained in:
94
src/main/resources/mapper/SysUserMapper.xml
Normal file
94
src/main/resources/mapper/SysUserMapper.xml
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.labelsys.backend.mapper.SysUserMapper">
|
||||
<resultMap id="SysUserResultMap" type="com.labelsys.backend.entity.SysUser">
|
||||
<id column="id" property="id"/>
|
||||
<result column="company_id" property="companyId"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="username" property="username"/>
|
||||
<result column="role" property="role"/>
|
||||
<result column="position" property="position"/>
|
||||
<result column="real_name" property="realName"/>
|
||||
<result column="password_hash" property="passwordHash"/>
|
||||
<result column="must_change_password" property="mustChangePassword"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="session_version" property="sessionVersion"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="UserColumns">
|
||||
id, company_id, phone, username, role, position, real_name, password_hash, must_change_password,
|
||||
status, session_version, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.labelsys.backend.entity.SysUser">
|
||||
insert into sys_user (
|
||||
id, company_id, phone, username, role, position, real_name, password_hash, must_change_password,
|
||||
status, session_version, created_at, updated_at
|
||||
)
|
||||
values (
|
||||
#{id}, #{companyId}, #{phone}, #{username}, #{role}, #{position}, #{realName}, #{passwordHash}, #{mustChangePassword},
|
||||
#{status}, #{sessionVersion}, current_timestamp, current_timestamp
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="findById" resultMap="SysUserResultMap">
|
||||
select <include refid="UserColumns"/> from sys_user where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByIdAndCompanyId" resultMap="SysUserResultMap">
|
||||
select <include refid="UserColumns"/> from sys_user where id = #{id} and company_id = #{companyId}
|
||||
</select>
|
||||
|
||||
<select id="findByCompanyIdAndPhone" resultMap="SysUserResultMap">
|
||||
select <include refid="UserColumns"/> from sys_user where company_id = #{companyId} and phone = #{phone}
|
||||
</select>
|
||||
|
||||
<select id="listByCompanyId" resultMap="SysUserResultMap">
|
||||
select <include refid="UserColumns"/> from sys_user where company_id = #{companyId} order by id
|
||||
</select>
|
||||
|
||||
<select id="listCompanyAdmins" resultMap="SysUserResultMap">
|
||||
select <include refid="UserColumns"/>
|
||||
from sys_user
|
||||
where company_id = #{companyId} and position = 'ADMIN'
|
||||
order by id
|
||||
</select>
|
||||
|
||||
<update id="updatePassword">
|
||||
update sys_user
|
||||
set password_hash = #{passwordHash},
|
||||
must_change_password = #{mustChangePassword},
|
||||
updated_at = current_timestamp
|
||||
where id = #{id} and company_id = #{companyId}
|
||||
</update>
|
||||
|
||||
<update id="updateAssignment">
|
||||
update sys_user
|
||||
set role = #{role},
|
||||
position = #{position},
|
||||
session_version = session_version + 1,
|
||||
updated_at = current_timestamp
|
||||
where id = #{id} and company_id = #{companyId}
|
||||
</update>
|
||||
|
||||
<update id="updateStatus">
|
||||
update sys_user
|
||||
set status = #{status},
|
||||
session_version = session_version + 1,
|
||||
updated_at = current_timestamp
|
||||
where id = #{id} and company_id = #{companyId}
|
||||
</update>
|
||||
|
||||
<update id="bumpSessionVersion">
|
||||
update sys_user
|
||||
set session_version = session_version + 1,
|
||||
updated_at = current_timestamp
|
||||
where id = #{id} and company_id = #{companyId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAll">
|
||||
delete from sys_user
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user