feat: 初始提交
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<?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.onixbyte.helix.mapper.AssetMapper">
|
||||
</mapper>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.onixbyte.helix.mapper.AuthorityMapper">
|
||||
<select id="selectByUserId" parameterType="long">
|
||||
SELECT DISTINCT a.id, a.code, a.name, a.description, a.status, a.created_at, a.updated_at
|
||||
FROM authorities a
|
||||
JOIN role_authorities ra ON a.id = ra.authority_id
|
||||
JOIN user_roles ur ON ra.role_id = ur.role_id
|
||||
WHERE ur.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.onixbyte.helix.mapper.DepartmentMapper">
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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.onixbyte.helix.mapper.MenuMapper">
|
||||
<select id="selectActiveMenusByUserId" parameterType="long" resultType="com.onixbyte.helix.domain.entity.Menu">
|
||||
WITH RECURSIVE
|
||||
UserGrantedMenus AS (SELECT DISTINCT m.*
|
||||
FROM menus m
|
||||
JOIN authorities a ON m.authority_code = a.code
|
||||
JOIN role_authorities ra ON ra.authority_id = a.id
|
||||
JOIN user_roles ur ON ur.role_id = ra.role_id
|
||||
WHERE ur.user_id = #{userId}
|
||||
AND m.status = 'ACTIVE'::status),
|
||||
Ancestors AS (SELECT ugm.*,
|
||||
TRUE AS is_granted
|
||||
FROM UserGrantedMenus ugm
|
||||
UNION ALL
|
||||
SELECT m.*,
|
||||
FALSE AS is_granted
|
||||
FROM menus m
|
||||
JOIN Ancestors a ON m.id = a.parent_id)
|
||||
SELECT DISTINCT id,
|
||||
name,
|
||||
parent_id,
|
||||
code,
|
||||
sort,
|
||||
path,
|
||||
is_external_link,
|
||||
is_visible,
|
||||
status,
|
||||
authority_code,
|
||||
icon,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM Ancestors
|
||||
ORDER BY parent_id, sort;
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.onixbyte.helix.mapper.PositionMapper">
|
||||
</mapper>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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.onixbyte.helix.mapper.RoleMapper">
|
||||
<select id="areRolesExisted" resultType="boolean">
|
||||
SELECT NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM (
|
||||
<foreach collection="roleIds" item="roleId" separator="UNION ALL">
|
||||
SELECT #{roleId} AS id
|
||||
</foreach>
|
||||
<if test="roleIds.size() == 0">
|
||||
SELECT NULL AS id WHERE FALSE
|
||||
</if>
|
||||
) AS input_roles_temp
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM roles r
|
||||
WHERE r.id = input_roles_temp.id
|
||||
)
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultType="role">
|
||||
SELECT id,
|
||||
name,
|
||||
code,
|
||||
sort,
|
||||
default_value,
|
||||
description,
|
||||
status,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM roles
|
||||
<where>
|
||||
<if test="wrapper.name != null and wrapper.name != ''">
|
||||
AND name LIKE '%' || #{wrapper.name} || '%'
|
||||
</if>
|
||||
<if test="wrapper.code != null and wrapper.code != ''">
|
||||
AND code = #{wrapper.code}
|
||||
</if>
|
||||
<if test="wrapper.status != null">
|
||||
AND status = #{wrapper.status}::STATUS
|
||||
</if>
|
||||
</where>
|
||||
<if test="pageable != null and pageable.sort != null">
|
||||
ORDER BY
|
||||
<foreach collection="pageable.sort" item="order" separator=", ">
|
||||
${order.property} ${order.direction}
|
||||
</foreach>
|
||||
LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="count" parameterType="com.onixbyte.helix.domain.database.query.wrapper.QueryRoleWrapper">
|
||||
SELECT COUNT(*)
|
||||
FROM roles
|
||||
<where>
|
||||
<if test="wrapper.name != null and wrapper.name != ''">
|
||||
AND name LIKE '%' || #{wrapper.name} || '%'
|
||||
</if>
|
||||
<if test="wrapper.code != null and wrapper.code != ''">
|
||||
AND code = #{wrapper.code}
|
||||
</if>
|
||||
<if test="wrapper.status != null">
|
||||
AND status = #{wrapper.status}::STATUS
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.onixbyte.helix.mapper.SettingMapper">
|
||||
</mapper>
|
||||
@@ -0,0 +1,228 @@
|
||||
<?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.onixbyte.helix.mapper.UserMapper">
|
||||
<select id="selectByUsername" parameterType="string">
|
||||
SELECT id,
|
||||
username,
|
||||
password,
|
||||
full_name,
|
||||
email,
|
||||
region_abbreviation,
|
||||
phone_number,
|
||||
avatar_url,
|
||||
status,
|
||||
department_id,
|
||||
position_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM users
|
||||
WHERE username = #{username}
|
||||
</select>
|
||||
|
||||
<select id="selectAll" parameterType="org.springframework.data.domain.Pageable"
|
||||
resultType="user">
|
||||
SELECT id,
|
||||
username,
|
||||
password,
|
||||
full_name,
|
||||
email,
|
||||
region_abbreviation,
|
||||
phone_number,
|
||||
avatar_url,
|
||||
status,
|
||||
department_id,
|
||||
position_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM users
|
||||
<if test="pageable != null and pageable.sort != null">
|
||||
ORDER BY
|
||||
<foreach collection="pageable.sort" item="order" separator=", ">
|
||||
${order.property} ${order.direction}
|
||||
</foreach>
|
||||
LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countAll" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM users
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultType="user">
|
||||
SELECT id,
|
||||
username,
|
||||
password,
|
||||
full_name,
|
||||
email,
|
||||
region_abbreviation,
|
||||
phone_number,
|
||||
avatar_url,
|
||||
status,
|
||||
department_id,
|
||||
position_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM users
|
||||
<where>
|
||||
<if test="wrapper.departmentId != null">
|
||||
AND department_id IN (WITH RECURSIVE SubDepartments AS (
|
||||
SELECT id
|
||||
FROM departments
|
||||
WHERE id = #{wrapper.departmentId}
|
||||
UNION ALL
|
||||
SELECT d.id
|
||||
FROM departments d
|
||||
INNER JOIN SubDepartments sd
|
||||
ON d.parent_id = sd.id)
|
||||
SELECT id
|
||||
FROM SubDepartments)
|
||||
</if>
|
||||
<if test="wrapper.username != null and wrapper.username != ''">
|
||||
AND username LIKE '%' || #{wrapper.username} || '%'
|
||||
</if>
|
||||
<if test="wrapper.regionAbbreviation != null and wrapper.regionAbbreviation != ''">
|
||||
AND region_abbreviation = #{wrapper.regionAbbreviation}
|
||||
</if>
|
||||
<if test="wrapper.phoneNumber != null and wrapper.phoneNumber != ''">
|
||||
AND phone_number = #{wrapper.phoneNumber}
|
||||
</if>
|
||||
<if test="wrapper.status != null">
|
||||
AND status = #{wrapper.status}::USER_STATUS
|
||||
</if>
|
||||
<if test="wrapper.createdAtStart != null">
|
||||
AND created_at >= #{wrapper.createdAtStart}
|
||||
</if>
|
||||
<if test="wrapper.createdAtEnd != null">
|
||||
AND created_at <![CDATA[<=]]> #{wrapper.createdAtEnd}
|
||||
</if>
|
||||
</where>
|
||||
<if test="pageable != null and pageable.sort != null">
|
||||
ORDER BY
|
||||
<foreach collection="pageable.sort" item="order" separator=", ">
|
||||
${order.property} ${order.direction}
|
||||
</foreach>
|
||||
LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM users
|
||||
<where>
|
||||
<if test="wrapper.departmentId != null">
|
||||
AND department_id IN (WITH RECURSIVE SubDepartments AS (
|
||||
SELECT id
|
||||
FROM departments
|
||||
WHERE id = #{wrapper.departmentId}
|
||||
UNION ALL
|
||||
SELECT d.id
|
||||
FROM departments d
|
||||
INNER JOIN SubDepartments sd
|
||||
ON d.parent_id = sd.id)
|
||||
SELECT id
|
||||
FROM SubDepartments)
|
||||
</if>
|
||||
<if test="wrapper.username != null and wrapper.username != ''">
|
||||
AND username LIKE '%' || #{wrapper.username} || '%'
|
||||
</if>
|
||||
<if test="wrapper.regionAbbreviation != null and wrapper.regionAbbreviation != ''">
|
||||
AND region_abbreviation = #{wrapper.regionAbbreviation}
|
||||
</if>
|
||||
<if test="wrapper.phoneNumber != null and wrapper.phoneNumber != ''">
|
||||
AND phone_number = #{wrapper.phoneNumber}
|
||||
</if>
|
||||
<if test="wrapper.status != null">
|
||||
AND status = #{wrapper.status}::USER_STATUS
|
||||
</if>
|
||||
<if test="wrapper.createdAtStart != null">
|
||||
AND created_at >= #{wrapper.createdAtStart}
|
||||
</if>
|
||||
<if test="wrapper.createdAtEnd != null">
|
||||
AND created_at <![CDATA[<=]]> #{wrapper.createdAtEnd}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectWithDetailByUserId" parameterType="long" resultType="com.onixbyte.helix.domain.web.response.UserDetailResponse">
|
||||
SELECT u.id,
|
||||
u.username,
|
||||
u.full_name,
|
||||
u.email,
|
||||
u.region_abbreviation,
|
||||
u.phone_number,
|
||||
u.avatar_url,
|
||||
u.status,
|
||||
u.department_id,
|
||||
d.name AS department_name,
|
||||
u.position_id,
|
||||
p.name AS position_name,
|
||||
u.created_at,
|
||||
u.updated_at
|
||||
FROM users u
|
||||
LEFT JOIN departments d ON u.department_id = d.id
|
||||
LEFT JOIN positions p ON u.position_id = p.id
|
||||
WHERE u.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectListWithDetails" resultType="com.onixbyte.helix.domain.web.response.UserDetailResponse">
|
||||
SELECT u.id,
|
||||
u.username,
|
||||
u.full_name,
|
||||
u.email,
|
||||
u.region_abbreviation,
|
||||
u.phone_number,
|
||||
u.avatar_url,
|
||||
u.status,
|
||||
u.department_id,
|
||||
d.name AS department_name,
|
||||
u.position_id,
|
||||
p.name AS position_name,
|
||||
u.created_at,
|
||||
u.updated_at
|
||||
FROM users u
|
||||
LEFT JOIN departments d ON u.department_id = d.id
|
||||
LEFT JOIN positions p ON u.position_id = p.id
|
||||
<where>
|
||||
<if test="wrapper.departmentId != null">
|
||||
AND department_id IN (WITH RECURSIVE SubDepartments AS (
|
||||
SELECT id
|
||||
FROM departments
|
||||
WHERE id = #{wrapper.departmentId}
|
||||
UNION ALL
|
||||
SELECT d.id
|
||||
FROM departments d
|
||||
INNER JOIN SubDepartments sd
|
||||
ON d.parent_id = sd.id)
|
||||
SELECT id
|
||||
FROM SubDepartments)
|
||||
</if>
|
||||
<if test="wrapper.username != null and wrapper.username != ''">
|
||||
AND username LIKE '%' || #{wrapper.username} || '%'
|
||||
</if>
|
||||
<if test="wrapper.regionAbbreviation != null and wrapper.regionAbbreviation != ''">
|
||||
AND region_abbreviation = #{wrapper.regionAbbreviation}
|
||||
</if>
|
||||
<if test="wrapper.phoneNumber != null and wrapper.phoneNumber != ''">
|
||||
AND phone_number = #{wrapper.phoneNumber}
|
||||
</if>
|
||||
<if test="wrapper.status != null">
|
||||
AND u.status = #{wrapper.status}::USER_STATUS
|
||||
</if>
|
||||
<if test="wrapper.createdAtStart != null">
|
||||
AND u.created_at >= #{wrapper.createdAtStart}
|
||||
</if>
|
||||
<if test="wrapper.createdAtEnd != null">
|
||||
AND u.created_at <![CDATA[<=]]> #{wrapper.createdAtEnd}
|
||||
</if>
|
||||
</where>
|
||||
<if test="pageable != null and pageable.sort != null">
|
||||
ORDER BY
|
||||
<foreach collection="pageable.sort" item="order" separator=", ">
|
||||
${order.property} ${order.direction}
|
||||
</foreach>
|
||||
LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.onixbyte.helix.mapper.UserRoleMapper">
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user