mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 09:55:16 +08:00
Merge remote-tracking branch 'origin/dev' into warm-flow-future
# Conflicts: # ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/DeptService.java # ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/PostService.java # ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/RoleService.java # ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/UserService.java # ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java # ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java
This commit is contained in:
commit
86212f4818
@ -14,18 +14,6 @@ import java.util.concurrent.*;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class Threads {
|
public class Threads {
|
||||||
|
|
||||||
/**
|
|
||||||
* sleep等待,单位为毫秒
|
|
||||||
*/
|
|
||||||
public static void sleep(long milliseconds) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(milliseconds);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止线程池
|
* 停止线程池
|
||||||
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
||||||
|
|||||||
@ -43,7 +43,13 @@ public class MailProperties {
|
|||||||
private String pass;
|
private String pass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送方,遵循RFC-822标准
|
* 发送方,遵循RFC-822标准<br>
|
||||||
|
* 发件人可以是以下形式:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 1. user@xxx.xx
|
||||||
|
* 2. name <user@xxx.xx>
|
||||||
|
* </pre>
|
||||||
*/
|
*/
|
||||||
private String from;
|
private String from;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,165 @@
|
|||||||
|
package org.dromara.common.redis.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.redisson.api.RIdGenerator;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发号器工具类
|
||||||
|
*
|
||||||
|
* @author 秋辞未寒
|
||||||
|
* @date 2024-12-10
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class SequenceUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认初始值
|
||||||
|
*/
|
||||||
|
public static final Long DEFAULT_INIT_VALUE = 1L;
|
||||||
|
/**
|
||||||
|
* 默认步长
|
||||||
|
*/
|
||||||
|
public static final Long DEFAULT_STEP_VALUE = 1L;
|
||||||
|
/**
|
||||||
|
* 默认过期时间-天
|
||||||
|
*/
|
||||||
|
public static final Duration DEFAULT_EXPIRE_TIME_DAY = Duration.ofDays(1);
|
||||||
|
/**
|
||||||
|
* 默认过期时间-分钟
|
||||||
|
*/
|
||||||
|
public static final Duration DEFAULT_EXPIRE_TIME_MINUTE = Duration.ofMinutes(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Redisson客户端实例
|
||||||
|
*/
|
||||||
|
private static final RedissonClient REDISSON_CLIENT = SpringUtils.getBean(RedissonClient.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ID生成器
|
||||||
|
*
|
||||||
|
* @param key 业务key
|
||||||
|
* @param expireTime 过期时间
|
||||||
|
* @param initValue ID初始值
|
||||||
|
* @param stepValue ID步长
|
||||||
|
* @return ID生成器
|
||||||
|
*/
|
||||||
|
private static RIdGenerator getIdGenerator(String key, Duration expireTime, Long initValue, Long stepValue) {
|
||||||
|
if (initValue == null || initValue <= 0) {
|
||||||
|
initValue = DEFAULT_INIT_VALUE;
|
||||||
|
}
|
||||||
|
if (stepValue == null || stepValue <= 0) {
|
||||||
|
stepValue = DEFAULT_STEP_VALUE;
|
||||||
|
}
|
||||||
|
RIdGenerator idGenerator = REDISSON_CLIENT.getIdGenerator(key);
|
||||||
|
// 设置过期时间
|
||||||
|
idGenerator.expire(expireTime);
|
||||||
|
// 设置初始值和步长
|
||||||
|
idGenerator.tryInit(initValue, stepValue);
|
||||||
|
return idGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定业务key的唯一id
|
||||||
|
*
|
||||||
|
* @param key 业务key
|
||||||
|
* @param expireTime 过期时间
|
||||||
|
* @param initValue ID初始值
|
||||||
|
* @param stepValue ID步长
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static long nextId(String key, Duration expireTime, Long initValue, Long stepValue) {
|
||||||
|
return getIdGenerator(key, expireTime, initValue, stepValue).nextId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定业务key的唯一id字符串
|
||||||
|
*
|
||||||
|
* @param key 业务key
|
||||||
|
* @param expireTime 过期时间
|
||||||
|
* @param initValue ID初始值
|
||||||
|
* @param stepValue ID步长
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static String nextIdStr(String key, Duration expireTime, Long initValue, Long stepValue) {
|
||||||
|
return String.valueOf(nextId(key, expireTime, initValue, stepValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定业务key的唯一id (ID初始值=1,ID步长=1)
|
||||||
|
*
|
||||||
|
* @param key 业务key
|
||||||
|
* @param expireTime 过期时间
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static long nextId(String key, Duration expireTime) {
|
||||||
|
return getIdGenerator(key, expireTime, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE).nextId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定业务key的唯一id字符串 (ID初始值=1,ID步长=1)
|
||||||
|
*
|
||||||
|
* @param key 业务key
|
||||||
|
* @param expireTime 过期时间
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static String nextIdStr(String key, Duration expireTime) {
|
||||||
|
return String.valueOf(nextId(key, expireTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 yyyyMMdd 开头的唯一id
|
||||||
|
*
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static String nextIdDate() {
|
||||||
|
return nextIdDate("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 prefix + yyyyMMdd 开头的唯一id
|
||||||
|
*
|
||||||
|
* @param prefix 业务前缀
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static String nextIdDate(String prefix) {
|
||||||
|
// 前缀+日期 构建 prefixKey
|
||||||
|
String prefixKey = StringUtils.format("{}{}", StringUtils.blankToDefault(prefix, ""), DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_FORMATTER));
|
||||||
|
// 获取下一个id
|
||||||
|
long nextId = getIdGenerator(prefixKey, DEFAULT_EXPIRE_TIME_DAY, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE).nextId();
|
||||||
|
// 返回完整id
|
||||||
|
return StringUtils.format("{}{}", prefixKey, nextId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 yyyyMMddHHmmss 开头的唯一id
|
||||||
|
*
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static String nextIdDateTime() {
|
||||||
|
return nextIdDateTime("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 prefix + yyyyMMddHHmmss 开头的唯一id
|
||||||
|
*
|
||||||
|
* @param prefix 业务前缀
|
||||||
|
* @return 唯一id
|
||||||
|
*/
|
||||||
|
public static String nextIdDateTime(String prefix) {
|
||||||
|
// 前缀+日期时间 构建 prefixKey
|
||||||
|
String prefixKey = StringUtils.format("{}{}", StringUtils.blankToDefault(prefix, ""), DateUtil.format(DateUtil.date(), DatePattern.PURE_DATETIME_FORMATTER));
|
||||||
|
// 获取下一个id
|
||||||
|
long nextId = getIdGenerator(prefixKey, DEFAULT_EXPIRE_TIME_MINUTE, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE).nextId();
|
||||||
|
// 返回完整id
|
||||||
|
return StringUtils.format("{}{}", prefixKey, nextId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.demo.controller;
|
package org.dromara.demo.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import org.dromara.common.core.constant.CacheNames;
|
import org.dromara.common.core.constant.CacheNames;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
@ -83,11 +84,7 @@ public class RedisCacheController {
|
|||||||
RedisUtils.setCacheObject(key, value);
|
RedisUtils.setCacheObject(key, value);
|
||||||
boolean flag = RedisUtils.expire(key, Duration.ofSeconds(10));
|
boolean flag = RedisUtils.expire(key, Duration.ofSeconds(10));
|
||||||
System.out.println("***********" + flag);
|
System.out.println("***********" + flag);
|
||||||
try {
|
ThreadUtil.sleep(11 * 1000);
|
||||||
Thread.sleep(11 * 1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Object obj = RedisUtils.getCacheObject(key);
|
Object obj = RedisUtils.getCacheObject(key);
|
||||||
return R.ok(value.equals(obj));
|
return R.ok(value.equals(obj));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.demo.controller;
|
package org.dromara.demo.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import com.baomidou.lock.LockInfo;
|
import com.baomidou.lock.LockInfo;
|
||||||
import com.baomidou.lock.LockTemplate;
|
import com.baomidou.lock.LockTemplate;
|
||||||
import com.baomidou.lock.annotation.Lock4j;
|
import com.baomidou.lock.annotation.Lock4j;
|
||||||
@ -33,13 +34,9 @@ public class RedisLockController {
|
|||||||
@Lock4j(keys = {"#key"})
|
@Lock4j(keys = {"#key"})
|
||||||
@GetMapping("/testLock4j")
|
@GetMapping("/testLock4j")
|
||||||
public R<String> testLock4j(String key, String value) {
|
public R<String> testLock4j(String key, String value) {
|
||||||
System.out.println("start:" + key + ",time:" + LocalTime.now().toString());
|
System.out.println("start:" + key + ",time:" + LocalTime.now());
|
||||||
try {
|
ThreadUtil.sleep(10000);
|
||||||
Thread.sleep(10000);
|
System.out.println("end :" + key + ",time:" + LocalTime.now());
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("end :" + key + ",time:" + LocalTime.now().toString());
|
|
||||||
return R.ok("操作成功", value);
|
return R.ok("操作成功", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +51,7 @@ public class RedisLockController {
|
|||||||
}
|
}
|
||||||
// 获取锁成功,处理业务
|
// 获取锁成功,处理业务
|
||||||
try {
|
try {
|
||||||
try {
|
ThreadUtil.sleep(8000);
|
||||||
Thread.sleep(8000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
System.out.println("执行简单方法1 , 当前线程:" + Thread.currentThread().getName());
|
System.out.println("执行简单方法1 , 当前线程:" + Thread.currentThread().getName());
|
||||||
} finally {
|
} finally {
|
||||||
//释放锁
|
//释放锁
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public class SysClientController extends BaseController {
|
|||||||
@Log(title = "客户端管理", businessType = BusinessType.UPDATE)
|
@Log(title = "客户端管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public R<Void> changeStatus(@RequestBody SysClientBo bo) {
|
public R<Void> changeStatus(@RequestBody SysClientBo bo) {
|
||||||
return toAjax(sysClientService.updateUserStatus(bo.getClientId(), bo.getStatus()));
|
return toAjax(sysClientService.updateClientStatus(bo.getClientId(), bo.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -218,7 +218,7 @@ public class SysUserController extends BaseController {
|
|||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysUserVo>> optionselect(@RequestParam(required = false) Long[] userIds,
|
public R<List<SysUserVo>> optionselect(@RequestParam(required = false) Long[] userIds,
|
||||||
@RequestParam(required = false) Long deptId) {
|
@RequestParam(required = false) Long deptId) {
|
||||||
return R.ok(userService.selectUserByIds(userIds == null ? null : List.of(userIds), deptId));
|
return R.ok(userService.selectUserByIds(ArrayUtil.isEmpty(userIds) ? null : List.of(userIds), deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public interface ISysClientService {
|
|||||||
/**
|
/**
|
||||||
* 修改状态
|
* 修改状态
|
||||||
*/
|
*/
|
||||||
int updateUserStatus(String clientId, String status);
|
int updateClientStatus(String clientId, String status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除客户端管理信息
|
* 校验并批量删除客户端管理信息
|
||||||
|
|||||||
@ -123,7 +123,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
*/
|
*/
|
||||||
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
|
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
|
||||||
@Override
|
@Override
|
||||||
public int updateUserStatus(String clientId, String status) {
|
public int updateClientStatus(String clientId, String status) {
|
||||||
return baseMapper.update(null,
|
return baseMapper.update(null,
|
||||||
new LambdaUpdateWrapper<SysClient>()
|
new LambdaUpdateWrapper<SysClient>()
|
||||||
.set(SysClient::getStatus, status)
|
.set(SysClient::getStatus, status)
|
||||||
|
|||||||
@ -116,7 +116,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
.setName(dept.getDeptName())
|
.setName(dept.getDeptName())
|
||||||
.setWeight(dept.getOrderNum())
|
.setWeight(dept.getOrderNum())
|
||||||
.putExtra("disabled", SystemConstants.DISABLE.equals(dept.getStatus())));
|
.putExtra("disabled", SystemConstants.DISABLE.equals(dept.getStatus())));
|
||||||
Tree<Long> tree = trees.stream().filter(it -> it.getId().longValue() == d.getDeptId()).findFirst().get();
|
Tree<Long> tree = StreamUtils.findFirst(trees, it -> it.getId().longValue() == d.getDeptId());
|
||||||
treeList.add(tree);
|
treeList.add(tree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,4 +425,29 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
return baseMapper.deleteById(deptId);
|
return baseMapper.deleteById(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门ID查询部门负责人
|
||||||
|
*
|
||||||
|
* @param deptId 部门ID,用于指定需要查询的部门
|
||||||
|
* @return 返回该部门的负责人ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long selectDeptLeaderById(Long deptId) {
|
||||||
|
SysDeptVo vo = SpringUtils.getAopProxy(this).selectDeptById(deptId);
|
||||||
|
return vo.getLeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询部门
|
||||||
|
*
|
||||||
|
* @return 部门列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DeptDTO> selectDeptsByList() {
|
||||||
|
List<SysDeptVo> list = baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
|
||||||
|
.select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)
|
||||||
|
.eq(SysDept::getStatus, SystemConstants.NORMAL));
|
||||||
|
return BeanUtil.copyToList(list, DeptDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,8 +118,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
|||||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||||
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"));
|
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"));
|
||||||
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||||
pageQuery.setOrderByColumn("info_id");
|
lqw.orderByDesc(SysLogininfor::getInfoId);
|
||||||
pageQuery.setIsAsc("desc");
|
|
||||||
}
|
}
|
||||||
Page<SysLogininforVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<SysLogininforVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
|
|||||||
@ -53,8 +53,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||||||
public TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery) {
|
public TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<SysOperLog> lqw = buildQueryWrapper(operLog);
|
LambdaQueryWrapper<SysOperLog> lqw = buildQueryWrapper(operLog);
|
||||||
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||||
pageQuery.setOrderByColumn("oper_id");
|
lqw.orderByDesc(SysOperLog::getOperId);
|
||||||
pageQuery.setIsAsc("desc");
|
|
||||||
}
|
}
|
||||||
Page<SysOperLogVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<SysOperLogVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user