This commit is contained in:
2026-03-21 16:53:49 +08:00
parent 7d1ad3e58c
commit 01ccc9f4b3
30 changed files with 54 additions and 441 deletions

View File

@@ -1,73 +0,0 @@
package com.njcn.rdms.module.system.api.file;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.file.dto.FileCreateReqDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 文件")
public interface FileApi {
String PREFIX = ApiConstants.PREFIX + "/file";
/**
* 保存文件,并返回文件的访问路径
*
* @param content 文件内容
* @return 文件路径
*/
default String createFile(byte[] content) {
return createFile(content, null, null, null);
}
/**
* 保存文件,并返回文件的访问路径
*
* @param content 文件内容
* @param name 文件名称,允许空
* @return 文件路径
*/
default String createFile(byte[] content, String name) {
return createFile(content, name, null, null);
}
/**
* 保存文件,并返回文件的访问路径
*
* @param content 文件内容
* @param name 文件名称,允许空
* @param directory 目录,允许空
* @param type 文件的 MIME 类型,允许空
* @return 文件路径
*/
default String createFile(@NotEmpty(message = "文件内容不能为空") byte[] content,
String name, String directory, String type) {
return createFile(new FileCreateReqDTO().setName(name).setDirectory(directory).setType(type).setContent(content)).getCheckedData();
}
@PostMapping(PREFIX + "/create")
@Operation(summary = "保存文件,并返回文件的访问路径")
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
/**
* 生成文件预签名地址,用于读取
*
* @param url 完整的文件访问地址
* @param expirationSeconds 访问有效期,单位秒
* @return 文件预签名地址
*/
@GetMapping(PREFIX + "/presigned-url")
@Operation(summary = "生成文件预签名地址,用于读取")
CommonResult<String> presignGetUrl(@NotEmpty(message = "URL 不能为空") @RequestParam("url") String url,
Integer expirationSeconds);
}

View File

@@ -1,24 +0,0 @@
package com.njcn.rdms.module.system.api.file.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
@Schema(description = "RPC 服务 - 文件创建 Request DTO")
@Data
public class FileCreateReqDTO {
@Schema(description = "原文件名称", example = "xxx.png")
private String name;
@Schema(description = "文件目录", example = "xxx")
private String directory;
@Schema(description = "文件的 MIME 类型", example = "image/png")
private String type;
@Schema(description = "文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "文件内容不能为空")
private byte[] content;
}

View File

@@ -1,24 +0,0 @@
package com.njcn.rdms.module.system.api.logger;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import jakarta.validation.Valid;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 登录日志")
public interface LoginLogApi {
String PREFIX = ApiConstants.PREFIX + "/login-log";
@PostMapping(PREFIX + "/create")
@Operation(summary = "创建登录日志")
CommonResult<Boolean> createLoginLog(@Valid @RequestBody LoginLogCreateReqDTO reqDTO);
}

View File

@@ -1,40 +0,0 @@
package com.njcn.rdms.module.system.api.logger.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
@Schema(description = "RPC 服务 - 登录日志创建 Request DTO")
@Data
public class LoginLogCreateReqDTO {
@Schema(description = "日志类型,参见 LoginLogTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1" )
@NotNull(message = "日志类型不能为空")
private Integer logType;
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "89aca178-a370-411c-ae02-3f0d672be4ab")
private String traceId;
@Schema(description = "用户编号", example = "666")
private Long userId;
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2" )
@NotNull(message = "用户类型不能为空")
private Integer userType;
@Schema(description = "用户账号", example = "rdms")
@Size(max = 30, message = "用户账号长度不能超过30个字符")
private String username; // 不再强制校验 username 非空,兼容无 username 的登录场景
@Schema(description = "登录结果,参见 LoginResultEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "登录结果不能为空")
private Integer result;
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
@NotEmpty(message = "用户 IP 不能为空")
private String userIp;
@Schema(description = "浏览器 UserAgent", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
private String userAgent;
}

View File

@@ -1,28 +0,0 @@
package com.njcn.rdms.module.system.api.notify;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 站内信发送")
public interface NotifyMessageSendApi {
String PREFIX = ApiConstants.PREFIX + "/notify/send";
@PostMapping(PREFIX + "/send-single-admin")
@Operation(summary = "发送单条站内信给 Admin 用户")
CommonResult<Long> sendSingleMessageToAdmin(@Valid @RequestBody NotifySendSingleToUserReqDTO reqDTO);
@PostMapping(PREFIX + "/send-single-member")
@Operation(summary = "发送单条站内信给 Member 用户")
CommonResult<Long> sendSingleMessageToMember(@Valid @RequestBody NotifySendSingleToUserReqDTO reqDTO);
}

View File

@@ -1,23 +0,0 @@
package com.njcn.rdms.module.system.api.notify.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.Map;
@Schema(description = "RPC 服务 - 站内信发送给 Admin 或者 Member 用户 Request DTO")
@Data
public class NotifySendSingleToUserReqDTO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "用户编号不能为空")
private Long userId;
@Schema(description = "站内信模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "USER_SEND")
@NotEmpty(message = "站内信模板编号不能为空")
private String templateCode;
@Schema(description = "邮件模板参数")
private Map<String, Object> templateParams;
}

View File

@@ -1,25 +0,0 @@
package com.njcn.rdms.module.system.api.permission;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 角色")
public interface RoleApi {
String PREFIX = ApiConstants.PREFIX + "/role";
@GetMapping(PREFIX + "/valid")
@Operation(summary = "校验角色是否合法")
@Parameter(name = "ids", description = "角色编号数组", example = "1,2", required = true)
CommonResult<Boolean> validRoleList(@RequestParam("ids") Collection<Long> ids);
}

View File

@@ -2,7 +2,7 @@ package com.njcn.rdms.module.system.api.websocket;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.util.json.JsonUtils;
import com.njcn.rdms.module.system.api.websocket.dto.WebSocketSendReqDTO;
import com.njcn.rdms.module.system.api.websocket.dto.WebSocketSendToUsersReqDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -11,63 +11,32 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Collection;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - WebSocket 发送器的") // 对 WebSocketMessageSender 进行封装,提供给其它模块使用
public interface WebSocketSenderApi {
String PREFIX = ApiConstants.PREFIX + "/websocket";
@PostMapping(PREFIX + "/send")
@Operation(summary = "发送 WebSocket 消息")
CommonResult<Boolean> send(@Valid @RequestBody WebSocketSendReqDTO message);
@PostMapping(PREFIX + "/send-to-users")
@Operation(summary = "按用户编号集合发送 WebSocket 消息")
CommonResult<Boolean> sendToUsers(@Valid @RequestBody WebSocketSendToUsersReqDTO message);
/**
* 发送消息给指定用户
* 发送消息给指定用户集合
*
* @param userType 用户类型
* @param userId 用户编号
* @param userIds 用户编号集合
* @param messageType 消息类型
* @param messageContent 消息内容JSON 格式
*/
default void send(Integer userType, Long userId, String messageType, String messageContent) {
send(new WebSocketSendReqDTO().setUserType(userType).setUserId(userId)
default void send(Collection<Long> userIds, String messageType, String messageContent) {
sendToUsers(new WebSocketSendToUsersReqDTO().setUserIds(userIds)
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
}
/**
* 发送消息给指定用户类型
*
* @param userType 用户类型
* @param messageType 消息类型
* @param messageContent 消息内容JSON 格式
*/
default void send(Integer userType, String messageType, String messageContent) {
send(new WebSocketSendReqDTO().setUserType(userType)
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
}
/**
* 发送消息给指定 Session
*
* @param sessionId Session 编号
* @param messageType 消息类型
* @param messageContent 消息内容JSON 格式
*/
default void send(String sessionId, String messageType, String messageContent) {
send(new WebSocketSendReqDTO().setSessionId(sessionId)
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
}
default void sendObject(Integer userType, Long userId, String messageType, Object messageContent) {
send(userType, userId, messageType, JsonUtils.toJsonString(messageContent));
}
default void sendObject(Integer userType, String messageType, Object messageContent) {
send(userType, messageType, JsonUtils.toJsonString(messageContent));
}
default void sendObject(String sessionId, String messageType, Object messageContent) {
send(sessionId, messageType, JsonUtils.toJsonString(messageContent));
default void sendObject(Collection<Long> userIds, String messageType, Object messageContent) {
send(userIds, messageType, JsonUtils.toJsonString(messageContent));
}
}

View File

@@ -1,25 +0,0 @@
package com.njcn.rdms.module.system.api.websocket.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
@Schema(description = "RPC 服务 - WebSocket 消息发送 Request DTO")
@Data
public class WebSocketSendReqDTO {
@Schema(description = "Session 编号", example = "abc")
private String sessionId;
@Schema(description = "用户编号", example = "1024")
private Long userId;
@Schema(description = "用户类型", example = "1")
private Integer userType;
@Schema(description = "消息类型", example = "demo-message")
@NotEmpty(message = "消息类型不能为空")
private String messageType;
@Schema(description = "消息内容", example = "{\"name\":\"李四\"}}")
@NotEmpty(message = "消息内容不能为空")
private String messageContent;
}

View File

@@ -14,9 +14,9 @@ public class ApiConstants {
*
* 注意,需要保证和 spring.application.name 保持一致
*/
public static final String NAME = "rdms-system-server";
public static final String NAME = RpcConstants.SYSTEM_NAME;
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/system";
public static final String PREFIX = RpcConstants.SYSTEM_PREFIX;
public static final String VERSION = "1.0.0";

View File

@@ -3,6 +3,7 @@ package com.njcn.rdms.module.system.api.config;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.dal.dataobject.config.ConfigDO;
import com.njcn.rdms.module.system.service.config.ConfigService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -11,6 +12,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class ConfigApiImpl implements ConfigApi {
@Resource

View File

@@ -5,6 +5,7 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.api.dept.dto.DeptRespDTO;
import com.njcn.rdms.module.system.dal.dataobject.dept.DeptDO;
import com.njcn.rdms.module.system.service.dept.DeptService;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.context.annotation.Bean;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -17,6 +18,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class DeptApiImpl implements DeptApi {
@Resource

View File

@@ -5,6 +5,7 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.api.dept.dto.PostRespDTO;
import com.njcn.rdms.module.system.dal.dataobject.dept.PostDO;
import com.njcn.rdms.module.system.service.dept.PostService;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -16,6 +17,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class PostApiImpl implements PostApi {
@Resource

View File

@@ -5,6 +5,7 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.framework.common.biz.system.dict.dto.DictDataRespDTO;
import com.njcn.rdms.module.system.dal.dataobject.dict.DictDataDO;
import com.njcn.rdms.module.system.service.dict.DictDataService;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -18,6 +19,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Primary // 由于 DictDataCommonApi 的存在,必须声明为 @Primary Bean
@Hidden
public class DictDataApiImpl implements DictDataApi {
@Resource

View File

@@ -1,30 +0,0 @@
package com.njcn.rdms.module.system.api.file;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.file.dto.FileCreateReqDTO;
import com.njcn.rdms.module.system.service.file.FileService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class FileApiImpl implements FileApi {
@Resource
private FileService fileService;
@Override
public CommonResult<String> createFile(FileCreateReqDTO createReqDTO) {
return success(fileService.createFile(createReqDTO.getContent(), createReqDTO.getName(),
createReqDTO.getDirectory(), createReqDTO.getType()));
}
@Override
public CommonResult<String> presignGetUrl(String url, Integer expirationSeconds) {
return success(fileService.presignGetUrl(url, expirationSeconds));
}
}

View File

@@ -4,6 +4,7 @@ import com.njcn.rdms.framework.common.biz.system.logger.ApiAccessLogCommonApi;
import com.njcn.rdms.framework.common.biz.system.logger.dto.ApiAccessLogCreateReqDTO;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.service.logger.ApiAccessLogService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -12,6 +13,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class ApiAccessLogApiImpl implements ApiAccessLogCommonApi {
@Resource

View File

@@ -4,6 +4,7 @@ import com.njcn.rdms.framework.common.biz.system.logger.ApiErrorLogCommonApi;
import com.njcn.rdms.framework.common.biz.system.logger.dto.ApiErrorLogCreateReqDTO;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.service.logger.ApiErrorLogService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -12,6 +13,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class ApiErrorLogApiImpl implements ApiErrorLogCommonApi {
@Resource

View File

@@ -1,26 +0,0 @@
package com.njcn.rdms.module.system.api.logger;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.service.logger.LoginLogService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class LoginLogApiImpl implements LoginLogApi {
@Resource
private LoginLogService loginLogService;
@Override
public CommonResult<Boolean> createLoginLog(LoginLogCreateReqDTO reqDTO) {
loginLogService.createLoginLog(reqDTO);
return success(true);
}
}

View File

@@ -8,6 +8,7 @@ import com.njcn.rdms.module.system.api.logger.dto.OperateLogPageReqDTO;
import com.njcn.rdms.module.system.api.logger.dto.OperateLogRespDTO;
import com.njcn.rdms.module.system.dal.dataobject.logger.OperateLogDO;
import com.njcn.rdms.module.system.service.logger.OperateLogService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;
@@ -18,6 +19,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Primary // 由于 OperateLogCommonApi 的存在,必须声明为 @Primary Bean
@Hidden
public class OperateLogApiImpl implements OperateLogApi {
@Resource

View File

@@ -1,32 +0,0 @@
package com.njcn.rdms.module.system.api.notify;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import com.njcn.rdms.module.system.service.notify.NotifySendService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class NotifyMessageSendApiImpl implements NotifyMessageSendApi {
@Resource
private NotifySendService notifySendService;
@Override
public CommonResult<Long> sendSingleMessageToAdmin(NotifySendSingleToUserReqDTO reqDTO) {
return success(notifySendService.sendSingleNotifyToAdmin(reqDTO.getUserId(),
reqDTO.getTemplateCode(), reqDTO.getTemplateParams()));
}
@Override
public CommonResult<Long> sendSingleMessageToMember(NotifySendSingleToUserReqDTO reqDTO) {
return success(notifySendService.sendSingleNotifyToMember(reqDTO.getUserId(),
reqDTO.getTemplateCode(), reqDTO.getTemplateParams()));
}
}

View File

@@ -8,6 +8,7 @@ import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import com.njcn.rdms.module.system.service.oauth2.OAuth2TokenService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -16,6 +17,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController
@Validated
@Hidden
public class OAuth2TokenApiImpl implements OAuth2TokenCommonApi {
@Resource

View File

@@ -2,6 +2,7 @@ package com.njcn.rdms.module.system.api.permission;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.service.permission.PermissionService;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -15,6 +16,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Primary // 由于 PermissionCommonApi 的存在,必须声明为 @Primary Bean
@Hidden
public class PermissionApiImpl implements PermissionApi {
@Resource

View File

@@ -1,25 +0,0 @@
package com.njcn.rdms.module.system.api.permission;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.service.permission.RoleService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import java.util.Collection;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class RoleApiImpl implements RoleApi {
@Resource
private RoleService roleService;
@Override
public CommonResult<Boolean> validRoleList(Collection<Long> ids) {
roleService.validateRoleList(ids);
return success(true);
}
}

View File

@@ -5,6 +5,7 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
import com.njcn.rdms.module.system.dal.dataobject.user.AdminUserDO;
import com.njcn.rdms.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -16,6 +17,7 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class AdminUserApiImpl implements AdminUserApi {
@Resource

View File

@@ -1,9 +1,11 @@
package com.njcn.rdms.module.system.api.websocket;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.collection.CollUtil;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.enums.UserTypeEnum;
import com.njcn.rdms.framework.websocket.core.sender.WebSocketMessageSender;
import com.njcn.rdms.module.system.api.websocket.dto.WebSocketSendReqDTO;
import com.njcn.rdms.module.system.api.websocket.dto.WebSocketSendToUsersReqDTO;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -12,22 +14,20 @@ import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
@Hidden
public class WebSocketSenderApiImpl implements WebSocketSenderApi {
private static final Integer SYSTEM_USER_TYPE = UserTypeEnum.ADMIN.getValue();
@Resource
private WebSocketMessageSender webSocketMessageSender;
@Override
public CommonResult<Boolean> send(WebSocketSendReqDTO message) {
if (StrUtil.isNotEmpty(message.getSessionId())) {
webSocketMessageSender.send(message.getSessionId(),
message.getMessageType(), message.getMessageContent());
} else if (message.getUserType() != null && message.getUserId() != null) {
webSocketMessageSender.send(message.getUserType(), message.getUserId(),
message.getMessageType(), message.getMessageContent());
} else if (message.getUserType() != null) {
webSocketMessageSender.send(message.getUserType(),
message.getMessageType(), message.getMessageContent());
public CommonResult<Boolean> sendToUsers(WebSocketSendToUsersReqDTO message) {
if (CollUtil.isNotEmpty(message.getUserIds())) {
message.getUserIds().stream().distinct().forEach(userId ->
webSocketMessageSender.send(SYSTEM_USER_TYPE, userId,
message.getMessageType(), message.getMessageContent()));
}
return success(true);
}

View File

@@ -1,16 +1,16 @@
package com.njcn.rdms.module.system.controller.admin.notice;
import cn.hutool.core.lang.Assert;
import com.njcn.rdms.framework.common.enums.UserTypeEnum;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.pojo.PageResult;
import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.api.websocket.WebSocketSenderApi;
import com.njcn.rdms.module.system.controller.admin.notice.vo.NoticePageReqVO;
import com.njcn.rdms.module.system.controller.admin.notice.vo.NoticeRespVO;
import com.njcn.rdms.module.system.controller.admin.notice.vo.NoticeSaveReqVO;
import com.njcn.rdms.module.system.dal.dataobject.notice.NoticeDO;
import com.njcn.rdms.module.system.service.notice.NoticeService;
import com.njcn.rdms.framework.common.enums.UserTypeEnum;
import com.njcn.rdms.framework.websocket.core.sender.WebSocketMessageSender;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -34,7 +34,7 @@ public class NoticeController {
private NoticeService noticeService;
@Resource
private WebSocketSenderApi webSocketSenderApi;
private WebSocketMessageSender webSocketMessageSender;
@PostMapping("/create")
@Operation(summary = "创建通知公告")
@@ -95,7 +95,7 @@ public class NoticeController {
NoticeDO notice = noticeService.getNotice(id);
Assert.notNull(notice, "公告不能为空");
// 通过 websocket 推送给在线的用户
webSocketSenderApi.sendObject(UserTypeEnum.ADMIN.getValue(), "notice-push", notice);
webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), "notice-push", notice);
return success(true);
}

View File

@@ -1,12 +1,11 @@
package com.njcn.rdms.module.system.framework.rpc.config;
import com.njcn.rdms.module.system.api.config.ConfigApi;
import com.njcn.rdms.module.system.api.file.FileApi;
import com.njcn.rdms.module.system.api.websocket.WebSocketSenderApi;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;
@Configuration(value = "systemRpcConfiguration", proxyBeanMethods = false)
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, ConfigApi.class})
@EnableFeignClients(clients = {WebSocketSenderApi.class, ConfigApi.class})
public class RpcConfiguration {
}

View File

@@ -11,7 +11,6 @@ import com.njcn.rdms.framework.common.util.monitor.TracerUtils;
import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.framework.common.util.servlet.ServletUtils;
import com.njcn.rdms.framework.common.util.validation.ValidationUtils;
import com.njcn.rdms.module.system.api.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.controller.admin.auth.vo.AuthLoginReqVO;
import com.njcn.rdms.module.system.controller.admin.auth.vo.AuthLoginRespVO;
import com.njcn.rdms.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
@@ -22,6 +21,7 @@ import com.njcn.rdms.module.system.enums.logger.LoginLogTypeEnum;
import com.njcn.rdms.module.system.enums.logger.LoginResultEnum;
import com.njcn.rdms.module.system.enums.oauth2.OAuth2ClientConstants;
import com.njcn.rdms.module.system.service.logger.LoginLogService;
import com.njcn.rdms.module.system.service.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.service.member.MemberService;
import com.njcn.rdms.module.system.service.oauth2.OAuth2TokenService;
import com.njcn.rdms.module.system.service.user.AdminUserService;

View File

@@ -1,7 +1,7 @@
package com.njcn.rdms.module.system.service.logger;
import com.njcn.rdms.framework.common.pojo.PageResult;
import com.njcn.rdms.module.system.api.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.service.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
import com.njcn.rdms.module.system.dal.dataobject.logger.LoginLogDO;

View File

@@ -2,7 +2,7 @@ package com.njcn.rdms.module.system.service.logger;
import com.njcn.rdms.framework.common.pojo.PageResult;
import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.api.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.service.logger.dto.LoginLogCreateReqDTO;
import com.njcn.rdms.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
import com.njcn.rdms.module.system.dal.dataobject.logger.LoginLogDO;
import com.njcn.rdms.module.system.dal.mysql.logger.LoginLogMapper;