parent
d7b0dc91d5
commit
dd17246086
@ -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;
|
||||||
|
|
||||||
|
@ -126,10 +126,10 @@ public class SseEmitterManager {
|
|||||||
SseMessageDto broadcastMessage = new SseMessageDto();
|
SseMessageDto broadcastMessage = new SseMessageDto();
|
||||||
broadcastMessage.setMessage(sseMessageDto.getMessage());
|
broadcastMessage.setMessage(sseMessageDto.getMessage());
|
||||||
broadcastMessage.setUserIds(sseMessageDto.getUserIds());
|
broadcastMessage.setUserIds(sseMessageDto.getUserIds());
|
||||||
RedisUtils.publish(SSE_TOPIC, broadcastMessage, consumer -> {
|
RedisUtils.publish(SSE_TOPIC, broadcastMessage, consumer ->
|
||||||
log.info("SSE发送主题订阅消息topic:{} session keys:{} message:{}",
|
log.info("SSE发送主题订阅消息topic:{} session keys:{} message:{}",
|
||||||
SSE_TOPIC, sseMessageDto.getUserIds(), sseMessageDto.getMessage());
|
SSE_TOPIC, sseMessageDto.getUserIds(), sseMessageDto.getMessage())
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,8 +140,8 @@ public class SseEmitterManager {
|
|||||||
public void publishAll(String message) {
|
public void publishAll(String message) {
|
||||||
SseMessageDto broadcastMessage = new SseMessageDto();
|
SseMessageDto broadcastMessage = new SseMessageDto();
|
||||||
broadcastMessage.setMessage(message);
|
broadcastMessage.setMessage(message);
|
||||||
RedisUtils.publish(SSE_TOPIC, broadcastMessage, consumer -> {
|
RedisUtils.publish(SSE_TOPIC, broadcastMessage, consumer ->
|
||||||
log.info("SSE发送主题订阅消息topic:{} message:{}", SSE_TOPIC, message);
|
log.info("SSE发送主题订阅消息topic:{} message:{}", SSE_TOPIC, message)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
@ -110,7 +110,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user