2026-04-23 11:59:31 +08:00
|
|
|
<?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>
|
|
|
|
|
|
|
|
|
|
<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="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>
|
2026-04-23 17:00:02 +08:00
|
|
|
</mapper>
|