Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
custom-server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhonghong
custom-server
Commits
77f582aa
Commit
77f582aa
authored
Jul 14, 2026
by
Lizh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: P1 Step 2.3+2.4 — RBAC DomainServices + AppServices (17 files)
parent
02d10269
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
989 additions
and
2 deletions
+989
-2
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysDeptService.java
+58
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysMenuService.java
+67
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysPostService.java
+51
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysRoleService.java
+120
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysUserService.java
+116
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysDeptServiceImpl.java
+80
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysMenuServiceImpl.java
+134
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysPostServiceImpl.java
+83
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysRoleServiceImpl.java
+0
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysUserServiceImpl.java
+0
-0
custom-server-app/src/main/java/com/jomalls/custom/app/vo/TreeSelectVO.java
+31
-0
custom-server-domain/src/main/java/com/jomalls/custom/dal/entity/SysDeptEntity.java
+11
-0
custom-server-domain/src/main/java/com/jomalls/custom/dal/entity/SysRoleEntity.java
+13
-1
custom-server-domain/src/main/java/com/jomalls/custom/dal/entity/SysUserEntity.java
+19
-1
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysDeptDomainService.java
+54
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysPostDomainService.java
+12
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysRoleDomainService.java
+8
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysUserPostDomainService.java
+12
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysDeptDomainServiceImpl.java
+68
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysPostDomainServiceImpl.java
+23
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysRoleDomainServiceImpl.java
+6
-0
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysUserPostDomainServiceImpl.java
+23
-0
No files found.
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysDeptService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
;
import
com.jomalls.custom.dal.entity.SysDeptEntity
;
import
java.util.List
;
/**
* 部门管理 App Service 接口
*
* @author Lizh
*/
public
interface
SysDeptService
{
/**
* 查询部门列表(树结构)
*
* @param dept 查询条件
* @return 部门树
*/
List
<
SysDeptEntity
>
selectDeptList
(
SysDeptEntity
dept
);
/**
* 查询部门列表(排除指定子部门)
*
* @param deptId 部门ID
* @return 部门列表
*/
List
<
SysDeptEntity
>
selectDeptListExcludeChild
(
Long
deptId
);
/**
* 根据ID查询部门
*
* @param deptId 部门ID
* @return 部门信息
*/
SysDeptEntity
getById
(
Long
deptId
);
/**
* 新增部门
*
* @param dept 部门信息
*/
void
add
(
SysDeptEntity
dept
);
/**
* 修改部门
*
* @param dept 部门信息
*/
void
edit
(
SysDeptEntity
dept
);
/**
* 删除部门
*
* @param deptId 部门ID
*/
void
remove
(
Long
deptId
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysMenuService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
;
import
com.jomalls.custom.app.vo.TreeSelectVO
;
import
com.jomalls.custom.dal.entity.SysMenuEntity
;
import
java.util.List
;
import
java.util.Map
;
/**
* 菜单管理 App Service 接口
*
* @author Lizh
*/
public
interface
SysMenuService
{
/**
* 查询菜单列表(树结构)
*
* @param menu 查询条件
* @return 菜单树
*/
List
<
SysMenuEntity
>
selectMenuList
(
SysMenuEntity
menu
);
/**
* 根据ID查询菜单
*
* @param menuId 菜单ID
* @return 菜单信息
*/
SysMenuEntity
getById
(
Long
menuId
);
/**
* 查询菜单树下拉列表
*
* @return TreeSelectVO 树
*/
List
<
TreeSelectVO
>
treeselect
();
/**
* 根据角色ID查询菜单树(含选中的菜单ID)
*
* @param roleId 角色ID
* @return 包含 treeselect 和 checkedKeys 的Map
*/
Map
<
String
,
Object
>
roleMenuTreeselect
(
Long
roleId
);
/**
* 新增菜单
*
* @param menu 菜单信息
*/
void
add
(
SysMenuEntity
menu
);
/**
* 修改菜单
*
* @param menu 菜单信息
*/
void
edit
(
SysMenuEntity
menu
);
/**
* 删除菜单
*
* @param menuId 菜单ID
*/
void
remove
(
Long
menuId
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysPostService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jomalls.custom.dal.entity.SysPostEntity
;
/**
* 岗位管理 App Service 接口
*
* @author Lizh
*/
public
interface
SysPostService
{
/**
* 分页查询岗位列表
*
* @param post 查询条件
* @param page 分页参数
* @return 分页结果
*/
IPage
<
SysPostEntity
>
pageList
(
SysPostEntity
post
,
Page
<
SysPostEntity
>
page
);
/**
* 根据ID查询岗位
*
* @param postId 岗位ID
* @return 岗位信息
*/
SysPostEntity
getById
(
Long
postId
);
/**
* 新增岗位
*
* @param post 岗位信息
*/
void
add
(
SysPostEntity
post
);
/**
* 修改岗位
*
* @param post 岗位信息
*/
void
edit
(
SysPostEntity
post
);
/**
* 批量删除岗位
*
* @param postIds 岗位ID数组
*/
void
remove
(
Long
[]
postIds
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysRoleService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jomalls.custom.dal.entity.SysDeptEntity
;
import
com.jomalls.custom.dal.entity.SysRoleEntity
;
import
com.jomalls.custom.dal.entity.SysUserEntity
;
import
java.util.List
;
/**
* 角色管理 App Service 接口
*
* @author Lizh
*/
public
interface
SysRoleService
{
/**
* 分页查询角色列表
*
* @param role 查询条件
* @param page 分页参数
* @return 分页结果
*/
IPage
<
SysRoleEntity
>
pageList
(
SysRoleEntity
role
,
Page
<
SysRoleEntity
>
page
);
/**
* 根据ID查询角色
*
* @param roleId 角色ID
* @return 角色信息
*/
SysRoleEntity
getById
(
Long
roleId
);
/**
* 新增角色
*
* @param role 角色信息
*/
void
add
(
SysRoleEntity
role
);
/**
* 修改角色
*
* @param role 角色信息
*/
void
edit
(
SysRoleEntity
role
);
/**
* 修改角色数据权限
*
* @param role 角色信息(含deptIds)
*/
void
dataScope
(
SysRoleEntity
role
);
/**
* 修改角色状态
*
* @param roleId 角色ID
* @param status 状态
*/
void
changeStatus
(
Long
roleId
,
String
status
);
/**
* 批量删除角色
*
* @param roleIds 角色ID数组
*/
void
remove
(
Long
[]
roleIds
);
/**
* 分页查询已分配用户
*
* @param user 查询条件
* @param page 分页参数
* @return 分页结果
*/
IPage
<
SysUserEntity
>
allocatedList
(
SysUserEntity
user
,
Page
<
SysUserEntity
>
page
);
/**
* 分页查询未分配用户
*
* @param user 查询条件
* @param page 分页参数
* @return 分页结果
*/
IPage
<
SysUserEntity
>
unallocatedList
(
SysUserEntity
user
,
Page
<
SysUserEntity
>
page
);
/**
* 取消授权用户
*
* @param roleId 角色ID
* @param userId 用户ID
*/
void
cancelAuthUser
(
Long
roleId
,
Long
userId
);
/**
* 批量取消授权用户
*
* @param roleId 角色ID
* @param userIds 用户ID数组
*/
void
cancelAuthUserAll
(
Long
roleId
,
Long
[]
userIds
);
/**
* 批量选择授权用户
*
* @param roleId 角色ID
* @param userIds 用户ID数组
*/
void
selectAuthUserAll
(
Long
roleId
,
Long
[]
userIds
);
/**
* 查询部门树(含角色已选部门ID)
*
* @param roleId 角色ID
* @return 部门树
*/
List
<
SysDeptEntity
>
deptTree
(
Long
roleId
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/SysUserService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jomalls.custom.dal.entity.SysDeptEntity
;
import
com.jomalls.custom.dal.entity.SysUserEntity
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户管理 App Service 接口
*
* @author Lizh
*/
public
interface
SysUserService
{
/**
* 分页查询用户列表
*
* @param user 查询条件
* @param page 分页参数
* @return 分页结果
*/
IPage
<
SysUserEntity
>
pageList
(
SysUserEntity
user
,
Page
<
SysUserEntity
>
page
);
/**
* 查询用户详情(含角色列表、岗位ID)
*
* @param userId 用户ID
* @return 包含 user、roles、postIds 的Map
*/
Map
<
String
,
Object
>
getInfo
(
Long
userId
);
/**
* 新增用户
*
* @param user 用户信息
*/
void
add
(
SysUserEntity
user
);
/**
* 修改用户
*
* @param user 用户信息
*/
void
edit
(
SysUserEntity
user
);
/**
* 批量删除用户(逻辑删除)
*
* @param userIds 用户ID数组
*/
void
remove
(
Long
[]
userIds
);
/**
* 重置密码
*
* @param userId 用户ID
* @param password 新密码
*/
void
resetPwd
(
Long
userId
,
String
password
);
/**
* 修改用户状态
*
* @param userId 用户ID
* @param status 状态
*/
void
changeStatus
(
Long
userId
,
String
status
);
/**
* 获取当前登录用户信息
*
* @return 当前登录用户
*/
SysUserEntity
getProfile
();
/**
* 更新当前登录用户信息
*
* @param user 用户信息
*/
void
updateProfile
(
SysUserEntity
user
);
/**
* 修改当前登录用户密码
*
* @param oldPassword 旧密码
* @param newPassword 新密码
*/
void
updatePwd
(
String
oldPassword
,
String
newPassword
);
/**
* 查询用户已分配的角色ID列表
*
* @param userId 用户ID
* @return 角色ID列表
*/
List
<
Long
>
getAuthRoleList
(
Long
userId
);
/**
* 批量插入用户角色关联
*
* @param userId 用户ID
* @param roleIds 角色ID数组
*/
void
insertAuthRole
(
Long
userId
,
Long
[]
roleIds
);
/**
* 查询部门树
*
* @return 部门树
*/
List
<
SysDeptEntity
>
deptTree
();
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysDeptServiceImpl.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
.
impl
;
import
com.jomalls.custom.app.exception.ServiceException
;
import
com.jomalls.custom.app.service.system.SysDeptService
;
import
com.jomalls.custom.dal.entity.SysDeptEntity
;
import
com.jomalls.custom.domain.service.system.SysDeptDomainService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 部门管理 App Service 实现
*
* @author Lizh
*/
@Slf4j
@Service
@RequiredArgsConstructor
public
class
SysDeptServiceImpl
implements
SysDeptService
{
private
final
SysDeptDomainService
sysDeptDomainService
;
@Override
public
List
<
SysDeptEntity
>
selectDeptList
(
SysDeptEntity
dept
)
{
// 查询扁平部门列表
List
<
SysDeptEntity
>
deptList
=
sysDeptDomainService
.
selectDeptList
(
dept
);
// 构建部门树
return
sysDeptDomainService
.
buildDeptTree
(
deptList
);
}
@Override
public
List
<
SysDeptEntity
>
selectDeptListExcludeChild
(
Long
deptId
)
{
return
sysDeptDomainService
.
selectDeptListExcludeChild
(
deptId
);
}
@Override
public
SysDeptEntity
getById
(
Long
deptId
)
{
return
sysDeptDomainService
.
getById
(
deptId
);
}
@Override
public
void
add
(
SysDeptEntity
dept
)
{
// 设置祖级列表
if
(
dept
.
getParentId
()
==
null
||
dept
.
getParentId
()
==
0L
)
{
dept
.
setAncestors
(
"0"
);
}
else
{
SysDeptEntity
parentDept
=
sysDeptDomainService
.
getById
(
dept
.
getParentId
());
if
(
parentDept
==
null
)
{
throw
new
ServiceException
(
"父部门不存在"
);
}
dept
.
setAncestors
(
parentDept
.
getAncestors
()
+
","
+
dept
.
getParentId
());
}
boolean
saved
=
sysDeptDomainService
.
save
(
dept
);
if
(
saved
)
{
log
.
info
(
"新增部门成功: deptName={}"
,
dept
.
getDeptName
());
}
}
@Override
public
void
edit
(
SysDeptEntity
dept
)
{
sysDeptDomainService
.
updateById
(
dept
);
log
.
info
(
"修改部门成功: deptId={}"
,
dept
.
getDeptId
());
}
@Override
public
void
remove
(
Long
deptId
)
{
// 检查是否有子部门
if
(
sysDeptDomainService
.
hasChildByDeptId
(
deptId
))
{
throw
new
ServiceException
(
"存在子部门,不允许删除"
);
}
// 检查部门下是否存在用户
if
(
sysDeptDomainService
.
checkDeptExistUser
(
deptId
))
{
throw
new
ServiceException
(
"部门存在用户,不允许删除"
);
}
sysDeptDomainService
.
removeById
(
deptId
);
log
.
info
(
"删除部门成功: deptId={}"
,
deptId
);
}
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysMenuServiceImpl.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.jomalls.custom.app.exception.ServiceException
;
import
com.jomalls.custom.app.service.system.SysMenuService
;
import
com.jomalls.custom.app.vo.TreeSelectVO
;
import
com.jomalls.custom.dal.entity.SysMenuEntity
;
import
com.jomalls.custom.dal.entity.SysRoleMenuEntity
;
import
com.jomalls.custom.domain.service.system.SysMenuDomainService
;
import
com.jomalls.custom.domain.service.system.SysRoleMenuDomainService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 菜单管理 App Service 实现
*
* @author Lizh
*/
@Slf4j
@Service
@RequiredArgsConstructor
public
class
SysMenuServiceImpl
implements
SysMenuService
{
private
final
SysMenuDomainService
sysMenuDomainService
;
private
final
SysRoleMenuDomainService
sysRoleMenuDomainService
;
@Override
public
List
<
SysMenuEntity
>
selectMenuList
(
SysMenuEntity
menu
)
{
LambdaQueryWrapper
<
SysMenuEntity
>
wrapper
=
new
LambdaQueryWrapper
<>();
if
(
StringUtils
.
hasText
(
menu
.
getMenuName
()))
{
wrapper
.
like
(
SysMenuEntity:
:
getMenuName
,
menu
.
getMenuName
());
}
if
(
StringUtils
.
hasText
(
menu
.
getStatus
()))
{
wrapper
.
eq
(
SysMenuEntity:
:
getStatus
,
menu
.
getStatus
());
}
wrapper
.
eq
(
SysMenuEntity:
:
getDelFlag
,
"0"
);
wrapper
.
orderByAsc
(
SysMenuEntity:
:
getParentId
,
SysMenuEntity:
:
getOrderNum
);
return
sysMenuDomainService
.
list
(
wrapper
);
}
@Override
public
SysMenuEntity
getById
(
Long
menuId
)
{
return
sysMenuDomainService
.
getById
(
menuId
);
}
@Override
public
List
<
TreeSelectVO
>
treeselect
()
{
List
<
SysMenuEntity
>
allMenus
=
sysMenuDomainService
.
list
(
new
LambdaQueryWrapper
<
SysMenuEntity
>()
.
eq
(
SysMenuEntity:
:
getDelFlag
,
"0"
)
.
orderByAsc
(
SysMenuEntity:
:
getParentId
,
SysMenuEntity:
:
getOrderNum
));
return
buildMenuTreeSelect
(
allMenus
);
}
@Override
public
Map
<
String
,
Object
>
roleMenuTreeselect
(
Long
roleId
)
{
List
<
TreeSelectVO
>
menus
=
treeselect
();
// 查询角色已关联的菜单ID
List
<
SysRoleMenuEntity
>
roleMenus
=
sysRoleMenuDomainService
.
list
(
new
LambdaQueryWrapper
<
SysRoleMenuEntity
>().
eq
(
SysRoleMenuEntity:
:
getRoleId
,
roleId
));
List
<
Long
>
checkedKeys
=
roleMenus
.
stream
()
.
map
(
SysRoleMenuEntity:
:
getMenuId
)
.
collect
(
Collectors
.
toList
());
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"menus"
,
menus
);
result
.
put
(
"checkedKeys"
,
checkedKeys
);
return
result
;
}
@Override
public
void
add
(
SysMenuEntity
menu
)
{
menu
.
setCreateTime
(
new
Date
());
sysMenuDomainService
.
save
(
menu
);
log
.
info
(
"新增菜单成功: menuName={}"
,
menu
.
getMenuName
());
}
@Override
public
void
edit
(
SysMenuEntity
menu
)
{
menu
.
setUpdateTime
(
new
Date
());
sysMenuDomainService
.
updateById
(
menu
);
log
.
info
(
"修改菜单成功: menuId={}"
,
menu
.
getMenuId
());
}
@Override
public
void
remove
(
Long
menuId
)
{
// 检查是否有子菜单
long
count
=
sysMenuDomainService
.
count
(
new
LambdaQueryWrapper
<
SysMenuEntity
>().
eq
(
SysMenuEntity:
:
getParentId
,
menuId
));
if
(
count
>
0
)
{
throw
new
ServiceException
(
"存在子菜单,不允许删除"
);
}
// 删除角色菜单关联
sysRoleMenuDomainService
.
remove
(
new
LambdaQueryWrapper
<
SysRoleMenuEntity
>().
eq
(
SysRoleMenuEntity:
:
getMenuId
,
menuId
));
sysMenuDomainService
.
removeById
(
menuId
);
log
.
info
(
"删除菜单成功: menuId={}"
,
menuId
);
}
// ==================== 私有辅助方法 ====================
/**
* 构建菜单树选择列表
*/
private
List
<
TreeSelectVO
>
buildMenuTreeSelect
(
List
<
SysMenuEntity
>
menus
)
{
if
(
menus
==
null
||
menus
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
// 从根节点开始递归构建
return
menus
.
stream
()
.
filter
(
m
->
m
.
getParentId
()
!=
null
&&
m
.
getParentId
()
==
0L
)
.
map
(
m
->
buildTreeSelect
(
m
,
menus
))
.
collect
(
Collectors
.
toList
());
}
/**
* 递归构建树节点
*/
private
TreeSelectVO
buildTreeSelect
(
SysMenuEntity
menu
,
List
<
SysMenuEntity
>
menus
)
{
TreeSelectVO
vo
=
new
TreeSelectVO
();
vo
.
setId
(
menu
.
getMenuId
());
vo
.
setLabel
(
menu
.
getMenuName
());
List
<
TreeSelectVO
>
children
=
menus
.
stream
()
.
filter
(
m
->
menu
.
getMenuId
().
equals
(
m
.
getParentId
()))
.
map
(
m
->
buildTreeSelect
(
m
,
menus
))
.
collect
(
Collectors
.
toList
());
vo
.
setChildren
(
children
.
isEmpty
()
?
null
:
children
);
return
vo
;
}
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysPostServiceImpl.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
service
.
system
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jomalls.custom.app.exception.ServiceException
;
import
com.jomalls.custom.app.service.system.SysPostService
;
import
com.jomalls.custom.dal.entity.SysPostEntity
;
import
com.jomalls.custom.domain.service.system.SysPostDomainService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
/**
* 岗位管理 App Service 实现
*
* @author Lizh
*/
@Slf4j
@Service
@RequiredArgsConstructor
public
class
SysPostServiceImpl
implements
SysPostService
{
private
final
SysPostDomainService
sysPostDomainService
;
@Override
public
IPage
<
SysPostEntity
>
pageList
(
SysPostEntity
post
,
Page
<
SysPostEntity
>
page
)
{
LambdaQueryWrapper
<
SysPostEntity
>
wrapper
=
new
LambdaQueryWrapper
<>();
if
(
StringUtils
.
hasText
(
post
.
getPostCode
()))
{
wrapper
.
like
(
SysPostEntity:
:
getPostCode
,
post
.
getPostCode
());
}
if
(
StringUtils
.
hasText
(
post
.
getPostName
()))
{
wrapper
.
like
(
SysPostEntity:
:
getPostName
,
post
.
getPostName
());
}
if
(
StringUtils
.
hasText
(
post
.
getStatus
()))
{
wrapper
.
eq
(
SysPostEntity:
:
getStatus
,
post
.
getStatus
());
}
wrapper
.
orderByAsc
(
SysPostEntity:
:
getPostSort
);
return
sysPostDomainService
.
page
(
page
,
wrapper
);
}
@Override
public
SysPostEntity
getById
(
Long
postId
)
{
return
sysPostDomainService
.
getById
(
postId
);
}
@Override
public
void
add
(
SysPostEntity
post
)
{
// 检查岗位编码唯一性
long
count
=
sysPostDomainService
.
count
(
new
LambdaQueryWrapper
<
SysPostEntity
>().
eq
(
SysPostEntity:
:
getPostCode
,
post
.
getPostCode
()));
if
(
count
>
0
)
{
throw
new
ServiceException
(
"岗位编码已存在"
);
}
boolean
saved
=
sysPostDomainService
.
save
(
post
);
if
(
saved
)
{
log
.
info
(
"新增岗位成功: postName={}"
,
post
.
getPostName
());
}
}
@Override
public
void
edit
(
SysPostEntity
post
)
{
// 检查岗位编码唯一性(排除自身)
long
count
=
sysPostDomainService
.
count
(
new
LambdaQueryWrapper
<
SysPostEntity
>()
.
eq
(
SysPostEntity:
:
getPostCode
,
post
.
getPostCode
())
.
ne
(
SysPostEntity:
:
getPostId
,
post
.
getPostId
()));
if
(
count
>
0
)
{
throw
new
ServiceException
(
"岗位编码已存在"
);
}
sysPostDomainService
.
updateById
(
post
);
log
.
info
(
"修改岗位成功: postId={}"
,
post
.
getPostId
());
}
@Override
public
void
remove
(
Long
[]
postIds
)
{
for
(
Long
postId
:
postIds
)
{
sysPostDomainService
.
removeById
(
postId
);
}
log
.
info
(
"批量删除岗位成功: count={}"
,
postIds
.
length
);
}
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysRoleServiceImpl.java
0 → 100644
View file @
77f582aa
This diff is collapsed.
Click to expand it.
custom-server-app/src/main/java/com/jomalls/custom/app/service/system/impl/SysUserServiceImpl.java
0 → 100644
View file @
77f582aa
This diff is collapsed.
Click to expand it.
custom-server-app/src/main/java/com/jomalls/custom/app/vo/TreeSelectVO.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
app
.
vo
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
java.util.List
;
/**
* 树结构下拉选择VO
*
* @author Lizh
*/
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
TreeSelectVO
{
/**
* 节点ID
*/
private
Long
id
;
/**
* 节点标签
*/
private
String
label
;
/**
* 子节点
*/
private
List
<
TreeSelectVO
>
children
;
}
custom-server-domain/src/main/java/com/jomalls/custom/dal/entity/SysDeptEntity.java
View file @
77f582aa
...
...
@@ -2,9 +2,12 @@ package com.jomalls.custom.dal.entity;
import
com.baomidou.mybatisplus.annotation.*
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 部门表 Entity
...
...
@@ -100,4 +103,12 @@ public class SysDeptEntity implements Serializable {
*/
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
UPDATE
)
private
LocalDateTime
updateTime
;
/**
* 子部门列表(非数据库字段)
*/
@TableField
(
exist
=
false
)
@EqualsAndHashCode
.
Exclude
@ToString
.
Exclude
private
List
<
SysDeptEntity
>
children
;
}
custom-server-domain/src/main/java/com/jomalls/custom/dal/entity/SysRoleEntity.java
View file @
77f582aa
...
...
@@ -105,5 +105,17 @@ public class SysRoleEntity implements Serializable {
*/
@TableField
(
"remark"
)
private
String
remark
;
/**
* 菜单ID数组(非数据库字段,用于菜单分配)
*/
@TableField
(
exist
=
false
)
private
Long
[]
menuIds
;
/**
* 部门ID数组(非数据库字段,用于数据权限)
*/
@TableField
(
exist
=
false
)
private
Long
[]
deptIds
;
}
custom-server-domain/src/main/java/com/jomalls/custom/dal/entity/SysUserEntity.java
View file @
77f582aa
...
...
@@ -123,5 +123,23 @@ public class SysUserEntity implements Serializable {
*/
@TableField
(
"remark"
)
private
String
remark
;
/**
* 角色ID(非数据库字段,用于查询过滤)
*/
@TableField
(
exist
=
false
)
private
Long
roleId
;
/**
* 角色ID数组(非数据库字段,用于分配角色)
*/
@TableField
(
exist
=
false
)
private
Long
[]
roleIds
;
/**
* 岗位ID数组(非数据库字段,用于分配岗位)
*/
@TableField
(
exist
=
false
)
private
Long
[]
postIds
;
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysDeptDomainService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
domain
.
service
.
system
;
import
com.jomalls.custom.dal.entity.SysDeptEntity
;
import
com.jomalls.custom.service.IBaseService
;
import
java.util.List
;
/**
* 部门表 接口
*
* @author Lizh
*/
public
interface
SysDeptDomainService
extends
IBaseService
<
SysDeptEntity
>
{
/**
* 查询部门列表
*
* @param dept 查询条件
* @return 部门列表
*/
List
<
SysDeptEntity
>
selectDeptList
(
SysDeptEntity
dept
);
/**
* 查询部门列表(排除指定子部门)
*
* @param deptId 部门ID
* @return 部门列表
*/
List
<
SysDeptEntity
>
selectDeptListExcludeChild
(
Long
deptId
);
/**
* 查询是否有子部门
*
* @param deptId 部门ID
* @return true-有子部门
*/
boolean
hasChildByDeptId
(
Long
deptId
);
/**
* 检查部门下是否存在用户
*
* @param deptId 部门ID
* @return true-存在用户
*/
boolean
checkDeptExistUser
(
Long
deptId
);
/**
* 构建部门树
*
* @param depts 部门列表(扁平)
* @return 部门树(嵌套结构)
*/
List
<
SysDeptEntity
>
buildDeptTree
(
List
<
SysDeptEntity
>
depts
);
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysPostDomainService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
domain
.
service
.
system
;
import
com.jomalls.custom.dal.entity.SysPostEntity
;
import
com.jomalls.custom.service.IBaseService
;
/**
* 岗位信息表 接口
*
* @author Lizh
*/
public
interface
SysPostDomainService
extends
IBaseService
<
SysPostEntity
>
{
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysRoleDomainService.java
View file @
77f582aa
...
...
@@ -21,5 +21,13 @@ public interface SysRoleDomainService extends IBaseService<SysRoleEntity> {
* @return 角色 key 集合
*/
Set
<
String
>
selectRoleKeysByUserId
(
Long
userId
);
/**
* 根据用户ID查询角色列表
*
* @param userId 用户ID
* @return 角色列表
*/
List
<
SysRoleEntity
>
selectRoleListByUserId
(
Long
userId
);
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/SysUserPostDomainService.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
domain
.
service
.
system
;
import
com.jomalls.custom.dal.entity.SysUserPostEntity
;
import
com.jomalls.custom.service.IBaseService
;
/**
* 用户与岗位关联表 接口
*
* @author Lizh
*/
public
interface
SysUserPostDomainService
extends
IBaseService
<
SysUserPostEntity
>
{
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysDeptDomainServiceImpl.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
domain
.
service
.
system
.
impl
;
import
com.jomalls.custom.dal.entity.SysDeptEntity
;
import
com.jomalls.custom.dal.mapper.SysDeptMapper
;
import
com.jomalls.custom.domain.service.system.SysDeptDomainService
;
import
com.jomalls.custom.service.impl.BaseServiceImpl
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 部门表 接口实现
*
* @author Lizh
*/
@Service
public
class
SysDeptDomainServiceImpl
extends
BaseServiceImpl
<
SysDeptMapper
,
SysDeptEntity
>
implements
SysDeptDomainService
{
@Autowired
public
SysDeptDomainServiceImpl
(
SqlSessionFactory
sqlSessionFactory
)
{
super
(
sqlSessionFactory
);
}
@Override
public
List
<
SysDeptEntity
>
selectDeptList
(
SysDeptEntity
dept
)
{
return
baseMapper
.
selectDeptList
(
dept
);
}
@Override
public
List
<
SysDeptEntity
>
selectDeptListExcludeChild
(
Long
deptId
)
{
return
baseMapper
.
selectDeptListExcludeChild
(
deptId
);
}
@Override
public
boolean
hasChildByDeptId
(
Long
deptId
)
{
return
baseMapper
.
hasChildByDeptId
(
deptId
)
>
0
;
}
@Override
public
boolean
checkDeptExistUser
(
Long
deptId
)
{
return
baseMapper
.
checkDeptExistUser
(
deptId
)
>
0
;
}
@Override
public
List
<
SysDeptEntity
>
buildDeptTree
(
List
<
SysDeptEntity
>
depts
)
{
if
(
depts
==
null
||
depts
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
// 按 parentId 分组
Map
<
Long
,
List
<
SysDeptEntity
>>
parentIdMap
=
depts
.
stream
()
.
filter
(
d
->
d
.
getParentId
()
!=
null
)
.
collect
(
Collectors
.
groupingBy
(
SysDeptEntity:
:
getParentId
));
// 为每个节点设置子节点列表
for
(
SysDeptEntity
dept
:
depts
)
{
List
<
SysDeptEntity
>
children
=
parentIdMap
.
getOrDefault
(
dept
.
getDeptId
(),
Collections
.
emptyList
());
dept
.
setChildren
(
children
);
}
// 返回根节点(parentId == 0L)
return
depts
.
stream
()
.
filter
(
d
->
d
.
getParentId
()
!=
null
&&
d
.
getParentId
()
==
0L
)
.
collect
(
Collectors
.
toList
());
}
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysPostDomainServiceImpl.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
domain
.
service
.
system
.
impl
;
import
com.jomalls.custom.dal.entity.SysPostEntity
;
import
com.jomalls.custom.dal.mapper.SysPostMapper
;
import
com.jomalls.custom.domain.service.system.SysPostDomainService
;
import
com.jomalls.custom.service.impl.BaseServiceImpl
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* 岗位信息表 接口实现
*
* @author Lizh
*/
@Service
public
class
SysPostDomainServiceImpl
extends
BaseServiceImpl
<
SysPostMapper
,
SysPostEntity
>
implements
SysPostDomainService
{
@Autowired
public
SysPostDomainServiceImpl
(
SqlSessionFactory
sqlSessionFactory
)
{
super
(
sqlSessionFactory
);
}
}
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysRoleDomainServiceImpl.java
View file @
77f582aa
...
...
@@ -40,4 +40,9 @@ public class SysRoleDomainServiceImpl extends BaseServiceImpl<SysRoleMapper,SysR
.
filter
(
StringUtils:
:
hasText
)
.
collect
(
Collectors
.
toSet
());
}
@Override
public
List
<
SysRoleEntity
>
selectRoleListByUserId
(
Long
userId
)
{
return
baseMapper
.
selectRoleListByUserId
(
userId
);
}
}
\ No newline at end of file
custom-server-domain/src/main/java/com/jomalls/custom/domain/service/system/impl/SysUserPostDomainServiceImpl.java
0 → 100644
View file @
77f582aa
package
com
.
jomalls
.
custom
.
domain
.
service
.
system
.
impl
;
import
com.jomalls.custom.dal.entity.SysUserPostEntity
;
import
com.jomalls.custom.dal.mapper.SysUserPostMapper
;
import
com.jomalls.custom.domain.service.system.SysUserPostDomainService
;
import
com.jomalls.custom.service.impl.BaseServiceImpl
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* 用户与岗位关联表 接口实现
*
* @author Lizh
*/
@Service
public
class
SysUserPostDomainServiceImpl
extends
BaseServiceImpl
<
SysUserPostMapper
,
SysUserPostEntity
>
implements
SysUserPostDomainService
{
@Autowired
public
SysUserPostDomainServiceImpl
(
SqlSessionFactory
sqlSessionFactory
)
{
super
(
sqlSessionFactory
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment