Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
46444bd0
Commit
46444bd0
authored
Oct 08, 2019
by
RuoYi
Browse files
RuoYi-Vue 1.0
parent
5bc74554
Changes
400
Hide whitespace changes
Inline
Side-by-side
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysConfig
;
/**
* 参数配置 服务层
*
* @author ruoyi
*/
public
interface
ISysConfigService
{
/**
* 查询参数配置信息
*
* @param configId 参数配置ID
* @return 参数配置信息
*/
public
SysConfig
selectConfigById
(
Long
configId
);
/**
* 根据键名查询参数配置信息
*
* @param configKey 参数键名
* @return 参数键值
*/
public
Object
selectConfigByKey
(
String
configKey
);
/**
* 查询参数配置列表
*
* @param config 参数配置信息
* @return 参数配置集合
*/
public
List
<
SysConfig
>
selectConfigList
(
SysConfig
config
);
/**
* 新增参数配置
*
* @param config 参数配置信息
* @return 结果
*/
public
int
insertConfig
(
SysConfig
config
);
/**
* 修改参数配置
*
* @param config 参数配置信息
* @return 结果
*/
public
int
updateConfig
(
SysConfig
config
);
/**
* 删除参数配置信息
*
* @param configId 需要删除的数据ID
* @return 结果
*/
public
int
deleteConfigById
(
Long
configId
);
/**
* 校验参数键名是否唯一
*
* @param config 参数信息
* @return 结果
*/
public
String
checkConfigKeyUnique
(
SysConfig
config
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.framework.web.domain.TreeSelect
;
import
com.ruoyi.project.system.domain.SysDept
;
/**
* 部门管理 服务层
*
* @author ruoyi
*/
public
interface
ISysDeptService
{
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public
List
<
SysDept
>
selectDeptList
(
SysDept
dept
);
/**
* 构建前端所需要树结构
*
* @param depts 部门列表
* @return 树结构列表
*/
public
List
<
SysDept
>
buildDeptTree
(
List
<
SysDept
>
depts
);
/**
* 构建前端所需要下拉树结构
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
public
List
<
TreeSelect
>
buildDeptTreeSelect
(
List
<
SysDept
>
depts
);
/**
* 根据角色ID查询部门树信息
*
* @param roleId 角色ID
* @return 选中部门列表
*/
public
List
<
Integer
>
selectDeptListByRoleId
(
Long
roleId
);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public
SysDept
selectDeptById
(
Long
deptId
);
/**
* 是否存在部门子节点
*
* @param deptId 部门ID
* @return 结果
*/
public
boolean
hasChildByDeptId
(
Long
deptId
);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
public
boolean
checkDeptExistUser
(
Long
deptId
);
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
public
String
checkDeptNameUnique
(
SysDept
dept
);
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public
int
insertDept
(
SysDept
dept
);
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public
int
updateDept
(
SysDept
dept
);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public
int
deleteDeptById
(
Long
deptId
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysDictData
;
/**
* 字典 业务层
*
* @author ruoyi
*/
public
interface
ISysDictDataService
{
/**
* 根据条件分页查询字典数据
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
public
List
<
SysDictData
>
selectDictDataList
(
SysDictData
dictData
);
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
public
List
<
SysDictData
>
selectDictDataByType
(
String
dictType
);
/**
* 根据字典类型和字典键值查询字典数据信息
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典标签
*/
public
String
selectDictLabel
(
String
dictType
,
String
dictValue
);
/**
* 根据字典数据ID查询信息
*
* @param dictCode 字典数据ID
* @return 字典数据
*/
public
SysDictData
selectDictDataById
(
Long
dictCode
);
/**
* 通过字典ID删除字典数据信息
*
* @param dictCode 字典数据ID
* @return 结果
*/
public
int
deleteDictDataById
(
Long
dictCode
);
/**
* 新增保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
public
int
insertDictData
(
SysDictData
dictData
);
/**
* 修改保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
public
int
updateDictData
(
SysDictData
dictData
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysDictType
;
/**
* 字典 业务层
*
* @author ruoyi
*/
public
interface
ISysDictTypeService
{
/**
* 根据条件分页查询字典类型
*
* @param dictType 字典类型信息
* @return 字典类型集合信息
*/
public
List
<
SysDictType
>
selectDictTypeList
(
SysDictType
dictType
);
/**
* 根据所有字典类型
*
* @return 字典类型集合信息
*/
public
List
<
SysDictType
>
selectDictTypeAll
();
/**
* 根据字典类型ID查询信息
*
* @param dictId 字典类型ID
* @return 字典类型
*/
public
SysDictType
selectDictTypeById
(
Long
dictId
);
/**
* 根据字典类型查询信息
*
* @param dictType 字典类型
* @return 字典类型
*/
public
SysDictType
selectDictTypeByType
(
String
dictType
);
/**
* 通过字典ID删除字典信息
*
* @param dictId 字典ID
* @return 结果
*/
public
int
deleteDictTypeById
(
Long
dictId
);
/**
* 新增保存字典类型信息
*
* @param dictType 字典类型信息
* @return 结果
*/
public
int
insertDictType
(
SysDictType
dictType
);
/**
* 修改保存字典类型信息
*
* @param dictType 字典类型信息
* @return 结果
*/
public
int
updateDictType
(
SysDictType
dictType
);
/**
* 校验字典类型称是否唯一
*
* @param dictType 字典类型
* @return 结果
*/
public
String
checkDictTypeUnique
(
SysDictType
dictType
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
java.util.Set
;
import
com.ruoyi.framework.web.domain.TreeSelect
;
import
com.ruoyi.project.system.domain.SysMenu
;
import
com.ruoyi.project.system.domain.vo.RouterVo
;
/**
* 菜单 业务层
*
* @author ruoyi
*/
public
interface
ISysMenuService
{
/**
* 查询系统菜单列表
*
* @param menu 菜单信息
* @return 菜单列表
*/
public
List
<
SysMenu
>
selectMenuList
(
SysMenu
menu
);
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
public
Set
<
String
>
selectMenuPermsByUserId
(
Long
userId
);
/**
* 根据用户ID查询菜单树信息
*
* @param userId 用户ID
* @return 菜单列表
*/
public
List
<
SysMenu
>
selectMenuTreeByUserId
(
Long
userId
);
/**
* 根据角色ID查询菜单树信息
*
* @param roleId 角色ID
* @return 选中菜单列表
*/
public
List
<
Integer
>
selectMenuListByRoleId
(
Long
roleId
);
/**
* 构建前端路由所需要的菜单
*
* @param menus 菜单列表
* @return 路由列表
*/
public
List
<
RouterVo
>
buildMenus
(
List
<
SysMenu
>
menus
);
/**
* 构建前端所需要树结构
*
* @param menus 菜单列表
* @return 树结构列表
*/
public
List
<
SysMenu
>
buildMenuTree
(
List
<
SysMenu
>
menus
);
/**
* 构建前端所需要下拉树结构
*
* @param menus 菜单列表
* @return 下拉树结构列表
*/
public
List
<
TreeSelect
>
buildMenuTreeSelect
(
List
<
SysMenu
>
menus
);
/**
* 根据菜单ID查询信息
*
* @param menuId 菜单ID
* @return 菜单信息
*/
public
SysMenu
selectMenuById
(
Long
menuId
);
/**
* 是否存在菜单子节点
*
* @param menuId 菜单ID
* @return 结果 true 存在 false 不存在
*/
public
boolean
hasChildByMenuId
(
Long
menuId
);
/**
* 查询菜单是否存在角色
*
* @param menuId 菜单ID
* @return 结果 true 存在 false 不存在
*/
public
boolean
checkMenuExistRole
(
Long
menuId
);
/**
* 新增保存菜单信息
*
* @param menu 菜单信息
* @return 结果
*/
public
int
insertMenu
(
SysMenu
menu
);
/**
* 修改保存菜单信息
*
* @param menu 菜单信息
* @return 结果
*/
public
int
updateMenu
(
SysMenu
menu
);
/**
* 删除菜单管理信息
*
* @param menuId 菜单ID
* @return 结果
*/
public
int
deleteMenuById
(
Long
menuId
);
/**
* 校验菜单名称是否唯一
*
* @param menu 菜单信息
* @return 结果
*/
public
String
checkMenuNameUnique
(
SysMenu
menu
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysNotice
;
/**
* 公告 服务层
*
* @author ruoyi
*/
public
interface
ISysNoticeService
{
/**
* 查询公告信息
*
* @param noticeId 公告ID
* @return 公告信息
*/
public
SysNotice
selectNoticeById
(
Long
noticeId
);
/**
* 查询公告列表
*
* @param notice 公告信息
* @return 公告集合
*/
public
List
<
SysNotice
>
selectNoticeList
(
SysNotice
notice
);
/**
* 新增公告
*
* @param notice 公告信息
* @return 结果
*/
public
int
insertNotice
(
SysNotice
notice
);
/**
* 修改公告
*
* @param notice 公告信息
* @return 结果
*/
public
int
updateNotice
(
SysNotice
notice
);
/**
* 删除公告信息
*
* @param noticeId 公告ID
* @return 结果
*/
public
int
deleteNoticeById
(
Long
noticeId
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysPostService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysPost
;
/**
* 岗位信息 服务层
*
* @author ruoyi
*/
public
interface
ISysPostService
{
/**
* 查询岗位信息集合
*
* @param post 岗位信息
* @return 岗位列表
*/
public
List
<
SysPost
>
selectPostList
(
SysPost
post
);
/**
* 查询所有岗位
*
* @return 岗位列表
*/
public
List
<
SysPost
>
selectPostAll
();
/**
* 通过岗位ID查询岗位信息
*
* @param postId 岗位ID
* @return 角色对象信息
*/
public
SysPost
selectPostById
(
Long
postId
);
/**
* 根据用户ID获取岗位选择框列表
*
* @param userId 用户ID
* @return 选中岗位ID列表
*/
public
List
<
Integer
>
selectPostListByUserId
(
Long
userId
);
/**
* 校验岗位名称
*
* @param post 岗位信息
* @return 结果
*/
public
String
checkPostNameUnique
(
SysPost
post
);
/**
* 校验岗位编码
*
* @param post 岗位信息
* @return 结果
*/
public
String
checkPostCodeUnique
(
SysPost
post
);
/**
* 删除岗位信息
*
* @param postId 岗位ID
* @return 结果
*/
public
int
deletePostById
(
Long
postId
);
/**
* 新增保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
public
int
insertPost
(
SysPost
post
);
/**
* 修改保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
public
int
updatePost
(
SysPost
post
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysRoleService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
java.util.Set
;
import
com.ruoyi.project.system.domain.SysRole
;
/**
* 角色业务层
*
* @author ruoyi
*/
public
interface
ISysRoleService
{
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
public
List
<
SysRole
>
selectRoleList
(
SysRole
role
);
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 权限列表
*/
public
Set
<
String
>
selectRolePermissionByUserId
(
Long
userId
);
/**
* 查询所有角色
*
* @return 角色列表
*/
public
List
<
SysRole
>
selectRoleAll
();
/**
* 根据用户ID获取角色选择框列表
*
* @param userId 用户ID
* @return 选中角色ID列表
*/
public
List
<
Integer
>
selectRoleListByUserId
(
Long
userId
);
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID
* @return 角色对象信息
*/
public
SysRole
selectRoleById
(
Long
roleId
);
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
public
String
checkRoleNameUnique
(
SysRole
role
);
/**
* 校验角色权限是否唯一
*
* @param role 角色信息
* @return 结果
*/
public
String
checkRoleKeyUnique
(
SysRole
role
);
/**
* 校验角色是否允许操作
*
* @param role 角色信息
*/
public
void
checkRoleAllowed
(
SysRole
role
);
/**
* 新增保存角色信息
*
* @param role 角色信息
* @return 结果
*/
public
int
insertRole
(
SysRole
role
);
/**
* 修改保存角色信息
*
* @param role 角色信息
* @return 结果
*/
public
int
updateRole
(
SysRole
role
);
/**
* 修改角色状态
*
* @param role 角色信息
* @return 结果
*/
public
int
updateRoleStatus
(
SysRole
role
);
/**
* 修改数据权限信息
*
* @param role 角色信息
* @return 结果
*/
public
int
authDataScope
(
SysRole
role
);
/**
* 通过角色ID删除角色
*
* @param roleId 角色ID
* @return 结果
*/
public
int
deleteRoleById
(
Long
roleId
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserService.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysUser
;
/**
* 用户 业务层
*
* @author ruoyi
*/
public
interface
ISysUserService
{
/**
* 根据条件分页查询用户列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public
List
<
SysUser
>
selectUserList
(
SysUser
user
);
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
public
SysUser
selectUserByUserName
(
String
userName
);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public
SysUser
selectUserById
(
Long
userId
);
/**
* 根据用户ID查询用户所属角色组
*
* @param userName 用户名
* @return 结果
*/
public
String
selectUserRoleGroup
(
String
userName
);
/**
* 根据用户ID查询用户所属岗位组
*
* @param userName 用户名
* @return 结果
*/
public
String
selectUserPostGroup
(
String
userName
);
/**
* 校验用户名称是否唯一
*
* @param userName 用户名称
* @return 结果
*/
public
String
checkUserNameUnique
(
String
userName
);
/**
* 校验手机号码是否唯一
*
* @param user 用户信息
* @return 结果
*/
public
String
checkPhoneUnique
(
SysUser
user
);
/**
* 校验email是否唯一
*
* @param user 用户信息
* @return 结果
*/
public
String
checkEmailUnique
(
SysUser
user
);
/**
* 校验用户是否允许操作
*
* @param user 用户信息
*/
public
void
checkUserAllowed
(
SysUser
user
);
/**
* 新增用户信息
*
* @param user 用户信息
* @return 结果
*/
public
int
insertUser
(
SysUser
user
);
/**
* 修改用户信息
*
* @param user 用户信息
* @return 结果
*/
public
int
updateUser
(
SysUser
user
);
/**
* 修改用户状态
*
* @param user 用户信息
* @return 结果
*/
public
int
updateUserStatus
(
SysUser
user
);
/**
* 修改用户基本信息
*
* @param user 用户信息
* @return 结果
*/
public
int
updateUserProfile
(
SysUser
user
);
/**
* 修改用户头像
*
* @param userName 用户名
* @param avatar 头像地址
* @return 结果
*/
public
boolean
updateUserAvatar
(
String
userName
,
String
avatar
);
/**
* 重置用户密码
*
* @param user 用户信息
* @return 结果
*/
public
int
resetPwd
(
SysUser
user
);
/**
* 重置用户密码
*
* @param userName 用户名
* @param password 密码
* @return 结果
*/
public
int
resetUserPwd
(
String
userName
,
String
password
);
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
public
int
deleteUserById
(
Long
userId
);
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.project.system.domain.SysConfig
;
import
com.ruoyi.project.system.mapper.SysConfigMapper
;
import
com.ruoyi.project.system.service.ISysConfigService
;
/**
* 参数配置 服务层实现
*
* @author ruoyi
*/
@Service
public
class
SysConfigServiceImpl
implements
ISysConfigService
{
@Autowired
private
SysConfigMapper
configMapper
;
/**
* 查询参数配置信息
*
* @param configId 参数配置ID
* @return 参数配置信息
*/
@Override
public
SysConfig
selectConfigById
(
Long
configId
)
{
SysConfig
config
=
new
SysConfig
();
config
.
setConfigId
(
configId
);
return
configMapper
.
selectConfig
(
config
);
}
/**
* 根据键名查询参数配置信息
*
* @param configKey 参数key
* @return 参数键值
*/
@Override
public
Object
selectConfigByKey
(
String
configKey
)
{
SysConfig
config
=
new
SysConfig
();
config
.
setConfigKey
(
configKey
);
SysConfig
retConfig
=
configMapper
.
selectConfig
(
config
);
return
StringUtils
.
isNotNull
(
retConfig
)
?
retConfig
.
getConfigValue
()
:
""
;
}
/**
* 查询参数配置列表
*
* @param config 参数配置信息
* @return 参数配置集合
*/
@Override
public
List
<
SysConfig
>
selectConfigList
(
SysConfig
config
)
{
return
configMapper
.
selectConfigList
(
config
);
}
/**
* 新增参数配置
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public
int
insertConfig
(
SysConfig
config
)
{
return
configMapper
.
insertConfig
(
config
);
}
/**
* 修改参数配置
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public
int
updateConfig
(
SysConfig
config
)
{
return
configMapper
.
updateConfig
(
config
);
}
/**
* 删除参数配置信息
*
* @param configId 需要删除的数据ID
* @return 结果
*/
@Override
public
int
deleteConfigById
(
Long
configId
)
{
return
configMapper
.
deleteConfigById
(
configId
);
}
/**
* 校验参数键名是否唯一
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public
String
checkConfigKeyUnique
(
SysConfig
config
)
{
Long
configId
=
StringUtils
.
isNull
(
config
.
getConfigId
())
?
-
1L
:
config
.
getConfigId
();
SysConfig
info
=
configMapper
.
checkConfigKeyUnique
(
config
.
getConfigKey
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getConfigId
().
longValue
()
!=
configId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.aspectj.lang.annotation.DataScope
;
import
com.ruoyi.framework.web.domain.TreeSelect
;
import
com.ruoyi.project.system.domain.SysDept
;
import
com.ruoyi.project.system.mapper.SysDeptMapper
;
import
com.ruoyi.project.system.service.ISysDeptService
;
/**
* 部门管理 服务实现
*
* @author ruoyi
*/
@Service
public
class
SysDeptServiceImpl
implements
ISysDeptService
{
@Autowired
private
SysDeptMapper
deptMapper
;
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
@Override
@DataScope
(
deptAlias
=
"d"
)
public
List
<
SysDept
>
selectDeptList
(
SysDept
dept
)
{
return
deptMapper
.
selectDeptList
(
dept
);
}
/**
* 构建前端所需要树结构
*
* @param depts 部门列表
* @return 树结构列表
*/
@Override
public
List
<
SysDept
>
buildDeptTree
(
List
<
SysDept
>
depts
)
{
List
<
SysDept
>
returnList
=
new
ArrayList
<
SysDept
>();
for
(
Iterator
<
SysDept
>
iterator
=
depts
.
iterator
();
iterator
.
hasNext
();)
{
SysDept
t
=
(
SysDept
)
iterator
.
next
();
// 根据传入的某个父节点ID,遍历该父节点的所有子节点
if
(
t
.
getParentId
()
==
0
)
{
recursionFn
(
depts
,
t
);
returnList
.
add
(
t
);
}
}
if
(
returnList
.
isEmpty
())
{
returnList
=
depts
;
}
return
returnList
;
}
/**
* 构建前端所需要下拉树结构
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
@Override
public
List
<
TreeSelect
>
buildDeptTreeSelect
(
List
<
SysDept
>
depts
)
{
List
<
SysDept
>
deptTrees
=
buildDeptTree
(
depts
);
return
deptTrees
.
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
/**
* 根据角色ID查询部门树信息
*
* @param roleId 角色ID
* @return 选中部门列表
*/
@Override
public
List
<
Integer
>
selectDeptListByRoleId
(
Long
roleId
)
{
return
deptMapper
.
selectDeptListByRoleId
(
roleId
);
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
@Override
public
SysDept
selectDeptById
(
Long
deptId
)
{
return
deptMapper
.
selectDeptById
(
deptId
);
}
/**
* 是否存在子节点
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public
boolean
hasChildByDeptId
(
Long
deptId
)
{
int
result
=
deptMapper
.
hasChildByDeptId
(
deptId
);
return
result
>
0
?
true
:
false
;
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public
boolean
checkDeptExistUser
(
Long
deptId
)
{
int
result
=
deptMapper
.
checkDeptExistUser
(
deptId
);
return
result
>
0
?
true
:
false
;
}
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
@Override
public
String
checkDeptNameUnique
(
SysDept
dept
)
{
Long
deptId
=
StringUtils
.
isNull
(
dept
.
getDeptId
())
?
-
1L
:
dept
.
getDeptId
();
SysDept
info
=
deptMapper
.
checkDeptNameUnique
(
dept
.
getDeptName
(),
dept
.
getParentId
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getDeptId
().
longValue
()
!=
deptId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public
int
insertDept
(
SysDept
dept
)
{
SysDept
info
=
deptMapper
.
selectDeptById
(
dept
.
getParentId
());
// 如果父节点不为正常状态,则不允许新增子节点
if
(!
UserConstants
.
DEPT_NORMAL
.
equals
(
info
.
getStatus
()))
{
throw
new
CustomException
(
"部门停用,不允许新增"
);
}
dept
.
setAncestors
(
info
.
getAncestors
()
+
","
+
dept
.
getParentId
());
return
deptMapper
.
insertDept
(
dept
);
}
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public
int
updateDept
(
SysDept
dept
)
{
SysDept
newParentDept
=
deptMapper
.
selectDeptById
(
dept
.
getParentId
());
SysDept
oldDept
=
deptMapper
.
selectDeptById
(
dept
.
getDeptId
());
if
(
StringUtils
.
isNotNull
(
newParentDept
)
&&
StringUtils
.
isNotNull
(
oldDept
))
{
String
newAncestors
=
newParentDept
.
getAncestors
()
+
","
+
newParentDept
.
getDeptId
();
String
oldAncestors
=
oldDept
.
getAncestors
();
dept
.
setAncestors
(
newAncestors
);
updateDeptChildren
(
dept
.
getDeptId
(),
newAncestors
,
oldAncestors
);
}
int
result
=
deptMapper
.
updateDept
(
dept
);
if
(
UserConstants
.
DEPT_NORMAL
.
equals
(
dept
.
getStatus
()))
{
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatus
(
dept
);
}
return
result
;
}
/**
* 修改该部门的父级部门状态
*
* @param dept 当前部门
*/
private
void
updateParentDeptStatus
(
SysDept
dept
)
{
String
updateBy
=
dept
.
getUpdateBy
();
dept
=
deptMapper
.
selectDeptById
(
dept
.
getDeptId
());
dept
.
setUpdateBy
(
updateBy
);
deptMapper
.
updateDeptStatus
(
dept
);
}
/**
* 修改子元素关系
*
* @param deptId 被修改的部门ID
* @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合
*/
public
void
updateDeptChildren
(
Long
deptId
,
String
newAncestors
,
String
oldAncestors
)
{
List
<
SysDept
>
children
=
deptMapper
.
selectChildrenDeptById
(
deptId
);
for
(
SysDept
child
:
children
)
{
child
.
setAncestors
(
child
.
getAncestors
().
replace
(
oldAncestors
,
newAncestors
));
}
if
(
children
.
size
()
>
0
)
{
deptMapper
.
updateDeptChildren
(
children
);
}
}
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public
int
deleteDeptById
(
Long
deptId
)
{
return
deptMapper
.
deleteDeptById
(
deptId
);
}
/**
* 递归列表
*/
private
void
recursionFn
(
List
<
SysDept
>
list
,
SysDept
t
)
{
// 得到子节点列表
List
<
SysDept
>
childList
=
getChildList
(
list
,
t
);
t
.
setChildren
(
childList
);
for
(
SysDept
tChild
:
childList
)
{
if
(
hasChild
(
list
,
tChild
))
{
// 判断是否有子节点
Iterator
<
SysDept
>
it
=
childList
.
iterator
();
while
(
it
.
hasNext
())
{
SysDept
n
=
(
SysDept
)
it
.
next
();
recursionFn
(
list
,
n
);
}
}
}
}
/**
* 得到子节点列表
*/
private
List
<
SysDept
>
getChildList
(
List
<
SysDept
>
list
,
SysDept
t
)
{
List
<
SysDept
>
tlist
=
new
ArrayList
<
SysDept
>();
Iterator
<
SysDept
>
it
=
list
.
iterator
();
while
(
it
.
hasNext
())
{
SysDept
n
=
(
SysDept
)
it
.
next
();
if
(
n
.
getParentId
().
longValue
()
==
t
.
getDeptId
().
longValue
())
{
tlist
.
add
(
n
);
}
}
return
tlist
;
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
SysDept
>
list
,
SysDept
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
?
true
:
false
;
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.mapper.SysDictDataMapper
;
import
com.ruoyi.project.system.service.ISysDictDataService
;
/**
* 字典 业务层处理
*
* @author ruoyi
*/
@Service
public
class
SysDictDataServiceImpl
implements
ISysDictDataService
{
@Autowired
private
SysDictDataMapper
dictDataMapper
;
/**
* 根据条件分页查询字典数据
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
@Override
public
List
<
SysDictData
>
selectDictDataList
(
SysDictData
dictData
)
{
return
dictDataMapper
.
selectDictDataList
(
dictData
);
}
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public
List
<
SysDictData
>
selectDictDataByType
(
String
dictType
)
{
return
dictDataMapper
.
selectDictDataByType
(
dictType
);
}
/**
* 根据字典类型和字典键值查询字典数据信息
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典标签
*/
@Override
public
String
selectDictLabel
(
String
dictType
,
String
dictValue
)
{
return
dictDataMapper
.
selectDictLabel
(
dictType
,
dictValue
);
}
/**
* 根据字典数据ID查询信息
*
* @param dictCode 字典数据ID
* @return 字典数据
*/
@Override
public
SysDictData
selectDictDataById
(
Long
dictCode
)
{
return
dictDataMapper
.
selectDictDataById
(
dictCode
);
}
/**
* 通过字典ID删除字典数据信息
*
* @param dictCode 字典数据ID
* @return 结果
*/
@Override
public
int
deleteDictDataById
(
Long
dictCode
)
{
return
dictDataMapper
.
deleteDictDataById
(
dictCode
);
}
/**
* 新增保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public
int
insertDictData
(
SysDictData
dictData
)
{
return
dictDataMapper
.
insertDictData
(
dictData
);
}
/**
* 修改保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public
int
updateDictData
(
SysDictData
dictData
)
{
return
dictDataMapper
.
updateDictData
(
dictData
);
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.project.system.domain.SysDictType
;
import
com.ruoyi.project.system.mapper.SysDictDataMapper
;
import
com.ruoyi.project.system.mapper.SysDictTypeMapper
;
import
com.ruoyi.project.system.service.ISysDictTypeService
;
/**
* 字典 业务层处理
*
* @author ruoyi
*/
@Service
public
class
SysDictTypeServiceImpl
implements
ISysDictTypeService
{
@Autowired
private
SysDictTypeMapper
dictTypeMapper
;
@Autowired
private
SysDictDataMapper
dictDataMapper
;
/**
* 根据条件分页查询字典类型
*
* @param dictType 字典类型信息
* @return 字典类型集合信息
*/
@Override
public
List
<
SysDictType
>
selectDictTypeList
(
SysDictType
dictType
)
{
return
dictTypeMapper
.
selectDictTypeList
(
dictType
);
}
/**
* 根据所有字典类型
*
* @return 字典类型集合信息
*/
@Override
public
List
<
SysDictType
>
selectDictTypeAll
()
{
return
dictTypeMapper
.
selectDictTypeAll
();
}
/**
* 根据字典类型ID查询信息
*
* @param dictId 字典类型ID
* @return 字典类型
*/
@Override
public
SysDictType
selectDictTypeById
(
Long
dictId
)
{
return
dictTypeMapper
.
selectDictTypeById
(
dictId
);
}
/**
* 根据字典类型查询信息
*
* @param dictType 字典类型
* @return 字典类型
*/
public
SysDictType
selectDictTypeByType
(
String
dictType
)
{
return
dictTypeMapper
.
selectDictTypeByType
(
dictType
);
}
/**
* 通过字典ID删除字典信息
*
* @param dictId 字典ID
* @return 结果
*/
@Override
public
int
deleteDictTypeById
(
Long
dictId
)
{
return
dictTypeMapper
.
deleteDictTypeById
(
dictId
);
}
/**
* 新增保存字典类型信息
*
* @param dictType 字典类型信息
* @return 结果
*/
@Override
public
int
insertDictType
(
SysDictType
dictType
)
{
return
dictTypeMapper
.
insertDictType
(
dictType
);
}
/**
* 修改保存字典类型信息
*
* @param dictType 字典类型信息
* @return 结果
*/
@Override
@Transactional
public
int
updateDictType
(
SysDictType
dictType
)
{
SysDictType
oldDict
=
dictTypeMapper
.
selectDictTypeById
(
dictType
.
getDictId
());
dictDataMapper
.
updateDictDataType
(
oldDict
.
getDictType
(),
dictType
.
getDictType
());
return
dictTypeMapper
.
updateDictType
(
dictType
);
}
/**
* 校验字典类型称是否唯一
*
* @param dict 字典类型
* @return 结果
*/
@Override
public
String
checkDictTypeUnique
(
SysDictType
dict
)
{
Long
dictId
=
StringUtils
.
isNull
(
dict
.
getDictId
())
?
-
1L
:
dict
.
getDictId
();
SysDictType
dictType
=
dictTypeMapper
.
checkDictTypeUnique
(
dict
.
getDictType
());
if
(
StringUtils
.
isNotNull
(
dictType
)
&&
dictType
.
getDictId
().
longValue
()
!=
dictId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.web.domain.TreeSelect
;
import
com.ruoyi.project.system.domain.SysMenu
;
import
com.ruoyi.project.system.domain.vo.MetaVo
;
import
com.ruoyi.project.system.domain.vo.RouterVo
;
import
com.ruoyi.project.system.mapper.SysMenuMapper
;
import
com.ruoyi.project.system.mapper.SysRoleMenuMapper
;
import
com.ruoyi.project.system.service.ISysMenuService
;
/**
* 菜单 业务层处理
*
* @author ruoyi
*/
@Service
public
class
SysMenuServiceImpl
implements
ISysMenuService
{
public
static
final
String
PREMISSION_STRING
=
"perms[\"{0}\"]"
;
@Autowired
private
SysMenuMapper
menuMapper
;
@Autowired
private
SysRoleMenuMapper
roleMenuMapper
;
/**
* 查询系统菜单列表
*
* @param menu 菜单信息
* @return 菜单列表
*/
@Override
public
List
<
SysMenu
>
selectMenuList
(
SysMenu
menu
)
{
List
<
SysMenu
>
menuList
=
menuMapper
.
selectMenuList
(
menu
);
return
menuList
;
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public
Set
<
String
>
selectMenuPermsByUserId
(
Long
userId
)
{
List
<
String
>
perms
=
menuMapper
.
selectMenuPermsByUserId
(
userId
);
Set
<
String
>
permsSet
=
new
HashSet
<>();
for
(
String
perm
:
perms
)
{
if
(
StringUtils
.
isNotEmpty
(
perm
))
{
permsSet
.
addAll
(
Arrays
.
asList
(
perm
.
trim
().
split
(
","
)));
}
}
return
permsSet
;
}
/**
* 根据用户名称查询菜单
*
* @param username 用户名称
* @return 菜单列表
*/
@Override
public
List
<
SysMenu
>
selectMenuTreeByUserId
(
Long
userId
)
{
List
<
SysMenu
>
menus
=
null
;
if
(
SecurityUtils
.
isAdmin
(
userId
))
{
menus
=
menuMapper
.
selectMenuTreeAll
();
}
else
{
menus
=
menuMapper
.
selectMenuTreeByUserId
(
userId
);
}
return
getChildPerms
(
menus
,
0
);
}
/**
* 根据角色ID查询菜单树信息
*
* @param roleId 角色ID
* @return 选中菜单列表
*/
public
List
<
Integer
>
selectMenuListByRoleId
(
Long
roleId
)
{
return
menuMapper
.
selectMenuListByRoleId
(
roleId
);
}
/**
* 构建前端路由所需要的菜单
*
* @param menus 菜单列表
* @return 路由列表
*/
@Override
public
List
<
RouterVo
>
buildMenus
(
List
<
SysMenu
>
menus
)
{
List
<
RouterVo
>
routers
=
new
LinkedList
<
RouterVo
>();
for
(
SysMenu
menu
:
menus
)
{
RouterVo
router
=
new
RouterVo
();
router
.
setName
(
menu
.
getMenuName
());
router
.
setPath
(
getRouterPath
(
menu
));
router
.
setComponent
(
StringUtils
.
isEmpty
(
menu
.
getComponent
())
?
"Layout"
:
menu
.
getComponent
());
router
.
setMeta
(
new
MetaVo
(
menu
.
getMenuName
(),
menu
.
getIcon
()));
router
.
setName
(
menu
.
getMenuName
());
List
<
SysMenu
>
cMenus
=
menu
.
getChildren
();
if
(!
cMenus
.
isEmpty
()
&&
cMenus
.
size
()
>
0
&&
"M"
.
equals
(
menu
.
getMenuType
()))
{
router
.
setAlwaysShow
(
true
);
router
.
setRedirect
(
"noRedirect"
);
router
.
setChildren
(
buildMenus
(
cMenus
));
}
routers
.
add
(
router
);
}
return
routers
;
}
/**
* 构建前端所需要树结构
*
* @param menus 菜单列表
* @return 树结构列表
*/
@Override
public
List
<
SysMenu
>
buildMenuTree
(
List
<
SysMenu
>
menus
)
{
List
<
SysMenu
>
returnList
=
new
ArrayList
<
SysMenu
>();
for
(
Iterator
<
SysMenu
>
iterator
=
menus
.
iterator
();
iterator
.
hasNext
();)
{
SysMenu
t
=
(
SysMenu
)
iterator
.
next
();
// 根据传入的某个父节点ID,遍历该父节点的所有子节点
if
(
t
.
getParentId
()
==
0
)
{
recursionFn
(
menus
,
t
);
returnList
.
add
(
t
);
}
}
if
(
returnList
.
isEmpty
())
{
returnList
=
menus
;
}
return
returnList
;
}
/**
* 构建前端所需要下拉树结构
*
* @param menus 菜单列表
* @return 下拉树结构列表
*/
@Override
public
List
<
TreeSelect
>
buildMenuTreeSelect
(
List
<
SysMenu
>
menus
)
{
List
<
SysMenu
>
menuTrees
=
buildMenuTree
(
menus
);
return
menuTrees
.
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
/**
* 根据菜单ID查询信息
*
* @param menuId 菜单ID
* @return 菜单信息
*/
@Override
public
SysMenu
selectMenuById
(
Long
menuId
)
{
return
menuMapper
.
selectMenuById
(
menuId
);
}
/**
* 是否存在菜单子节点
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public
boolean
hasChildByMenuId
(
Long
menuId
)
{
int
result
=
menuMapper
.
hasChildByMenuId
(
menuId
);
return
result
>
0
?
true
:
false
;
}
/**
* 查询菜单使用数量
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public
boolean
checkMenuExistRole
(
Long
menuId
)
{
int
result
=
roleMenuMapper
.
checkMenuExistRole
(
menuId
);
return
result
>
0
?
true
:
false
;
}
/**
* 新增保存菜单信息
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public
int
insertMenu
(
SysMenu
menu
)
{
return
menuMapper
.
insertMenu
(
menu
);
}
/**
* 修改保存菜单信息
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public
int
updateMenu
(
SysMenu
menu
)
{
return
menuMapper
.
updateMenu
(
menu
);
}
/**
* 删除菜单管理信息
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public
int
deleteMenuById
(
Long
menuId
)
{
return
menuMapper
.
deleteMenuById
(
menuId
);
}
/**
* 校验菜单名称是否唯一
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public
String
checkMenuNameUnique
(
SysMenu
menu
)
{
Long
menuId
=
StringUtils
.
isNull
(
menu
.
getMenuId
())
?
-
1L
:
menu
.
getMenuId
();
SysMenu
info
=
menuMapper
.
checkMenuNameUnique
(
menu
.
getMenuName
(),
menu
.
getParentId
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getMenuId
().
longValue
()
!=
menuId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 获取路由地址
*
* @param menu 菜单信息
* @return 路由地址
*/
public
String
getRouterPath
(
SysMenu
menu
)
{
String
routerPath
=
menu
.
getPath
();
// 非外链并且是一级目录
if
(
0
==
menu
.
getParentId
()
&&
"1"
.
equals
(
menu
.
getIsFrame
()))
{
routerPath
=
"/"
+
menu
.
getPath
();
}
return
routerPath
;
}
/**
* 根据父节点的ID获取所有子节点
*
* @param list 分类表
* @param parentId 传入的父节点ID
* @return String
*/
public
List
<
SysMenu
>
getChildPerms
(
List
<
SysMenu
>
list
,
int
parentId
)
{
List
<
SysMenu
>
returnList
=
new
ArrayList
<
SysMenu
>();
for
(
Iterator
<
SysMenu
>
iterator
=
list
.
iterator
();
iterator
.
hasNext
();)
{
SysMenu
t
=
(
SysMenu
)
iterator
.
next
();
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
if
(
t
.
getParentId
()
==
parentId
)
{
recursionFn
(
list
,
t
);
returnList
.
add
(
t
);
}
}
return
returnList
;
}
/**
* 递归列表
*
* @param list
* @param t
*/
private
void
recursionFn
(
List
<
SysMenu
>
list
,
SysMenu
t
)
{
// 得到子节点列表
List
<
SysMenu
>
childList
=
getChildList
(
list
,
t
);
t
.
setChildren
(
childList
);
for
(
SysMenu
tChild
:
childList
)
{
if
(
hasChild
(
list
,
tChild
))
{
// 判断是否有子节点
Iterator
<
SysMenu
>
it
=
childList
.
iterator
();
while
(
it
.
hasNext
())
{
SysMenu
n
=
(
SysMenu
)
it
.
next
();
recursionFn
(
list
,
n
);
}
}
}
}
/**
* 得到子节点列表
*/
private
List
<
SysMenu
>
getChildList
(
List
<
SysMenu
>
list
,
SysMenu
t
)
{
List
<
SysMenu
>
tlist
=
new
ArrayList
<
SysMenu
>();
Iterator
<
SysMenu
>
it
=
list
.
iterator
();
while
(
it
.
hasNext
())
{
SysMenu
n
=
(
SysMenu
)
it
.
next
();
if
(
n
.
getParentId
().
longValue
()
==
t
.
getMenuId
().
longValue
())
{
tlist
.
add
(
n
);
}
}
return
tlist
;
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
SysMenu
>
list
,
SysMenu
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
?
true
:
false
;
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.system.domain.SysNotice
;
import
com.ruoyi.project.system.mapper.SysNoticeMapper
;
import
com.ruoyi.project.system.service.ISysNoticeService
;
/**
* 公告 服务层实现
*
* @author ruoyi
*/
@Service
public
class
SysNoticeServiceImpl
implements
ISysNoticeService
{
@Autowired
private
SysNoticeMapper
noticeMapper
;
/**
* 查询公告信息
*
* @param noticeId 公告ID
* @return 公告信息
*/
@Override
public
SysNotice
selectNoticeById
(
Long
noticeId
)
{
return
noticeMapper
.
selectNoticeById
(
noticeId
);
}
/**
* 查询公告列表
*
* @param notice 公告信息
* @return 公告集合
*/
@Override
public
List
<
SysNotice
>
selectNoticeList
(
SysNotice
notice
)
{
return
noticeMapper
.
selectNoticeList
(
notice
);
}
/**
* 新增公告
*
* @param notice 公告信息
* @return 结果
*/
@Override
public
int
insertNotice
(
SysNotice
notice
)
{
return
noticeMapper
.
insertNotice
(
notice
);
}
/**
* 修改公告
*
* @param notice 公告信息
* @return 结果
*/
@Override
public
int
updateNotice
(
SysNotice
notice
)
{
return
noticeMapper
.
updateNotice
(
notice
);
}
/**
* 删除公告对象
*
* @param noticeId 公告ID
* @return 结果
*/
@Override
public
int
deleteNoticeById
(
Long
noticeId
)
{
return
noticeMapper
.
deleteNoticeById
(
noticeId
);
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysPostServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.project.system.domain.SysPost
;
import
com.ruoyi.project.system.mapper.SysPostMapper
;
import
com.ruoyi.project.system.service.ISysPostService
;
/**
* 岗位信息 服务层处理
*
* @author ruoyi
*/
@Service
public
class
SysPostServiceImpl
implements
ISysPostService
{
@Autowired
private
SysPostMapper
postMapper
;
/**
* 查询岗位信息集合
*
* @param post 岗位信息
* @return 岗位信息集合
*/
@Override
public
List
<
SysPost
>
selectPostList
(
SysPost
post
)
{
return
postMapper
.
selectPostList
(
post
);
}
/**
* 查询所有岗位
*
* @return 岗位列表
*/
@Override
public
List
<
SysPost
>
selectPostAll
()
{
return
postMapper
.
selectPostAll
();
}
/**
* 通过岗位ID查询岗位信息
*
* @param postId 岗位ID
* @return 角色对象信息
*/
@Override
public
SysPost
selectPostById
(
Long
postId
)
{
return
postMapper
.
selectPostById
(
postId
);
}
/**
* 根据用户ID获取岗位选择框列表
*
* @param userId 用户ID
* @return 选中岗位ID列表
*/
public
List
<
Integer
>
selectPostListByUserId
(
Long
userId
)
{
return
postMapper
.
selectPostListByUserId
(
userId
);
}
/**
* 校验岗位名称是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public
String
checkPostNameUnique
(
SysPost
post
)
{
Long
postId
=
StringUtils
.
isNull
(
post
.
getPostId
())
?
-
1L
:
post
.
getPostId
();
SysPost
info
=
postMapper
.
checkPostNameUnique
(
post
.
getPostName
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getPostId
().
longValue
()
!=
postId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 校验岗位编码是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public
String
checkPostCodeUnique
(
SysPost
post
)
{
Long
postId
=
StringUtils
.
isNull
(
post
.
getPostId
())
?
-
1L
:
post
.
getPostId
();
SysPost
info
=
postMapper
.
checkPostCodeUnique
(
post
.
getPostCode
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getPostId
().
longValue
()
!=
postId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 删除岗位信息
*
* @param postId 岗位ID
* @return 结果
*/
@Override
public
int
deletePostById
(
Long
postId
)
{
return
postMapper
.
deletePostById
(
postId
);
}
/**
* 新增保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
@Override
public
int
insertPost
(
SysPost
post
)
{
return
postMapper
.
insertPost
(
post
);
}
/**
* 修改保存岗位信息
*
* @param post 岗位信息
* @return 结果
*/
@Override
public
int
updatePost
(
SysPost
post
)
{
return
postMapper
.
updatePost
(
post
);
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.aspectj.lang.annotation.DataScope
;
import
com.ruoyi.project.system.domain.SysRole
;
import
com.ruoyi.project.system.domain.SysRoleDept
;
import
com.ruoyi.project.system.domain.SysRoleMenu
;
import
com.ruoyi.project.system.mapper.SysRoleDeptMapper
;
import
com.ruoyi.project.system.mapper.SysRoleMapper
;
import
com.ruoyi.project.system.mapper.SysRoleMenuMapper
;
import
com.ruoyi.project.system.service.ISysRoleService
;
/**
* 角色 业务层处理
*
* @author ruoyi
*/
@Service
public
class
SysRoleServiceImpl
implements
ISysRoleService
{
@Autowired
private
SysRoleMapper
roleMapper
;
@Autowired
private
SysRoleMenuMapper
roleMenuMapper
;
@Autowired
private
SysRoleDeptMapper
roleDeptMapper
;
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
@DataScope
(
deptAlias
=
"d"
)
public
List
<
SysRole
>
selectRoleList
(
SysRole
role
)
{
return
roleMapper
.
selectRoleList
(
role
);
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public
Set
<
String
>
selectRolePermissionByUserId
(
Long
userId
)
{
List
<
SysRole
>
perms
=
roleMapper
.
selectRolePermissionByUserId
(
userId
);
Set
<
String
>
permsSet
=
new
HashSet
<>();
for
(
SysRole
perm
:
perms
)
{
if
(
StringUtils
.
isNotNull
(
perm
))
{
permsSet
.
addAll
(
Arrays
.
asList
(
perm
.
getRoleKey
().
trim
().
split
(
","
)));
}
}
return
permsSet
;
}
/**
* 查询所有角色
*
* @return 角色列表
*/
public
List
<
SysRole
>
selectRoleAll
()
{
return
roleMapper
.
selectRoleAll
();
}
/**
* 根据用户ID获取角色选择框列表
*
* @param userId 用户ID
* @return 选中角色ID列表
*/
public
List
<
Integer
>
selectRoleListByUserId
(
Long
userId
)
{
return
roleMapper
.
selectRoleListByUserId
(
userId
);
}
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID
* @return 角色对象信息
*/
public
SysRole
selectRoleById
(
Long
roleId
)
{
return
roleMapper
.
selectRoleById
(
roleId
);
}
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public
String
checkRoleNameUnique
(
SysRole
role
)
{
Long
roleId
=
StringUtils
.
isNull
(
role
.
getRoleId
())
?
-
1L
:
role
.
getRoleId
();
SysRole
info
=
roleMapper
.
checkRoleNameUnique
(
role
.
getRoleName
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getRoleId
().
longValue
()
!=
roleId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 校验角色权限是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public
String
checkRoleKeyUnique
(
SysRole
role
)
{
Long
roleId
=
StringUtils
.
isNull
(
role
.
getRoleId
())
?
-
1L
:
role
.
getRoleId
();
SysRole
info
=
roleMapper
.
checkRoleKeyUnique
(
role
.
getRoleKey
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getRoleId
().
longValue
()
!=
roleId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 校验角色是否允许操作
*
* @param role 角色信息
*/
public
void
checkRoleAllowed
(
SysRole
role
)
{
if
(
StringUtils
.
isNotNull
(
role
.
getRoleId
())
&&
role
.
isAdmin
())
{
throw
new
CustomException
(
"不允许操作超级管理员角色"
);
}
}
/**
* 新增保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public
int
insertRole
(
SysRole
role
)
{
// 新增角色信息
roleMapper
.
insertRole
(
role
);
return
insertRoleMenu
(
role
);
}
/**
* 修改保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public
int
updateRole
(
SysRole
role
)
{
// 修改角色信息
roleMapper
.
updateRole
(
role
);
// 删除角色与菜单关联
roleMenuMapper
.
deleteRoleMenuByRoleId
(
role
.
getRoleId
());
return
insertRoleMenu
(
role
);
}
/**
* 修改角色状态
*
* @param role 角色信息
* @return 结果
*/
public
int
updateRoleStatus
(
SysRole
role
)
{
return
roleMapper
.
updateRole
(
role
);
}
/**
* 修改数据权限信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public
int
authDataScope
(
SysRole
role
)
{
// 修改角色信息
roleMapper
.
updateRole
(
role
);
// 删除角色与部门关联
roleDeptMapper
.
deleteRoleDeptByRoleId
(
role
.
getRoleId
());
// 新增角色和部门信息(数据权限)
return
insertRoleDept
(
role
);
}
/**
* 新增角色菜单信息
*
* @param role 角色对象
*/
public
int
insertRoleMenu
(
SysRole
role
)
{
int
rows
=
1
;
// 新增用户与角色管理
List
<
SysRoleMenu
>
list
=
new
ArrayList
<
SysRoleMenu
>();
for
(
Long
menuId
:
role
.
getMenuIds
())
{
SysRoleMenu
rm
=
new
SysRoleMenu
();
rm
.
setRoleId
(
role
.
getRoleId
());
rm
.
setMenuId
(
menuId
);
list
.
add
(
rm
);
}
if
(
list
.
size
()
>
0
)
{
rows
=
roleMenuMapper
.
batchRoleMenu
(
list
);
}
return
rows
;
}
/**
* 新增角色部门信息(数据权限)
*
* @param role 角色对象
*/
public
int
insertRoleDept
(
SysRole
role
)
{
int
rows
=
1
;
// 新增角色与部门(数据权限)管理
List
<
SysRoleDept
>
list
=
new
ArrayList
<
SysRoleDept
>();
for
(
Long
deptId
:
role
.
getDeptIds
())
{
SysRoleDept
rd
=
new
SysRoleDept
();
rd
.
setRoleId
(
role
.
getRoleId
());
rd
.
setDeptId
(
deptId
);
list
.
add
(
rd
);
}
if
(
list
.
size
()
>
0
)
{
rows
=
roleDeptMapper
.
batchRoleDept
(
list
);
}
return
rows
;
}
/**
* 通过角色ID删除角色
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public
int
deleteRoleById
(
Long
roleId
)
{
return
roleMapper
.
deleteRoleById
(
roleId
);
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.system.service.impl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.aspectj.lang.annotation.DataScope
;
import
com.ruoyi.project.system.domain.SysPost
;
import
com.ruoyi.project.system.domain.SysRole
;
import
com.ruoyi.project.system.domain.SysUser
;
import
com.ruoyi.project.system.domain.SysUserPost
;
import
com.ruoyi.project.system.domain.SysUserRole
;
import
com.ruoyi.project.system.mapper.SysPostMapper
;
import
com.ruoyi.project.system.mapper.SysRoleMapper
;
import
com.ruoyi.project.system.mapper.SysUserMapper
;
import
com.ruoyi.project.system.mapper.SysUserPostMapper
;
import
com.ruoyi.project.system.mapper.SysUserRoleMapper
;
import
com.ruoyi.project.system.service.ISysUserService
;
/**
* 用户 业务层处理
*
* @author ruoyi
*/
@Service
public
class
SysUserServiceImpl
implements
ISysUserService
{
@Autowired
private
SysUserMapper
userMapper
;
@Autowired
private
SysRoleMapper
roleMapper
;
@Autowired
private
SysPostMapper
postMapper
;
@Autowired
private
SysUserRoleMapper
userRoleMapper
;
@Autowired
private
SysUserPostMapper
userPostMapper
;
/**
* 根据条件分页查询用户列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
@DataScope
(
deptAlias
=
"d"
,
userAlias
=
"u"
)
public
List
<
SysUser
>
selectUserList
(
SysUser
user
)
{
return
userMapper
.
selectUserList
(
user
);
}
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
@Override
public
SysUser
selectUserByUserName
(
String
userName
)
{
return
userMapper
.
selectUserByUserName
(
userName
);
}
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
@Override
public
SysUser
selectUserById
(
Long
userId
)
{
return
userMapper
.
selectUserById
(
userId
);
}
/**
* 查询用户所属角色组
*
* @param userName 用户名
* @return 结果
*/
@Override
public
String
selectUserRoleGroup
(
String
userName
)
{
List
<
SysRole
>
list
=
roleMapper
.
selectRolesByUserName
(
userName
);
StringBuffer
idsStr
=
new
StringBuffer
();
for
(
SysRole
role
:
list
)
{
idsStr
.
append
(
role
.
getRoleName
()).
append
(
","
);
}
if
(
StringUtils
.
isNotEmpty
(
idsStr
.
toString
()))
{
return
idsStr
.
substring
(
0
,
idsStr
.
length
()
-
1
);
}
return
idsStr
.
toString
();
}
/**
* 查询用户所属岗位组
*
* @param userName 用户名
* @return 结果
*/
@Override
public
String
selectUserPostGroup
(
String
userName
)
{
List
<
SysPost
>
list
=
postMapper
.
selectPostsByUserName
(
userName
);
StringBuffer
idsStr
=
new
StringBuffer
();
for
(
SysPost
post
:
list
)
{
idsStr
.
append
(
post
.
getPostName
()).
append
(
","
);
}
if
(
StringUtils
.
isNotEmpty
(
idsStr
.
toString
()))
{
return
idsStr
.
substring
(
0
,
idsStr
.
length
()
-
1
);
}
return
idsStr
.
toString
();
}
/**
* 校验用户名称是否唯一
*
* @param userName 用户名称
* @return 结果
*/
@Override
public
String
checkUserNameUnique
(
String
userName
)
{
int
count
=
userMapper
.
checkUserNameUnique
(
userName
);
if
(
count
>
0
)
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 校验用户名称是否唯一
*
* @param user 用户信息
* @return
*/
@Override
public
String
checkPhoneUnique
(
SysUser
user
)
{
Long
userId
=
StringUtils
.
isNull
(
user
.
getUserId
())
?
-
1L
:
user
.
getUserId
();
SysUser
info
=
userMapper
.
checkPhoneUnique
(
user
.
getPhonenumber
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getUserId
().
longValue
()
!=
userId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 校验email是否唯一
*
* @param user 用户信息
* @return
*/
@Override
public
String
checkEmailUnique
(
SysUser
user
)
{
Long
userId
=
StringUtils
.
isNull
(
user
.
getUserId
())
?
-
1L
:
user
.
getUserId
();
SysUser
info
=
userMapper
.
checkEmailUnique
(
user
.
getEmail
());
if
(
StringUtils
.
isNotNull
(
info
)
&&
info
.
getUserId
().
longValue
()
!=
userId
.
longValue
())
{
return
UserConstants
.
NOT_UNIQUE
;
}
return
UserConstants
.
UNIQUE
;
}
/**
* 校验用户是否允许操作
*
* @param user 用户信息
*/
public
void
checkUserAllowed
(
SysUser
user
)
{
if
(
StringUtils
.
isNotNull
(
user
.
getUserId
())
&&
user
.
isAdmin
())
{
throw
new
CustomException
(
"不允许操作超级管理员用户"
);
}
}
/**
* 新增保存用户信息
*
* @param user 用户信息
* @return 结果
*/
@Override
@Transactional
public
int
insertUser
(
SysUser
user
)
{
// 新增用户信息
int
rows
=
userMapper
.
insertUser
(
user
);
// 新增用户岗位关联
insertUserPost
(
user
);
// 新增用户与角色管理
insertUserRole
(
user
);
return
rows
;
}
/**
* 修改保存用户信息
*
* @param user 用户信息
* @return 结果
*/
@Override
@Transactional
public
int
updateUser
(
SysUser
user
)
{
Long
userId
=
user
.
getUserId
();
// 删除用户与角色关联
userRoleMapper
.
deleteUserRoleByUserId
(
userId
);
// 新增用户与角色管理
insertUserRole
(
user
);
// 删除用户与岗位关联
userPostMapper
.
deleteUserPostByUserId
(
userId
);
// 新增用户与岗位管理
insertUserPost
(
user
);
return
userMapper
.
updateUser
(
user
);
}
/**
* 修改用户状态
*
* @param user 用户信息
* @return 结果
*/
@Override
public
int
updateUserStatus
(
SysUser
user
)
{
return
userMapper
.
updateUser
(
user
);
}
/**
* 修改用户基本信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public
int
updateUserProfile
(
SysUser
user
)
{
return
userMapper
.
updateUser
(
user
);
}
/**
* 修改用户头像
*
* @param userId 用户ID
* @param avatar 头像地址
* @return 结果
*/
public
boolean
updateUserAvatar
(
String
userName
,
String
avatar
)
{
return
userMapper
.
updateUserAvatar
(
userName
,
avatar
)
>
0
;
}
/**
* 重置用户密码
*
* @param user 用户信息
* @return 结果
*/
@Override
public
int
resetPwd
(
SysUser
user
)
{
return
userMapper
.
updateUser
(
user
);
}
/**
* 重置用户密码
*
* @param userName 用户名
* @param password 密码
* @return 结果
*/
@Override
public
int
resetUserPwd
(
String
userName
,
String
password
)
{
return
userMapper
.
resetUserPwd
(
userName
,
password
);
}
/**
* 新增用户角色信息
*
* @param user 用户对象
*/
public
void
insertUserRole
(
SysUser
user
)
{
Long
[]
roles
=
user
.
getRoleIds
();
if
(
StringUtils
.
isNotNull
(
roles
))
{
// 新增用户与角色管理
List
<
SysUserRole
>
list
=
new
ArrayList
<
SysUserRole
>();
for
(
Long
roleId
:
roles
)
{
SysUserRole
ur
=
new
SysUserRole
();
ur
.
setUserId
(
user
.
getUserId
());
ur
.
setRoleId
(
roleId
);
list
.
add
(
ur
);
}
if
(
list
.
size
()
>
0
)
{
userRoleMapper
.
batchUserRole
(
list
);
}
}
}
/**
* 新增用户岗位信息
*
* @param user 用户对象
*/
public
void
insertUserPost
(
SysUser
user
)
{
Long
[]
posts
=
user
.
getPostIds
();
if
(
StringUtils
.
isNotNull
(
posts
))
{
// 新增用户与岗位管理
List
<
SysUserPost
>
list
=
new
ArrayList
<
SysUserPost
>();
for
(
Long
postId
:
posts
)
{
SysUserPost
up
=
new
SysUserPost
();
up
.
setUserId
(
user
.
getUserId
());
up
.
setPostId
(
postId
);
list
.
add
(
up
);
}
if
(
list
.
size
()
>
0
)
{
userPostMapper
.
batchUserPost
(
list
);
}
}
}
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
@Override
public
int
deleteUserById
(
Long
userId
)
{
// 删除用户与角色关联
userRoleMapper
.
deleteUserRoleByUserId
(
userId
);
// 删除用户与岗位表
userPostMapper
.
deleteUserPostByUserId
(
userId
);
return
userMapper
.
deleteUserById
(
userId
);
}
}
ruoyi/src/main/java/com/ruoyi/project/tool/swagger/TestController.java
0 → 100644
View file @
46444bd0
package
com.ruoyi.project.tool.swagger
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.web.controller.BaseController
;
import
com.ruoyi.framework.web.domain.AjaxResult
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
/**
* swagger 用户测试方法
*
* @author ruoyi
*/
@Api
(
"用户信息管理"
)
@RestController
@RequestMapping
(
"/test/user"
)
public
class
TestController
extends
BaseController
{
private
final
static
Map
<
Integer
,
UserEntity
>
users
=
new
LinkedHashMap
<
Integer
,
UserEntity
>();
{
users
.
put
(
1
,
new
UserEntity
(
1
,
"admin"
,
"admin123"
,
"15888888888"
));
users
.
put
(
2
,
new
UserEntity
(
2
,
"ry"
,
"admin123"
,
"15666666666"
));
}
@ApiOperation
(
"获取用户列表"
)
@GetMapping
(
"/list"
)
public
AjaxResult
userList
()
{
List
<
UserEntity
>
userList
=
new
ArrayList
<
UserEntity
>(
users
.
values
());
return
AjaxResult
.
success
(
userList
);
}
@ApiOperation
(
"获取用户详细"
)
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户ID"
,
required
=
true
,
dataType
=
"int"
,
paramType
=
"path"
)
@GetMapping
(
"/{userId}"
)
public
AjaxResult
getUser
(
@PathVariable
Integer
userId
)
{
if
(!
users
.
isEmpty
()
&&
users
.
containsKey
(
userId
))
{
return
AjaxResult
.
success
(
users
.
get
(
userId
));
}
else
{
return
AjaxResult
.
error
(
"用户不存在"
);
}
}
@ApiOperation
(
"新增用户"
)
@ApiImplicitParam
(
name
=
"userEntity"
,
value
=
"新增用户信息"
,
dataType
=
"UserEntity"
)
@PostMapping
(
"/save"
)
public
AjaxResult
save
(
UserEntity
user
)
{
if
(
StringUtils
.
isNull
(
user
)
||
StringUtils
.
isNull
(
user
.
getUserId
()))
{
return
AjaxResult
.
error
(
"用户ID不能为空"
);
}
return
AjaxResult
.
success
(
users
.
put
(
user
.
getUserId
(),
user
));
}
@ApiOperation
(
"更新用户"
)
@ApiImplicitParam
(
name
=
"userEntity"
,
value
=
"新增用户信息"
,
dataType
=
"UserEntity"
)
@PutMapping
(
"/update"
)
public
AjaxResult
update
(
UserEntity
user
)
{
if
(
StringUtils
.
isNull
(
user
)
||
StringUtils
.
isNull
(
user
.
getUserId
()))
{
return
AjaxResult
.
error
(
"用户ID不能为空"
);
}
if
(
users
.
isEmpty
()
||
!
users
.
containsKey
(
user
.
getUserId
()))
{
return
AjaxResult
.
error
(
"用户不存在"
);
}
users
.
remove
(
user
.
getUserId
());
return
AjaxResult
.
success
(
users
.
put
(
user
.
getUserId
(),
user
));
}
@ApiOperation
(
"删除用户信息"
)
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户ID"
,
required
=
true
,
dataType
=
"int"
,
paramType
=
"path"
)
@DeleteMapping
(
"/{userId}"
)
public
AjaxResult
delete
(
@PathVariable
Integer
userId
)
{
if
(!
users
.
isEmpty
()
&&
users
.
containsKey
(
userId
))
{
users
.
remove
(
userId
);
return
AjaxResult
.
success
();
}
else
{
return
AjaxResult
.
error
(
"用户不存在"
);
}
}
}
@ApiModel
(
"用户实体"
)
class
UserEntity
{
@ApiModelProperty
(
"用户ID"
)
private
Integer
userId
;
@ApiModelProperty
(
"用户名称"
)
private
String
username
;
@ApiModelProperty
(
"用户密码"
)
private
String
password
;
@ApiModelProperty
(
"用户手机"
)
private
String
mobile
;
public
UserEntity
()
{
}
public
UserEntity
(
Integer
userId
,
String
username
,
String
password
,
String
mobile
)
{
this
.
userId
=
userId
;
this
.
username
=
username
;
this
.
password
=
password
;
this
.
mobile
=
mobile
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getMobile
()
{
return
mobile
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
}
ruoyi/src/main/resources/application-druid.yml
0 → 100644
View file @
46444bd0
# 数据源配置
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
com.mysql.cj.jdbc.Driver
druid
:
# 主库数据源
master
:
url
:
jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username
:
root
password
:
password
# 从库数据源
slave
:
# 从数据源开关/默认关闭
enabled
:
false
url
:
username
:
password
:
# 初始连接数
initialSize
:
5
# 最小连接池数量
minIdle
:
10
# 最大连接池数量
maxActive
:
20
# 配置获取连接等待超时的时间
maxWait
:
60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis
:
60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis
:
300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis
:
900000
# 配置检测连接是否有效
validationQuery
:
SELECT 1 FROM DUAL
testWhileIdle
:
true
testOnBorrow
:
false
testOnReturn
:
false
webStatFilter
:
enabled
:
true
statViewServlet
:
enabled
:
true
# 设置白名单,不填则允许所有访问
allow
:
url-pattern
:
/druid/*
# 控制台管理用户名和密码
login-username
:
login-password
:
filter
:
stat
:
enabled
:
true
# 慢SQL记录
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
true
wall
:
config
:
multi-statement-allow
:
true
\ No newline at end of file
Prev
1
…
15
16
17
18
19
20
Next
Write
Preview
Supports
Markdown
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