refactor api

This commit is contained in:
Timi
2026-08-27 16:08:56 +08:00
parent 6fa75b3045
commit eef7a78fe9
62 changed files with 835 additions and 2057 deletions
-52
View File
@@ -1,52 +0,0 @@
import type { Attachment } from "./Attachment";
import type { Comment } from "./Comment";
import type { Model } from "./Model";
import type { Setting } from "./Setting";
/** 文章业务类型 */
export type ArticleBizType = "BLOG" | "FEEDBACK";
/** 文章正文类型 */
export type ArticleContentType = "TEXT" | "MARKDOWN" | "TIP_TAP";
/** 文章状态 */
export type ArticleStatus = "DART" | "NORMAL" | "HIDDEN";
/** 文章实体 */
export type Article = {
/** 业务类型 */
bizType?: ArticleBizType;
/** 业务 ID */
bizId?: string;
/** 标题 */
title?: string;
/** 描述 */
description?: string;
/** 正文类型 */
contentType?: ArticleContentType;
/** 正文内容 */
content?: string;
/** 阅读数量 */
reads?: number;
/** 喜欢数量 */
likes?: number;
/** 文章状态 */
status?: ArticleStatus;
/** 设置列表 */
settingList?: Setting[];
/** 评论列表 */
commentList?: Comment[];
/** 附件列表 */
attachmentList?: Attachment[];
} & Model;
-48
View File
@@ -1,48 +0,0 @@
import { Model } from "./Model";
export type Attachment = {
bizType?: AttachmentBizType;
bizId?: string;
attachType?: string;
mongoId?: string;
title?: string;
name?: string;
mimeType?: string;
metadata?: Record<string, any>;
accessKey?: AttachmentAccessKey;
size?: number;
md5?: string;
uploaderIp?: string;
isDestroyed?: boolean;
destroyAt?: number;
tempFileId?: string;
} & Model;
export type TempFile = {
id: string;
expireAt?: number;
};
export type BizIdUpdate = {
bizType: AttachmentBizType;
bizId: string;
items: Partial<Attachment>[];
};
export type AttachmentBizType =
| "ARTICLE"
| "USER"
| "GAO_CUSTOMER"
| "GAO_EVENT_RECORD"
| "GAO_REGISTER_RECORD"
| "TEMP_FILE"
| "MIRROR";
/** 附件访问密钥 */
export type AttachmentAccessKey = {
value: string;
attachmentId: string;
isDisposable: boolean;
expiredAt: number;
createdAt: number;
};
-34
View File
@@ -1,34 +0,0 @@
import { Model, Page } from "./Model";
import { User } from "./User";
/** 评论 */
export type Comment = {
bizType?: CommentBizType;
bizId?: number;
userId?: number;
nick?: string;
content?: string;
/** 所属用户 */
user?: User;
/** 回复列表 */
replies?: Comment[];
/** 回复分页 */
repliesPage?: Page<Comment>;
/** 用于绑定组件当前页下标 */
repliesCurrent?: number;
/** 回复数量 */
repliesLength?: number;
/** 关联文章 */
article?: object;
/** 关联 Git 仓库 */
repository?: object;
} & Model
export type CommentBizType = "ARTICLE" | "GIT_ISSUE" | "GIT_MERGE";
-6
View File
@@ -1,6 +0,0 @@
/** 开发者配置 */
export type Developer = {
developerId?: number;
name?: string;
rsa?: string;
}
-60
View File
@@ -1,60 +0,0 @@
// 基本实体模型
export type Model = {
id?: string;
createdAt?: number;
updatedAt?: number;
deletedAt?: number;
}
export type ApiResponse<T> = {
code: number;
message: string;
messageCode: string;
success: boolean;
fail: boolean;
data: T;
}
export type Page<T> = {
orderMap?: { [K in keyof T]?: OrderType };
equalsExample?: Partial<T>;
likesExample?: Partial<T>;
} & BasePage;
export type BasePage = {
index: number;
size: number;
}
export type OrderType = "ASC" | "DESC";
export type PageResult<T> = {
total: number;
list: T[];
}
// 携带验证码的请求体
export type CaptchaData<T> = {
captchaId: string;
captcha: string;
data: T;
}
// 图形验证码
export type CaptchaResult = {
id: string;
data: string;
}
export type ImageType = "IR-AUTO" | "IR-SMOOTH" | "IR-PIXELATED";
export type KeyValue<V, K = string> = {
key: K;
value?: V;
}
export type LabelValue<L, V = string> = {
label: L;
value?: V;
}
-70
View File
@@ -1,70 +0,0 @@
import type { Model } from "./Model";
import type { Attachment } from "./Attachment";
import type { User } from "./User";
/** 通知消息类型 */
export type NotifyMsgType = "INTERNAL" | "SMS" | "MAIL" | "HTTP" | "WECHAT";
/** 通知投递状态 */
export type NotifyStatus = "WAITING" | "REMINDED" | "TIMEOUT" | "CANCEL" | "FAIL";
/** 通知内容类型 */
export type NotifyContentType = "TEXT" | "TIP_TAP";
/** 通知 */
export type Notify = {
/** 业务类型 */
bizType?: string;
/** 提醒业务类型 */
bizRemindedType?: string;
/** 提醒业务 ID */
bizRemindedId?: string;
/** 参数 */
args?: string;
/** 创建者 */
createdBy?: string;
/** 通知详情列表 */
detailList?: NotifyDetail[];
} & Model;
/** 通知详情 */
export type NotifyDetail = {
/** 所属通知 ID */
notifyId?: string;
/** 消息类型 */
msgType?: NotifyMsgType;
/** 模板 ID */
templateId?: string;
/** 标题 */
subject?: string;
/** 内容 */
content?: string;
/** 内容类型 */
contentType?: NotifyContentType;
/** 媒体附件列表 */
attachmentList?: Attachment[];
/** 参数 */
args?: string;
/** 发送来源 */
sendFrom?: string;
/** 发送去向 */
sendTo?: string;
/** 发送时间 */
sendAt?: number;
/** 重试计数 */
retry?: number;
/** 超时时间 */
timeoutAt?: number;
/** 结果描述 */
resultDesc?: string;
/** 投递状态 */
status?: NotifyStatus;
/** 已读时间,站内通知未读时为空 */
readAt?: number;
/** 所属通知 */
notify?: Notify;
/** 发送用户 */
fromUser?: User;
/** 接收用户 */
toUser?: User;
} & Model;
-24
View File
@@ -1,24 +0,0 @@
export type ModuleCode = "CORE" | "GAO";
export interface Permission {
id: string;
moduleCode: ModuleCode;
code: string;
nameLangId?: string;
name?: string;
description?: string;
builtin?: boolean;
protectedPermission?: boolean;
ownerType?: AuthOwnerType;
ownerId?: string;
createdBy?: string;
createdAt?: number;
updatedAt?: number;
deletedAt?: number;
}
export type AuthOwnerType = "SYSTEM" | "MODULE" | "TENANT" | "STORE" | "USER";
export type PermissionPayload = Pick<Permission, "moduleCode" | "code" | "nameLangId" | "name" | "description"> & {
id?: string;
};
-41
View File
@@ -1,41 +0,0 @@
import type { AuthOwnerType, ModuleCode, Permission } from "./Permission";
import { Model } from "./Model";
export type Role = {
moduleCode: ModuleCode;
code: string;
nameLangId?: string;
name?: string;
description?: string;
builtin?: boolean;
protectedRole?: boolean;
parentRoleId?: string;
ownerType?: AuthOwnerType;
ownerId?: string;
createdBy?: string;
permissionList?: Permission[];
allPermissionList?: Permission[];
childRoleList?: Role[];
parentRole?: Role;
delegationPermissionList?: Permission[];
permissionIdList?: string[];
childRoleIdList?: string[];
delegationPermissionIdList?: string[];
} & Model;
export type RolePayload = Partial<Pick<Role, "moduleCode" | "code" | "nameLangId" | "name" | "description">> & {
id?: string;
parentRoleId?: string;
ownerType?: AuthOwnerType;
ownerId?: string;
permissionIdList?: string[];
childRoleIdList?: string[];
delegationPermissionIdList?: string[];
};
export interface AuthorizeUserRole {
userId: string;
moduleCode?: ModuleCode;
roleIdList?: string[];
}
-27
View File
@@ -1,27 +0,0 @@
import {Model} from "./Model";
export type SettingValueType =
| "STRING"
| "SELECT_RADIO"
| "SELECT_CHECKBOX"
| "INTEGER"
| "COLOR"
| "FLOAT"
| "DATE"
| "DATETIME"
| "TIME"
| "DURATION"
| "BOOLEAN"
| "JSON_LIST"
| "JSON_OBJECT"
;
export type Setting = {
module: string;
key: string;
title?: string;
description?: string;
value?: string;
valueType: SettingValueType;
valueArgs?: any;
} & Model;
-83
View File
@@ -1,83 +0,0 @@
import { ImageType, Model } from "./Model";
import { Attachment } from "./Attachment";
import type { Setting } from "./Setting";
import { Role } from "./Role";
export type Gender = "MALE" | "FEMALE";
export type User = {
name: string;
nick?: string;
password?: string;
email?: string;
emailVerifyAt?: number;
phoneNo?: string;
phoneNoVerifyAt?: number;
wrapperType?: ImageType;
avatarType?: ImageType;
exp?: number;
gender?: Gender;
birthdate?: number;
qq?: string;
description?: string;
lastLoginIP?: string;
lastLoginAt?: number;
unmuteAt?: number;
unbanAt?: number;
roleList?: string[];
roleEntityList?: Role[];
permissionList?: string[];
attachmentList?: Attachment[];
settingList?: Setting[];
tempFileIdList?: string[];
muting?: boolean;
banning?: boolean;
emailVerified?: boolean;
phoneNoVerified?: boolean;
} & Model;
export type UserAttachType = "AVATAR" | "WRAPPER";
export type RegisterRequest = {
name: string;
password: string;
email?: string;
};
export type LoginRequest = {
user: string;
password: string;
};
export type SmsLoginRequest = {
detailId: string;
captcha: string;
};
export type UpdatePasswordRequest = {
oldValue: string;
newValue: string;
};
// 登录返回
export type LoginResponse = {
id: string;
token: string;
expireAt: number;
user?: User;
};
export type LoginUser = {
id?: string;
token?: string;
expireAt?: number;
user?: User;
};
export type UserLevelType = {
exp: number; // 经验数值,和 UserData.exp 一样
value: number; // 经验对应等级,[0, 8]
percent: number; // 该经验在该等级的百分比 [0, 1]
nextLevelUp: number; // 下一级经验值
}
-12
View File
@@ -1,17 +1,5 @@
import type { Plugin } from "vue";
export * from "./Model";
export * from "./Article";
export * from "./Setting";
export * from "./Attachment";
export * from "./Model";
export * from "./Permission";
export * from "./Role";
export * from "./User";
export * from "./Comment";
export * from "./Developer";
export * from "./Notify";
/**
* 安装方法
*/
+10
View File
@@ -0,0 +1,10 @@
import type { Directive } from "vue";
import type { PopupConfig } from "../utils/directives/Popup";
declare module "vue" {
export interface GlobalDirectives {
popup: Directive<HTMLElement, string | PopupConfig>;
}
}
export {};