main主干首次提交,包含用户认证模块
This commit is contained in:
40
src/main/resources/mapper/BizDataRecordMapper.xml
Normal file
40
src/main/resources/mapper/BizDataRecordMapper.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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.BizDataRecordMapper">
|
||||
<resultMap id="BizDataRecordResultMap" type="com.labelsys.backend.entity.BizDataRecord">
|
||||
<id column="id" property="id"/>
|
||||
<result column="company_id" property="companyId"/>
|
||||
<result column="creator_id" property="creatorId"/>
|
||||
<result column="creator_role" property="creatorRole"/>
|
||||
<result column="record_name" property="recordName"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="RecordColumns">
|
||||
id, company_id, creator_id, creator_role, record_name, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
<select id="listVisibleByEmployee" resultMap="BizDataRecordResultMap">
|
||||
select <include refid="RecordColumns"/>
|
||||
from biz_data_record
|
||||
where company_id = #{companyId}
|
||||
and creator_id = #{creatorId}
|
||||
order by id
|
||||
</select>
|
||||
|
||||
<select id="listVisibleByManager" resultMap="BizDataRecordResultMap">
|
||||
select <include refid="RecordColumns"/>
|
||||
from biz_data_record
|
||||
where company_id = #{companyId}
|
||||
and creator_role in ('EMPLOYEE', 'MANAGER')
|
||||
order by id
|
||||
</select>
|
||||
|
||||
<select id="listVisibleByEngineer" resultMap="BizDataRecordResultMap">
|
||||
select <include refid="RecordColumns"/>
|
||||
from biz_data_record
|
||||
where company_id = #{companyId}
|
||||
order by id
|
||||
</select>
|
||||
</mapper>
|
||||
59
src/main/resources/mapper/SysCompanyMapper.xml
Normal file
59
src/main/resources/mapper/SysCompanyMapper.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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.SysCompanyMapper">
|
||||
<resultMap id="SysCompanyResultMap" type="com.labelsys.backend.entity.SysCompany">
|
||||
<id column="id" property="id"/>
|
||||
<result column="company_code" property="companyCode"/>
|
||||
<result column="company_name" property="companyName"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="CompanyColumns">
|
||||
id, company_code, company_name, status, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.labelsys.backend.entity.SysCompany">
|
||||
insert into sys_company (id, company_code, company_name, status, created_at, updated_at)
|
||||
values (#{id}, #{companyCode}, #{companyName}, #{status}, current_timestamp, current_timestamp)
|
||||
</insert>
|
||||
|
||||
<select id="findById" resultMap="SysCompanyResultMap">
|
||||
select <include refid="CompanyColumns"/>
|
||||
from sys_company
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByCompanyCode" resultMap="SysCompanyResultMap">
|
||||
select <include refid="CompanyColumns"/>
|
||||
from sys_company
|
||||
where company_code = #{companyCode}
|
||||
</select>
|
||||
|
||||
<select id="findEnabledCompaniesByPhone" resultMap="SysCompanyResultMap">
|
||||
select distinct c.id, c.company_code, c.company_name, c.status, c.created_at, c.updated_at
|
||||
from sys_company c
|
||||
inner join sys_user u on u.company_id = c.id
|
||||
where u.phone = #{phone}
|
||||
and u.status = 'ENABLED'
|
||||
and c.status = 'ENABLED'
|
||||
order by c.id
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="SysCompanyResultMap">
|
||||
select <include refid="CompanyColumns"/>
|
||||
from sys_company
|
||||
order by id
|
||||
</select>
|
||||
|
||||
<update id="updateStatus">
|
||||
update sys_company
|
||||
set status = #{status}, updated_at = current_timestamp
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAll">
|
||||
delete from sys_company
|
||||
</delete>
|
||||
</mapper>
|
||||
29
src/main/resources/mapper/SysMenuMapper.xml
Normal file
29
src/main/resources/mapper/SysMenuMapper.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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.SysMenuMapper">
|
||||
<resultMap id="SysMenuResultMap" type="com.labelsys.backend.entity.SysMenu">
|
||||
<id column="id" property="id"/>
|
||||
<result column="company_id" property="companyId"/>
|
||||
<result column="permission_code" property="permissionCode"/>
|
||||
<result column="menu_code" property="menuCode"/>
|
||||
<result column="menu_name" property="menuName"/>
|
||||
<result column="path" property="path"/>
|
||||
<result column="sort_order" property="sortOrder"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="listCurrentMenus" resultMap="SysMenuResultMap">
|
||||
select distinct m.id, m.company_id, m.permission_code, m.menu_code, m.menu_name, m.path, m.sort_order, m.created_at, m.updated_at
|
||||
from sys_menu m
|
||||
inner join sys_position_permission pp
|
||||
on pp.company_id = m.company_id
|
||||
and pp.permission_code = m.permission_code
|
||||
where m.company_id = #{companyId}
|
||||
and pp.position_code in
|
||||
<foreach collection="positionCodes" item="positionCode" open="(" separator="," close=")">
|
||||
#{positionCode}
|
||||
</foreach>
|
||||
order by m.sort_order, m.id
|
||||
</select>
|
||||
</mapper>
|
||||
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