refactor: 项目结构优化调整

This commit is contained in:
Ray.Hao
2025-12-20 21:56:48 +08:00
parent 5851976c5d
commit 65ad4fe59f
68 changed files with 2463 additions and 1761 deletions

147
src/types/api/ai.ts Normal file
View File

@@ -0,0 +1,147 @@
/**
* AI 模块类型定义
*/
/** AI命令请求参数 */
export interface AiCommandRequest {
/** 用户输入的自然语言命令 */
command: string;
/** 当前页面路由(用于上下文) */
currentRoute?: string;
/** 当前激活的组件名称 */
currentComponent?: string;
/** 额外上下文信息 */
context?: Record<string, any>;
}
/** 函数调用参数 */
export interface FunctionCall {
/** 函数名称 */
name: string;
/** 函数描述 */
description?: string;
/** 参数对象 */
arguments: Record<string, any>;
}
/** AI命令解析响应 */
export interface AiCommandResponse {
/** 解析日志ID用于关联执行记录 */
parseLogId?: string;
/** 是否成功解析 */
success: boolean;
/** 解析后的函数调用列表 */
functionCalls: FunctionCall[];
/** AI的理解和说明 */
explanation?: string;
/** 置信度(0-1) */
confidence?: number;
/** 错误信息 */
error?: string;
/** 原始LLM响应用于调试 */
rawResponse?: string;
}
/** AI命令执行请求 */
export interface AiExecuteRequest {
/** 关联的解析日志ID */
parseLogId?: string;
/** 原始命令(用于审计) */
originalCommand?: string;
/** 要执行的函数调用 */
functionCall: FunctionCall;
/** 确认模式auto=自动执行, manual=需要用户确认 */
confirmMode?: "auto" | "manual";
/** 用户确认标志 */
userConfirmed?: boolean;
/** 幂等性令牌(防止重复执行) */
idempotencyKey?: string;
/** 当前页面路由 */
currentRoute?: string;
}
/** AI命令执行响应 */
export interface AiExecuteResponse {
/** 是否执行成功 */
success: boolean;
/** 执行结果数据 */
data?: any;
/** 执行结果说明 */
message?: string;
/** 影响的记录数 */
affectedRows?: number;
/** 错误信息 */
error?: string;
/** 记录ID用于追踪 */
recordId?: string;
/** 需要用户确认 */
requiresConfirmation?: boolean;
/** 确认提示信息 */
confirmationPrompt?: string;
}
/** AI命令记录分页查询参数 */
export interface AiCommandRecordPageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
/** 执行状态 */
executeStatus?: number;
/** 解析状态 */
parseStatus?: number;
/** 用户ID */
userId?: number;
/** AI提供商 */
aiProvider?: string;
/** AI模型 */
aiModel?: string;
/** 函数名称 */
functionName?: string;
/** 创建时间 */
createTime?: [string, string];
}
/** AI命令记录视图对象 */
export interface AiCommandRecordVo {
/** 记录ID */
id: string;
/** 用户ID */
userId: number;
/** 用户名 */
username: string;
/** 原始命令 */
originalCommand: string;
/** AI提供商 */
aiProvider?: string;
/** AI模型 */
aiModel?: string;
/** 解析状态 */
parseStatus?: number;
/** 函数调用列表 */
functionCalls?: string;
/** 解析说明 */
explanation?: string;
/** 置信度 */
confidence?: number;
/** 解析错误信息 */
parseErrorMessage?: string;
/** 输入Token数 */
inputTokens?: number;
/** 输出Token数 */
outputTokens?: number;
/** 解析耗时(毫秒) */
parseDurationMs?: number;
/** 函数名称 */
functionName?: string;
/** 函数参数 */
functionArguments?: string;
/** 执行状态 */
executeStatus?: number;
/** 执行错误信息 */
executeErrorMessage?: string;
/** IP地址 */
ipAddress?: string;
/** 创建时间 */
createTime?: string;
/** 更新时间 */
updateTime?: string;
}

99
src/types/api/codegen.ts Normal file
View File

@@ -0,0 +1,99 @@
/**
* CodeGen 代码生成类型定义
*/
/** 代码生成预览对象 */
export interface GeneratorPreviewVo {
/** 文件生成路径 */
path: string;
/** 文件名称 */
fileName: string;
/** 文件内容 */
content: string;
}
/** 数据表分页查询参数 */
export interface TablePageQuery extends PageQuery {
/** 搜索关键字(表名) */
keywords?: string;
}
/** 数据表分页对象 */
export interface TablePageVo {
/** 表名称 */
tableName: string;
/** 表描述 */
tableComment: string;
/** 是否已配置(1:是;0:否) */
isConfigured?: number;
/** 存储引擎 */
engine: string;
/** 字符集排序规则 */
tableCollation: string;
/** 创建时间 */
createTime: string;
}
/** 代码生成配置表单 */
export interface GenConfigForm {
/** 主键 */
id?: string;
/** 表名 */
tableName?: string;
/** 业务名 */
businessName?: string;
/** 模块名 */
moduleName?: string;
/** 包名 */
packageName?: string;
/** 实体名 */
entityName?: string;
/** 作者 */
author?: string;
/** 上级菜单 */
parentMenuId?: string;
/** 后端应用名 */
backendAppName?: string;
/** 前端应用名 */
frontendAppName?: string;
/** 字段配置列表 */
fieldConfigs?: FieldConfig[];
/** 页面类型 classic|curd */
pageType?: "classic" | "curd";
/** 要移除的表前缀,如 sys_ */
removeTablePrefix?: string;
}
/** 字段配置 */
export interface FieldConfig {
/** 主键 */
id?: string;
/** 列名 */
columnName?: string;
/** 列类型 */
columnType?: string;
/** 字段名 */
fieldName?: string;
/** 字段类型 */
fieldType?: string;
/** 字段描述 */
fieldComment?: string;
/** 是否在列表显示 */
isShowInList?: number;
/** 是否在表单显示 */
isShowInForm?: number;
/** 是否在查询条件显示 */
isShowInQuery?: number;
/** 是否必填 */
isRequired?: number;
/** 表单类型 */
formType?: number;
/** 查询类型 */
queryType?: number;
/** 字段长度 */
maxLength?: number;
/** 字段排序 */
fieldSort?: number;
/** 字典类型 */
dictType?: string;
}

View File

@@ -2,31 +2,50 @@
* 通用 API 类型定义
*/
/** API 响应结构 */
export interface ApiResponse<T = any> {
/** 响应码 */
code: string;
/** 响应数据 */
data: T;
/** 响应消息 */
msg: string;
}
/** 分页查询参数 */
export interface PageQuery {
/** 页码 */
pageNum: number;
/** 每页记录数 */
pageSize: number;
}
/** 分页响应结构 */
export interface PageResult<T> {
/** 数据列表 */
list: T;
/** 总记录数 */
total: number;
}
/** 下拉选项 */
export interface OptionType {
/** 选项值 */
value: string | number;
/** 选项标签 */
label: string;
/** 子选项 */
children?: OptionType[];
}
/** Excel 导入结果 */
export interface ExcelResult {
/** 响应码 */
code: string;
/** 无效数据数量 */
invalidCount: number;
/** 有效数据数量 */
validCount: number;
/** 错误信息列表 */
messageList: string[];
}

35
src/types/api/config.ts Normal file
View File

@@ -0,0 +1,35 @@
/**
* Config 配置类型定义
*/
/** 配置分页查询参数 */
export interface ConfigPageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
}
/** 配置表单对象 */
export interface ConfigForm {
/** 配置ID */
id?: string;
/** 配置名称 */
configName?: string;
/** 配置键 */
configKey?: string;
/** 配置值 */
configValue?: string;
/** 备注 */
remark?: string;
}
/** 配置分页对象 */
export interface ConfigPageVo {
/** 配置ID */
id?: string;
/** 配置名称 */
configName?: string;
/** 配置键 */
configKey?: string;
/** 配置值 */
configValue?: string;
}

49
src/types/api/dept.ts Normal file
View File

@@ -0,0 +1,49 @@
/**
* Dept 部门类型定义
*/
/** 部门查询参数 */
export interface DeptQuery {
/** 搜索关键字 */
keywords?: string;
/** 状态 */
status?: number;
}
/** 部门视图对象 */
export interface DeptVo {
/** 子部门 */
children?: DeptVo[];
/** 创建时间 */
createTime?: Date;
/** 部门ID */
id?: string;
/** 部门名称 */
name?: string;
/** 父部门ID */
parentId?: string;
/** 排序 */
sort?: number;
/** 状态(1:启用0:禁用) */
status?: number;
/** 父节点ID路径 */
treePath?: string;
/** 修改时间 */
updateTime?: Date;
}
/** 部门表单对象 */
export interface DeptForm {
/** 部门ID */
id?: string;
/** 部门名称 */
name?: string;
/** 部门编号 */
code?: string;
/** 父部门ID */
parentId?: string;
/** 排序 */
sort?: number;
/** 状态(1:启用0:禁用) */
status?: number;
}

90
src/types/api/dict.ts Normal file
View File

@@ -0,0 +1,90 @@
/**
* Dict 字典类型定义
*/
/** 字典分页查询参数 */
export interface DictPageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
/** 状态(1:启用;0:禁用) */
status?: number;
}
/** 字典分页对象 */
export interface DictPageVo {
/** 字典ID */
id: string;
/** 字典名称 */
name: string;
/** 字典编码 */
dictCode: string;
/** 状态(1:启用;0:禁用) */
status: number;
}
/** 字典表单对象 */
export interface DictForm {
/** 字典ID */
id?: string;
/** 字典名称 */
name?: string;
/** 字典编码 */
dictCode?: string;
/** 状态(1:启用;0:禁用) */
status?: number;
/** 备注 */
remark?: string;
}
/** 字典项分页查询参数 */
export interface DictItemPageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
/** 字典编码 */
dictCode?: string;
}
/** 字典项分页对象 */
export interface DictItemPageVo {
/** 字典项ID */
id: string;
/** 字典编码 */
dictCode: string;
/** 字典项标签 */
label: string;
/** 字典项值 */
value: string;
/** 状态(1:启用;0:禁用) */
status: number;
/** 排序 */
sort?: number;
}
/** 字典项表单对象 */
export interface DictItemForm {
/** 字典项ID */
id?: string;
/** 字典编码 */
dictCode?: string;
/** 字典项标签 */
label?: string;
/** 字典项值 */
value?: string;
/** 状态(1:启用;0:禁用) */
status?: number;
/** 排序 */
sort?: number;
/** 标签类型 */
tagType?: "success" | "warning" | "info" | "primary" | "danger" | "";
}
/** 字典项选项 */
export interface DictItemOption {
/** 字典项值 */
value: number | string;
/** 字典项标签 */
label: string;
/** 标签类型 */
tagType?: "success" | "warning" | "info" | "primary" | "danger" | "";
}

11
src/types/api/file.ts Normal file
View File

@@ -0,0 +1,11 @@
/**
* File 文件上传类型定义
*/
/** 文件信息 */
export interface FileInfo {
/** 文件名称 */
name: string;
/** 文件URL */
url: string;
}

View File

@@ -2,5 +2,22 @@
* API 类型统一导出
*/
export * from "./common";
export * from "./auth";
export * from "./common";
// System 模块
export * from "./user";
export * from "./role";
export * from "./menu";
export * from "./dept";
export * from "./dict";
export * from "./config";
export * from "./log";
export * from "./statistics";
export * from "./notice";
export * from "./tenant";
// 其他模块
export * from "./ai";
export * from "./file";
export * from "./codegen";

37
src/types/api/log.ts Normal file
View File

@@ -0,0 +1,37 @@
/**
* Log 日志类型定义
*/
/** 日志分页查询参数 */
export interface LogPageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
/** 操作时间 */
createTime?: [string, string];
}
/** 日志分页对象 */
export interface LogPageVo {
/** 日志ID */
id: string;
/** 日志模块 */
module: string;
/** 日志内容 */
content: string;
/** 请求路径 */
requestUri: string;
/** 请求方法 */
method: string;
/** IP地址 */
ip: string;
/** 地区 */
region: string;
/** 浏览器 */
browser: string;
/** 终端系统 */
os: string;
/** 执行时间(毫秒) */
executionTime: number;
/** 操作人 */
operator: string;
}

103
src/types/api/menu.ts Normal file
View File

@@ -0,0 +1,103 @@
/**
* Menu 菜单类型定义
*/
/** 菜单查询参数 */
export interface MenuQuery {
/** 搜索关键字 */
keywords?: string;
}
/** 菜单视图对象 */
export interface MenuVo {
/** 子菜单 */
children?: MenuVo[];
/** 组件路径 */
component?: string;
/** ICON */
icon?: string;
/** 菜单ID */
id?: string;
/** 菜单名称 */
name?: string;
/** 父菜单ID */
parentId?: string;
/** 路由路径 */
path?: string;
/** 按钮权限标识 */
perm?: string;
/** 跳转路径 */
redirect?: string;
/** 菜单排序(数字越小排名越靠前) */
sort?: number;
/** 菜单类型C-目录 M-菜单 B-按钮) */
type?: string;
/** 菜单是否可见(1:显示;0:隐藏) */
visible?: number;
}
/** 菜单表单对象 */
export interface MenuForm {
/** 菜单ID */
id?: string;
/** 父菜单ID */
parentId?: string;
/** 菜单名称 */
name?: string;
/** 菜单类型C-目录 M-菜单 B-按钮) */
type?: string;
/** 路由路径 */
path?: string;
/** 跳转路径 */
redirect?: string;
/** 组件路径 */
component?: string;
/** ICON */
icon?: string;
/** 排序 */
sort?: number;
/** 菜单是否可见 */
visible?: number;
/** 按钮权限标识 */
perm?: string;
}
/** 菜单选项 */
export interface MenuOption {
key: string;
value: string;
}
/** 路由对象 */
export interface RouteVo {
/** 子路由列表 */
children: RouteVo[];
/** 组件路径 */
component?: string;
/** 路由名称 */
name?: string;
/** 路由路径 */
path?: string;
/** 路由属性 */
meta?: Meta;
/** 跳转链接 */
redirect?: string;
}
/** 路由属性 */
export interface Meta {
/** 【目录】只有一个子路由是否始终显示 */
alwaysShow?: boolean;
/** 是否隐藏(true-是 false-否) */
hidden?: boolean;
/** ICON */
icon?: string;
/** 【菜单】是否开启页面缓存 */
keepAlive?: boolean;
/** 路由参数 */
params?: Record<string, any>;
/** 角色集合 */
roles?: string[];
/** 路由title */
title?: string;
}

71
src/types/api/notice.ts Normal file
View File

@@ -0,0 +1,71 @@
/**
* Notice 通知类型定义
*/
/** 通知分页查询参数 */
export interface NoticePageQuery extends PageQuery {
/** 通知标题 */
title?: string;
/** 发布状态(0:草稿;1:已发布;2:已撤回) */
publishStatus?: number;
/** 是否已读(1:是;0:否) */
isRead?: number;
}
/** 通知表单对象 */
export interface NoticeForm {
/** 通知ID */
id?: string;
/** 通知标题 */
title?: string;
/** 通知内容 */
content?: string;
/** 通知类型 */
type?: number;
/** 通知等级 */
level?: string;
/** 发布状态(0:草稿;1:已发布;2:已撤回) */
publishStatus?: number;
/** 目标用户ID(多个以英文逗号(,)分割) */
targetUserIds?: string;
}
/** 通知分页对象 */
export interface NoticePageVo {
/** 通知ID */
id: string;
/** 通知标题 */
title: string;
/** 通知内容 */
content: string;
/** 通知类型 */
type: number;
/** 通知等级 */
level: string;
/** 发布状态 */
publishStatus: number;
/** 是否已读 */
isRead: number;
/** 发布时间 */
publishTime?: Date;
/** 撤回时间 */
revokeTime?: Date;
}
/** 通知详情对象 */
export interface NoticeDetailVo {
/** 通知ID */
id?: string;
/** 通知标题 */
title?: string;
/** 通知内容 */
content?: string;
/** 通知类型 */
type?: number;
/** 通知等级 */
level?: string;
/** 发布状态 */
publishStatus?: number;
/** 目标用户ID */
targetUserIds?: string;
}

45
src/types/api/role.ts Normal file
View File

@@ -0,0 +1,45 @@
/**
* Role 角色类型定义
*/
/** 角色分页查询参数 */
export interface RolePageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
}
/** 角色分页对象 */
export interface RolePageVo {
/** 角色ID */
id?: string;
/** 角色编码 */
code?: string;
/** 角色名称 */
name?: string;
/** 排序 */
sort?: number;
/** 角色状态 */
status?: number;
/** 创建时间 */
createTime?: Date;
/** 修改时间 */
updateTime?: Date;
}
/** 角色表单对象 */
export interface RoleForm {
/** 角色ID */
id?: string;
/** 角色编码 */
code?: string;
/** 角色名称 */
name?: string;
/** 排序 */
sort?: number;
/** 数据权限 */
dataScope?: number;
/** 角色状态 */
status?: number;
/** 备注 */
remark?: string;
}

View File

@@ -0,0 +1,39 @@
/**
* Statistics 统计类型定义
*/
/** 访问趋势查询参数 */
export interface VisitTrendQuery {
/** 开始日期 */
startDate: string;
/** 结束日期 */
endDate: string;
}
/** 访问趋势视图对象 */
export interface VisitTrendVo {
/** 日期列表 */
dates: string[];
/** 浏览量(PV)列表 */
pvList: number[];
/** 访客数(UV)列表 */
uvList: number[];
/** IP数列表 */
ipList: number[];
}
/** 访问量统计视图对象 */
export interface VisitStatsVo {
/** 今日独立访客数(UV) */
todayUvCount: number;
/** 累计独立访客数(UV) */
totalUvCount: number;
/** 独立访客增长率 */
uvGrowthRate: number;
/** 今日页面浏览量(PV) */
todayPvCount: number;
/** 累计页面浏览量(PV) */
totalPvCount: number;
/** 页面浏览量增长率 */
pvGrowthRate: number;
}

79
src/types/api/tenant.ts Normal file
View File

@@ -0,0 +1,79 @@
/**
* Tenant 租户类型定义
*/
import type { PageQuery } from "./common";
/** 租户信息 */
export interface TenantInfo {
/** 租户ID */
id: number;
/** 租户名称 */
name: string;
/** 租户域名 */
domain?: string;
}
/** 租户分页查询参数 */
export interface TenantPageQuery extends PageQuery {
/** 关键字(租户名称/租户编码/域名) */
keywords?: string;
/** 租户状态(1-正常 0-禁用) */
status?: number;
}
/** 租户分页对象 */
export interface TenantPageVo {
id?: string;
name?: string;
code?: string;
contactName?: string;
contactPhone?: string;
contactEmail?: string;
domain?: string;
logo?: string;
status?: number;
remark?: string;
expireTime?: string;
createTime?: string;
updateTime?: string;
}
/** 租户表单对象(编辑) */
export interface TenantForm {
id?: string;
name?: string;
code?: string;
contactName?: string;
contactPhone?: string;
contactEmail?: string;
domain?: string;
logo?: string;
status?: number;
remark?: string;
expireTime?: string;
}
/** 新增租户表单对象 */
export interface TenantCreateForm {
name?: string;
code?: string;
contactName?: string;
contactPhone?: string;
contactEmail?: string;
domain?: string;
logo?: string;
remark?: string;
expireTime?: string;
adminUsername?: string;
}
/** 新增租户结果 */
export interface TenantCreateResultVo {
tenantId?: string;
tenantCode?: string;
tenantName?: string;
adminUsername?: string;
adminInitialPassword?: string;
adminRoleCode?: string;
}

149
src/types/api/user.ts Normal file
View File

@@ -0,0 +1,149 @@
/**
* User 用户类型定义
*/
/** 登录用户信息 */
export interface UserInfo {
/** 用户ID */
userId?: string;
/** 用户名 */
username?: string;
/** 用户昵称 */
nickname?: string;
/** 头像URL */
avatar?: string;
/** 角色集合 */
roles: string[];
/** 权限集合 */
perms: string[];
}
/** 用户分页查询参数 */
export interface UserPageQuery extends PageQuery {
/** 搜索关键字 */
keywords?: string;
/** 用户状态 */
status?: number;
/** 部门ID */
deptId?: string;
/** 创建时间 */
createTime?: [string, string];
}
/** 用户分页对象 */
export interface UserPageVo {
/** 用户ID */
id: string;
/** 用户头像地址 */
avatar?: string;
/** 创建时间 */
createTime?: Date;
/** 部门名称 */
deptName?: string;
/** 用户邮箱 */
email?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 用户昵称 */
nickname?: string;
/** 角色名称,多个使用英文逗号(,)分割 */
roleNames?: string;
/** 用户状态(1:启用;0:禁用) */
status?: number;
/** 用户名 */
username?: string;
}
/** 用户表单对象 */
export interface UserForm {
/** 用户ID */
id?: string;
/** 用户头像 */
avatar?: string;
/** 部门ID */
deptId?: string;
/** 用户邮箱 */
email?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 用户昵称 */
nickname?: string;
/** 角色ID集合 */
roleIds?: number[];
/** 用户状态(1:正常;0:禁用) */
status?: number;
/** 用户名 */
username?: string;
}
/** 个人中心用户信息 */
export interface UserProfileVo {
/** 用户ID */
id?: string;
/** 用户名 */
username?: string;
/** 用户昵称 */
nickname?: string;
/** 头像URL */
avatar?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 邮箱 */
email?: string;
/** 部门名称 */
deptName?: string;
/** 角色名称 */
roleNames?: string;
/** 创建时间 */
createTime?: Date;
}
/** 个人中心用户信息表单 */
export interface UserProfileForm {
/** 用户ID */
id?: string;
/** 用户名 */
username?: string;
/** 用户昵称 */
nickname?: string;
/** 头像URL */
avatar?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 邮箱 */
email?: string;
}
/** 修改密码表单 */
export interface PasswordChangeForm {
/** 原密码 */
oldPassword?: string;
/** 新密码 */
newPassword?: string;
/** 确认新密码 */
confirmPassword?: string;
}
/** 修改手机表单 */
export interface MobileUpdateForm {
/** 手机号 */
mobile?: string;
/** 验证码 */
code?: string;
}
/** 修改邮箱表单 */
export interface EmailUpdateForm {
/** 邮箱 */
email?: string;
/** 验证码 */
code?: string;
}