refactor(system): 重构系统模块的缓存键和数据对象配置
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.redis;
|
package cn.odboy.system.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关于缓存的Key集合
|
* 关于缓存的Key集合
|
||||||
+1
-1
@@ -21,6 +21,7 @@ import cn.odboy.system.dal.model.response.SystemAuthVo;
|
|||||||
import cn.odboy.system.service.SystemAuthService;
|
import cn.odboy.system.service.SystemAuthService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -28,7 +29,6 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权、根据token获取用户详细信息
|
* 授权、根据token获取用户详细信息
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/listMenuByPid")
|
@PostMapping(value = "/listMenuByPid")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
||||||
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid);
|
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid, false);
|
||||||
return ResponseEntity.ok(systemMenuTbs);
|
return ResponseEntity.ok(systemMenuTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,10 +20,10 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
+11
@@ -43,31 +43,42 @@ public class SystemUserTb extends KitBaseUserTimeTb {
|
|||||||
private Long deptId;
|
private Long deptId;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "用户名称")
|
@ApiModelProperty(value = "用户名称")
|
||||||
|
@TableField(value = "username")
|
||||||
private String username;
|
private String username;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "用户昵称")
|
@ApiModelProperty(value = "用户昵称")
|
||||||
|
@TableField(value = "nick_name")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
@Email
|
@Email
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "邮箱")
|
@ApiModelProperty(value = "邮箱")
|
||||||
|
@TableField(value = "email")
|
||||||
private String email;
|
private String email;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "电话号码")
|
@ApiModelProperty(value = "电话号码")
|
||||||
|
@TableField(value = "phone")
|
||||||
private String phone;
|
private String phone;
|
||||||
@ApiModelProperty(value = "用户性别")
|
@ApiModelProperty(value = "用户性别")
|
||||||
|
@TableField(value = "gender")
|
||||||
private String gender;
|
private String gender;
|
||||||
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
||||||
|
@TableField(value = "avatar_name")
|
||||||
private String avatarName;
|
private String avatarName;
|
||||||
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
||||||
|
@TableField(value = "avatar_path")
|
||||||
private String avatarPath;
|
private String avatarPath;
|
||||||
@ApiModelProperty(value = "密码")
|
@ApiModelProperty(value = "密码")
|
||||||
|
@TableField(value = "password")
|
||||||
private String password;
|
private String password;
|
||||||
@NotNull
|
@NotNull
|
||||||
@ApiModelProperty(value = "是否启用")
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
@TableField(value = "enabled")
|
||||||
private Boolean enabled;
|
private Boolean enabled;
|
||||||
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
||||||
|
@TableField(value = "is_admin")
|
||||||
private Boolean isAdmin = false;
|
private Boolean isAdmin = false;
|
||||||
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
||||||
|
@TableField(value = "pwd_reset_time")
|
||||||
private Date pwdResetTime;
|
private Date pwdResetTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-69
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.dal.redis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关于缓存的Key集合
|
|
||||||
*/
|
|
||||||
public interface SystemRedisKey {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*/
|
|
||||||
String USER_ID = "user::id:";
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
String DATA_USER = "data::user:";
|
|
||||||
/**
|
|
||||||
* 菜单
|
|
||||||
*/
|
|
||||||
String MENU_ID = "menu::id:";
|
|
||||||
String MENU_USER = "menu::user:";
|
|
||||||
/**
|
|
||||||
* 角色授权
|
|
||||||
*/
|
|
||||||
String ROLE_AUTH = "role::auth:";
|
|
||||||
String ROLE_USER = "role::user:";
|
|
||||||
/**
|
|
||||||
* 角色信息
|
|
||||||
*/
|
|
||||||
String ROLE_ID = "role::id:";
|
|
||||||
/**
|
|
||||||
* 部门
|
|
||||||
*/
|
|
||||||
String DEPT_ID = "dept::id:";
|
|
||||||
/**
|
|
||||||
* 岗位
|
|
||||||
*/
|
|
||||||
String JOB_ID = "job::id:";
|
|
||||||
/**
|
|
||||||
* 数据字典
|
|
||||||
*/
|
|
||||||
String DICT_NAME = "dict::name:";
|
|
||||||
/**
|
|
||||||
* 在线用户
|
|
||||||
*/
|
|
||||||
String ONLINE_USER = "online::token:";
|
|
||||||
/**
|
|
||||||
* 登录验证码
|
|
||||||
*/
|
|
||||||
String CAPTCHA_LOGIN = "captcha::login:";
|
|
||||||
/**
|
|
||||||
* 用户信息
|
|
||||||
*/
|
|
||||||
String USER_INFO = "user::info:";
|
|
||||||
}
|
|
||||||
+4
-3
@@ -18,6 +18,7 @@ package cn.odboy.system.dal.redis;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@@ -42,7 +43,7 @@ public class SystemUserInfoDAO {
|
|||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 添加数据, 避免数据同时过期(2小时左右)
|
// 添加数据, 避免数据同时过期(2小时左右)
|
||||||
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
||||||
redisHelper.set(SystemRedisKey.USER_INFO + userName, user, time);
|
redisHelper.set(SystemCacheKey.ONLINE_USER + userName, user, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class SystemUserInfoDAO {
|
|||||||
public void deleteUserLoginInfoByUserName(String userName) {
|
public void deleteUserLoginInfoByUserName(String userName) {
|
||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 清除数据
|
// 清除数据
|
||||||
redisHelper.del(SystemRedisKey.USER_INFO + userName);
|
redisHelper.del(SystemCacheKey.ONLINE_USER + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class SystemUserInfoDAO {
|
|||||||
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
||||||
if (StrUtil.isNotEmpty(username)) {
|
if (StrUtil.isNotEmpty(username)) {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
return redisHelper.get(SystemRedisKey.USER_INFO + username, SystemUserJwtVo.class);
|
return redisHelper.get(SystemCacheKey.ONLINE_USER + username, SystemUserJwtVo.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -19,6 +19,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo;
|
import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserOnlineVo;
|
import cn.odboy.system.dal.model.response.SystemUserOnlineVo;
|
||||||
@@ -122,7 +123,7 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @param username /
|
* @param username /
|
||||||
*/
|
*/
|
||||||
public void kickOutByUsername(String username) {
|
public void kickOutByUsername(String username) {
|
||||||
String loginKey = SystemRedisKey.ONLINE_USER + username + "*";
|
String loginKey = SystemCacheKey.ONLINE_USER + username + "*";
|
||||||
redisHelper.scanDel(loginKey);
|
redisHelper.scanDel(loginKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,15 +134,13 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @param pageable /
|
* @param pageable /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo,
|
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo, IPage<SystemUserOnlineVo> pageable) {
|
||||||
IPage<SystemUserOnlineVo> pageable) {
|
|
||||||
String username = null;
|
String username = null;
|
||||||
if (onlineVo != null) {
|
if (onlineVo != null) {
|
||||||
username = onlineVo.getUserName();
|
username = onlineVo.getUserName();
|
||||||
}
|
}
|
||||||
List<SystemUserOnlineVo> onlineUserList = queryUserOnlineModelListByUsername(username);
|
List<SystemUserOnlineVo> onlineUserList = this.queryUserOnlineModelListByUsername(username);
|
||||||
List<SystemUserOnlineVo> paging =
|
List<SystemUserOnlineVo> paging = KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
||||||
KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
|
||||||
return KitPageUtil.toPage(paging, onlineUserList.size());
|
return KitPageUtil.toPage(paging, onlineUserList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +151,7 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
||||||
String loginKey = SystemRedisKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
String loginKey = SystemCacheKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
||||||
List<String> keys = redisHelper.scan(loginKey + "*");
|
List<String> keys = redisHelper.scan(loginKey + "*");
|
||||||
Collections.reverse(keys);
|
Collections.reverse(keys);
|
||||||
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import cn.odboy.constant.SystemConst;
|
|||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import cn.odboy.system.dal.redis.SystemCacheKey;
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.JwtParser;
|
import io.jsonwebtoken.JwtParser;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
|
|||||||
+1
-1
@@ -22,8 +22,8 @@ import cn.odboy.constant.SystemConst;
|
|||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.response.SystemCaptchaVo;
|
import cn.odboy.system.dal.model.response.SystemCaptchaVo;
|
||||||
import cn.odboy.system.dal.redis.SystemCacheKey;
|
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
+230
-159
@@ -99,16 +99,6 @@ public class SystemDeptService {
|
|||||||
this.updateDeptSubCnt(newPid);
|
this.updateDeptSubCnt(newPid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门id查询部门信息 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param id 部门id
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private SystemDeptTb getDeptById(Long id) {
|
|
||||||
return systemDeptMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*
|
*
|
||||||
@@ -139,43 +129,6 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countDeptByPid(Long pid) {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemDeptTb::getPid, pid);
|
|
||||||
return systemDeptMapper.selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
|
||||||
*/
|
|
||||||
private List<SystemDeptTb> deduplication(List<SystemDeptTb> list) {
|
|
||||||
List<SystemDeptTb> deptList = new ArrayList<>();
|
|
||||||
// 使用 Set 存储所有部门的 id
|
|
||||||
Set<Long> idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
|
||||||
// 遍历部门列表, 筛选出没有父部门的部门
|
|
||||||
for (SystemDeptTb dept : list) {
|
|
||||||
if (!idSet.contains(dept.getPid())) {
|
|
||||||
deptList.add(dept);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return deptList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
|
|
||||||
KitValidUtil.notNull(args);
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
|
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName());
|
|
||||||
wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled());
|
|
||||||
wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid());
|
|
||||||
wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid);
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemDeptTb::getDeptSort);
|
|
||||||
return systemDeptMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据
|
* 查询所有数据
|
||||||
*
|
*
|
||||||
@@ -213,7 +166,7 @@ public class SystemDeptService {
|
|||||||
List<SystemDeptTb> list = this.queryDeptByArgs(args);
|
List<SystemDeptTb> list = this.queryDeptByArgs(args);
|
||||||
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
||||||
if (StrUtil.isBlank(dataScopeType)) {
|
if (StrUtil.isBlank(dataScopeType)) {
|
||||||
return this.deduplication(list);
|
return this.filterRootDeptList(list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -229,25 +182,11 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门下所有关联的部门
|
* 根据部门id遍历所有部门和子部门id集合
|
||||||
*
|
*
|
||||||
* @param deptTbList /
|
* @param deptList 部门集合
|
||||||
* @param depts /
|
* @param deptPidMap 父部门id和子部门集合的映射关系
|
||||||
*/
|
*/
|
||||||
private void queryRelationDeptByArgs(List<SystemDeptVo> deptTbList, Set<SystemDeptVo> depts) {
|
|
||||||
for (SystemDeptVo dept : deptTbList) {
|
|
||||||
depts.add(dept);
|
|
||||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(dept.getId());
|
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
|
||||||
queryRelationDeptByArgs(deptList, depts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemDeptVo> listDeptVoByPid(Long pid) {
|
|
||||||
return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Long> queryChildDeptIdByDeptIds(List<SystemDeptTb> deptList, Map<Long, List<SystemDeptTb>> deptPidMap) {
|
public List<Long> queryChildDeptIdByDeptIds(List<SystemDeptTb> deptList, Map<Long, List<SystemDeptTb>> deptPidMap) {
|
||||||
List<Long> list = new ArrayList<>();
|
List<Long> list = new ArrayList<>();
|
||||||
for (SystemDeptTb systemDeptTb : deptList) {
|
for (SystemDeptTb systemDeptTb : deptList) {
|
||||||
@@ -262,28 +201,6 @@ public class SystemDeptService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID查询同级与上级数据
|
|
||||||
*
|
|
||||||
* @param dept /
|
|
||||||
* @param deptList /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private List<SystemDeptVo> querySuperiorDeptByPid(SystemDeptVo dept, List<SystemDeptVo> deptList) {
|
|
||||||
if (dept.getPid() == null) {
|
|
||||||
deptList.addAll(this.listRootDept());
|
|
||||||
return deptList;
|
|
||||||
}
|
|
||||||
deptList.addAll(this.listDeptVoByPid(dept.getPid()));
|
|
||||||
return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemDeptVo> listRootDept() {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(SystemDeptTb::getPid);
|
|
||||||
return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建树形数据
|
* 构建树形数据
|
||||||
*
|
*
|
||||||
@@ -357,16 +274,10 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemDeptTb> listEnabledDepts() {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
|
||||||
return systemDeptMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 遍历所有部门和子部门
|
* 根据部门id遍历所有部门和子部门
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids 部门id集合
|
||||||
*/
|
*/
|
||||||
public Set<SystemDeptVo> traverseDeptByIdWithPids(Set<Long> ids) {
|
public Set<SystemDeptVo> traverseDeptByIdWithPids(Set<Long> ids) {
|
||||||
Set<SystemDeptVo> depts = new HashSet<>();
|
Set<SystemDeptVo> depts = new HashSet<>();
|
||||||
@@ -376,61 +287,27 @@ public class SystemDeptService {
|
|||||||
// 子部门
|
// 子部门
|
||||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(id);
|
List<SystemDeptVo> deptList = this.listDeptVoByPid(id);
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
queryRelationDeptByArgs(deptList, depts);
|
this.queryRelationDeptByArgs(deptList, depts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public List<SystemProductLineVo> listDeptSelectDataSource() {
|
public List<SystemProductLineVo> listDeptSelectDataSource() {
|
||||||
List<SystemDeptTb> depts = this.listEnabledDepts();
|
List<SystemDeptTb> depts = this.listEnabledDepts();
|
||||||
return buildDeptSelectOptions(depts);
|
return this.buildDeptSelectOptions(depts);
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemProductLineVo> buildDeptSelectOptions(List<SystemDeptTb> depts) {
|
|
||||||
// 查询所有部门并按父子关系组织
|
|
||||||
Map<Long, SystemDeptTb> deptMap =
|
|
||||||
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
|
||||||
List<SystemProductLineVo> options = new ArrayList<>();
|
|
||||||
for (SystemDeptTb dept : depts) {
|
|
||||||
// 构建部门ID路径
|
|
||||||
List<Long> pathIds = new ArrayList<>();
|
|
||||||
buildDeptIdPath(dept, deptMap, pathIds);
|
|
||||||
// 反转路径,从顶级部门到当前部门
|
|
||||||
Collections.reverse(pathIds);
|
|
||||||
SystemProductLineVo dto = new SystemProductLineVo();
|
|
||||||
dto.setValue(dept.getId());
|
|
||||||
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
|
||||||
// 保留名称路径用于显示
|
|
||||||
dto.setLabel(buildNamePath(dept, deptMap));
|
|
||||||
options.add(dto);
|
|
||||||
}
|
|
||||||
// 按部门名称路径排序
|
|
||||||
options.sort(Comparator.comparing(SystemProductLineVo::getLabel));
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
|
||||||
pathIds.add(dept.getId());
|
|
||||||
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
|
||||||
buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
|
||||||
List<String> pathNames = new ArrayList<>();
|
|
||||||
buildDeptNamePath(dept, deptMap, pathNames);
|
|
||||||
Collections.reverse(pathNames);
|
|
||||||
return String.join(" / ", pathNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
|
||||||
pathNames.add(dept.getName());
|
|
||||||
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
|
||||||
buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件Pro版 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public List<SystemProductLineTreeVo> listDeptSelectProDataSource() {
|
public List<SystemProductLineTreeVo> listDeptSelectProDataSource() {
|
||||||
List<SystemDeptTb> depts = this.listEnabledDepts();
|
List<SystemDeptTb> depts = this.listEnabledDepts();
|
||||||
// 查询所有部门并按父子关系组织
|
// 查询所有部门并按父子关系组织
|
||||||
@@ -441,7 +318,7 @@ public class SystemDeptService {
|
|||||||
for (SystemDeptTb dept : depts) {
|
for (SystemDeptTb dept : depts) {
|
||||||
// 只处理顶级部门(pid为null或0的部门)
|
// 只处理顶级部门(pid为null或0的部门)
|
||||||
if (dept.getPid() == null || dept.getPid() == 0) {
|
if (dept.getPid() == null || dept.getPid() == 0) {
|
||||||
SystemProductLineTreeVo vo = buildDeptTreePro(dept, deptMap);
|
SystemProductLineTreeVo vo = this.buildDeptTreePro(dept, deptMap);
|
||||||
options.add(vo);
|
options.add(vo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,6 +330,49 @@ public class SystemDeptService {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父部门id查询部门集合
|
||||||
|
*
|
||||||
|
* @param pid 父部门id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> listDeptByPid(long pid) {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getPid, pid);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出部门数据
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args /
|
||||||
|
*/
|
||||||
|
public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
|
||||||
|
List<SystemDeptTb> systemDeptTbs = this.queryAllDeptByArgs(args, false);
|
||||||
|
List<SystemDeptExportRowVo> rowVos = new ArrayList<>();
|
||||||
|
for (SystemDeptTb dataObject : systemDeptTbs) {
|
||||||
|
SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo();
|
||||||
|
rowVo.setName(dataObject.getName());
|
||||||
|
rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR);
|
||||||
|
rowVo.setCreateTime(dataObject.getCreateTime());
|
||||||
|
rowVos.add(rowVo);
|
||||||
|
}
|
||||||
|
KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询父部门非空且启用的部门数据
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> listPidNonNull() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
|
wrapper.isNotNull(SystemDeptTb::getPid);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归构建部门树
|
* 递归构建部门树
|
||||||
*
|
*
|
||||||
@@ -468,7 +388,7 @@ public class SystemDeptService {
|
|||||||
List<SystemProductLineTreeVo> children = new ArrayList<>();
|
List<SystemProductLineTreeVo> children = new ArrayList<>();
|
||||||
for (SystemDeptTb childDept : deptMap.values()) {
|
for (SystemDeptTb childDept : deptMap.values()) {
|
||||||
if (dept.getId().equals(childDept.getPid())) {
|
if (dept.getId().equals(childDept.getPid())) {
|
||||||
children.add(buildDeptTreePro(childDept, deptMap));
|
children.add(this.buildDeptTreePro(childDept, deptMap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 子部门按排序字段排序
|
// 子部门按排序字段排序
|
||||||
@@ -480,29 +400,180 @@ public class SystemDeptService {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDeptTb> listDeptByPid(long pid) {
|
/**
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
* 产品线选择组件使用
|
||||||
wrapper.eq(SystemDeptTb::getPid, pid);
|
*
|
||||||
return systemDeptMapper.selectList(wrapper);
|
* @param depts 部门集合
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemProductLineVo> buildDeptSelectOptions(List<SystemDeptTb> depts) {
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<SystemProductLineVo> options = new ArrayList<>();
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 构建部门ID路径
|
||||||
|
List<Long> pathIds = new ArrayList<>();
|
||||||
|
this.buildDeptIdPath(dept, deptMap, pathIds);
|
||||||
|
// 反转路径,从顶级部门到当前部门
|
||||||
|
Collections.reverse(pathIds);
|
||||||
|
SystemProductLineVo dto = new SystemProductLineVo();
|
||||||
|
dto.setValue(dept.getId());
|
||||||
|
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
||||||
|
// 保留名称路径用于显示
|
||||||
|
dto.setLabel(this.buildNamePath(dept, deptMap));
|
||||||
|
options.add(dto);
|
||||||
|
}
|
||||||
|
// 按部门名称路径排序
|
||||||
|
options.sort(Comparator.comparing(SystemProductLineVo::getLabel));
|
||||||
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
|
/**
|
||||||
List<SystemDeptTb> systemDeptTbs = this.queryAllDeptByArgs(args, false);
|
* 产品线选择组件使用
|
||||||
List<SystemDeptExportRowVo> rowVos = new ArrayList<>();
|
*/
|
||||||
for (SystemDeptTb dataObject : systemDeptTbs) {
|
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
||||||
SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo();
|
pathIds.add(dept.getId());
|
||||||
rowVo.setName(dataObject.getName());
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR);
|
this.buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
||||||
rowVo.setCreateTime(dataObject.getCreateTime());
|
|
||||||
rowVos.add(rowVo);
|
|
||||||
}
|
}
|
||||||
KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemDeptTb> listPidNonNull() {
|
/**
|
||||||
|
* 产品线选择组件使用
|
||||||
|
*/
|
||||||
|
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
List<String> pathNames = new ArrayList<>();
|
||||||
|
this.buildDeptNamePath(dept, deptMap, pathNames);
|
||||||
|
Collections.reverse(pathNames);
|
||||||
|
return String.join(" / ", pathNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件使用
|
||||||
|
*/
|
||||||
|
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
||||||
|
pathNames.add(dept.getName());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询启用的所有部门集合
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemDeptTb> listEnabledDepts() {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
wrapper.isNotNull(SystemDeptTb::getPid);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询部门下所有关联的部门
|
||||||
|
*
|
||||||
|
* @param deptTbList /
|
||||||
|
* @param depts /
|
||||||
|
*/
|
||||||
|
private void queryRelationDeptByArgs(List<SystemDeptVo> deptTbList, Set<SystemDeptVo> depts) {
|
||||||
|
for (SystemDeptVo dept : deptTbList) {
|
||||||
|
depts.add(dept);
|
||||||
|
List<SystemDeptVo> deptList = this.listDeptVoByPid(dept.getId());
|
||||||
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
|
this.queryRelationDeptByArgs(deptList, depts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SystemDeptVo> listDeptVoByPid(Long pid) {
|
||||||
|
return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询同级与上级数据
|
||||||
|
*
|
||||||
|
* @param dept /
|
||||||
|
* @param deptList /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemDeptVo> querySuperiorDeptByPid(SystemDeptVo dept, List<SystemDeptVo> deptList) {
|
||||||
|
if (dept.getPid() == null) {
|
||||||
|
deptList.addAll(this.listRootDept());
|
||||||
|
return deptList;
|
||||||
|
}
|
||||||
|
deptList.addAll(this.listDeptVoByPid(dept.getPid()));
|
||||||
|
return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有根部门
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemDeptVo> listRootDept() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(SystemDeptTb::getPid);
|
||||||
|
return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门id查询部门信息 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param id 部门id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private SystemDeptTb getDeptById(Long id) {
|
||||||
|
return systemDeptMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父部门id统计数量
|
||||||
|
*
|
||||||
|
* @param pid 父部门id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private long countDeptByPid(Long pid) {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getPid, pid);
|
||||||
|
return systemDeptMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
||||||
|
*/
|
||||||
|
private List<SystemDeptTb> filterRootDeptList(List<SystemDeptTb> list) {
|
||||||
|
List<SystemDeptTb> deptList = new ArrayList<>();
|
||||||
|
// 使用 Set 存储所有部门的 id
|
||||||
|
Set<Long> idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
|
// 遍历部门列表, 筛选出没有父部门的部门
|
||||||
|
for (SystemDeptTb dept : list) {
|
||||||
|
if (!idSet.contains(dept.getPid())) {
|
||||||
|
deptList.add(dept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deptList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据复杂条件查询部门集合
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
|
||||||
|
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName());
|
||||||
|
wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled());
|
||||||
|
wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid());
|
||||||
|
wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid);
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemDeptTb::getDeptSort);
|
||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -84,6 +84,11 @@ public class SystemDictDetailService {
|
|||||||
systemDictDetailMapper.deleteById(id);
|
systemDictDetailMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典id集合删除字典明细
|
||||||
|
*
|
||||||
|
* @param ids 字典id集合
|
||||||
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteDictDetailByDictIds(Set<Long> ids) {
|
public void deleteDictDetailByDictIds(Set<Long> ids) {
|
||||||
if (CollUtil.isNotEmpty(ids)) {
|
if (CollUtil.isNotEmpty(ids)) {
|
||||||
@@ -100,8 +105,10 @@ public class SystemDictDetailService {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDictDetailVo> searchDictDetail(SystemQueryDictDetailArgs args,
|
public KitPageResult<SystemDictDetailVo> searchDictDetail(
|
||||||
Page<SystemDictDetailTb> page) {
|
SystemQueryDictDetailArgs args,
|
||||||
|
Page<SystemDictDetailTb> page
|
||||||
|
) {
|
||||||
IPage<SystemDictDetailVo> iPage = systemDictDetailMapper.selectPageByArgs(page, args);
|
IPage<SystemDictDetailVo> iPage = systemDictDetailMapper.selectPageByArgs(page, args);
|
||||||
List<Long> dictIds =
|
List<Long> dictIds =
|
||||||
iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList());
|
iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList());
|
||||||
|
|||||||
+25
-7
@@ -96,19 +96,24 @@ public class SystemDictService {
|
|||||||
return KitPageUtil.toPage(selectPage);
|
return KitPageUtil.toPage(selectPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
/**
|
||||||
if (args != null) {
|
* 复杂条件查询字典列表
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
*
|
||||||
.like(SystemDictTb::getDescription, args.getBlurry()));
|
* @param args /
|
||||||
}
|
* @return /
|
||||||
}
|
*/
|
||||||
|
|
||||||
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
||||||
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
this.injectQueryParams(args, wrapper);
|
this.injectQueryParams(args, wrapper);
|
||||||
return systemDictMapper.selectList(wrapper);
|
return systemDictMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字典数据
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args /
|
||||||
|
*/
|
||||||
public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) {
|
public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) {
|
||||||
List<SystemDictTb> systemDictTbs = this.queryDictByArgs(args);
|
List<SystemDictTb> systemDictTbs = this.queryDictByArgs(args);
|
||||||
List<SystemDictExportRowVo> rowVos = new ArrayList<>();
|
List<SystemDictExportRowVo> rowVos = new ArrayList<>();
|
||||||
@@ -136,4 +141,17 @@ public class SystemDictService {
|
|||||||
}
|
}
|
||||||
KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
||||||
|
.like(SystemDictTb::getDescription, args.getBlurry()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-13
@@ -108,19 +108,6 @@ public class SystemEmailService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验邮箱验证码 -> TestPassed
|
|
||||||
*/
|
|
||||||
public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) {
|
|
||||||
String redisKey = biEnum.getRedisKey() + email;
|
|
||||||
String value = redisHelper.get(redisKey, String.class);
|
|
||||||
if (value == null || !value.equals(code)) {
|
|
||||||
throw new BadRequestException("无效验证码");
|
|
||||||
} else {
|
|
||||||
redisHelper.del(redisKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送给邮箱验证码
|
* 发送给邮箱验证码
|
||||||
*/
|
*/
|
||||||
@@ -148,11 +135,19 @@ public class SystemEmailService {
|
|||||||
sendEmail(sendEmailRequest);
|
sendEmail(sendEmailRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮箱配置
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemEmailConfigTb getLastEmailConfig() {
|
public SystemEmailConfigTb getLastEmailConfig() {
|
||||||
SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L);
|
SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L);
|
||||||
return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb;
|
return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验邮箱验证码 -> TestPassed
|
||||||
|
*/
|
||||||
public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) {
|
public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) {
|
||||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
||||||
if (biEnum == null) {
|
if (biEnum == null) {
|
||||||
@@ -160,4 +155,14 @@ public class SystemEmailService {
|
|||||||
}
|
}
|
||||||
this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode());
|
this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) {
|
||||||
|
String redisKey = biEnum.getRedisKey() + email;
|
||||||
|
String value = redisHelper.get(redisKey, String.class);
|
||||||
|
if (value == null || !value.equals(code)) {
|
||||||
|
throw new BadRequestException("无效验证码");
|
||||||
|
} else {
|
||||||
|
redisHelper.del(redisKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-16
@@ -119,6 +119,22 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出岗位数据 -> TestPassed
|
||||||
|
*/
|
||||||
|
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
|
||||||
|
List<SystemJobTb> systemJobTbs = this.queryJobByArgs(args);
|
||||||
|
List<SystemJobExportRowVo> rowVos = new ArrayList<>();
|
||||||
|
for (SystemJobTb dataObject : systemJobTbs) {
|
||||||
|
SystemJobExportRowVo rowVo = new SystemJobExportRowVo();
|
||||||
|
rowVo.setName(dataObject.getName());
|
||||||
|
rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用");
|
||||||
|
rowVo.setCreateTime(dataObject.getCreateTime());
|
||||||
|
rowVos.add(rowVo);
|
||||||
|
}
|
||||||
|
KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位名称查询岗位是否存在 -> TestPassed
|
* 根据岗位名称查询岗位是否存在 -> TestPassed
|
||||||
*/
|
*/
|
||||||
@@ -138,6 +154,12 @@ public class SystemJobService {
|
|||||||
return systemJobMapper.exists(wrapper);
|
return systemJobMapper.exists(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
|
private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
|
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
|
||||||
@@ -148,20 +170,4 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
|
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出岗位数据 -> TestPassed
|
|
||||||
*/
|
|
||||||
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
|
|
||||||
List<SystemJobTb> systemJobTbs = this.queryJobByArgs(args);
|
|
||||||
List<SystemJobExportRowVo> rowVos = new ArrayList<>();
|
|
||||||
for (SystemJobTb dataObject : systemJobTbs) {
|
|
||||||
SystemJobExportRowVo rowVo = new SystemJobExportRowVo();
|
|
||||||
rowVo.setName(dataObject.getName());
|
|
||||||
rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用");
|
|
||||||
rowVo.setCreateTime(dataObject.getCreateTime());
|
|
||||||
rowVos.add(rowVo);
|
|
||||||
}
|
|
||||||
KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-17
@@ -133,29 +133,13 @@ public class SystemLocalStorageService {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemLocalStorageTb> searchLocalStorage(SystemQueryStorageArgs args,
|
public KitPageResult<SystemLocalStorageTb> searchLocalStorage(SystemQueryStorageArgs args, Page<SystemLocalStorageTb> page) {
|
||||||
Page<SystemLocalStorageTb> page) {
|
|
||||||
LambdaQueryWrapper<SystemLocalStorageTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemLocalStorageTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
this.injectQueryParams(args, wrapper);
|
this.injectQueryParams(args, wrapper);
|
||||||
Page<SystemLocalStorageTb> selectPage = systemLocalStorageMapper.selectPage(page, wrapper);
|
Page<SystemLocalStorageTb> selectPage = systemLocalStorageMapper.selectPage(page, wrapper);
|
||||||
return KitPageUtil.toPage(selectPage);
|
return KitPageUtil.toPage(selectPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
|
|
||||||
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
|
|
||||||
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
|
|
||||||
.like(SystemLocalStorageTb::getType, args.getBlurry()).or()
|
|
||||||
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
|
||||||
args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemLocalStorageTb::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文件上传记录 -> TestPassed
|
* 查询文件上传记录 -> TestPassed
|
||||||
*/
|
*/
|
||||||
@@ -186,4 +170,28 @@ public class SystemLocalStorageService {
|
|||||||
List<SystemLocalStorageExportRowVo> rowVos = KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class);
|
List<SystemLocalStorageExportRowVo> rowVos = KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class);
|
||||||
KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.and(
|
||||||
|
StrUtil.isNotBlank(args.getBlurry()),
|
||||||
|
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
|
||||||
|
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
|
||||||
|
.like(SystemLocalStorageTb::getType, args.getBlurry()).or()
|
||||||
|
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry())
|
||||||
|
);
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
||||||
|
args.getCreateTime().get(1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemLocalStorageTb::getId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+182
-178
@@ -95,56 +95,6 @@ public class SystemMenuService {
|
|||||||
this.updateMenuSubCnt(args.getPid());
|
this.updateMenuSubCnt(args.getPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据组件名称查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param componentName 组件名称
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithComponentName(String componentName) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据组件名称查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param componentName 组件名称
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithComponentNameNeSelf(String componentName, Long currentMenuId) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
|
||||||
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param title 菜单标题
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithTitle(String title) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getTitle, title);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param title 菜单标题
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithTitleNeSelf(String title, Long currentMenuId) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getTitle, title);
|
|
||||||
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -222,7 +172,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
// 查询所有菜单数据
|
// 查询所有菜单数据
|
||||||
List<SystemMenuTb> allMenus = systemMenuMapper.listAll();
|
List<SystemMenuTb> allMenus = systemMenuMapper.listAll();
|
||||||
// 根据ID集合获取当前菜单和其子菜单
|
// 根据ID集合查询当前菜单和其子菜单
|
||||||
Set<Long> allMenuIds = this.getAllMenuIdsWithChildren(ids, allMenus);
|
Set<Long> allMenuIds = this.getAllMenuIdsWithChildren(ids, allMenus);
|
||||||
if (CollUtil.isNotEmpty(allMenuIds)) {
|
if (CollUtil.isNotEmpty(allMenuIds)) {
|
||||||
// 删除角色菜单关联
|
// 删除角色菜单关联
|
||||||
@@ -234,60 +184,6 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 从所有菜单中找出指定ID及其子菜单ID
|
|
||||||
*
|
|
||||||
* @param rootIds 要删除的根菜单ID集合
|
|
||||||
* @param allMenus 所有菜单数据
|
|
||||||
* @return 包含根菜单及其所有子菜单的ID集合
|
|
||||||
*/
|
|
||||||
private Set<Long> getAllMenuIdsWithChildren(Set<Long> rootIds, List<SystemMenuTb> allMenus) {
|
|
||||||
Set<Long> result = new HashSet<>(rootIds);
|
|
||||||
Set<Long> currentLevelIds = new HashSet<>(rootIds);
|
|
||||||
// 构建父ID到子菜单的映射
|
|
||||||
Map<Long, List<SystemMenuTb>> parentToChildrenMap = allMenus.stream().filter(menu -> menu.getPid() != null)
|
|
||||||
.collect(Collectors.groupingBy(SystemMenuTb::getPid));
|
|
||||||
while (!currentLevelIds.isEmpty()) {
|
|
||||||
Set<Long> nextLevelIds = new HashSet<>();
|
|
||||||
// 对于当前层级的每个菜单ID,查找其子菜单
|
|
||||||
for (Long parentId : currentLevelIds) {
|
|
||||||
List<SystemMenuTb> children = parentToChildrenMap.get(parentId);
|
|
||||||
if (children != null && !children.isEmpty()) {
|
|
||||||
for (SystemMenuTb child : children) {
|
|
||||||
if (result.add(child.getId())) { // 如果成功添加(之前不存在),则继续查找其子菜单
|
|
||||||
nextLevelIds.add(child.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentLevelIds = nextLevelIds;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新被删除菜单的父菜单子节点计数
|
|
||||||
*/
|
|
||||||
private void updateParentMenuCounts(Set<Long> deletedMenuIds, List<SystemMenuTb> allMenus) {
|
|
||||||
// 获取被删除菜单的父ID
|
|
||||||
Set<Long> parentIds =
|
|
||||||
allMenus.stream().filter(menu -> deletedMenuIds.contains(menu.getId()) && menu.getPid() != null)
|
|
||||||
.map(SystemMenuTb::getPid).collect(Collectors.toSet());
|
|
||||||
// 更新每个父菜单的子节点计数
|
|
||||||
for (Long parentId : parentIds) {
|
|
||||||
proxyService.updateMenuSubCnt(parentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单id查询目录 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param id 菜单id
|
|
||||||
*/
|
|
||||||
private SystemMenuTb getMenuById(Long id) {
|
|
||||||
return systemMenuMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateMenuSubCnt(Long menuId) {
|
public void updateMenuSubCnt(Long menuId) {
|
||||||
if (menuId != null) {
|
if (menuId != null) {
|
||||||
@@ -341,35 +237,21 @@ public class SystemMenuService {
|
|||||||
return systemRoleMenuService.listMenuByRoleIds(roleIds, false);
|
return systemRoleMenuService.listMenuByRoleIds(roleIds, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 查询所有子节点, 包含自身ID
|
|
||||||
// *
|
|
||||||
// * @param menuList /
|
|
||||||
// * @param menuSet /
|
|
||||||
// * @return /
|
|
||||||
// */
|
|
||||||
// public Set<SystemMenuTb> queryChildMenuByArgs(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
|
||||||
// for (SystemMenuTb menu : menuList) {
|
|
||||||
// menuSet.add(menu);
|
|
||||||
// List<SystemMenuTb> menus = this.listMenuByPid(menu.getId());
|
|
||||||
// if (CollUtil.isNotEmpty(menus)) {
|
|
||||||
// queryChildMenuByArgs(menus, menuSet);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return menuSet;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 懒加载菜单数据
|
* 懒加载菜单数据
|
||||||
*
|
*
|
||||||
* @param pid /
|
* @param pid /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemMenuTb> listMenuByPid(Long pid) {
|
public List<SystemMenuTb> listMenuByPid(Long pid, boolean includeButton) {
|
||||||
List<SystemMenuTb> menus;
|
List<SystemMenuTb> menus;
|
||||||
if (pid != null && !pid.equals(0L)) {
|
if (pid != null && !pid.equals(0L)) {
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
if (!includeButton) {
|
||||||
|
// 是否剔除按钮
|
||||||
|
wrapper.ne(SystemMenuTb::getType, 2);
|
||||||
|
}
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
return systemMenuMapper.selectList(wrapper);
|
return systemMenuMapper.selectList(wrapper);
|
||||||
} else {
|
} else {
|
||||||
@@ -390,7 +272,7 @@ public class SystemMenuService {
|
|||||||
menus.addAll(this.listRootMenu());
|
menus.addAll(this.listRootMenu());
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
menus.addAll(this.listMenuByPid(menu.getPid()));
|
menus.addAll(this.listMenuByPid(menu.getPid(), true));
|
||||||
return querySuperiorMenuByArgs(this.getMenuById(menu.getPid()), menus);
|
return querySuperiorMenuByArgs(this.getMenuById(menu.getPid()), menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,62 +355,10 @@ public class SystemMenuService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询 MenuResponse
|
|
||||||
*
|
|
||||||
* @param menu /
|
|
||||||
* @param menuVo /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) {
|
|
||||||
SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo();
|
|
||||||
menuVo1.setMeta(menuVo.getMeta());
|
|
||||||
// 非外链
|
|
||||||
if (!menu.getIFrame()) {
|
|
||||||
menuVo1.setPath("index");
|
|
||||||
menuVo1.setName(menuVo.getName());
|
|
||||||
menuVo1.setComponent(menuVo.getComponent());
|
|
||||||
} else {
|
|
||||||
menuVo1.setPath(menu.getPath());
|
|
||||||
}
|
|
||||||
return menuVo1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SystemMenuTb> listMenuByIds(List<Long> ids) {
|
public List<SystemMenuTb> listMenuByIds(List<Long> ids) {
|
||||||
return systemMenuMapper.selectByIds(ids);
|
return systemMenuMapper.selectByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long countMenuByPid(Long pid) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
|
||||||
return systemMenuMapper.selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
|
|
||||||
KitValidUtil.notNull(args);
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
|
|
||||||
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
|
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or()
|
|
||||||
.like(SystemMenuTb::getComponentName, args.getBlurry()).or()
|
|
||||||
.like(SystemMenuTb::getPermission, args.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return systemMenuMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询根目录 -> TestPassed
|
|
||||||
*/
|
|
||||||
private List<SystemMenuTb> listRootMenu() {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(SystemMenuTb::getPid);
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return systemMenuMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SystemMenuRouterVo> buildFrontMenus() {
|
public List<SystemMenuRouterVo> buildFrontMenus() {
|
||||||
List<SystemMenuTb> originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId());
|
List<SystemMenuTb> originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId());
|
||||||
List<SystemMenuVo> targetMenus = this.buildMenuTree(originMenus);
|
List<SystemMenuVo> targetMenus = this.buildMenuTree(originMenus);
|
||||||
@@ -563,7 +393,7 @@ public class SystemMenuService {
|
|||||||
List<SystemMenuTb> newMenuList = new ArrayList<>(menus);
|
List<SystemMenuTb> newMenuList = new ArrayList<>(menus);
|
||||||
return this.buildMenuTree(newMenuList);
|
return this.buildMenuTree(newMenuList);
|
||||||
} else {
|
} else {
|
||||||
List<SystemMenuTb> records = this.listMenuByPid(null);
|
List<SystemMenuTb> records = this.listMenuByPid(null, true);
|
||||||
return KitBeanUtil.copyToList(records, SystemMenuVo.class);
|
return KitBeanUtil.copyToList(records, SystemMenuVo.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,4 +414,178 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询 MenuResponse
|
||||||
|
*
|
||||||
|
* @param menu /
|
||||||
|
* @param menuVo /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) {
|
||||||
|
SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo();
|
||||||
|
menuVo1.setMeta(menuVo.getMeta());
|
||||||
|
// 非外链
|
||||||
|
if (!menu.getIFrame()) {
|
||||||
|
menuVo1.setPath("index");
|
||||||
|
menuVo1.setName(menuVo.getName());
|
||||||
|
menuVo1.setComponent(menuVo.getComponent());
|
||||||
|
} else {
|
||||||
|
menuVo1.setPath(menu.getPath());
|
||||||
|
}
|
||||||
|
return menuVo1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long countMenuByPid(Long pid) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
return systemMenuMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
|
||||||
|
KitValidUtil.notNull(args);
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
|
||||||
|
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
|
||||||
|
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or()
|
||||||
|
.like(SystemMenuTb::getComponentName, args.getBlurry()).or()
|
||||||
|
.like(SystemMenuTb::getPermission, args.getBlurry()));
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询根目录 -> TestPassed
|
||||||
|
*/
|
||||||
|
private List<SystemMenuTb> listRootMenu() {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(SystemMenuTb::getPid);
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据组件名称查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param componentName 组件名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithComponentName(String componentName) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据组件名称查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param componentName 组件名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithComponentNameNeSelf(String componentName, Long currentMenuId) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
||||||
|
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param title 菜单标题
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithTitle(String title) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getTitle, title);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param title 菜单标题
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithTitleNeSelf(String title, Long currentMenuId) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getTitle, title);
|
||||||
|
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从所有菜单中找出指定ID及其子菜单ID
|
||||||
|
*
|
||||||
|
* @param rootIds 要删除的根菜单ID集合
|
||||||
|
* @param allMenus 所有菜单数据
|
||||||
|
* @return 包含根菜单及其所有子菜单的ID集合
|
||||||
|
*/
|
||||||
|
private Set<Long> getAllMenuIdsWithChildren(Set<Long> rootIds, List<SystemMenuTb> allMenus) {
|
||||||
|
Set<Long> result = new HashSet<>(rootIds);
|
||||||
|
Set<Long> currentLevelIds = new HashSet<>(rootIds);
|
||||||
|
// 构建父ID到子菜单的映射
|
||||||
|
Map<Long, List<SystemMenuTb>> parentToChildrenMap = allMenus.stream().filter(menu -> menu.getPid() != null)
|
||||||
|
.collect(Collectors.groupingBy(SystemMenuTb::getPid));
|
||||||
|
while (!currentLevelIds.isEmpty()) {
|
||||||
|
Set<Long> nextLevelIds = new HashSet<>();
|
||||||
|
// 对于当前层级的每个菜单ID,查找其子菜单
|
||||||
|
for (Long parentId : currentLevelIds) {
|
||||||
|
List<SystemMenuTb> children = parentToChildrenMap.get(parentId);
|
||||||
|
if (children != null && !children.isEmpty()) {
|
||||||
|
for (SystemMenuTb child : children) {
|
||||||
|
if (result.add(child.getId())) { // 如果成功添加(之前不存在),则继续查找其子菜单
|
||||||
|
nextLevelIds.add(child.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentLevelIds = nextLevelIds;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新被删除菜单的父菜单子节点计数
|
||||||
|
*/
|
||||||
|
private void updateParentMenuCounts(Set<Long> deletedMenuIds, List<SystemMenuTb> allMenus) {
|
||||||
|
// 查询被删除菜单的父ID
|
||||||
|
Set<Long> parentIds =
|
||||||
|
allMenus.stream().filter(menu -> deletedMenuIds.contains(menu.getId()) && menu.getPid() != null)
|
||||||
|
.map(SystemMenuTb::getPid).collect(Collectors.toSet());
|
||||||
|
// 更新每个父菜单的子节点计数
|
||||||
|
for (Long parentId : parentIds) {
|
||||||
|
proxyService.updateMenuSubCnt(parentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单id查询目录 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param id 菜单id
|
||||||
|
*/
|
||||||
|
private SystemMenuTb getMenuById(Long id) {
|
||||||
|
return systemMenuMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有子节点, 包含自身ID
|
||||||
|
*
|
||||||
|
* @param menuList /
|
||||||
|
* @param menuSet /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private Set<SystemMenuTb> queryChildMenuByArgs(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
||||||
|
for (SystemMenuTb menu : menuList) {
|
||||||
|
menuSet.add(menu);
|
||||||
|
List<SystemMenuTb> menus = this.listMenuByPid(menu.getId(), true);
|
||||||
|
if (CollUtil.isNotEmpty(menus)) {
|
||||||
|
queryChildMenuByArgs(menus, menuSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuSet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -141,8 +141,10 @@ public class SystemMonitorService {
|
|||||||
memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal()));
|
memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal()));
|
||||||
memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable()));
|
memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable()));
|
||||||
memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable()));
|
memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable()));
|
||||||
memoryInfo.put("usageRate",
|
memoryInfo.put(
|
||||||
df.format((memory.getTotal() - memory.getAvailable()) / (double) memory.getTotal() * 100));
|
"usageRate",
|
||||||
|
df.format((memory.getTotal() - memory.getAvailable()) / (double) memory.getTotal() * 100)
|
||||||
|
);
|
||||||
return memoryInfo;
|
return memoryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
@@ -35,13 +35,43 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface SystemOssStorageService extends IService<SystemOssStorageTb> {
|
public interface SystemOssStorageService extends IService<SystemOssStorageTb> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param args 查询条件
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page);
|
KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂条件查询
|
||||||
|
*
|
||||||
|
* @param args 查询条件
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
List<SystemOssStorageVo> queryOssStorage(SystemQueryStorageArgs args);
|
List<SystemOssStorageVo> queryOssStorage(SystemQueryStorageArgs args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param file /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
String uploadFile(MultipartFile file);
|
String uploadFile(MultipartFile file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除文件
|
||||||
|
*
|
||||||
|
* @param ids 文件记录id
|
||||||
|
*/
|
||||||
void deleteFileByIds(Long[] ids);
|
void deleteFileByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出文件上传记录
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args 查询条件
|
||||||
|
*/
|
||||||
void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args);
|
void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args);
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-35
@@ -59,19 +59,6 @@ public class SystemQuartzJobService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private KitRedisHelper redisHelper;
|
private KitRedisHelper redisHelper;
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
|
||||||
*
|
|
||||||
* @param beanName Bean名称
|
|
||||||
*/
|
|
||||||
private void checkBean(String beanName) {
|
|
||||||
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
|
||||||
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
|
||||||
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
|
||||||
throw new BadRequestException("非法的 Bean,请重新输入!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -207,28 +194,6 @@ public class SystemQuartzJobService {
|
|||||||
return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper));
|
return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzJobTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName());
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemQuartzJobTb::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
|
|
||||||
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0),
|
|
||||||
args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemQuartzLogTb::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询日志 -> TestPassed
|
* 分页查询日志 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -324,4 +289,52 @@ public class SystemQuartzJobService {
|
|||||||
public SystemQuartzJobTb getQuartzJobById(Long id) {
|
public SystemQuartzJobTb getQuartzJobById(Long id) {
|
||||||
return systemQuartzJobMapper.selectById(id);
|
return systemQuartzJobMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzJobTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName());
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemQuartzJobTb::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
|
||||||
|
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0),
|
||||||
|
args.getCreateTime().get(1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemQuartzLogTb::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
|
*
|
||||||
|
* @param beanName Bean名称
|
||||||
|
*/
|
||||||
|
private void checkBean(String beanName) {
|
||||||
|
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
||||||
|
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
||||||
|
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
||||||
|
throw new BadRequestException("非法的 Bean,请重新输入!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+64
-29
@@ -66,7 +66,7 @@ public class SystemRoleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveRole(SystemCreateRoleArgs args) {
|
public void saveRole(SystemCreateRoleArgs args) {
|
||||||
checkRoleLevels(args.getLevel());
|
this.checkRoleLevels(args.getLevel());
|
||||||
if (this.existRoleWithName(args.getName())) {
|
if (this.existRoleWithName(args.getName())) {
|
||||||
throw new BadRequestException("角色名称已存在");
|
throw new BadRequestException("角色名称已存在");
|
||||||
}
|
}
|
||||||
@@ -78,19 +78,6 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean existRoleWithName(String name) {
|
|
||||||
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemRoleTb::getName, name);
|
|
||||||
return systemRoleMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existRoleWithNameNeSelf(String name, Long roleId) {
|
|
||||||
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemRoleTb::getName, name);
|
|
||||||
wrapper.eq(SystemRoleTb::getId, roleId);
|
|
||||||
return systemRoleMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改 -> TestPassed
|
* 修改 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -98,7 +85,7 @@ public class SystemRoleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateRoleById(SystemRoleVo args) {
|
public void updateRoleById(SystemRoleVo args) {
|
||||||
checkRoleLevels(args.getLevel());
|
this.checkRoleLevels(args.getLevel());
|
||||||
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
||||||
if (this.existRoleWithNameNeSelf(args.getName(), role.getId())) {
|
if (this.existRoleWithNameNeSelf(args.getName(), role.getId())) {
|
||||||
throw new BadRequestException("角色名称已存在");
|
throw new BadRequestException("角色名称已存在");
|
||||||
@@ -125,7 +112,7 @@ public class SystemRoleService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateBindMenuById(SystemRoleVo args) {
|
public void updateBindMenuById(SystemRoleVo args) {
|
||||||
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
||||||
checkRoleLevels(role.getLevel());
|
this.checkRoleLevels(role.getLevel());
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
||||||
Set<SystemMenuTb> menus = args.getMenus();
|
Set<SystemMenuTb> menus = args.getMenus();
|
||||||
@@ -143,7 +130,7 @@ public class SystemRoleService {
|
|||||||
public void deleteRoleByIds(Set<Long> ids) {
|
public void deleteRoleByIds(Set<Long> ids) {
|
||||||
List<Integer> roleLevels = systemRoleMapper.listRoleLevelByRoleIds(new ArrayList<>(ids));
|
List<Integer> roleLevels = systemRoleMapper.listRoleLevelByRoleIds(new ArrayList<>(ids));
|
||||||
for (Integer roleLevel : roleLevels) {
|
for (Integer roleLevel : roleLevels) {
|
||||||
checkRoleLevels(roleLevel);
|
this.checkRoleLevels(roleLevel);
|
||||||
}
|
}
|
||||||
// 验证是否被用户关联
|
// 验证是否被用户关联
|
||||||
this.verifyBindRelationByIds(ids);
|
this.verifyBindRelationByIds(ids);
|
||||||
@@ -176,17 +163,6 @@ public class SystemRoleService {
|
|||||||
return systemRoleMapper.selectList(wrapper);
|
return systemRoleMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryRoleArgs args, LambdaQueryWrapper<SystemRoleTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
|
|
||||||
.like(SystemRoleTb::getDescription, args.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemRoleTb::getLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询角色 -> TestPassed
|
* 分页查询角色 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -239,6 +215,12 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色id查询用户可访问的部门和菜单信息
|
||||||
|
*
|
||||||
|
* @param id 角色id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemRoleVo getRoleVoById(Long id) {
|
public SystemRoleVo getRoleVoById(Long id) {
|
||||||
SystemRoleTb roleTb = systemRoleMapper.selectById(id);
|
SystemRoleTb roleTb = systemRoleMapper.selectById(id);
|
||||||
if (roleTb == null) {
|
if (roleTb == null) {
|
||||||
@@ -247,8 +229,55 @@ public class SystemRoleService {
|
|||||||
return systemUserRoleService.convertToRoleVo(roleTb);
|
return systemUserRoleService.convertToRoleVo(roleTb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户角色级别
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public Dict getCurrentUserRoleLevel() {
|
public Dict getCurrentUserRoleLevel() {
|
||||||
return Dict.create().set("level", checkRoleLevels(null));
|
return Dict.create().set("level", this.checkRoleLevels(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryRoleArgs args, LambdaQueryWrapper<SystemRoleTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
|
||||||
|
.like(SystemRoleTb::getDescription, args.getBlurry()));
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemRoleTb::getLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询角色名称是否存在
|
||||||
|
*
|
||||||
|
* @param name 角色名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existRoleWithName(String name) {
|
||||||
|
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemRoleTb::getName, name);
|
||||||
|
return systemRoleMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询角色名称是否存在(排除本身)
|
||||||
|
*
|
||||||
|
* @param name 角色名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existRoleWithNameNeSelf(String name, Long roleId) {
|
||||||
|
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemRoleTb::getName, name);
|
||||||
|
wrapper.eq(SystemRoleTb::getId, roleId);
|
||||||
|
return systemRoleMapper.exists(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,6 +296,12 @@ public class SystemRoleService {
|
|||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出部门数据
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args /
|
||||||
|
*/
|
||||||
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
|
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
|
||||||
List<SystemRoleTb> systemRoleVos = this.queryRoleByArgs(args, null);
|
List<SystemRoleTb> systemRoleVos = this.queryRoleByArgs(args, null);
|
||||||
List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
|
List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
|
||||||
|
|||||||
+174
-102
@@ -117,27 +117,6 @@ public class SystemUserService {
|
|||||||
systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId());
|
systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean existUserWithPhone(String phone) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getPhone, phone);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithEmail(String email) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getEmail, email);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithUsername(String username) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑用户 -> TestPassed
|
* 编辑用户 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -178,27 +157,6 @@ public class SystemUserService {
|
|||||||
systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId());
|
systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean existUserWithPhoneNeSelf(String phone, Long currentUserId) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getPhone, phone);
|
|
||||||
wrapper.ne(SystemUserTb::getId, currentUserId);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithEmailNeSelf(String email, Long currentUserId) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getEmail, email);
|
|
||||||
wrapper.ne(SystemUserTb::getId, currentUserId);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithUsernameNeSelf(String username, Long currentUserId) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
|
||||||
wrapper.ne(SystemUserTb::getId, currentUserId);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户自助修改资料 -> TestPassed
|
* 用户自助修改资料 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -354,8 +312,8 @@ public class SystemUserService {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserVo> searchUserByArgs(SystemQueryUserArgs args, Page<SystemUserTb> page) {
|
public KitPageResult<SystemUserVo> searchUserByArgs(SystemQueryUserArgs args, Page<SystemUserTb> page) {
|
||||||
// 查询用户基本信息
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = this.buildUserQueryWrapper(args);
|
this.injectQueryParams(args, wrapper);
|
||||||
IPage<SystemUserTb> userPage = systemUserMapper.selectPage(page, wrapper);
|
IPage<SystemUserTb> userPage = systemUserMapper.selectPage(page, wrapper);
|
||||||
List<SystemUserTb> users = userPage.getRecords();
|
List<SystemUserTb> users = userPage.getRecords();
|
||||||
// 转换为SystemUserVo并关联查询
|
// 转换为SystemUserVo并关联查询
|
||||||
@@ -363,15 +321,29 @@ public class SystemUserService {
|
|||||||
return KitPageUtil.toPage(userVos, userPage.getTotal());
|
return KitPageUtil.toPage(userVos, userPage.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂条件统计用户数量
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public long countUserByArgs(SystemQueryUserArgs args) {
|
public long countUserByArgs(SystemQueryUserArgs args) {
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = this.buildUserQueryWrapper(args);
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
this.injectQueryParams(args, wrapper);
|
||||||
return systemUserMapper.selectCount(wrapper);
|
return systemUserMapper.selectCount(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询用户基础信息,限制返回的条数
|
||||||
|
*
|
||||||
|
* @param pageArgs 分页参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public List<KitSelectOptionVo> queryUserMetadataOptions(KitPageArgs<SystemQueryUserArgs> pageArgs) {
|
public List<KitSelectOptionVo> queryUserMetadataOptions(KitPageArgs<SystemQueryUserArgs> pageArgs) {
|
||||||
SystemQueryUserArgs args = pageArgs.getArgs();
|
SystemQueryUserArgs args = pageArgs.getArgs();
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
wrapper.select(
|
||||||
|
SystemUserTb::getId, SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
wrapper.and(c -> {
|
wrapper.and(c -> {
|
||||||
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
||||||
c.or();
|
c.or();
|
||||||
@@ -392,62 +364,11 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建用户查询条件 -> TestPassed
|
* 根据用户名查询启用的用户信息
|
||||||
*
|
*
|
||||||
* @param args 查询条件
|
* @param username 用户名
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
private LambdaQueryWrapper<SystemUserTb> buildUserQueryWrapper(SystemQueryUserArgs args) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (args != null) {
|
|
||||||
if (args.getId() != null) {
|
|
||||||
wrapper.eq(SystemUserTb::getId, args.getId());
|
|
||||||
}
|
|
||||||
if (args.getEnabled() != null) {
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(args.getDeptIds())) {
|
|
||||||
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
|
|
||||||
}
|
|
||||||
if (StrUtil.isNotBlank(args.getBlurry())) {
|
|
||||||
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or()
|
|
||||||
.like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry()));
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemUserTb::getCreateTime);
|
|
||||||
return wrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param user 用户基本信息
|
|
||||||
* @param includePassword 是否包含用户密码
|
|
||||||
* @return 包含关联信息的SystemUserVo
|
|
||||||
*/
|
|
||||||
private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) {
|
|
||||||
if (user == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!includePassword) {
|
|
||||||
// 查询用户时,清空密码
|
|
||||||
user.setPassword(null);
|
|
||||||
}
|
|
||||||
SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class);
|
|
||||||
// 查询关联的部门信息
|
|
||||||
if (user.getDeptId() != null) {
|
|
||||||
userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId()));
|
|
||||||
}
|
|
||||||
// 查询关联的岗位信息
|
|
||||||
userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId()));
|
|
||||||
// 查询关联的角色信息
|
|
||||||
userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId()));
|
|
||||||
return userVo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemUserTb getUserByUsername(String username) {
|
public SystemUserTb getUserByUsername(String username) {
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
@@ -455,10 +376,22 @@ public class SystemUserService {
|
|||||||
return systemUserMapper.selectOne(wrapper);
|
return systemUserMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户名查询用户的部门、岗位和角色信息,用户信息中有密码数据
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemUserVo getUserVoWithPasswordByUsername(String username) {
|
public SystemUserVo getUserVoWithPasswordByUsername(String username) {
|
||||||
return this.convertToUserVo(this.getUserByUsername(username), true);
|
return this.convertToUserVo(this.getUserByUsername(username), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户名查询用户的部门、岗位和角色信息,用户信息中无密码数据
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemUserVo getUserVoByUsername(String username) {
|
public SystemUserVo getUserVoByUsername(String username) {
|
||||||
return this.convertToUserVo(this.getUserByUsername(username), false);
|
return this.convertToUserVo(this.getUserByUsername(username), false);
|
||||||
}
|
}
|
||||||
@@ -466,8 +399,10 @@ public class SystemUserService {
|
|||||||
/**
|
/**
|
||||||
* 聚合查询 -> TestPassed
|
* 聚合查询 -> TestPassed
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(Page<SystemUserTb> page, SystemQueryUserArgs args,
|
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(
|
||||||
String currentUsername) {
|
Page<SystemUserTb> page, SystemQueryUserArgs args,
|
||||||
|
String currentUsername
|
||||||
|
) {
|
||||||
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
||||||
args.getDeptIds().add(args.getDeptId());
|
args.getDeptIds().add(args.getDeptId());
|
||||||
// 先查找是否存在子节点
|
// 先查找是否存在子节点
|
||||||
@@ -518,6 +453,143 @@ public class SystemUserService {
|
|||||||
rowVos.add(rowVo);
|
rowVos.add(rowVo);
|
||||||
}
|
}
|
||||||
return rowVos;
|
return rowVos;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号是否存在
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithPhone(String phone) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getPhone, phone);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮箱是否存在
|
||||||
|
*
|
||||||
|
* @param email 邮箱
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithEmail(String email) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getEmail, email);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户名是否存在
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithUsername(String username) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号是否存在(排除指定用户)
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param currentUserId 指定用户id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithPhoneNeSelf(String phone, Long currentUserId) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getPhone, phone);
|
||||||
|
wrapper.ne(SystemUserTb::getId, currentUserId);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮箱是否存在(排除指定用户)
|
||||||
|
*
|
||||||
|
* @param email 邮箱
|
||||||
|
* @param currentUserId 指定用户id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithEmailNeSelf(String email, Long currentUserId) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getEmail, email);
|
||||||
|
wrapper.ne(SystemUserTb::getId, currentUserId);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户名是否存在(排除指定用户)
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param currentUserId 指定用户id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithUsernameNeSelf(String username, Long currentUserId) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
|
wrapper.ne(SystemUserTb::getId, currentUserId);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryUserArgs args, LambdaQueryWrapper<SystemUserTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
if (args.getId() != null) {
|
||||||
|
wrapper.eq(SystemUserTb::getId, args.getId());
|
||||||
|
}
|
||||||
|
if (args.getEnabled() != null) {
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(args.getDeptIds())) {
|
||||||
|
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(args.getBlurry())) {
|
||||||
|
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or()
|
||||||
|
.like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry()));
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemUserTb::getCreateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param user 用户基本信息
|
||||||
|
* @param includePassword 是否包含用户密码
|
||||||
|
* @return 包含关联信息的SystemUserVo
|
||||||
|
*/
|
||||||
|
private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) {
|
||||||
|
if (user == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!includePassword) {
|
||||||
|
// 查询用户时,清空密码
|
||||||
|
user.setPassword(null);
|
||||||
|
}
|
||||||
|
SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class);
|
||||||
|
// 查询关联的部门信息
|
||||||
|
if (user.getDeptId() != null) {
|
||||||
|
userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId()));
|
||||||
|
}
|
||||||
|
// 查询关联的岗位信息
|
||||||
|
userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId()));
|
||||||
|
// 查询关联的角色信息
|
||||||
|
userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId()));
|
||||||
|
return userVo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-7
@@ -69,8 +69,10 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
|
|||||||
private SystemOssStorageMapper systemOssStorageMapper;
|
private SystemOssStorageMapper systemOssStorageMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args,
|
public KitPageResult<SystemOssStorageVo> searchOssStorage(
|
||||||
Page<SystemOssStorageTb> page) {
|
SystemQueryStorageArgs args,
|
||||||
|
Page<SystemOssStorageTb> page
|
||||||
|
) {
|
||||||
IPage<SystemOssStorageVo> ossStorageTbs = this.selectOssStorageByArgs(args, page);
|
IPage<SystemOssStorageVo> ossStorageTbs = this.selectOssStorageByArgs(args, page);
|
||||||
for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) {
|
for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) {
|
||||||
storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize()));
|
storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize()));
|
||||||
@@ -78,18 +80,23 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
|
|||||||
return KitPageUtil.toPage(ossStorageTbs);
|
return KitPageUtil.toPage(ossStorageTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPage<SystemOssStorageVo> selectOssStorageByArgs(SystemQueryStorageArgs args,
|
private IPage<SystemOssStorageVo> selectOssStorageByArgs(
|
||||||
Page<SystemOssStorageTb> page) {
|
SystemQueryStorageArgs args,
|
||||||
|
Page<SystemOssStorageTb> page
|
||||||
|
) {
|
||||||
KitValidUtil.notNull(args);
|
KitValidUtil.notNull(args);
|
||||||
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
|
wrapper.and(
|
||||||
|
StrUtil.isNotBlank(args.getBlurry()),
|
||||||
c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or()
|
c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or()
|
||||||
.like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or()
|
.like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or()
|
||||||
.like(SystemOssStorageTb::getFileMime, args.getBlurry()).or()
|
.like(SystemOssStorageTb::getFileMime, args.getBlurry()).or()
|
||||||
.like(SystemOssStorageTb::getFileMd5, args.getBlurry()));
|
.like(SystemOssStorageTb::getFileMd5, args.getBlurry())
|
||||||
|
);
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
||||||
args.getCreateTime().get(1));
|
args.getCreateTime().get(1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
wrapper.orderByAsc(SystemOssStorageTb::getId);
|
wrapper.orderByAsc(SystemOssStorageTb::getId);
|
||||||
return systemOssStorageMapper.selectPage(page, wrapper)
|
return systemOssStorageMapper.selectPage(page, wrapper)
|
||||||
|
|||||||
Reference in New Issue
Block a user