Merge branch 'master' of https://gitee.com/youlaiorg/youlai-boot into feature/noticews
# Conflicts: # src/main/java/com/youlai/boot/module/websocket/service/OnlineUserService.java
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.youlai.boot.common.base;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 基础分页请求对象
|
||||
*
|
||||
@@ -12,7 +14,11 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
@Schema
|
||||
public class BasePageQuery {
|
||||
public class BasePageQuery implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@Schema(description = "页码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private int pageNum = 1;
|
||||
|
||||
@@ -273,7 +273,8 @@ public class CodegenServiceImpl implements CodegenService {
|
||||
for (String tableName : tableNames) {
|
||||
generateAndZipCode(tableName, zip);
|
||||
}
|
||||
|
||||
// 确保所有压缩数据写入输出流,避免数据残留在内存缓冲区引发的数据不完整
|
||||
zip.finish();
|
||||
return outputStream.toByteArray();
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -51,9 +51,10 @@ public class WebsocketController {
|
||||
*/
|
||||
@MessageMapping("/sendToUser/{username}")
|
||||
public void sendToUser(Principal principal, @DestinationVariable String username, String message) {
|
||||
|
||||
String sender = principal.getName(); // 发送人
|
||||
String receiver = username; // 接收人
|
||||
// 发送人
|
||||
String sender = principal.getName();
|
||||
// 接收人
|
||||
String receiver = username;
|
||||
|
||||
log.info("发送人:{}; 接收人:{}", sender, receiver);
|
||||
// 发送消息给指定用户,拼接后路径 /user/{receiver}/queue/greeting
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.youlai.boot.module.websocket.service;
|
||||
|
||||
public interface WebsocketService {
|
||||
|
||||
void addUser(String username);
|
||||
|
||||
void removeUser(String username) ;
|
||||
|
||||
}
|
||||
@@ -34,10 +34,10 @@ public class LogController {
|
||||
|
||||
@Operation(summary = "日志分页列表")
|
||||
@GetMapping("/page")
|
||||
public PageResult<LogPageVO> listPagedLogs(
|
||||
public PageResult<LogPageVO> getLogPage(
|
||||
LogPageQuery queryParams
|
||||
) {
|
||||
Page<LogPageVO> result = logService.listPagedLogs(queryParams);
|
||||
Page<LogPageVO> result = logService.getLogPage(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class UserController {
|
||||
@Operation(summary = "删除用户")
|
||||
@DeleteMapping("/{ids}")
|
||||
@PreAuthorize("@ss.hasPerm('sys:user:delete')")
|
||||
public Result<?> deleteUsers(
|
||||
public Result<Void> deleteUsers(
|
||||
@Parameter(description = "用户ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
) {
|
||||
boolean result = userService.deleteUsers(ids);
|
||||
@@ -108,7 +108,7 @@ public class UserController {
|
||||
|
||||
@Operation(summary = "修改用户状态")
|
||||
@PatchMapping(value = "/{userId}/status")
|
||||
public Result<?> updateUserStatus(
|
||||
public Result<Void> updateUserStatus(
|
||||
@Parameter(description = "用户ID") @PathVariable Long userId,
|
||||
@Parameter(description = "用户状态(1:启用;0:禁用)") @RequestParam Integer status
|
||||
) {
|
||||
@@ -144,7 +144,7 @@ public class UserController {
|
||||
|
||||
@Operation(summary = "导入用户")
|
||||
@PostMapping("/import")
|
||||
public Result<?> importUsers(MultipartFile file) throws IOException {
|
||||
public Result<String> importUsers(MultipartFile file) throws IOException {
|
||||
UserImportListener listener = new UserImportListener();
|
||||
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportDTO.class, listener);
|
||||
return Result.success(msg);
|
||||
|
||||
@@ -3,11 +3,33 @@ package com.youlai.boot.system.event;
|
||||
import lombok.Getter;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
|
||||
/**
|
||||
* 用户连接事件
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Getter
|
||||
public class UserConnectionEvent extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private final String username;
|
||||
|
||||
/**
|
||||
* 是否连接
|
||||
*/
|
||||
private final boolean connected;
|
||||
|
||||
/**
|
||||
* 用户连接事件
|
||||
*
|
||||
* @param source 事件源
|
||||
* @param username 用户名
|
||||
* @param connected 是否连接
|
||||
*/
|
||||
public UserConnectionEvent(Object source, String username, boolean connected) {
|
||||
super(source);
|
||||
this.username = username;
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface LogMapper extends BaseMapper<Log> {
|
||||
* @param queryParams
|
||||
* @return
|
||||
*/
|
||||
Page<LogPageVO> listPagedLogs(Page<LogPageVO> page, LogPageQuery queryParams);
|
||||
Page<LogPageVO> getLogPage(Page<LogPageVO> page, LogPageQuery queryParams);
|
||||
|
||||
/**
|
||||
* 统计浏览数(PV)
|
||||
|
||||
@@ -7,6 +7,12 @@ import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 访问趋势VO
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Schema(description = "访问趋势VO")
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface LogService extends IService<Log> {
|
||||
* @param queryParams 查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<LogPageVO> listPagedLogs(LogPageQuery queryParams);
|
||||
Page<LogPageVO> getLogPage(LogPageQuery queryParams);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,8 +36,8 @@ public class LogServiceImpl extends ServiceImpl<LogMapper, Log>
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<LogPageVO> listPagedLogs(LogPageQuery queryParams) {
|
||||
return this.baseMapper.listPagedLogs(new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||
public Page<LogPageVO> getLogPage(LogPageQuery queryParams) {
|
||||
return this.baseMapper.getLogPage(new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||
queryParams);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,9 +268,32 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
roleMenuService.refreshRolePermsCache();
|
||||
}
|
||||
}
|
||||
// 修改菜单如果有子菜单,则更新子菜单的树路径
|
||||
updateChildrenTreePath(entity.getId(), treePath);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新子菜单树路径
|
||||
* @param id 当前菜单ID
|
||||
* @param treePath 当前菜单树路径
|
||||
*/
|
||||
private void updateChildrenTreePath(Long id, String treePath) {
|
||||
List<Menu> children = this.list(new LambdaQueryWrapper<Menu>().eq(Menu::getParentId, id));
|
||||
if (CollectionUtil.isNotEmpty(children)) {
|
||||
// 子菜单的树路径等于父菜单的树路径加上父菜单ID
|
||||
String childTreePath = treePath + "," + id;
|
||||
this.update(new LambdaUpdateWrapper<Menu>()
|
||||
.eq(Menu::getParentId, id)
|
||||
.set(Menu::getTreePath, childTreePath)
|
||||
);
|
||||
for (Menu child : children) {
|
||||
// 递归更新子菜单
|
||||
updateChildrenTreePath(child.getId(), childTreePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门路径生成
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user