读写分离
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package cn.odboy.core.api.job;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzJob;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzLog;
|
||||
import cn.odboy.core.service.job.dto.QueryQuartzJobRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
|
||||
public interface QuartzJobApi {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QuartzJob> describeQuartzJobPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QuartzJob> describeQuartzJobList(QueryQuartzJobRequest criteria);
|
||||
|
||||
/**
|
||||
* 分页查询日志
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QuartzLog> describeQuartzLogPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QuartzLog> describeQuartzLogList(QueryQuartzJobRequest criteria);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package cn.odboy.core.api.job.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.job.QuartzJobApi;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzJob;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzLog;
|
||||
import cn.odboy.core.dal.mysql.job.QuartzJobMapper;
|
||||
import cn.odboy.core.dal.mysql.job.QuartzLogMapper;
|
||||
import cn.odboy.core.service.job.dto.QueryQuartzJobRequest;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class QuartzJobApiImpl implements QuartzJobApi {
|
||||
private final QuartzJobMapper quartzJobMapper;
|
||||
private final QuartzLogMapper quartzLogMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<QuartzJob> describeQuartzJobPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(quartzJobMapper.queryQuartzJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<QuartzLog> describeQuartzLogPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(quartzLogMapper.queryQuartzLogPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartzJob> describeQuartzJobList(QueryQuartzJobRequest criteria) {
|
||||
return quartzJobMapper.queryQuartzJobPageByArgs(criteria, PageUtil.getCount(quartzJobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartzLog> describeQuartzLogList(QueryQuartzJobRequest criteria) {
|
||||
return quartzLogMapper.queryQuartzLogPageByArgs(criteria, PageUtil.getCount(quartzLogMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package cn.odboy.core.service.system;
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
/**
|
||||
* 数据权限服务类
|
||||
*/
|
||||
public interface DataService {
|
||||
public interface DataApi {
|
||||
|
||||
/**
|
||||
* 获取数据权限
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.BaseResult;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
import cn.odboy.core.service.system.dto.QueryDeptRequest;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DeptApi {
|
||||
|
||||
/**
|
||||
* 查询所有数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param isQuery /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<Dept> describeDeptList(QueryDeptRequest criteria, Boolean isQuery) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Dept describeDeptById(Long id);
|
||||
/**
|
||||
* 根据PID查询
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<Dept> describeDeptListByPid(long pid);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Set<Dept> describeDeptByRoleId(Long id);
|
||||
/**
|
||||
* 获取部门下所有关联的部门
|
||||
*
|
||||
* @param deptList /
|
||||
* @param depts /
|
||||
* @return /
|
||||
*/
|
||||
Set<Dept> describeRelationDeptSet(List<Dept> deptList, Set<Dept> depts);
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
*
|
||||
* @param dept /
|
||||
* @param depts /
|
||||
* @return /
|
||||
*/
|
||||
List<Dept> describeSuperiorDeptListByPid(Dept dept, List<Dept> depts);
|
||||
|
||||
/**
|
||||
* 构建树形数据
|
||||
*
|
||||
* @param depts /
|
||||
* @return /
|
||||
*/
|
||||
BaseResult<Object> buildDeptTree(List<Dept> depts);
|
||||
|
||||
/**
|
||||
* 获取
|
||||
*
|
||||
* @param deptList 、
|
||||
* @return 、
|
||||
*/
|
||||
List<Long> describeChildDeptIdListByDeptIds(List<Dept> deptList);
|
||||
|
||||
/**
|
||||
* 验证是否被角色或用户关联
|
||||
*
|
||||
* @param depts /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Dept> depts);
|
||||
|
||||
/**
|
||||
* 遍历所有部门和子部门
|
||||
*
|
||||
* @param ids /
|
||||
* @param depts /
|
||||
*/
|
||||
void traverseDeptByIdWithPids(Set<Long> ids, Set<Dept> depts);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.system.Dict;
|
||||
import cn.odboy.core.service.system.dto.QueryDictRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
|
||||
public interface DictApi {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<Dict> describeDictPage(QueryDictRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<Dict> describeDictList(QueryDictRequest criteria);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.system.DictDetail;
|
||||
import cn.odboy.core.service.system.dto.QueryDictDetailRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
|
||||
public interface DictDetailApi {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<DictDetail> describeDictDetailPage(QueryDictDetailRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据字典名称获取字典详情
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return /
|
||||
*/
|
||||
List<DictDetail> describeDictDetailListByName(String name);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.system.Job;
|
||||
import cn.odboy.core.service.system.dto.QueryJobRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface JobApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<Job> describeJobPage(QueryJobRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<Job> describeJobList(QueryJobRequest criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Job describeJobById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
import cn.odboy.core.dal.dataobject.system.MenuResponse;
|
||||
import cn.odboy.core.service.system.dto.QueryMenuRequest;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MenuApi {
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param isQuery /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<Menu> describeMenuList(QueryMenuRequest criteria, Boolean isQuery) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Menu describeMenuById(long id);
|
||||
/**
|
||||
* 获取所有子节点,包含自身ID
|
||||
*
|
||||
* @param menuList /
|
||||
* @param menuSet /
|
||||
* @return /
|
||||
*/
|
||||
Set<Menu> describeChildMenuSet(List<Menu> menuList, Set<Menu> menuSet);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus 原始数据
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> buildMenuTree(List<Menu> menus);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus /
|
||||
* @return /
|
||||
*/
|
||||
List<MenuResponse> buildMenuResponse(List<Menu> menus);
|
||||
/**
|
||||
* 懒加载菜单数据
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> describeMenuListByPid(Long pid);
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
*
|
||||
* @param menu /
|
||||
* @param objects /
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> describeSuperiorMenuList(Menu menu, List<Menu> objects);
|
||||
|
||||
/**
|
||||
* 根据当前用户获取菜单
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> describeMenuListByUserId(Long currentUserId);
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package cn.odboy.core.service.system;
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface MonitorService {
|
||||
public interface MonitorApi {
|
||||
|
||||
/**
|
||||
* 查询服务器监控信息
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.service.system.dto.QueryRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.RoleCodeVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface RoleApi {
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleList();
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleList(QueryRoleRequest criteria);
|
||||
|
||||
/**
|
||||
* 待条件分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<Role> describeRolePage(QueryRoleRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Role describeRoleById(long id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleListByUsersId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色查询角色级别
|
||||
*
|
||||
* @param roles /
|
||||
* @return /
|
||||
*/
|
||||
Integer describeDeptLevelByRoles(Set<Role> roles);
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
List<RoleCodeVo> buildUserRolePermissions(User user);
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据菜单Id查询
|
||||
*
|
||||
* @param menuId /
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleListByMenuId(Long menuId);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.service.system.dto.QueryUserRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserApi {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return /
|
||||
*/
|
||||
User describeUserById(long id);
|
||||
|
||||
/**
|
||||
* 根据用户名查询
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
User describeUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<User> describeUserPage(QueryUserRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部不分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<User> describeUserList(QueryUserRequest criteria);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.core.service.system.dto.UserJwtVo;
|
||||
|
||||
public interface UserCacheApi {
|
||||
/**
|
||||
* 返回用户缓存
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return UserJwtVo
|
||||
*/
|
||||
UserJwtVo describeUserJwtModelByUsername(String username);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.odboy.core.api.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.UserOnlineVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserOnlineApi {
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param username /
|
||||
* @param pageable /
|
||||
* @return /
|
||||
*/
|
||||
PageResult<UserOnlineVo> describeUserOnlineModelPage(String username, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询全部数据,不分页
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
List<UserOnlineVo> describeUserOnlineModelListByUsername(String username);
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param key /
|
||||
* @return /
|
||||
*/
|
||||
UserOnlineVo describeUserOnlineModelByKey(String key);
|
||||
}
|
||||
+11
-10
@@ -1,13 +1,14 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.core.api.system.DataApi;
|
||||
import cn.odboy.core.api.system.DeptApi;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.constant.DataScopeEnum;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.service.system.DataService;
|
||||
import cn.odboy.core.service.system.DeptService;
|
||||
import cn.odboy.core.service.system.RoleService;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -24,10 +25,10 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DataServiceImpl implements DataService {
|
||||
public class DataApiImpl implements DataApi {
|
||||
private final RedisHelper redisHelper;
|
||||
private final RoleService roleService;
|
||||
private final DeptService deptService;
|
||||
private final RoleApi roleApi;
|
||||
private final DeptApi deptApi;
|
||||
|
||||
/**
|
||||
* 用户角色和用户部门改变时需清理缓存
|
||||
@@ -42,7 +43,7 @@ public class DataServiceImpl implements DataService {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
Set<Long> deptIds = new HashSet<>();
|
||||
// 查询用户角色
|
||||
List<Role> roleList = roleService.describeRoleListByUsersId(user.getId());
|
||||
List<Role> roleList = roleApi.describeRoleListByUsersId(user.getId());
|
||||
// 获取对应的部门ID
|
||||
for (Role role : roleList) {
|
||||
DataScopeEnum dataScopeEnum = DataScopeEnum.find(role.getDataScope());
|
||||
@@ -71,12 +72,12 @@ public class DataServiceImpl implements DataService {
|
||||
* @return 数据权限ID
|
||||
*/
|
||||
public Set<Long> getCustomize(Set<Long> deptIds, Role role) {
|
||||
Set<Dept> deptList = deptService.describeDeptByRoleId(role.getId());
|
||||
Set<Dept> deptList = deptApi.describeDeptByRoleId(role.getId());
|
||||
for (Dept dept : deptList) {
|
||||
deptIds.add(dept.getId());
|
||||
List<Dept> deptChildren = deptService.describeDeptListByPid(dept.getId());
|
||||
List<Dept> deptChildren = deptApi.describeDeptListByPid(dept.getId());
|
||||
if (CollUtil.isNotEmpty(deptChildren)) {
|
||||
deptIds.addAll(deptService.describeChildDeptIdListByDeptIds(deptChildren));
|
||||
deptIds.addAll(deptApi.describeChildDeptIdListByDeptIds(deptChildren));
|
||||
}
|
||||
}
|
||||
return deptIds;
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.base.BaseResult;
|
||||
import cn.odboy.core.api.system.DeptApi;
|
||||
import cn.odboy.core.constant.DataScopeEnum;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
import cn.odboy.core.dal.mysql.system.DeptMapper;
|
||||
import cn.odboy.core.dal.mysql.system.RoleMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.service.system.dto.QueryDeptRequest;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeptApiImpl implements DeptApi {
|
||||
private final DeptMapper deptMapper;
|
||||
private final RoleMapper roleMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
/**
|
||||
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
||||
*/
|
||||
private List<Dept> deduplication(List<Dept> list) {
|
||||
List<Dept> deptList = new ArrayList<>();
|
||||
// 使用 Set 存储所有部门的 id
|
||||
Set<Long> idSet = list.stream().map(Dept::getId).collect(Collectors.toSet());
|
||||
// 遍历部门列表,筛选出没有父部门的部门
|
||||
for (Dept dept : list) {
|
||||
if (!idSet.contains(dept.getPid())) {
|
||||
deptList.add(dept);
|
||||
}
|
||||
}
|
||||
return deptList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dept> describeDeptList(QueryDeptRequest criteria, Boolean isQuery) throws Exception {
|
||||
String dataScopeType = SecurityHelper.getDataScopeType();
|
||||
if (isQuery) {
|
||||
if (dataScopeType.equals(DataScopeEnum.ALL.getValue())) {
|
||||
criteria.setPidIsNull(true);
|
||||
}
|
||||
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
|
||||
List<String> fieldNames = new ArrayList<>() {{
|
||||
add("pidIsNull");
|
||||
add("enabled");
|
||||
}};
|
||||
for (Field field : fields) {
|
||||
// 设置对象的访问权限,保证对private的属性的访问
|
||||
field.setAccessible(true);
|
||||
Object val = field.get(criteria);
|
||||
if (fieldNames.contains(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(val)) {
|
||||
criteria.setPidIsNull(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数据权限
|
||||
criteria.setIds(SecurityHelper.getCurrentUserDataScope());
|
||||
List<Dept> list = deptMapper.queryDeptListByArgs(criteria);
|
||||
// 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果
|
||||
if (StringUtil.isBlank(dataScopeType)) {
|
||||
return deduplication(list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dept describeDeptById(Long id) {
|
||||
String key = SystemRedisKey.DEPT_ID + id;
|
||||
Dept dept = redisHelper.get(key, Dept.class);
|
||||
if (dept == null) {
|
||||
dept = deptMapper.selectById(id);
|
||||
redisHelper.set(key, dept, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return dept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dept> describeDeptListByPid(long pid) {
|
||||
return deptMapper.queryDeptListByPid(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dept> describeDeptByRoleId(Long id) {
|
||||
return deptMapper.queryDeptSetByRoleId(id);
|
||||
}
|
||||
@Override
|
||||
public Set<Dept> describeRelationDeptSet(List<Dept> menuList, Set<Dept> deptSet) {
|
||||
for (Dept dept : menuList) {
|
||||
deptSet.add(dept);
|
||||
List<Dept> deptList = deptMapper.queryDeptListByPid(dept.getId());
|
||||
if (CollUtil.isNotEmpty(deptList)) {
|
||||
describeRelationDeptSet(deptList, deptSet);
|
||||
}
|
||||
}
|
||||
return deptSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> describeChildDeptIdListByDeptIds(List<Dept> deptList) {
|
||||
List<Long> list = new ArrayList<>();
|
||||
deptList.forEach(dept -> {
|
||||
if (dept != null && dept.getEnabled()) {
|
||||
List<Dept> deptList1 = deptMapper.queryDeptListByPid(dept.getId());
|
||||
if (CollUtil.isNotEmpty(deptList1)) {
|
||||
list.addAll(describeChildDeptIdListByDeptIds(deptList1));
|
||||
}
|
||||
list.add(dept.getId());
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dept> describeSuperiorDeptListByPid(Dept dept, List<Dept> deptList) {
|
||||
if (dept.getPid() == null) {
|
||||
deptList.addAll(deptMapper.queryDeptListByPidIsNull());
|
||||
return deptList;
|
||||
}
|
||||
deptList.addAll(deptMapper.queryDeptListByPid(dept.getPid()));
|
||||
return describeSuperiorDeptListByPid(describeDeptById(dept.getPid()), deptList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResult<Object> buildDeptTree(List<Dept> deptList) {
|
||||
Set<Dept> trees = new LinkedHashSet<>();
|
||||
Set<Dept> deptSet = new LinkedHashSet<>();
|
||||
List<String> deptNames = deptList.stream().map(Dept::getName).collect(Collectors.toList());
|
||||
boolean isChild;
|
||||
for (Dept dept : deptList) {
|
||||
isChild = false;
|
||||
if (dept.getPid() == null) {
|
||||
trees.add(dept);
|
||||
}
|
||||
for (Dept it : deptList) {
|
||||
if (it.getPid() != null && dept.getId().equals(it.getPid())) {
|
||||
isChild = true;
|
||||
if (dept.getChildren() == null) {
|
||||
dept.setChildren(new ArrayList<>());
|
||||
}
|
||||
dept.getChildren().add(it);
|
||||
}
|
||||
}
|
||||
if (isChild) {
|
||||
deptSet.add(dept);
|
||||
} else if (dept.getPid() != null && !deptNames.contains(describeDeptById(dept.getPid()).getName())) {
|
||||
deptSet.add(dept);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(trees)) {
|
||||
trees = deptSet;
|
||||
}
|
||||
BaseResult<Object> baseResult = new BaseResult<>();
|
||||
baseResult.setContent(CollectionUtil.isEmpty(trees) ? deptSet : trees);
|
||||
baseResult.setTotalElements(deptSet.size());
|
||||
return baseResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Dept> deptSet) {
|
||||
Set<Long> deptIds = deptSet.stream().map(Dept::getId).collect(Collectors.toSet());
|
||||
if (userMapper.getUserCountByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||
}
|
||||
if (roleMapper.getRoleCountByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在角色关联,请解除后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void traverseDeptByIdWithPids(Set<Long> ids, Set<Dept> depts) {
|
||||
for (Long id : ids) {
|
||||
// 根部门
|
||||
depts.add(describeDeptById(id));
|
||||
// 子部门
|
||||
List<Dept> deptList = describeDeptListByPid(id);
|
||||
if (CollectionUtil.isNotEmpty(deptList)) {
|
||||
depts = describeRelationDeptSet(deptList, depts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.DictApi;
|
||||
import cn.odboy.core.dal.dataobject.system.Dict;
|
||||
import cn.odboy.core.dal.mysql.system.DictMapper;
|
||||
import cn.odboy.core.service.system.dto.QueryDictRequest;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictApiImpl implements DictApi {
|
||||
private final DictMapper dictMapper;
|
||||
@Override
|
||||
public PageResult<Dict> describeDictPage(QueryDictRequest criteria, Page<Object> page) {
|
||||
IPage<Dict> dicts = dictMapper.queryDictPageByArgs(criteria, page);
|
||||
return PageUtil.toPage(dicts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> describeDictList(QueryDictRequest criteria) {
|
||||
return dictMapper.queryDictPageByArgs(criteria, PageUtil.getCount(dictMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.DictDetailApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.DictDetail;
|
||||
import cn.odboy.core.dal.mysql.system.DictDetailMapper;
|
||||
import cn.odboy.core.service.system.dto.QueryDictDetailRequest;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictDetailApiImpl implements DictDetailApi {
|
||||
private final DictDetailMapper dictDetailMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
@Override
|
||||
public PageResult<DictDetail> describeDictDetailPage(QueryDictDetailRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(dictDetailMapper.queryDictDetailPageByArgs(criteria, page));
|
||||
}
|
||||
@Override
|
||||
public List<DictDetail> describeDictDetailListByName(String name) {
|
||||
String key = SystemRedisKey.DICT_NAME + name;
|
||||
List<DictDetail> dictDetails = redisHelper.getList(key, DictDetail.class);
|
||||
if (CollUtil.isEmpty(dictDetails)) {
|
||||
dictDetails = dictDetailMapper.queryDictDetailListByDictName(name);
|
||||
redisHelper.set(key, dictDetails, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return dictDetails;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.JobApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.Job;
|
||||
import cn.odboy.core.dal.mysql.system.JobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.dto.QueryJobRequest;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class JobApiImpl implements JobApi {
|
||||
private final JobMapper jobMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
@Override
|
||||
public PageResult<Job> describeJobPage(QueryJobRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(jobMapper.queryJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Job> describeJobList(QueryJobRequest criteria) {
|
||||
return jobMapper.queryJobPageByArgs(criteria, PageUtil.getCount(jobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Job describeJobById(Long id) {
|
||||
String key = SystemRedisKey.JOB_ID + id;
|
||||
Job job = redisHelper.get(key, Job.class);
|
||||
if (job == null) {
|
||||
job = jobMapper.selectById(id);
|
||||
redisHelper.set(key, job, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (userMapper.getUserCountByJobIds(ids) > 0) {
|
||||
throw new BadRequestException("所选的岗位中存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.core.api.system.MenuApi;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
import cn.odboy.core.dal.dataobject.system.MenuResponse;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.mysql.system.MenuMapper;
|
||||
import cn.odboy.core.service.system.RoleService;
|
||||
import cn.odboy.core.service.system.dto.MenuMetaVo;
|
||||
import cn.odboy.core.service.system.dto.QueryMenuRequest;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MenuApiImpl implements MenuApi {
|
||||
private final MenuMapper menuMapper;
|
||||
private final RoleApi roleApi;
|
||||
private final RoleService roleService;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public List<Menu> describeMenuList(QueryMenuRequest criteria, Boolean isQuery) throws Exception {
|
||||
if (Boolean.TRUE.equals(isQuery)) {
|
||||
criteria.setPidIsNull(true);
|
||||
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
|
||||
for (Field field : fields) {
|
||||
//设置对象的访问权限,保证对private的属性的访问
|
||||
field.setAccessible(true);
|
||||
Object val = field.get(criteria);
|
||||
if ("pidIsNull".equals(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
// 如果有查询条件,则不指定pidIsNull
|
||||
if (ObjectUtil.isNotNull(val)) {
|
||||
criteria.setPidIsNull(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return menuMapper.queryMenuListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu describeMenuById(long id) {
|
||||
String key = SystemRedisKey.MENU_ID + id;
|
||||
Menu menu = redisHelper.get(key, Menu.class);
|
||||
if (menu == null) {
|
||||
menu = menuMapper.selectById(id);
|
||||
redisHelper.set(key, menu, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色改变时需清理缓存
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> describeMenuListByUserId(Long currentUserId) {
|
||||
String key = SystemRedisKey.MENU_USER + currentUserId;
|
||||
List<Menu> menus = redisHelper.getList(key, Menu.class);
|
||||
if (CollUtil.isEmpty(menus)) {
|
||||
List<Role> roles = roleApi.describeRoleListByUsersId(currentUserId);
|
||||
Set<Long> roleIds = roles.stream().map(Role::getId).collect(Collectors.toSet());
|
||||
menus = new ArrayList<>(menuMapper.queryMenuSetByRoleIdsAndType(roleIds, 2));
|
||||
redisHelper.set(key, menus, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
@Override
|
||||
public Set<Menu> describeChildMenuSet(List<Menu> menuList, Set<Menu> menuSet) {
|
||||
for (Menu menu : menuList) {
|
||||
menuSet.add(menu);
|
||||
List<Menu> menus = menuMapper.queryMenuListByPidOrderByMenuSort(menu.getId());
|
||||
if (CollUtil.isNotEmpty(menus)) {
|
||||
describeChildMenuSet(menus, menuSet);
|
||||
}
|
||||
}
|
||||
return menuSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Menu> describeMenuListByPid(Long pid) {
|
||||
List<Menu> menus;
|
||||
if (pid != null && !pid.equals(0L)) {
|
||||
menus = menuMapper.queryMenuListByPidOrderByMenuSort(pid);
|
||||
} else {
|
||||
menus = menuMapper.queryMenuListByPidIsNullOrderByMenuSort();
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Menu> describeSuperiorMenuList(Menu menu, List<Menu> menus) {
|
||||
if (menu.getPid() == null) {
|
||||
menus.addAll(menuMapper.queryMenuListByPidIsNullOrderByMenuSort());
|
||||
return menus;
|
||||
}
|
||||
menus.addAll(menuMapper.queryMenuListByPidOrderByMenuSort(menu.getPid()));
|
||||
return describeSuperiorMenuList(describeMenuById(menu.getPid()), menus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Menu> buildMenuTree(List<Menu> menus) {
|
||||
List<Menu> trees = new ArrayList<>();
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (Menu menu : menus) {
|
||||
if (menu.getPid() == null) {
|
||||
trees.add(menu);
|
||||
}
|
||||
for (Menu it : menus) {
|
||||
if (menu.getId().equals(it.getPid())) {
|
||||
if (menu.getChildren() == null) {
|
||||
menu.setChildren(new ArrayList<>());
|
||||
}
|
||||
menu.getChildren().add(it);
|
||||
ids.add(it.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(trees)) {
|
||||
trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuResponse> buildMenuResponse(List<Menu> menus) {
|
||||
List<MenuResponse> list = new LinkedList<>();
|
||||
menus.forEach(menu -> {
|
||||
if (menu != null) {
|
||||
List<Menu> menuList = menu.getChildren();
|
||||
MenuResponse menuResponse = new MenuResponse();
|
||||
menuResponse.setName(ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuResponse.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath());
|
||||
menuResponse.setHidden(menu.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menu.getIFrame()) {
|
||||
if (menu.getPid() == null) {
|
||||
menuResponse.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent());
|
||||
// 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单
|
||||
} else if (menu.getType() == 0) {
|
||||
menuResponse.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent());
|
||||
} else if (StringUtil.isNoneBlank(menu.getComponent())) {
|
||||
menuResponse.setComponent(menu.getComponent());
|
||||
}
|
||||
}
|
||||
menuResponse.setMeta(new MenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache()));
|
||||
if (CollectionUtil.isNotEmpty(menuList)) {
|
||||
menuResponse.setAlwaysShow(true);
|
||||
menuResponse.setRedirect("noredirect");
|
||||
menuResponse.setChildren(buildMenuResponse(menuList));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (menu.getPid() == null) {
|
||||
MenuResponse menuResponse1 = getMenuVo(menu, menuResponse);
|
||||
menuResponse.setName(null);
|
||||
menuResponse.setMeta(null);
|
||||
menuResponse.setComponent("Layout");
|
||||
List<MenuResponse> list1 = new ArrayList<>();
|
||||
list1.add(menuResponse1);
|
||||
menuResponse.setChildren(list1);
|
||||
}
|
||||
list.add(menuResponse);
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MenuResponse
|
||||
*
|
||||
* @param menu /
|
||||
* @param menuResponse /
|
||||
* @return /
|
||||
*/
|
||||
private static MenuResponse getMenuVo(Menu menu, MenuResponse menuResponse) {
|
||||
MenuResponse menuResponse1 = new MenuResponse();
|
||||
menuResponse1.setMeta(menuResponse.getMeta());
|
||||
// 非外链
|
||||
if (!menu.getIFrame()) {
|
||||
menuResponse1.setPath("index");
|
||||
menuResponse1.setName(menuResponse.getName());
|
||||
menuResponse1.setComponent(menuResponse.getComponent());
|
||||
} else {
|
||||
menuResponse1.setPath(menu.getPath());
|
||||
}
|
||||
return menuResponse1;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.hutool.core.date.BetweenFormatter.Level;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.core.service.system.MonitorService;
|
||||
import cn.odboy.core.api.system.MonitorApi;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.IpUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MonitorServiceImpl implements MonitorService {
|
||||
public class MonitorApiImpl implements MonitorApi {
|
||||
private final DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
@Override
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.dal.mysql.system.RoleMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.dto.QueryRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.RoleCodeVo;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RoleApiImpl implements RoleApi {
|
||||
private final RoleMapper roleMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleList() {
|
||||
return roleMapper.queryRoleList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleList(QueryRoleRequest criteria) {
|
||||
return roleMapper.queryRoleListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Role> describeRolePage(QueryRoleRequest criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<Role> roles = roleMapper.queryRoleListByArgs(criteria);
|
||||
Long total = roleMapper.getRoleCountByArgs(criteria);
|
||||
return PageUtil.toPage(roles, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role describeRoleById(long id) {
|
||||
String key = SystemRedisKey.ROLE_ID + id;
|
||||
Role role = redisHelper.get(key, Role.class);
|
||||
if (role == null) {
|
||||
role = roleMapper.selectById(id);
|
||||
redisHelper.set(key, role, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleListByUsersId(Long userId) {
|
||||
String key = SystemRedisKey.ROLE_USER + userId;
|
||||
List<Role> roles = redisHelper.getList(key, Role.class);
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
roles = roleMapper.queryRoleListByUserId(userId);
|
||||
redisHelper.set(key, roles, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer describeDeptLevelByRoles(Set<Role> roles) {
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
Set<Role> roleSet = new HashSet<>();
|
||||
for (Role role : roles) {
|
||||
roleSet.add(describeRoleById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleSet.stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleCodeVo> buildUserRolePermissions(User user) {
|
||||
String key = SystemRedisKey.ROLE_AUTH + user.getId();
|
||||
List<RoleCodeVo> authorityList = redisHelper.getList(key, RoleCodeVo.class);
|
||||
if (CollUtil.isEmpty(authorityList)) {
|
||||
Set<String> permissions = new HashSet<>();
|
||||
// 如果是管理员直接返回
|
||||
if (user.getIsAdmin()) {
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(RoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<Role> roles = roleMapper.queryRoleListByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream())
|
||||
.map(Menu::getPermission)
|
||||
.filter(StringUtil::isNotBlank).collect(Collectors.toSet());
|
||||
authorityList = permissions.stream().map(RoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
redisHelper.set(key, authorityList, 1, TimeUnit.HOURS);
|
||||
}
|
||||
return authorityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (userMapper.getUserCountByRoleIds(ids) > 0) {
|
||||
throw new BadRequestException("所选角色存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleListByMenuId(Long menuId) {
|
||||
return roleMapper.queryRoleListByMenuId(menuId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.UserApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.dto.QueryUserRequest;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserApiImpl implements UserApi {
|
||||
private final UserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public PageResult<User> describeUserPage(QueryUserRequest criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<User> users = userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords();
|
||||
Long total = userMapper.getUserCountByArgs(criteria);
|
||||
return PageUtil.toPage(users, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> describeUserList(QueryUserRequest criteria) {
|
||||
return userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public User describeUserById(long id) {
|
||||
String key = SystemRedisKey.USER_ID + id;
|
||||
User user = redisHelper.get(key, User.class);
|
||||
if (user == null) {
|
||||
user = userMapper.selectById(id);
|
||||
redisHelper.set(key, user, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User describeUserByUsername(String username) {
|
||||
return userMapper.getUserByUsername(username);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.odboy.core.api.system.UserCacheApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.service.system.dto.UserJwtVo;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserCacheApiImpl implements UserCacheApi {
|
||||
@Resource
|
||||
private RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public UserJwtVo describeUserJwtModelByUsername(String username) {
|
||||
// 转小写
|
||||
username = StringUtil.lowerCase(username);
|
||||
if (StringUtil.isNotEmpty(username)) {
|
||||
// 获取数据
|
||||
return redisHelper.get(SystemRedisKey.USER_INFO + username, UserJwtVo.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package cn.odboy.core.api.system.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.UserOnlineApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.service.system.dto.UserOnlineVo;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserOnlineApiImpl implements UserOnlineApi {
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<UserOnlineVo> describeUserOnlineModelPage(String username, Pageable pageable) {
|
||||
List<UserOnlineVo> onlineUserList = describeUserOnlineModelListByUsername(username);
|
||||
List<UserOnlineVo> paging = PageUtil.softPaging(pageable.getPageNumber(), pageable.getPageSize(), onlineUserList);
|
||||
return PageUtil.toPage(paging, onlineUserList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOnlineVo> describeUserOnlineModelListByUsername(String username) {
|
||||
String loginKey = SystemRedisKey.ONLINE_USER + (StringUtil.isBlank(username) ? "" : "*" + username);
|
||||
List<String> keys = redisHelper.scan(loginKey + "*");
|
||||
Collections.reverse(keys);
|
||||
List<UserOnlineVo> onlineUserList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
onlineUserList.add(redisHelper.get(key, UserOnlineVo.class));
|
||||
}
|
||||
onlineUserList.sort((o1, o2) -> o2.getLoginTime().compareTo(o1.getLoginTime()));
|
||||
return onlineUserList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOnlineVo describeUserOnlineModelByKey(String key) {
|
||||
return redisHelper.get(key, UserOnlineVo.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.odboy.core.api.tools;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.tools.EmailConfig;
|
||||
|
||||
public interface EmailApi {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return EmailConfig 邮件配置
|
||||
*/
|
||||
EmailConfig describeEmailConfig();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.odboy.core.api.tools;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.tools.LocalStorage;
|
||||
import cn.odboy.core.service.tools.dto.QueryLocalStorageRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
|
||||
public interface LocalStorageApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<LocalStorage> describeLocalStoragePage(QueryLocalStorageRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<LocalStorage> describeLocalStorageList(QueryLocalStorageRequest criteria);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.odboy.core.api.tools;
|
||||
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuConfig;
|
||||
|
||||
public interface QiniuConfigApi {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return QiniuConfig
|
||||
*/
|
||||
QiniuConfig describeQiniuConfig();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.odboy.core.api.tools;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuContent;
|
||||
import cn.odboy.core.service.tools.dto.QueryQiniuRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
|
||||
public interface QiniuContentApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QiniuContent> describeQiniuContentPage(QueryQiniuRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QiniuContent> describeQiniuContentList(QueryQiniuRequest criteria);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.odboy.core.api.tools.impl;
|
||||
|
||||
import cn.odboy.core.api.tools.EmailApi;
|
||||
import cn.odboy.core.dal.dataobject.tools.EmailConfig;
|
||||
import cn.odboy.core.dal.mysql.tools.EmailConfigMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "email")
|
||||
public class EmailApiImpl implements EmailApi {
|
||||
private final EmailConfigMapper emailConfigMapper;
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public EmailConfig describeEmailConfig() {
|
||||
EmailConfig emailConfig = emailConfigMapper.selectById(1L);
|
||||
return emailConfig == null ? new EmailConfig() : emailConfig;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package cn.odboy.core.api.tools.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.tools.LocalStorageApi;
|
||||
import cn.odboy.core.dal.dataobject.tools.LocalStorage;
|
||||
import cn.odboy.core.dal.mysql.tools.LocalStorageMapper;
|
||||
import cn.odboy.core.service.tools.dto.QueryLocalStorageRequest;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LocalStorageApiImpl implements LocalStorageApi {
|
||||
private final LocalStorageMapper localStorageMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<LocalStorage> describeLocalStoragePage(QueryLocalStorageRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(localStorageMapper.queryLocalStoragePageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorage> describeLocalStorageList(QueryLocalStorageRequest criteria) {
|
||||
return localStorageMapper.queryLocalStoragePageByArgs(criteria, PageUtil.getCount(localStorageMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package cn.odboy.core.api.tools.impl;
|
||||
|
||||
import cn.odboy.core.api.tools.QiniuConfigApi;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuConfig;
|
||||
import cn.odboy.core.dal.mysql.tools.QiniuConfigMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class QiniuConfigApiImpl implements QiniuConfigApi {
|
||||
private final QiniuConfigMapper qiniuConfigMapper;
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public QiniuConfig describeQiniuConfig() {
|
||||
QiniuConfig qiniuConfig = qiniuConfigMapper.selectById(1L);
|
||||
return qiniuConfig == null ? new QiniuConfig() : qiniuConfig;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package cn.odboy.core.api.tools.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.tools.QiniuContentApi;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuContent;
|
||||
import cn.odboy.core.dal.mysql.tools.QiniuContentMapper;
|
||||
import cn.odboy.core.service.tools.dto.QueryQiniuRequest;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class QiniuContentApiImpl implements QiniuContentApi {
|
||||
private final QiniuContentMapper qiniuContentMapper;
|
||||
@Override
|
||||
public PageResult<QiniuContent> describeQiniuContentPage(QueryQiniuRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(qiniuContentMapper.queryQiniuContentPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QiniuContent> describeQiniuContentList(QueryQiniuRequest criteria) {
|
||||
return qiniuContentMapper.queryQiniuContentPageByArgs(criteria, PageUtil.getCount(qiniuContentMapper)).getRecords();
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -2,6 +2,7 @@ package cn.odboy.core.controller.job;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.context.SpringBeanHolder;
|
||||
import cn.odboy.core.api.job.QuartzJobApi;
|
||||
import cn.odboy.core.service.job.dto.QueryQuartzJobRequest;
|
||||
import cn.odboy.core.service.job.dto.UpdateQuartzJobRequest;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzJob;
|
||||
@@ -38,27 +39,28 @@ import java.util.Set;
|
||||
public class QuartzJobController {
|
||||
private static final String ENTITY_NAME = "quartzJob";
|
||||
private final QuartzJobService quartzJobService;
|
||||
private final QuartzJobApi quartzJobApi;
|
||||
|
||||
@ApiOperation("查询定时任务")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public ResponseEntity<PageResult<QuartzJob>> queryQuartzJob(QueryQuartzJobRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(quartzJobService.describeQuartzJobPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(quartzJobApi.describeQuartzJobPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出任务数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public void exportQuartzJob(HttpServletResponse response, QueryQuartzJobRequest criteria) throws IOException {
|
||||
quartzJobService.downloadQuartzJobExcel(quartzJobService.describeQuartzJobList(criteria), response);
|
||||
quartzJobService.downloadQuartzJobExcel(quartzJobApi.describeQuartzJobList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("导出日志数据")
|
||||
@GetMapping(value = "/logs/download")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public void exportQuartzJobLog(HttpServletResponse response, QueryQuartzJobRequest criteria) throws IOException {
|
||||
quartzJobService.downloadQuartzLogExcel(quartzJobService.describeQuartzLogList(criteria), response);
|
||||
quartzJobService.downloadQuartzLogExcel(quartzJobApi.describeQuartzLogList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询任务执行日志")
|
||||
@@ -66,7 +68,7 @@ public class QuartzJobController {
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public ResponseEntity<PageResult<QuartzLog>> queryQuartzJobLog(QueryQuartzJobRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(quartzJobService.describeQuartzLogPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(quartzJobApi.describeQuartzLogPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增定时任务")
|
||||
|
||||
+9
-7
@@ -1,6 +1,7 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.DeptApi;
|
||||
import cn.odboy.core.service.system.dto.CreateDeptRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDeptRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
@@ -32,20 +33,21 @@ import java.util.stream.Collectors;
|
||||
@Api(tags = "系统:部门管理")
|
||||
@RequestMapping("/api/dept")
|
||||
public class DeptController {
|
||||
private final DeptApi deptApi;
|
||||
private final DeptService deptService;
|
||||
|
||||
@ApiOperation("导出部门数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dept:list')")
|
||||
public void exportDept(HttpServletResponse response, QueryDeptRequest criteria) throws Exception {
|
||||
deptService.downloadDeptExcel(deptService.describeDeptList(criteria, false), response);
|
||||
deptService.downloadDeptExcel(deptApi.describeDeptList(criteria, false), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<PageResult<Dept>> describeDeptPage(QueryDeptRequest criteria) throws Exception {
|
||||
List<Dept> depts = deptService.describeDeptList(criteria, true);
|
||||
List<Dept> depts = deptApi.describeDeptList(criteria, true);
|
||||
return new ResponseEntity<>(PageUtil.toPage(depts), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -55,8 +57,8 @@ public class DeptController {
|
||||
public ResponseEntity<Object> describeDeptSuperiorTree(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) {
|
||||
Set<Dept> deptSet = new LinkedHashSet<>();
|
||||
for (Long id : ids) {
|
||||
Dept dept = deptService.describeDeptById(id);
|
||||
List<Dept> depts = deptService.describeSuperiorDeptListByPid(dept, new ArrayList<>());
|
||||
Dept dept = deptApi.describeDeptById(id);
|
||||
List<Dept> depts = deptApi.describeSuperiorDeptListByPid(dept, new ArrayList<>());
|
||||
if (exclude) {
|
||||
for (Dept data : depts) {
|
||||
if (data.getId().equals(dept.getPid())) {
|
||||
@@ -68,7 +70,7 @@ public class DeptController {
|
||||
}
|
||||
deptSet.addAll(depts);
|
||||
}
|
||||
return new ResponseEntity<>(deptService.buildDeptTree(new ArrayList<>(deptSet)), HttpStatus.OK);
|
||||
return new ResponseEntity<>(deptApi.buildDeptTree(new ArrayList<>(deptSet)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增部门")
|
||||
@@ -93,9 +95,9 @@ public class DeptController {
|
||||
public ResponseEntity<Object> removeDeptByIds(@RequestBody Set<Long> ids) {
|
||||
Set<Dept> depts = new HashSet<>();
|
||||
// 获取部门,和其所有子部门
|
||||
deptService.traverseDeptByIdWithPids(ids, depts);
|
||||
deptApi.traverseDeptByIdWithPids(ids, depts);
|
||||
// 验证是否被角色或用户关联
|
||||
deptService.verifyBindRelationByIds(depts);
|
||||
deptApi.verifyBindRelationByIds(depts);
|
||||
deptService.removeDeptByIds(depts);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,6 +1,7 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.DictApi;
|
||||
import cn.odboy.core.service.system.dto.CreateDictRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDictRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dict;
|
||||
@@ -28,20 +29,21 @@ import java.util.Set;
|
||||
@Api(tags = "系统:字典管理")
|
||||
@RequestMapping("/api/dict")
|
||||
public class DictController {
|
||||
private final DictApi dictApi;
|
||||
private final DictService dictService;
|
||||
|
||||
@ApiOperation("导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public void exportDict(HttpServletResponse response, QueryDictRequest criteria) throws IOException {
|
||||
dictService.downloadDictExcel(dictService.describeDictList(criteria), response);
|
||||
dictService.downloadDictExcel(dictApi.describeDictList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@PostMapping(value = "/queryAllDict")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<List<Dict>> queryAllDict() {
|
||||
return new ResponseEntity<>(dictService.describeDictList(new QueryDictRequest()), HttpStatus.OK);
|
||||
return new ResponseEntity<>(dictApi.describeDictList(new QueryDictRequest()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@@ -49,7 +51,7 @@ public class DictController {
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<PageResult<Dict>> queryDict(QueryDictRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(dictService.describeDictPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(dictApi.describeDictPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增字典")
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.DictDetailApi;
|
||||
import cn.odboy.core.service.system.dto.CreateDictDetailRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDictDetailRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.DictDetail;
|
||||
@@ -29,12 +30,13 @@ import java.util.Map;
|
||||
@RequestMapping("/api/dictDetail")
|
||||
public class DictDetailController {
|
||||
private final DictDetailService dictDetailService;
|
||||
private final DictDetailApi dictDetailApi;
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@GetMapping
|
||||
public ResponseEntity<PageResult<DictDetail>> describeDictDetailPage(QueryDictDetailRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(dictDetailService.describeDictDetailPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(dictDetailApi.describeDictDetailPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询多个字典详情")
|
||||
@@ -43,7 +45,7 @@ public class DictDetailController {
|
||||
String[] names = dictName.split("[,,]");
|
||||
Map<String, List<DictDetail>> dictMap = new HashMap<>(16);
|
||||
for (String name : names) {
|
||||
dictMap.put(name, dictDetailService.describeDictDetailListByName(name));
|
||||
dictMap.put(name, dictDetailApi.describeDictDetailListByName(name));
|
||||
}
|
||||
return new ResponseEntity<>(dictMap, HttpStatus.OK);
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,6 +1,7 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.JobApi;
|
||||
import cn.odboy.core.service.system.dto.CreateJobRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryJobRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Job;
|
||||
@@ -28,13 +29,14 @@ import java.util.Set;
|
||||
@Api(tags = "系统:岗位管理")
|
||||
@RequestMapping("/api/job")
|
||||
public class JobController {
|
||||
private final JobApi jobApi;
|
||||
private final JobService jobService;
|
||||
|
||||
@ApiOperation("导出岗位数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('job:list')")
|
||||
public void exportJob(HttpServletResponse response, QueryJobRequest criteria) throws IOException {
|
||||
jobService.downloadJobExcel(jobService.describeJobList(criteria), response);
|
||||
jobService.downloadJobExcel(jobApi.describeJobList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@@ -42,7 +44,7 @@ public class JobController {
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<PageResult<Job>> queryJob(QueryJobRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(jobService.describeJobPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(jobApi.describeJobPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@@ -66,7 +68,7 @@ public class JobController {
|
||||
@PreAuthorize("@el.check('job:del')")
|
||||
public ResponseEntity<Object> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
// 验证是否被用户关联
|
||||
jobService.verifyBindRelationByIds(ids);
|
||||
jobApi.verifyBindRelationByIds(ids);
|
||||
jobService.removeJobByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
+19
-18
@@ -2,6 +2,7 @@ package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.MenuApi;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.service.system.dto.QueryMenuRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
@@ -36,30 +37,30 @@ import java.util.stream.Collectors;
|
||||
@Api(tags = "系统:菜单管理")
|
||||
@RequestMapping("/api/menus")
|
||||
public class MenuController {
|
||||
|
||||
private final MenuService menuService;
|
||||
private static final String ENTITY_NAME = "menu";
|
||||
private final MenuApi menuApi;
|
||||
private final MenuService menuService;
|
||||
|
||||
@ApiOperation("导出菜单数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public void exportMenu(HttpServletResponse response, QueryMenuRequest criteria) throws Exception {
|
||||
menuService.downloadMenuExcel(menuService.describeMenuList(criteria, false), response);
|
||||
menuService.downloadMenuExcel(menuApi.describeMenuList(criteria, false), response);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/buildMenus")
|
||||
@ApiOperation("获取前端所需菜单")
|
||||
public ResponseEntity<List<MenuResponse>> buildMenus() {
|
||||
List<Menu> menuList = menuService.describeMenuListByUserId(SecurityHelper.getCurrentUserId());
|
||||
List<Menu> menus = menuService.buildMenuTree(menuList);
|
||||
return new ResponseEntity<>(menuService.buildMenuResponse(menus), HttpStatus.OK);
|
||||
List<Menu> menuList = menuApi.describeMenuListByUserId(SecurityHelper.getCurrentUserId());
|
||||
List<Menu> menus = menuApi.buildMenuTree(menuList);
|
||||
return new ResponseEntity<>(menuApi.buildMenuResponse(menus), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
@PostMapping(value = "/describeMenuListByPid")
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<List<Menu>> describeMenuListByPid(@RequestParam Long pid) {
|
||||
return new ResponseEntity<>(menuService.describeMenuListByPid(pid), HttpStatus.OK);
|
||||
return new ResponseEntity<>(menuApi.describeMenuListByPid(pid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
||||
@@ -67,9 +68,9 @@ public class MenuController {
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<Object> describeChildMenuSet(@RequestParam Long id) {
|
||||
Set<Menu> menuSet = new HashSet<>();
|
||||
List<Menu> menuList = menuService.describeMenuListByPid(id);
|
||||
menuSet.add(menuService.getById(id));
|
||||
menuSet = menuService.describeChildMenuSet(menuList, menuSet);
|
||||
List<Menu> menuList = menuApi.describeMenuListByPid(id);
|
||||
menuSet.add(menuApi.describeMenuById(id));
|
||||
menuSet = menuApi.describeChildMenuSet(menuList, menuSet);
|
||||
Set<Long> ids = menuSet.stream().map(Menu::getId).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(ids, HttpStatus.OK);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class MenuController {
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<PageResult<Menu>> queryMenu(QueryMenuRequest criteria) throws Exception {
|
||||
List<Menu> menuList = menuService.describeMenuList(criteria, true);
|
||||
List<Menu> menuList = menuApi.describeMenuList(criteria, true);
|
||||
return new ResponseEntity<>(PageUtil.toPage(menuList), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -89,8 +90,8 @@ public class MenuController {
|
||||
Set<Menu> menus = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
for (Long id : ids) {
|
||||
Menu menu = menuService.describeMenuById(id);
|
||||
List<Menu> menuList = menuService.describeSuperiorMenuList(menu, new ArrayList<>());
|
||||
Menu menu = menuApi.describeMenuById(id);
|
||||
List<Menu> menuList = menuApi.describeSuperiorMenuList(menu, new ArrayList<>());
|
||||
for (Menu data : menuList) {
|
||||
if (data.getId().equals(menu.getPid())) {
|
||||
data.setSubCount(data.getSubCount() - 1);
|
||||
@@ -100,9 +101,9 @@ public class MenuController {
|
||||
}
|
||||
// 编辑菜单时不显示自己以及自己下级的数据,避免出现PID数据环形问题
|
||||
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(menuService.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
|
||||
return new ResponseEntity<>(menuApi.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(menuService.describeMenuListByPid(null), HttpStatus.OK);
|
||||
return new ResponseEntity<>(menuApi.describeMenuListByPid(null), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
@@ -130,9 +131,9 @@ public class MenuController {
|
||||
public ResponseEntity<Object> removeMenuByIds(@RequestBody Set<Long> ids) {
|
||||
Set<Menu> menuSet = new HashSet<>();
|
||||
for (Long id : ids) {
|
||||
List<Menu> menuList = menuService.describeMenuListByPid(id);
|
||||
menuSet.add(menuService.getById(id));
|
||||
menuSet = menuService.describeChildMenuSet(menuList, menuSet);
|
||||
List<Menu> menuList = menuApi.describeMenuListByPid(id);
|
||||
menuSet.add(menuApi.describeMenuById(id));
|
||||
menuSet = menuApi.describeChildMenuSet(menuList, menuSet);
|
||||
}
|
||||
menuService.removeMenuByIds(menuSet);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.core.service.system.MonitorService;
|
||||
import cn.odboy.core.api.system.MonitorApi;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/api/monitor")
|
||||
public class MonitorController {
|
||||
|
||||
private final MonitorService serverService;
|
||||
private final MonitorApi serverService;
|
||||
|
||||
@PostMapping(value = "/describeServerMonitorInfo")
|
||||
@ApiOperation("查询服务监控")
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.UserOnlineApi;
|
||||
import cn.odboy.core.service.system.dto.UserOnlineVo;
|
||||
import cn.odboy.core.service.system.UserOnlineService;
|
||||
import cn.odboy.util.DesEncryptUtil;
|
||||
@@ -26,20 +27,21 @@ import java.util.Set;
|
||||
@RequestMapping("/auth/online")
|
||||
@Api(tags = "系统:在线用户管理")
|
||||
public class OnlineController {
|
||||
private final UserOnlineApi userOnlineApi;
|
||||
private final UserOnlineService userOnlineService;
|
||||
|
||||
@ApiOperation("查询在线用户")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<PageResult<UserOnlineVo>> queryOnlineUser(String username, Pageable pageable) {
|
||||
return new ResponseEntity<>(userOnlineService.describeUserOnlineModelPage(username, pageable), HttpStatus.OK);
|
||||
return new ResponseEntity<>(userOnlineApi.describeUserOnlineModelPage(username, pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check()")
|
||||
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
|
||||
userOnlineService.downloadUserOnlineModelExcel(userOnlineService.describeUserOnlineModelListByUsername(username), response);
|
||||
userOnlineService.downloadUserOnlineModelExcel(userOnlineApi.describeUserOnlineModelListByUsername(username), response);
|
||||
}
|
||||
|
||||
@ApiOperation("踢出用户")
|
||||
|
||||
+8
-6
@@ -2,6 +2,7 @@ package cn.odboy.core.controller.system;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.service.system.dto.CreateRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryRoleRequest;
|
||||
@@ -34,27 +35,28 @@ import java.util.stream.Collectors;
|
||||
@Api(tags = "系统:角色管理")
|
||||
@RequestMapping("/api/roles")
|
||||
public class RoleController {
|
||||
private final RoleApi roleApi;
|
||||
private final RoleService roleService;
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@PostMapping(value = "/describeRoleById")
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<Role> describeRoleById(@RequestBody Role args) {
|
||||
return new ResponseEntity<>(roleService.describeRoleById(args.getId()), HttpStatus.OK);
|
||||
return new ResponseEntity<>(roleApi.describeRoleById(args.getId()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出角色数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('role:list')")
|
||||
public void exportRole(HttpServletResponse response, QueryRoleRequest criteria) throws IOException {
|
||||
roleService.downloadRoleExcel(roleService.describeRoleList(criteria), response);
|
||||
roleService.downloadRoleExcel(roleApi.describeRoleList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的角色")
|
||||
@PostMapping(value = "/describeRoleList")
|
||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||
public ResponseEntity<List<Role>> describeRoleList() {
|
||||
return new ResponseEntity<>(roleService.describeRoleList(), HttpStatus.OK);
|
||||
return new ResponseEntity<>(roleApi.describeRoleList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@@ -62,7 +64,7 @@ public class RoleController {
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<PageResult<Role>> describeRolePage(QueryRoleRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(roleService.describeRolePage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(roleApi.describeRolePage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户级别")
|
||||
@@ -108,7 +110,7 @@ public class RoleController {
|
||||
checkRoleLevels(role.getLevel());
|
||||
}
|
||||
// 验证是否被用户关联
|
||||
roleService.verifyBindRelationByIds(ids);
|
||||
roleApi.verifyBindRelationByIds(ids);
|
||||
roleService.removeRoleByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -119,7 +121,7 @@ public class RoleController {
|
||||
* @return /
|
||||
*/
|
||||
private int checkRoleLevels(Integer level) {
|
||||
List<Integer> levels = roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList());
|
||||
List<Integer> levels = roleApi.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList());
|
||||
int min = Collections.min(levels);
|
||||
if (level != null) {
|
||||
if (level < min) {
|
||||
|
||||
+24
-22
@@ -3,18 +3,19 @@ package cn.odboy.core.controller.system;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.MyMetaOption;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.api.system.DataApi;
|
||||
import cn.odboy.core.api.system.DeptApi;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.api.system.UserApi;
|
||||
import cn.odboy.core.constant.CaptchaBizEnum;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.service.system.dto.QueryUserRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.UpdateUserPasswordResponse;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.service.system.DataService;
|
||||
import cn.odboy.core.service.system.DeptService;
|
||||
import cn.odboy.core.service.system.RoleService;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.service.system.UserService;
|
||||
import cn.odboy.core.service.system.dto.QueryUserRequest;
|
||||
import cn.odboy.core.service.tools.CaptchaService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.PageUtil;
|
||||
@@ -55,9 +56,10 @@ import java.util.stream.Collectors;
|
||||
public class UserController {
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final UserService userService;
|
||||
private final DataService dataService;
|
||||
private final DeptService deptService;
|
||||
private final RoleService roleService;
|
||||
private final DataApi dataApi;
|
||||
private final DeptApi deptApi;
|
||||
private final RoleApi roleApi;
|
||||
private final UserApi userApi;
|
||||
private final CaptchaService verificationCodeService;
|
||||
private final AppProperties properties;
|
||||
|
||||
@@ -65,7 +67,7 @@ public class UserController {
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public void downloadUserExcel(HttpServletResponse response, QueryUserRequest criteria) throws IOException {
|
||||
userService.downloadUserExcel(userService.describeUserList(criteria), response);
|
||||
userService.downloadUserExcel(userApi.describeUserList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@@ -76,23 +78,23 @@ public class UserController {
|
||||
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
||||
criteria.getDeptIds().add(criteria.getDeptId());
|
||||
// 先查找是否存在子节点
|
||||
List<Dept> data = deptService.describeDeptListByPid(criteria.getDeptId());
|
||||
List<Dept> data = deptApi.describeDeptListByPid(criteria.getDeptId());
|
||||
// 然后把子节点的ID都加入到集合中
|
||||
criteria.getDeptIds().addAll(deptService.describeChildDeptIdListByDeptIds(data));
|
||||
criteria.getDeptIds().addAll(deptApi.describeChildDeptIdListByDeptIds(data));
|
||||
}
|
||||
// 数据权限
|
||||
List<Long> dataScopes = dataService.describeDeptIdListByUserIdWithDeptId(userService.describeUserByUsername(SecurityHelper.getCurrentUsername()));
|
||||
List<Long> dataScopes = dataApi.describeDeptIdListByUserIdWithDeptId(userApi.describeUserByUsername(SecurityHelper.getCurrentUsername()));
|
||||
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||
// 取交集
|
||||
criteria.getDeptIds().retainAll(dataScopes);
|
||||
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
||||
return new ResponseEntity<>(userService.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(userApi.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
} else {
|
||||
// 否则取并集
|
||||
criteria.getDeptIds().addAll(dataScopes);
|
||||
return new ResponseEntity<>(userService.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(userApi.describeUserPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(PageUtil.noData(), HttpStatus.OK);
|
||||
}
|
||||
@@ -132,10 +134,10 @@ public class UserController {
|
||||
@PreAuthorize("@el.check('user:del')")
|
||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
Integer currentLevel = Collections.min(roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(roleService.describeRoleListByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
Integer currentLevel = Collections.min(roleApi.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(roleApi.describeRoleListByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足,不能删除:" + userService.describeUserById(id).getUsername());
|
||||
throw new BadRequestException("角色权限不足,不能删除:" + userApi.describeUserById(id).getUsername());
|
||||
}
|
||||
}
|
||||
userService.removeUserByIds(ids);
|
||||
@@ -147,7 +149,7 @@ public class UserController {
|
||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody UpdateUserPasswordResponse passVo) throws Exception {
|
||||
String oldPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
||||
String newPass = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
||||
User user = userService.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
User user = userApi.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||
throw new BadRequestException("修改失败,旧密码错误");
|
||||
}
|
||||
@@ -176,7 +178,7 @@ public class UserController {
|
||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody User resources) throws Exception {
|
||||
String password = RsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), resources.getPassword());
|
||||
User user = userService.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
User user = userApi.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||
throw new BadRequestException("密码错误");
|
||||
}
|
||||
@@ -191,8 +193,8 @@ public class UserController {
|
||||
* @param resources /
|
||||
*/
|
||||
private void checkLevel(User resources) {
|
||||
Integer currentLevel = Collections.min(roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = roleService.describeDeptLevelByRoles(resources.getRoles());
|
||||
Integer currentLevel = Collections.min(roleApi.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = roleApi.describeDeptLevelByRoles(resources.getRoles());
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足");
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package cn.odboy.core.controller.tools;
|
||||
|
||||
import cn.odboy.core.api.tools.EmailApi;
|
||||
import cn.odboy.core.service.tools.dto.SendEmailRequest;
|
||||
import cn.odboy.core.dal.dataobject.tools.EmailConfig;
|
||||
import cn.odboy.core.service.tools.EmailService;
|
||||
@@ -22,12 +23,13 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("api/email")
|
||||
@Api(tags = "工具:邮件管理")
|
||||
public class EmailController {
|
||||
private final EmailApi emailApi;
|
||||
private final EmailService emailService;
|
||||
|
||||
@ApiOperation("查询配置")
|
||||
@PostMapping(value = "/describeEmailConfig")
|
||||
public ResponseEntity<EmailConfig> describeEmailConfig() {
|
||||
return new ResponseEntity<>(emailService.describeEmailConfig(), HttpStatus.OK);
|
||||
return new ResponseEntity<>(emailApi.describeEmailConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("配置邮件")
|
||||
|
||||
+4
-2
@@ -2,6 +2,7 @@ package cn.odboy.core.controller.tools;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.constant.FileTypeEnum;
|
||||
import cn.odboy.core.api.tools.LocalStorageApi;
|
||||
import cn.odboy.core.service.tools.dto.QueryLocalStorageRequest;
|
||||
import cn.odboy.core.dal.dataobject.tools.LocalStorage;
|
||||
import cn.odboy.core.service.tools.LocalStorageService;
|
||||
@@ -31,20 +32,21 @@ import java.io.IOException;
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class LocalStorageController {
|
||||
private final LocalStorageService localStorageService;
|
||||
private final LocalStorageApi localStorageApi;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<PageResult<LocalStorage>> queryFile(QueryLocalStorageRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(localStorageService.describeLocalStoragePage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(localStorageApi.describeLocalStoragePage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public void exportFile(HttpServletResponse response, QueryLocalStorageRequest criteria) throws IOException {
|
||||
localStorageService.downloadExcel(localStorageService.describeLocalStorageList(criteria), response);
|
||||
localStorageService.downloadExcel(localStorageApi.describeLocalStorageList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
|
||||
+7
-3
@@ -1,6 +1,8 @@
|
||||
package cn.odboy.core.controller.tools;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.api.tools.QiniuConfigApi;
|
||||
import cn.odboy.core.api.tools.QiniuContentApi;
|
||||
import cn.odboy.core.service.tools.dto.QueryQiniuRequest;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuConfig;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuContent;
|
||||
@@ -39,11 +41,13 @@ import java.util.Map;
|
||||
public class QiniuController {
|
||||
private final QiniuContentService qiniuContentService;
|
||||
private final QiniuConfigService qiNiuConfigService;
|
||||
private final QiniuConfigApi qiniuConfigApi;
|
||||
private final QiniuContentApi qiniuContentApi;
|
||||
|
||||
@ApiOperation("查询七牛云存储配置")
|
||||
@PostMapping(value = "/describeQiniuConfig")
|
||||
public ResponseEntity<QiniuConfig> describeQiniuConfig() {
|
||||
return new ResponseEntity<>(qiNiuConfigService.describeQiniuConfig(), HttpStatus.OK);
|
||||
return new ResponseEntity<>(qiniuConfigApi.describeQiniuConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("配置七牛云存储")
|
||||
@@ -57,14 +61,14 @@ public class QiniuController {
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportQiNiu(HttpServletResponse response, QueryQiniuRequest criteria) throws IOException {
|
||||
qiniuContentService.downloadExcel(qiniuContentService.describeQiniuContentList(criteria), response);
|
||||
qiniuContentService.downloadExcel(qiniuContentApi.describeQiniuContentList(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
public ResponseEntity<PageResult<QiniuContent>> queryQiNiu(QueryQiniuRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(qiniuContentService.describeQiniuContentPage(criteria, page), HttpStatus.OK);
|
||||
return new ResponseEntity<>(qiniuContentApi.describeQiniuContentPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
|
||||
+3
-3
@@ -34,11 +34,11 @@ public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
List<User> queryUserListByMenuId(@Param("menuId") Long menuId);
|
||||
|
||||
int getCountByJobIds(@Param("jobIds") Set<Long> jobIds);
|
||||
int getUserCountByJobIds(@Param("jobIds") Set<Long> jobIds);
|
||||
|
||||
int getCountByDeptIds(@Param("deptIds") Set<Long> deptIds);
|
||||
int getUserCountByDeptIds(@Param("deptIds") Set<Long> deptIds);
|
||||
|
||||
int getCountByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
||||
int getUserCountByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
||||
|
||||
void updatePasswordByUserIds(@Param("pwd") String password, @Param("userIds") Set<Long> userIds);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cn.odboy.core.framework.permission;
|
||||
|
||||
import cn.odboy.constant.RequestMethodEnum;
|
||||
import cn.odboy.core.service.system.impl.UserOnlineServiceImpl;
|
||||
import cn.odboy.core.api.system.UserOnlineApi;
|
||||
import cn.odboy.util.AnonTagUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -30,7 +30,7 @@ public class SpringSecurityConfig {
|
||||
private final JwtAuthenticationEntryPoint authenticationErrorHandler;
|
||||
private final JwtAccessDeniedHandler jwtAccessDeniedHandler;
|
||||
private final ApplicationContext applicationContext;
|
||||
private final UserOnlineServiceImpl onlineUserService;
|
||||
private final UserOnlineApi userOnlineApi;
|
||||
|
||||
@Bean
|
||||
GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
@@ -108,6 +108,6 @@ public class SpringSecurityConfig {
|
||||
}
|
||||
|
||||
private TokenConfigurer securityConfigurerAdapter() {
|
||||
return new TokenConfigurer(tokenProvider, onlineUserService);
|
||||
return new TokenConfigurer(tokenProvider, userOnlineApi);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package cn.odboy.core.framework.permission;
|
||||
|
||||
import cn.odboy.core.service.system.impl.UserOnlineServiceImpl;
|
||||
import cn.odboy.core.api.system.UserOnlineApi;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
@@ -10,11 +10,11 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
|
||||
@RequiredArgsConstructor
|
||||
public class TokenConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
|
||||
private final TokenProvider tokenProvider;
|
||||
private final UserOnlineServiceImpl onlineUserService;
|
||||
private final UserOnlineApi userOnlineApi;
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) {
|
||||
TokenFilter customFilter = new TokenFilter(tokenProvider, onlineUserService);
|
||||
TokenFilter customFilter = new TokenFilter(tokenProvider, userOnlineApi);
|
||||
http.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -2,8 +2,8 @@ package cn.odboy.core.framework.permission;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.core.api.system.UserOnlineApi;
|
||||
import cn.odboy.core.service.system.dto.UserOnlineVo;
|
||||
import cn.odboy.core.service.system.impl.UserOnlineServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -19,14 +19,14 @@ import java.io.IOException;
|
||||
@Slf4j
|
||||
public class TokenFilter extends GenericFilterBean {
|
||||
private final TokenProvider tokenProvider;
|
||||
private final UserOnlineServiceImpl onlineUserService;
|
||||
private final UserOnlineApi userOnlineApi;
|
||||
|
||||
/**
|
||||
* @param tokenProvider Token
|
||||
* @param onlineUserService 用户在线
|
||||
* @param userOnlineApi 用户在线
|
||||
*/
|
||||
public TokenFilter(TokenProvider tokenProvider, UserOnlineServiceImpl onlineUserService) {
|
||||
this.onlineUserService = onlineUserService;
|
||||
public TokenFilter(TokenProvider tokenProvider, UserOnlineApi userOnlineApi) {
|
||||
this.userOnlineApi = userOnlineApi;
|
||||
this.tokenProvider = tokenProvider;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TokenFilter extends GenericFilterBean {
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
// 获取用户Token的Key
|
||||
String loginKey = tokenProvider.loginKey(token);
|
||||
UserOnlineVo userOnlineVo = onlineUserService.describeUserOnlineModelByKey(loginKey);
|
||||
UserOnlineVo userOnlineVo = userOnlineApi.describeUserOnlineModelByKey(loginKey);
|
||||
// 判断用户在线信息是否为空
|
||||
if (userOnlineVo != null) {
|
||||
// Token 续期判断
|
||||
|
||||
+1
-39
@@ -1,11 +1,8 @@
|
||||
package cn.odboy.core.service.job;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.job.dto.QueryQuartzJobRequest;
|
||||
import cn.odboy.core.service.job.dto.UpdateQuartzJobRequest;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzJob;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzLog;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.odboy.core.service.job.dto.UpdateQuartzJobRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -14,41 +11,6 @@ import java.util.Set;
|
||||
|
||||
|
||||
public interface QuartzJobService extends IService<QuartzJob> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QuartzJob> describeQuartzJobPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QuartzJob> describeQuartzJobList(QueryQuartzJobRequest criteria);
|
||||
|
||||
/**
|
||||
* 分页查询日志
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QuartzLog> describeQuartzLogPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QuartzLog> describeQuartzLogList(QueryQuartzJobRequest criteria);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
|
||||
+1
-24
@@ -3,21 +3,17 @@ package cn.odboy.core.service.job.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.job.dto.QueryQuartzJobRequest;
|
||||
import cn.odboy.core.service.job.dto.UpdateQuartzJobRequest;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzJob;
|
||||
import cn.odboy.core.dal.dataobject.job.QuartzLog;
|
||||
import cn.odboy.core.dal.mysql.job.QuartzJobMapper;
|
||||
import cn.odboy.core.dal.mysql.job.QuartzLogMapper;
|
||||
import cn.odboy.core.framework.quartz.context.QuartzManage;
|
||||
import cn.odboy.core.service.job.QuartzJobService;
|
||||
import cn.odboy.core.service.job.dto.UpdateQuartzJobRequest;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.quartz.CronExpression;
|
||||
@@ -41,25 +37,6 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
private final QuartzManage quartzManage;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public PageResult<QuartzJob> describeQuartzJobPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(quartzJobMapper.queryQuartzJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<QuartzLog> describeQuartzLogPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(quartzLogMapper.queryQuartzLogPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartzJob> describeQuartzJobList(QueryQuartzJobRequest criteria) {
|
||||
return quartzJobMapper.queryQuartzJobPageByArgs(criteria, PageUtil.getCount(quartzJobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartzLog> describeQuartzLogList(QueryQuartzJobRequest criteria) {
|
||||
return quartzLogMapper.queryQuartzLogPageByArgs(criteria, PageUtil.getCount(quartzLogMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
+1
-86
@@ -1,9 +1,7 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.BaseResult;
|
||||
import cn.odboy.core.service.system.dto.CreateDeptRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDeptRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
import cn.odboy.core.service.system.dto.CreateDeptRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -12,24 +10,6 @@ import java.util.Set;
|
||||
|
||||
public interface DeptService extends IService<Dept> {
|
||||
|
||||
/**
|
||||
* 查询所有数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param isQuery /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<Dept> describeDeptList(QueryDeptRequest criteria, Boolean isQuery) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Dept describeDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
@@ -51,22 +31,6 @@ public interface DeptService extends IService<Dept> {
|
||||
*/
|
||||
void removeDeptByIds(Set<Dept> depts);
|
||||
|
||||
/**
|
||||
* 根据PID查询
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<Dept> describeDeptListByPid(long pid);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Set<Dept> describeDeptByRoleId(Long id);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
@@ -75,53 +39,4 @@ public interface DeptService extends IService<Dept> {
|
||||
* @throws IOException /
|
||||
*/
|
||||
void downloadDeptExcel(List<Dept> depts, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 获取部门下所有关联的部门
|
||||
*
|
||||
* @param deptList /
|
||||
* @param depts /
|
||||
* @return /
|
||||
*/
|
||||
Set<Dept> describeRelationDeptSet(List<Dept> deptList, Set<Dept> depts);
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
*
|
||||
* @param dept /
|
||||
* @param depts /
|
||||
* @return /
|
||||
*/
|
||||
List<Dept> describeSuperiorDeptListByPid(Dept dept, List<Dept> depts);
|
||||
|
||||
/**
|
||||
* 构建树形数据
|
||||
*
|
||||
* @param depts /
|
||||
* @return /
|
||||
*/
|
||||
BaseResult<Object> buildDeptTree(List<Dept> depts);
|
||||
|
||||
/**
|
||||
* 获取
|
||||
*
|
||||
* @param deptList 、
|
||||
* @return 、
|
||||
*/
|
||||
List<Long> describeChildDeptIdListByDeptIds(List<Dept> deptList);
|
||||
|
||||
/**
|
||||
* 验证是否被角色或用户关联
|
||||
*
|
||||
* @param depts /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Dept> depts);
|
||||
|
||||
/**
|
||||
* 遍历所有部门和子部门
|
||||
*
|
||||
* @param ids /
|
||||
* @param depts /
|
||||
*/
|
||||
void traverseDeptByIdWithPids(Set<Long> ids, Set<Dept> depts);
|
||||
}
|
||||
+1
-22
@@ -1,12 +1,8 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.CreateDictDetailRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDictDetailRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.DictDetail;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.odboy.core.service.system.dto.CreateDictDetailRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface DictDetailService extends IService<DictDetail> {
|
||||
@@ -31,21 +27,4 @@ public interface DictDetailService extends IService<DictDetail> {
|
||||
* @param id /
|
||||
*/
|
||||
void removeDictDetailById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<DictDetail> describeDictDetailPage(QueryDictDetailRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据字典名称获取字典详情
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return /
|
||||
*/
|
||||
List<DictDetail> describeDictDetailListByName(String name);
|
||||
}
|
||||
+1
-22
@@ -1,10 +1,7 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.CreateDictRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDictRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dict;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.odboy.core.service.system.dto.CreateDictRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -13,24 +10,6 @@ import java.util.Set;
|
||||
|
||||
|
||||
public interface DictService extends IService<Dict> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<Dict> describeDictPage(QueryDictRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<Dict> describeDictList(QueryDictRequest criteria);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
|
||||
+1
-36
@@ -1,10 +1,7 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.CreateJobRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryJobRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Job;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.odboy.core.service.system.dto.CreateJobRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -13,15 +10,6 @@ import java.util.Set;
|
||||
|
||||
|
||||
public interface JobService extends IService<Job> {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Job describeJobById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
@@ -43,23 +31,6 @@ public interface JobService extends IService<Job> {
|
||||
*/
|
||||
void removeJobByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<Job> describeJobPage(QueryJobRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria /
|
||||
* @return /
|
||||
*/
|
||||
List<Job> describeJobList(QueryJobRequest criteria);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
@@ -69,10 +40,4 @@ public interface JobService extends IService<Job> {
|
||||
*/
|
||||
void downloadJobExcel(List<Job> jobs, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.core.service.system.dto.QueryMenuRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
import cn.odboy.core.dal.dataobject.system.MenuResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -11,23 +9,7 @@ import java.util.Set;
|
||||
|
||||
|
||||
public interface MenuService extends IService<Menu> {
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param isQuery /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<Menu> describeMenuList(QueryMenuRequest criteria, Boolean isQuery) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Menu describeMenuById(long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
@@ -43,30 +25,6 @@ public interface MenuService extends IService<Menu> {
|
||||
*/
|
||||
void modifyMenuById(Menu resources);
|
||||
|
||||
/**
|
||||
* 获取所有子节点,包含自身ID
|
||||
*
|
||||
* @param menuList /
|
||||
* @param menuSet /
|
||||
* @return /
|
||||
*/
|
||||
Set<Menu> describeChildMenuSet(List<Menu> menuList, Set<Menu> menuSet);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus 原始数据
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> buildMenuTree(List<Menu> menus);
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param menus /
|
||||
* @return /
|
||||
*/
|
||||
List<MenuResponse> buildMenuResponse(List<Menu> menus);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@@ -84,28 +42,5 @@ public interface MenuService extends IService<Menu> {
|
||||
*/
|
||||
void downloadMenuExcel(List<Menu> menus, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 懒加载菜单数据
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> describeMenuListByPid(Long pid);
|
||||
|
||||
/**
|
||||
* 根据ID获取同级与上级数据
|
||||
*
|
||||
* @param menu /
|
||||
* @param objects /
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> describeSuperiorMenuList(Menu menu, List<Menu> objects);
|
||||
|
||||
/**
|
||||
* 根据当前用户获取菜单
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
List<Menu> describeMenuListByUserId(Long currentUserId);
|
||||
}
|
||||
|
||||
+1
-74
@@ -1,12 +1,7 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.CreateRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.RoleCodeVo;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.odboy.core.service.system.dto.CreateRoleRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -16,37 +11,6 @@ import java.util.Set;
|
||||
|
||||
public interface RoleService extends IService<Role> {
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleList();
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleList(QueryRoleRequest criteria);
|
||||
|
||||
/**
|
||||
* 待条件分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<Role> describeRolePage(QueryRoleRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
Role describeRoleById(long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
@@ -76,29 +40,6 @@ public interface RoleService extends IService<Role> {
|
||||
*/
|
||||
void removeRoleByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleListByUsersId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色查询角色级别
|
||||
*
|
||||
* @param roles /
|
||||
* @return /
|
||||
*/
|
||||
Integer describeDeptLevelByRoles(Set<Role> roles);
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
List<RoleCodeVo> buildUserRolePermissions(User user);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
@@ -109,18 +50,4 @@ public interface RoleService extends IService<Role> {
|
||||
*/
|
||||
void downloadRoleExcel(List<Role> roles, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 验证是否被用户关联
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void verifyBindRelationByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据菜单Id查询
|
||||
*
|
||||
* @param menuId /
|
||||
* @return /
|
||||
*/
|
||||
List<Role> describeRoleListByMenuId(Long menuId);
|
||||
}
|
||||
|
||||
-8
@@ -4,14 +4,6 @@ import cn.odboy.core.service.system.dto.UserJwtVo;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
public interface UserCacheService {
|
||||
/**
|
||||
* 返回用户缓存
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return UserJwtVo
|
||||
*/
|
||||
UserJwtVo describeUserJwtModelByUsername(String username);
|
||||
|
||||
/**
|
||||
* 添加缓存到Redis
|
||||
*
|
||||
|
||||
-25
@@ -1,9 +1,7 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.UserJwtVo;
|
||||
import cn.odboy.core.service.system.dto.UserOnlineVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -19,22 +17,6 @@ public interface UserOnlineService {
|
||||
*/
|
||||
void saveUserJwtModelByToken(UserJwtVo userJwtVo, String token, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param username /
|
||||
* @param pageable /
|
||||
* @return /
|
||||
*/
|
||||
PageResult<UserOnlineVo> describeUserOnlineModelPage(String username, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询全部数据,不分页
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
List<UserOnlineVo> describeUserOnlineModelListByUsername(String username);
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
@@ -52,13 +34,6 @@ public interface UserOnlineService {
|
||||
*/
|
||||
void downloadUserOnlineModelExcel(List<UserOnlineVo> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param key /
|
||||
* @return /
|
||||
*/
|
||||
UserOnlineVo describeUserOnlineModelByKey(String key);
|
||||
|
||||
/**
|
||||
* 根据用户名强退用户
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package cn.odboy.core.service.system;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.system.dto.QueryUserRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -13,15 +10,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface UserService extends IService<User> {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return /
|
||||
*/
|
||||
User describeUserById(long id);
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*
|
||||
@@ -43,15 +31,6 @@ public interface UserService extends IService<User> {
|
||||
* @param ids /
|
||||
*/
|
||||
void removeUserByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户名查询
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
User describeUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
@@ -76,23 +55,6 @@ public interface UserService extends IService<User> {
|
||||
*/
|
||||
void modifyUserEmailByUsername(String username, String email);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<User> describeUserPage(QueryUserRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部不分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<User> describeUserList(QueryUserRequest criteria);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
|
||||
+4
-182
@@ -1,40 +1,28 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.base.BaseResult;
|
||||
import cn.odboy.core.constant.DataScopeEnum;
|
||||
import cn.odboy.core.api.system.DeptApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.service.system.dto.CreateDeptRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDeptRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dept;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.dal.mysql.system.DeptMapper;
|
||||
import cn.odboy.core.dal.mysql.system.RoleMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.DeptService;
|
||||
import cn.odboy.core.service.system.dto.CreateDeptRequest;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -42,64 +30,9 @@ import java.util.stream.Collectors;
|
||||
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements DeptService {
|
||||
private final DeptMapper deptMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final RoleMapper roleMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
private final DeptApi deptApi;
|
||||
|
||||
@Override
|
||||
public List<Dept> describeDeptList(QueryDeptRequest criteria, Boolean isQuery) throws Exception {
|
||||
String dataScopeType = SecurityHelper.getDataScopeType();
|
||||
if (isQuery) {
|
||||
if (dataScopeType.equals(DataScopeEnum.ALL.getValue())) {
|
||||
criteria.setPidIsNull(true);
|
||||
}
|
||||
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
|
||||
List<String> fieldNames = new ArrayList<>() {{
|
||||
add("pidIsNull");
|
||||
add("enabled");
|
||||
}};
|
||||
for (Field field : fields) {
|
||||
// 设置对象的访问权限,保证对private的属性的访问
|
||||
field.setAccessible(true);
|
||||
Object val = field.get(criteria);
|
||||
if (fieldNames.contains(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(val)) {
|
||||
criteria.setPidIsNull(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数据权限
|
||||
criteria.setIds(SecurityHelper.getCurrentUserDataScope());
|
||||
List<Dept> list = deptMapper.queryDeptListByArgs(criteria);
|
||||
// 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果
|
||||
if (StringUtil.isBlank(dataScopeType)) {
|
||||
return deduplication(list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dept describeDeptById(Long id) {
|
||||
String key = SystemRedisKey.DEPT_ID + id;
|
||||
Dept dept = redisHelper.get(key, Dept.class);
|
||||
if (dept == null) {
|
||||
dept = deptMapper.selectById(id);
|
||||
redisHelper.set(key, dept, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return dept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dept> describeDeptListByPid(long pid) {
|
||||
return deptMapper.queryDeptListByPid(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dept> describeDeptByRoleId(Long id) {
|
||||
return deptMapper.queryDeptSetByRoleId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -115,7 +48,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyDept(Dept resources) {
|
||||
// 旧的部门
|
||||
Long oldPid = describeDeptById(resources.getId()).getPid();
|
||||
Long oldPid = deptApi.describeDeptById(resources.getId()).getPid();
|
||||
Long newPid = resources.getPid();
|
||||
if (resources.getPid() != null && resources.getId().equals(resources.getPid())) {
|
||||
throw new BadRequestException("上级不能为自己");
|
||||
@@ -154,102 +87,6 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dept> describeRelationDeptSet(List<Dept> menuList, Set<Dept> deptSet) {
|
||||
for (Dept dept : menuList) {
|
||||
deptSet.add(dept);
|
||||
List<Dept> deptList = deptMapper.queryDeptListByPid(dept.getId());
|
||||
if (CollUtil.isNotEmpty(deptList)) {
|
||||
describeRelationDeptSet(deptList, deptSet);
|
||||
}
|
||||
}
|
||||
return deptSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> describeChildDeptIdListByDeptIds(List<Dept> deptList) {
|
||||
List<Long> list = new ArrayList<>();
|
||||
deptList.forEach(dept -> {
|
||||
if (dept != null && dept.getEnabled()) {
|
||||
List<Dept> deptList1 = deptMapper.queryDeptListByPid(dept.getId());
|
||||
if (CollUtil.isNotEmpty(deptList1)) {
|
||||
list.addAll(describeChildDeptIdListByDeptIds(deptList1));
|
||||
}
|
||||
list.add(dept.getId());
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dept> describeSuperiorDeptListByPid(Dept dept, List<Dept> deptList) {
|
||||
if (dept.getPid() == null) {
|
||||
deptList.addAll(deptMapper.queryDeptListByPidIsNull());
|
||||
return deptList;
|
||||
}
|
||||
deptList.addAll(deptMapper.queryDeptListByPid(dept.getPid()));
|
||||
return describeSuperiorDeptListByPid(describeDeptById(dept.getPid()), deptList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResult<Object> buildDeptTree(List<Dept> deptList) {
|
||||
Set<Dept> trees = new LinkedHashSet<>();
|
||||
Set<Dept> deptSet = new LinkedHashSet<>();
|
||||
List<String> deptNames = deptList.stream().map(Dept::getName).collect(Collectors.toList());
|
||||
boolean isChild;
|
||||
for (Dept dept : deptList) {
|
||||
isChild = false;
|
||||
if (dept.getPid() == null) {
|
||||
trees.add(dept);
|
||||
}
|
||||
for (Dept it : deptList) {
|
||||
if (it.getPid() != null && dept.getId().equals(it.getPid())) {
|
||||
isChild = true;
|
||||
if (dept.getChildren() == null) {
|
||||
dept.setChildren(new ArrayList<>());
|
||||
}
|
||||
dept.getChildren().add(it);
|
||||
}
|
||||
}
|
||||
if (isChild) {
|
||||
deptSet.add(dept);
|
||||
} else if (dept.getPid() != null && !deptNames.contains(describeDeptById(dept.getPid()).getName())) {
|
||||
deptSet.add(dept);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(trees)) {
|
||||
trees = deptSet;
|
||||
}
|
||||
BaseResult<Object> baseResult = new BaseResult<>();
|
||||
baseResult.setContent(CollectionUtil.isEmpty(trees) ? deptSet : trees);
|
||||
baseResult.setTotalElements(deptSet.size());
|
||||
return baseResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Dept> deptSet) {
|
||||
Set<Long> deptIds = deptSet.stream().map(Dept::getId).collect(Collectors.toSet());
|
||||
if (userMapper.getCountByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||
}
|
||||
if (roleMapper.getRoleCountByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在角色关联,请解除后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void traverseDeptByIdWithPids(Set<Long> ids, Set<Dept> depts) {
|
||||
for (Long id : ids) {
|
||||
// 根部门
|
||||
depts.add(describeDeptById(id));
|
||||
// 子部门
|
||||
List<Dept> deptList = describeDeptListByPid(id);
|
||||
if (CollectionUtil.isNotEmpty(deptList)) {
|
||||
depts = describeRelationDeptSet(deptList, depts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSubCnt(Long deptId) {
|
||||
if (deptId != null) {
|
||||
@@ -258,21 +95,6 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
||||
*/
|
||||
private List<Dept> deduplication(List<Dept> list) {
|
||||
List<Dept> deptList = new ArrayList<>();
|
||||
// 使用 Set 存储所有部门的 id
|
||||
Set<Long> idSet = list.stream().map(Dept::getId).collect(Collectors.toSet());
|
||||
// 遍历部门列表,筛选出没有父部门的部门
|
||||
for (Dept dept : list) {
|
||||
if (!idSet.contains(dept.getPid())) {
|
||||
deptList.add(dept);
|
||||
}
|
||||
}
|
||||
return deptList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
|
||||
+3
-23
@@ -1,37 +1,26 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.service.system.dto.CreateDictDetailRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDictDetailRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dict;
|
||||
import cn.odboy.core.dal.dataobject.system.DictDetail;
|
||||
import cn.odboy.core.dal.mysql.system.DictDetailMapper;
|
||||
import cn.odboy.core.dal.mysql.system.DictMapper;
|
||||
import cn.odboy.core.service.system.DictDetailService;
|
||||
import cn.odboy.core.service.system.dto.CreateDictDetailRequest;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictDetailServiceImpl extends ServiceImpl<DictDetailMapper, DictDetail> implements DictDetailService {
|
||||
private final DictMapper dictMapper;
|
||||
private final DictDetailMapper dictDetailMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public PageResult<DictDetail> describeDictDetailPage(QueryDictDetailRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(dictDetailMapper.queryDictDetailPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -54,16 +43,7 @@ public class DictDetailServiceImpl extends ServiceImpl<DictDetailMapper, DictDet
|
||||
delCaches(dictDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDetail> describeDictDetailListByName(String name) {
|
||||
String key = SystemRedisKey.DICT_NAME + name;
|
||||
List<DictDetail> dictDetails = redisHelper.getList(key, DictDetail.class);
|
||||
if (CollUtil.isEmpty(dictDetails)) {
|
||||
dictDetails = dictDetailMapper.queryDictDetailListByDictName(name);
|
||||
redisHelper.set(key, dictDetails, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return dictDetails;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
+1
-16
@@ -2,20 +2,15 @@ package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.service.system.dto.CreateDictRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryDictRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Dict;
|
||||
import cn.odboy.core.dal.dataobject.system.DictDetail;
|
||||
import cn.odboy.core.dal.mysql.system.DictDetailMapper;
|
||||
import cn.odboy.core.dal.mysql.system.DictMapper;
|
||||
import cn.odboy.core.service.system.DictService;
|
||||
import cn.odboy.core.service.system.dto.CreateDictRequest;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -35,16 +30,6 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
||||
private final DictDetailMapper dictDetailMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public PageResult<Dict> describeDictPage(QueryDictRequest criteria, Page<Object> page) {
|
||||
IPage<Dict> dicts = dictMapper.queryDictPageByArgs(criteria, page);
|
||||
return PageUtil.toPage(dicts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> describeDictList(QueryDictRequest criteria) {
|
||||
return dictMapper.queryDictPageByArgs(criteria, PageUtil.getCount(dictMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
+1
-33
@@ -1,20 +1,15 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.service.system.dto.CreateJobRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryJobRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Job;
|
||||
import cn.odboy.core.dal.mysql.system.JobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.JobService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.core.service.system.dto.CreateJobRequest;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,35 +21,14 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobService {
|
||||
private final JobMapper jobMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public PageResult<Job> describeJobPage(QueryJobRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(jobMapper.queryJobPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Job> describeJobList(QueryJobRequest criteria) {
|
||||
return jobMapper.queryJobPageByArgs(criteria, PageUtil.getCount(jobMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Job describeJobById(Long id) {
|
||||
String key = SystemRedisKey.JOB_ID + id;
|
||||
Job job = redisHelper.get(key, Job.class);
|
||||
if (job == null) {
|
||||
job = getById(id);
|
||||
redisHelper.set(key, job, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -101,12 +75,6 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (userMapper.getCountByJobIds(ids) > 0) {
|
||||
throw new BadRequestException("所选的岗位中存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
|
||||
public void delCaches(Long id) {
|
||||
redisHelper.del(SystemRedisKey.JOB_ID + id);
|
||||
|
||||
+3
-184
@@ -1,25 +1,18 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.constant.TransferProtocolConst;
|
||||
import cn.odboy.core.service.system.dto.MenuMetaVo;
|
||||
import cn.odboy.core.service.system.dto.QueryMenuRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
import cn.odboy.core.dal.dataobject.system.MenuResponse;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.dal.mysql.system.MenuMapper;
|
||||
import cn.odboy.core.dal.mysql.system.RoleMenuMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.MenuService;
|
||||
import cn.odboy.core.service.system.RoleService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.ClassUtil;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -28,15 +21,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -46,63 +35,12 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
private final MenuMapper menuMapper;
|
||||
private final RoleMenuMapper roleMenuMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final RoleService roleService;
|
||||
private final RoleApi roleApi;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
private static final String YES_STR = "是";
|
||||
private static final String NO_STR = "否";
|
||||
|
||||
@Override
|
||||
public List<Menu> describeMenuList(QueryMenuRequest criteria, Boolean isQuery) throws Exception {
|
||||
if (Boolean.TRUE.equals(isQuery)) {
|
||||
criteria.setPidIsNull(true);
|
||||
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
|
||||
for (Field field : fields) {
|
||||
//设置对象的访问权限,保证对private的属性的访问
|
||||
field.setAccessible(true);
|
||||
Object val = field.get(criteria);
|
||||
if ("pidIsNull".equals(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
// 如果有查询条件,则不指定pidIsNull
|
||||
if (ObjectUtil.isNotNull(val)) {
|
||||
criteria.setPidIsNull(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return menuMapper.queryMenuListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu describeMenuById(long id) {
|
||||
String key = SystemRedisKey.MENU_ID + id;
|
||||
Menu menu = redisHelper.get(key, Menu.class);
|
||||
if (menu == null) {
|
||||
menu = getById(id);
|
||||
redisHelper.set(key, menu, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色改变时需清理缓存
|
||||
*
|
||||
* @param currentUserId /
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> describeMenuListByUserId(Long currentUserId) {
|
||||
String key = SystemRedisKey.MENU_USER + currentUserId;
|
||||
List<Menu> menus = redisHelper.getList(key, Menu.class);
|
||||
if (CollUtil.isEmpty(menus)) {
|
||||
List<Role> roles = roleService.describeRoleListByUsersId(currentUserId);
|
||||
Set<Long> roleIds = roles.stream().map(Role::getId).collect(Collectors.toSet());
|
||||
menus = new ArrayList<>(menuMapper.queryMenuSetByRoleIdsAndType(roleIds, 2));
|
||||
redisHelper.set(key, menus, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -182,17 +120,6 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
delCaches(resources.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Menu> describeChildMenuSet(List<Menu> menuList, Set<Menu> menuSet) {
|
||||
for (Menu menu : menuList) {
|
||||
menuSet.add(menu);
|
||||
List<Menu> menus = menuMapper.queryMenuListByPidOrderByMenuSort(menu.getId());
|
||||
if (CollUtil.isNotEmpty(menus)) {
|
||||
describeChildMenuSet(menus, menuSet);
|
||||
}
|
||||
}
|
||||
return menuSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -206,94 +133,6 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Menu> describeMenuListByPid(Long pid) {
|
||||
List<Menu> menus;
|
||||
if (pid != null && !pid.equals(0L)) {
|
||||
menus = menuMapper.queryMenuListByPidOrderByMenuSort(pid);
|
||||
} else {
|
||||
menus = menuMapper.queryMenuListByPidIsNullOrderByMenuSort();
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Menu> describeSuperiorMenuList(Menu menu, List<Menu> menus) {
|
||||
if (menu.getPid() == null) {
|
||||
menus.addAll(menuMapper.queryMenuListByPidIsNullOrderByMenuSort());
|
||||
return menus;
|
||||
}
|
||||
menus.addAll(menuMapper.queryMenuListByPidOrderByMenuSort(menu.getPid()));
|
||||
return describeSuperiorMenuList(describeMenuById(menu.getPid()), menus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Menu> buildMenuTree(List<Menu> menus) {
|
||||
List<Menu> trees = new ArrayList<>();
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (Menu menu : menus) {
|
||||
if (menu.getPid() == null) {
|
||||
trees.add(menu);
|
||||
}
|
||||
for (Menu it : menus) {
|
||||
if (menu.getId().equals(it.getPid())) {
|
||||
if (menu.getChildren() == null) {
|
||||
menu.setChildren(new ArrayList<>());
|
||||
}
|
||||
menu.getChildren().add(it);
|
||||
ids.add(it.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(trees)) {
|
||||
trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuResponse> buildMenuResponse(List<Menu> menus) {
|
||||
List<MenuResponse> list = new LinkedList<>();
|
||||
menus.forEach(menu -> {
|
||||
if (menu != null) {
|
||||
List<Menu> menuList = menu.getChildren();
|
||||
MenuResponse menuResponse = new MenuResponse();
|
||||
menuResponse.setName(ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuResponse.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath());
|
||||
menuResponse.setHidden(menu.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menu.getIFrame()) {
|
||||
if (menu.getPid() == null) {
|
||||
menuResponse.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent());
|
||||
// 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单
|
||||
} else if (menu.getType() == 0) {
|
||||
menuResponse.setComponent(StringUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent());
|
||||
} else if (StringUtil.isNoneBlank(menu.getComponent())) {
|
||||
menuResponse.setComponent(menu.getComponent());
|
||||
}
|
||||
}
|
||||
menuResponse.setMeta(new MenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache()));
|
||||
if (CollectionUtil.isNotEmpty(menuList)) {
|
||||
menuResponse.setAlwaysShow(true);
|
||||
menuResponse.setRedirect("noredirect");
|
||||
menuResponse.setChildren(buildMenuResponse(menuList));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (menu.getPid() == null) {
|
||||
MenuResponse menuResponse1 = getMenuVo(menu, menuResponse);
|
||||
menuResponse.setName(null);
|
||||
menuResponse.setMeta(null);
|
||||
menuResponse.setComponent("Layout");
|
||||
List<MenuResponse> list1 = new ArrayList<>();
|
||||
list1.add(menuResponse1);
|
||||
menuResponse.setChildren(list1);
|
||||
}
|
||||
list.add(menuResponse);
|
||||
}
|
||||
}
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadMenuExcel(List<Menu> menus, HttpServletResponse response) throws IOException {
|
||||
@@ -329,28 +168,8 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
redisHelper.del(SystemRedisKey.MENU_ID + id);
|
||||
redisHelper.delByKeys(SystemRedisKey.MENU_USER, users.stream().map(User::getId).collect(Collectors.toSet()));
|
||||
// 清除 Role 缓存
|
||||
List<Role> roles = roleService.describeRoleListByMenuId(id);
|
||||
List<Role> roles = roleApi.describeRoleListByMenuId(id);
|
||||
redisHelper.delByKeys(SystemRedisKey.ROLE_ID, roles.stream().map(Role::getId).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MenuResponse
|
||||
*
|
||||
* @param menu /
|
||||
* @param menuResponse /
|
||||
* @return /
|
||||
*/
|
||||
private static MenuResponse getMenuVo(Menu menu, MenuResponse menuResponse) {
|
||||
MenuResponse menuResponse1 = new MenuResponse();
|
||||
menuResponse1.setMeta(menuResponse.getMeta());
|
||||
// 非外链
|
||||
if (!menu.getIFrame()) {
|
||||
menuResponse1.setPath("index");
|
||||
menuResponse1.setName(menuResponse.getName());
|
||||
menuResponse1.setComponent(menuResponse.getComponent());
|
||||
} else {
|
||||
menuResponse1.setPath(menu.getPath());
|
||||
}
|
||||
return menuResponse1;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-99
@@ -3,12 +3,7 @@ package cn.odboy.core.service.system.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.service.system.dto.CreateRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.QueryRoleRequest;
|
||||
import cn.odboy.core.service.system.dto.RoleCodeVo;
|
||||
import cn.odboy.core.dal.dataobject.system.Menu;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.dal.mysql.system.RoleDeptMapper;
|
||||
@@ -17,13 +12,10 @@ import cn.odboy.core.dal.mysql.system.RoleMenuMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.service.system.RoleService;
|
||||
import cn.odboy.core.service.system.UserCacheService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.core.service.system.dto.CreateRoleRequest;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -31,13 +23,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -50,35 +39,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
private final UserCacheService userCacheService;
|
||||
private final RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleList() {
|
||||
return roleMapper.queryRoleList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleList(QueryRoleRequest criteria) {
|
||||
return roleMapper.queryRoleListByArgs(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Role> describeRolePage(QueryRoleRequest criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<Role> roles = roleMapper.queryRoleListByArgs(criteria);
|
||||
Long total = roleMapper.getRoleCountByArgs(criteria);
|
||||
return PageUtil.toPage(roles, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role describeRoleById(long id) {
|
||||
String key = SystemRedisKey.ROLE_ID + id;
|
||||
Role role = redisHelper.get(key, Role.class);
|
||||
if (role == null) {
|
||||
role = roleMapper.selectById(id);
|
||||
redisHelper.set(key, role, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveRole(CreateRoleRequest resources) {
|
||||
@@ -143,52 +103,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
roleMenuMapper.deleteByRoleIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleListByUsersId(Long userId) {
|
||||
String key = SystemRedisKey.ROLE_USER + userId;
|
||||
List<Role> roles = redisHelper.getList(key, Role.class);
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
roles = roleMapper.queryRoleListByUserId(userId);
|
||||
redisHelper.set(key, roles, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer describeDeptLevelByRoles(Set<Role> roles) {
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
Set<Role> roleSet = new HashSet<>();
|
||||
for (Role role : roles) {
|
||||
roleSet.add(describeRoleById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleSet.stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleCodeVo> buildUserRolePermissions(User user) {
|
||||
String key = SystemRedisKey.ROLE_AUTH + user.getId();
|
||||
List<RoleCodeVo> authorityList = redisHelper.getList(key, RoleCodeVo.class);
|
||||
if (CollUtil.isEmpty(authorityList)) {
|
||||
Set<String> permissions = new HashSet<>();
|
||||
// 如果是管理员直接返回
|
||||
if (user.getIsAdmin()) {
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(RoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<Role> roles = roleMapper.queryRoleListByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream())
|
||||
.map(Menu::getPermission)
|
||||
.filter(StringUtil::isNotBlank).collect(Collectors.toSet());
|
||||
authorityList = permissions.stream().map(RoleCodeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
redisHelper.set(key, authorityList, 1, TimeUnit.HOURS);
|
||||
}
|
||||
return authorityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadRoleExcel(List<Role> roles, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
@@ -203,18 +117,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
||||
if (userMapper.getCountByRoleIds(ids) > 0) {
|
||||
throw new BadRequestException("所选角色存在用户关联,请解除关联再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> describeRoleListByMenuId(Long menuId) {
|
||||
return roleMapper.queryRoleListByMenuId(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
|
||||
-12
@@ -17,18 +17,6 @@ public class UserCacheServiceImpl implements UserCacheService {
|
||||
@Resource
|
||||
private RedisHelper redisHelper;
|
||||
|
||||
@Override
|
||||
public UserJwtVo describeUserJwtModelByUsername(String username) {
|
||||
// 转小写
|
||||
username = StringUtil.lowerCase(username);
|
||||
if (StringUtil.isNotEmpty(username)) {
|
||||
// 获取数据
|
||||
return redisHelper.get(SystemRedisKey.USER_INFO + username, UserJwtVo.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveUserJwtModelByUserName(String userName, UserJwtVo user) {
|
||||
// 转小写
|
||||
|
||||
+14
-12
@@ -1,12 +1,13 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.odboy.core.api.system.DataApi;
|
||||
import cn.odboy.core.api.system.RoleApi;
|
||||
import cn.odboy.core.api.system.UserApi;
|
||||
import cn.odboy.core.api.system.UserCacheApi;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.service.system.UserCacheService;
|
||||
import cn.odboy.core.service.system.dto.RoleCodeVo;
|
||||
import cn.odboy.core.service.system.dto.UserJwtVo;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.service.system.DataService;
|
||||
import cn.odboy.core.service.system.RoleService;
|
||||
import cn.odboy.core.service.system.UserCacheService;
|
||||
import cn.odboy.core.service.system.UserService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -18,16 +19,17 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
@Service("userDetailsService")
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
private final DataService dataService;
|
||||
private final RoleApi roleApi;
|
||||
private final UserApi userApi;
|
||||
private final DataApi dataApi;
|
||||
private final UserCacheService userCacheService;
|
||||
private final UserCacheApi userCacheApi;
|
||||
|
||||
@Override
|
||||
public UserJwtVo loadUserByUsername(String username) {
|
||||
UserJwtVo userJwtVo = userCacheService.describeUserJwtModelByUsername(username);
|
||||
UserJwtVo userJwtVo = userCacheApi.describeUserJwtModelByUsername(username);
|
||||
if (userJwtVo == null) {
|
||||
User user = userService.describeUserByUsername(username);
|
||||
User user = userApi.describeUserByUsername(username);
|
||||
if (user == null) {
|
||||
throw new BadRequestException("用户不存在");
|
||||
} else {
|
||||
@@ -35,9 +37,9 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
throw new BadRequestException("账号未激活!");
|
||||
}
|
||||
// 获取用户的权限
|
||||
List<RoleCodeVo> authorities = roleService.buildUserRolePermissions(user);
|
||||
List<RoleCodeVo> authorities = roleApi.buildUserRolePermissions(user);
|
||||
// 初始化JwtUserDto
|
||||
userJwtVo = new UserJwtVo(user, dataService.describeDeptIdListByUserIdWithDeptId(user), authorities);
|
||||
userJwtVo = new UserJwtVo(user, dataApi.describeDeptIdListByUserIdWithDeptId(user), authorities);
|
||||
// 添加缓存数据
|
||||
userCacheService.saveUserJwtModelByUserName(username, userJwtVo);
|
||||
}
|
||||
|
||||
+1
-25
@@ -29,9 +29,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class UserOnlineServiceImpl implements UserOnlineService {
|
||||
private final AppProperties properties;
|
||||
@@ -64,25 +63,6 @@ public class UserOnlineServiceImpl implements UserOnlineService {
|
||||
redisHelper.set(loginKey, userOnlineVo, properties.getJwt().getTokenValidityInSeconds(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<UserOnlineVo> describeUserOnlineModelPage(String username, Pageable pageable) {
|
||||
List<UserOnlineVo> onlineUserList = describeUserOnlineModelListByUsername(username);
|
||||
List<UserOnlineVo> paging = PageUtil.softPaging(pageable.getPageNumber(), pageable.getPageSize(), onlineUserList);
|
||||
return PageUtil.toPage(paging, onlineUserList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOnlineVo> describeUserOnlineModelListByUsername(String username) {
|
||||
String loginKey = SystemRedisKey.ONLINE_USER + (StringUtil.isBlank(username) ? "" : "*" + username);
|
||||
List<String> keys = redisHelper.scan(loginKey + "*");
|
||||
Collections.reverse(keys);
|
||||
List<UserOnlineVo> onlineUserList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
onlineUserList.add(redisHelper.get(key, UserOnlineVo.class));
|
||||
}
|
||||
onlineUserList.sort((o1, o2) -> o2.getLoginTime().compareTo(o1.getLoginTime()));
|
||||
return onlineUserList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logoutByToken(String token) {
|
||||
@@ -106,10 +86,6 @@ public class UserOnlineServiceImpl implements UserOnlineService {
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOnlineVo describeUserOnlineModelByKey(String key) {
|
||||
return redisHelper.get(key, UserOnlineVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickOutByUsername(String username) {
|
||||
|
||||
+2
-37
@@ -1,16 +1,14 @@
|
||||
package cn.odboy.core.service.system.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.constant.SystemRedisKey;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.service.system.dto.QueryUserRequest;
|
||||
import cn.odboy.core.dal.dataobject.system.Job;
|
||||
import cn.odboy.core.dal.dataobject.system.Role;
|
||||
import cn.odboy.core.dal.dataobject.system.User;
|
||||
import cn.odboy.core.dal.mysql.system.UserJobMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserMapper;
|
||||
import cn.odboy.core.dal.mysql.system.UserRoleMapper;
|
||||
import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.service.system.UserCacheService;
|
||||
import cn.odboy.core.service.system.UserOnlineService;
|
||||
import cn.odboy.core.service.system.UserService;
|
||||
@@ -18,9 +16,7 @@ import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.exception.EntityExistException;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -38,7 +34,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -52,31 +47,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
private final UserCacheService userCacheService;
|
||||
private final UserOnlineService userOnlineService;
|
||||
|
||||
@Override
|
||||
public PageResult<User> describeUserPage(QueryUserRequest criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<User> users = userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords();
|
||||
Long total = userMapper.getUserCountByArgs(criteria);
|
||||
return PageUtil.toPage(users, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> describeUserList(QueryUserRequest criteria) {
|
||||
return userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public User describeUserById(long id) {
|
||||
String key = SystemRedisKey.USER_ID + id;
|
||||
User user = redisHelper.get(key, User.class);
|
||||
if (user == null) {
|
||||
user = getById(id);
|
||||
redisHelper.set(key, user, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUser(User resources) {
|
||||
@@ -180,11 +150,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
userRoleMapper.deleteByUserIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User describeUserByUsername(String username) {
|
||||
return userMapper.getUserByUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyUserPasswordByUsername(String username, String pass) {
|
||||
|
||||
@@ -16,13 +16,6 @@ public interface EmailService extends IService<EmailConfig> {
|
||||
*/
|
||||
void modifyEmailConfigOnPassChange(EmailConfig emailConfig) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return EmailConfig 邮件配置
|
||||
*/
|
||||
EmailConfig describeEmailConfig();
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
|
||||
-21
@@ -1,9 +1,6 @@
|
||||
package cn.odboy.core.service.tools;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.tools.dto.QueryLocalStorageRequest;
|
||||
import cn.odboy.core.dal.dataobject.tools.LocalStorage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -12,24 +9,6 @@ import java.util.List;
|
||||
|
||||
|
||||
public interface LocalStorageService extends IService<LocalStorage> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<LocalStorage> describeLocalStoragePage(QueryLocalStorageRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<LocalStorage> describeLocalStorageList(QueryLocalStorageRequest criteria);
|
||||
|
||||
/**
|
||||
* 上传
|
||||
*
|
||||
|
||||
-7
@@ -6,13 +6,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface QiniuConfigService extends IService<QiniuConfig> {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
*
|
||||
* @return QiniuConfig
|
||||
*/
|
||||
QiniuConfig describeQiniuConfig();
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
|
||||
-21
@@ -1,9 +1,6 @@
|
||||
package cn.odboy.core.service.tools;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.tools.dto.QueryQiniuRequest;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuContent;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -12,24 +9,6 @@ import java.util.List;
|
||||
|
||||
|
||||
public interface QiniuContentService extends IService<QiniuContent> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QiniuContent> describeQiniuContentPage(QueryQiniuRequest criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QiniuContent> describeQiniuContentList(QueryQiniuRequest criteria);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
|
||||
+5
-12
@@ -2,18 +2,17 @@ package cn.odboy.core.service.tools.impl;
|
||||
|
||||
import cn.hutool.extra.mail.Mail;
|
||||
import cn.hutool.extra.mail.MailAccount;
|
||||
import cn.odboy.core.service.tools.dto.SendEmailRequest;
|
||||
import cn.odboy.core.api.tools.EmailApi;
|
||||
import cn.odboy.core.dal.dataobject.tools.EmailConfig;
|
||||
import cn.odboy.core.dal.mysql.tools.EmailConfigMapper;
|
||||
import cn.odboy.core.service.tools.CaptchaService;
|
||||
import cn.odboy.core.service.tools.EmailService;
|
||||
import cn.odboy.core.service.tools.dto.SendEmailRequest;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.DesEncryptUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -25,13 +24,13 @@ public class EmailServiceImpl extends ServiceImpl<EmailConfigMapper, EmailConfig
|
||||
@Autowired
|
||||
private EmailService emailService;
|
||||
@Autowired
|
||||
private CaptchaService captchaService;
|
||||
private EmailApi emailApi;
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyEmailConfigOnPassChange(EmailConfig emailConfig) throws Exception {
|
||||
EmailConfig localConfig = emailService.describeEmailConfig();
|
||||
EmailConfig localConfig = emailApi.describeEmailConfig();
|
||||
if (!emailConfig.getPassword().equals(localConfig.getPassword())) {
|
||||
// 对称加密
|
||||
emailConfig.setPassword(DesEncryptUtil.desEncrypt(emailConfig.getPassword()));
|
||||
@@ -40,17 +39,11 @@ public class EmailServiceImpl extends ServiceImpl<EmailConfigMapper, EmailConfig
|
||||
saveOrUpdate(emailConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public EmailConfig describeEmailConfig() {
|
||||
EmailConfig emailConfig = getById(1L);
|
||||
return emailConfig == null ? new EmailConfig() : emailConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendEmail(SendEmailRequest sendEmailRequest) {
|
||||
EmailConfig emailConfig = emailService.describeEmailConfig();
|
||||
EmailConfig emailConfig = emailApi.describeEmailConfig();
|
||||
if (emailConfig.getId() == null) {
|
||||
throw new BadRequestException("请先配置,再操作");
|
||||
}
|
||||
|
||||
+1
-15
@@ -1,17 +1,13 @@
|
||||
package cn.odboy.core.service.tools.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.service.tools.dto.QueryLocalStorageRequest;
|
||||
import cn.odboy.core.dal.dataobject.tools.LocalStorage;
|
||||
import cn.odboy.core.dal.mysql.tools.LocalStorageMapper;
|
||||
import cn.odboy.core.framework.properties.AppProperties;
|
||||
import cn.odboy.core.service.tools.LocalStorageService;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import cn.odboy.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -32,16 +28,6 @@ public class LocalStorageServiceImpl extends ServiceImpl<LocalStorageMapper, Loc
|
||||
private final LocalStorageMapper localStorageMapper;
|
||||
private final AppProperties properties;
|
||||
|
||||
@Override
|
||||
public PageResult<LocalStorage> describeLocalStoragePage(QueryLocalStorageRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(localStorageMapper.queryLocalStoragePageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorage> describeLocalStorageList(QueryLocalStorageRequest criteria) {
|
||||
return localStorageMapper.queryLocalStoragePageByArgs(criteria, PageUtil.getCount(localStorageMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LocalStorage uploadFile(String name, MultipartFile multipartFile) {
|
||||
|
||||
+1
-7
@@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -18,12 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class QiniuConfigServiceImpl extends ServiceImpl<QiniuConfigMapper, QiniuConfig> implements QiniuConfigService {
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public QiniuConfig describeQiniuConfig() {
|
||||
QiniuConfig qiniuConfig = getById(1L);
|
||||
return qiniuConfig == null ? new QiniuConfig() : qiniuConfig;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "'config'")
|
||||
|
||||
+6
-20
@@ -1,18 +1,14 @@
|
||||
package cn.odboy.core.service.tools.impl;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.core.service.tools.dto.QueryQiniuRequest;
|
||||
import cn.odboy.core.api.tools.QiniuConfigApi;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuConfig;
|
||||
import cn.odboy.core.dal.dataobject.tools.QiniuContent;
|
||||
import cn.odboy.core.dal.mysql.tools.QiniuContentMapper;
|
||||
import cn.odboy.core.service.tools.QiniuConfigService;
|
||||
import cn.odboy.core.service.tools.QiniuContentService;
|
||||
import cn.odboy.core.util.QiniuUtil;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qiniu.common.QiniuException;
|
||||
import com.qiniu.http.Response;
|
||||
@@ -40,26 +36,16 @@ import java.util.Map;
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, QiniuContent> implements QiniuContentService {
|
||||
private final QiniuContentMapper qiniuContentMapper;
|
||||
private final QiniuConfigService qiNiuConfigService;
|
||||
private final QiniuConfigApi qiniuConfigApi;
|
||||
|
||||
@Value("${app.oss.qiniu.max-size}")
|
||||
private Long maxSize;
|
||||
|
||||
@Override
|
||||
public PageResult<QiniuContent> describeQiniuContentPage(QueryQiniuRequest criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(qiniuContentMapper.queryQiniuContentPageByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QiniuContent> describeQiniuContentList(QueryQiniuRequest criteria) {
|
||||
return qiniuContentMapper.queryQiniuContentPageByArgs(criteria, PageUtil.getCount(qiniuContentMapper)).getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QiniuContent uploadFile(MultipartFile file) {
|
||||
FileUtil.checkSize(maxSize, file.getSize());
|
||||
QiniuConfig qiniuConfig = qiNiuConfigService.describeQiniuConfig();
|
||||
QiniuConfig qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
if (qiniuConfig.getId() == null) {
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
@@ -97,7 +83,7 @@ public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, Qin
|
||||
|
||||
@Override
|
||||
public String createFilePreviewUrl(QiniuContent content) {
|
||||
QiniuConfig qiniuConfig = qiNiuConfigService.describeQiniuConfig();
|
||||
QiniuConfig qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
String finalUrl;
|
||||
String type = "公开";
|
||||
if (type.equals(content.getType())) {
|
||||
@@ -114,7 +100,7 @@ public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, Qin
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeFileById(Long id) {
|
||||
QiniuConfig qiniuConfig = qiNiuConfigService.describeQiniuConfig();
|
||||
QiniuConfig qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
QiniuContent qiniuContent = qiniuContentMapper.selectById(id);
|
||||
if (qiniuContent == null) {
|
||||
throw new BadRequestException("文件不存在");
|
||||
@@ -135,7 +121,7 @@ public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, Qin
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void synchronize() {
|
||||
QiniuConfig qiniuConfig = qiNiuConfigService.describeQiniuConfig();
|
||||
QiniuConfig qiniuConfig = qiniuConfigApi.describeQiniuConfig();
|
||||
if (qiniuConfig.getId() == null) {
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
|
||||
@@ -184,21 +184,21 @@
|
||||
AND rm.menu_id = #{menuId}
|
||||
group by u.user_id
|
||||
</select>
|
||||
<select id="getCountByJobIds" resultType="int">
|
||||
<select id="getUserCountByJobIds" resultType="int">
|
||||
SELECT count(*) FROM sys_user u, sys_users_jobs j
|
||||
WHERE u.user_id = j.user_id AND j.job_id IN
|
||||
<foreach collection="jobIds" item="jobId" open="(" separator="," close=")">
|
||||
#{jobId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getCountByDeptIds" resultType="int">
|
||||
<select id="getUserCountByDeptIds" resultType="int">
|
||||
SELECT count(*) FROM sys_user u
|
||||
WHERE u.dept_id IN
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getCountByRoleIds" resultType="int">
|
||||
<select id="getUserCountByRoleIds" resultType="int">
|
||||
SELECT count(*) FROM sys_user u, sys_users_roles r
|
||||
WHERE u.user_id = r.user_id AND r.role_id in
|
||||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||||
|
||||
Reference in New Issue
Block a user