1、结构化调整;

This commit is contained in:
2026-03-31 19:58:48 +08:00
parent ebdbdbeb41
commit e78565ea5a
369 changed files with 3790 additions and 1195 deletions

View File

@@ -0,0 +1,21 @@
package com.njcn.msgpush.module.system.api.config;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 参数配置")
public interface ConfigApi {
String PREFIX = ApiConstants.PREFIX + "/config";
@GetMapping(PREFIX + "/get-value-by-key")
@Operation(summary = "根据参数键查询参数值")
CommonResult<String> getConfigValueByKey(@RequestParam("key") String key);
}

View File

@@ -1,40 +0,0 @@
package com.njcn.msgpush.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 = "msgpush")
@Size(max = 30, message = "用户账号长度不能超过30个字符")
private String username; // 不再强制校验 username 非空,因为 Member 社交登录时,此时暂时没有 username(mobile
@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,12 +1,12 @@
package com.njcn.msgpush.module.system.api.user;
import cn.hutool.core.convert.Convert;
import com.fhs.core.trans.anno.AutoTrans;
import com.fhs.trans.service.AutoTransable;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.util.collection.CollectionUtils;
import com.njcn.msgpush.module.system.api.user.dto.AdminUserRespDTO;
import com.njcn.msgpush.module.system.enums.ApiConstants;
import com.fhs.core.trans.anno.AutoTrans;
import com.fhs.trans.service.AutoTransable;
import feign.FeignIgnore;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -22,7 +22,7 @@ import java.util.Map;
import static com.njcn.msgpush.module.system.api.user.AdminUserApi.PREFIX;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 管理员用户")
@AutoTrans(namespace = PREFIX, fields = {"nickname"})
public interface AdminUserApi extends AutoTransable<AdminUserRespDTO> {
@@ -34,11 +34,6 @@ public interface AdminUserApi extends AutoTransable<AdminUserRespDTO> {
@Parameter(name = "id", description = "用户编号", example = "1", required = true)
CommonResult<AdminUserRespDTO> getUser(@RequestParam("id") Long id);
@GetMapping(PREFIX + "/list-by-subordinate")
@Operation(summary = "通过用户 ID 查询用户下属")
@Parameter(name = "id", description = "用户编号", example = "1", required = true)
CommonResult<List<AdminUserRespDTO>> getUserListBySubordinate(@RequestParam("id") Long id);
@GetMapping(PREFIX + "/list")
@Operation(summary = "通过用户 ID 查询用户们")
@Parameter(name = "ids", description = "部门编号数组", example = "1,2", required = true)
@@ -66,9 +61,7 @@ public interface AdminUserApi extends AutoTransable<AdminUserRespDTO> {
}
/**
* 校验用户是否有效。如下情况,视为无效:
* 1. 用户编号不存在
* 2. 用户被禁用
* 校验用户是否有效
*
* @param id 用户编号
*/

View File

@@ -0,0 +1,42 @@
package com.njcn.msgpush.module.system.api.websocket;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.util.json.JsonUtils;
import com.njcn.msgpush.module.system.api.websocket.dto.WebSocketSendToUsersReqDTO;
import com.njcn.msgpush.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
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-to-users")
@Operation(summary = "按用户编号集合发送 WebSocket 消息")
CommonResult<Boolean> sendToUsers(@Valid @RequestBody WebSocketSendToUsersReqDTO message);
/**
* 发送消息给指定用户集合
*
* @param userIds 用户编号集合
* @param messageType 消息类型
* @param messageContent 消息内容JSON 格式
*/
default void send(Collection<Long> userIds, String messageType, String messageContent) {
sendToUsers(new WebSocketSendToUsersReqDTO().setUserIds(userIds)
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
}
default void sendObject(Collection<Long> userIds, String messageType, Object messageContent) {
send(userIds, messageType, JsonUtils.toJsonString(messageContent));
}
}

View File

@@ -0,0 +1,27 @@
package com.njcn.msgpush.module.system.api.websocket.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Collection;
@Schema(description = "RPC 服务 - 按用户编号集合发送 WebSocket 消息 Request DTO")
@Data
@Accessors(chain = true)
public class WebSocketSendToUsersReqDTO {
@Schema(description = "用户编号集合", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2,3]")
@NotEmpty(message = "用户编号集合不能为空")
private Collection<Long> userIds;
@Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "notice-push")
@NotEmpty(message = "消息类型不能为空")
private String messageType;
@Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "{\"name\":\"李四\"}")
@NotEmpty(message = "消息内容不能为空")
private String messageContent;
}

View File

@@ -0,0 +1,21 @@
package com.njcn.msgpush.module.system.enums.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ConfigTypeEnum {
/**
* 系统配置
*/
SYSTEM(1),
/**
* 自定义配置
*/
CUSTOM(2);
private final Integer type;
}

View File

@@ -0,0 +1,33 @@
package com.njcn.msgpush.module.system.enums.dept;
import java.util.Arrays;
/**
* 组织节点类型枚举
*/
public enum DeptOrgTypeEnum {
COMPANY("company"),
DEPT("dept"),
DIRECTION("direction"),
TEAM("team");
private final String type;
DeptOrgTypeEnum(String type) {
this.type = type;
}
public String getType() {
return type;
}
public static boolean isValid(String type) {
return Arrays.stream(values()).anyMatch(item -> item.type.equals(type));
}
public static String defaultType() {
return DEPT.type;
}
}

View File

@@ -0,0 +1,28 @@
package com.njcn.msgpush.module.system.enums.dept;
import java.util.Arrays;
/**
* 岗位类型枚举
*/
public enum PostTypeEnum {
MANAGEMENT("management"),
TECHNICAL("technical"),
BUSINESS("business");
private final String type;
PostTypeEnum(String type) {
this.type = type;
}
public String getType() {
return type;
}
public static boolean isValid(String type) {
return Arrays.stream(values()).anyMatch(item -> item.type.equals(type));
}
}

View File

@@ -0,0 +1,28 @@
package com.njcn.msgpush.module.system.enums.logger;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* API 异常数据的处理状态
*
* @author hongawen
*/
@AllArgsConstructor
@Getter
public enum ApiErrorLogProcessStatusEnum {
INIT(0, "未处理"),
DONE(1, "已处理"),
IGNORE(2, "已忽略");
/**
* 状态
*/
private final Integer status;
/**
* 资源类型名
*/
private final String name;
}

View File

@@ -0,0 +1,38 @@
package com.njcn.msgpush.module.system.enums.permission;
import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 菜单路由类型枚举
*/
@Getter
@AllArgsConstructor
public enum MenuRouteKindEnum {
DIR("dir"), // 目录路由
VIEW("view"), // 普通页面
SINGLE("single"), // 顶级单页
IFRAME("iframe"), // iframe 页面
EXTERNAL("external"), // 外链页面
REDIRECT("redirect"); // 重定向路由
/**
* 路由类型值
*/
private final String kind;
public static MenuRouteKindEnum valueOfKind(String kind) {
if (StrUtil.isBlank(kind)) {
return null;
}
for (MenuRouteKindEnum value : values()) {
if (StrUtil.equalsIgnoreCase(value.getKind(), StrUtil.trim(kind))) {
return value;
}
}
return null;
}
}