完成项目整体结构搭建,包含: 1. 前端Vue3+TS+Vite+Antd项目基础配置与核心依赖 2. 后端MidwayJS+TypeORM+JWT权限认证框架 3. 完整的用户、角色、权限、日志数据库表结构 4. 核心业务模块API与基础服务实现 5. 全局样式、路由、状态管理配置
113 lines
1.9 KiB
TypeScript
113 lines
1.9 KiB
TypeScript
import { Column, Model, Table, DataType, CreatedAt } from "sequelize-typescript";
|
|
|
|
@Table({
|
|
tableName: "operation_logs",
|
|
comment: "操作日志表",
|
|
timestamps: true,
|
|
createdAt: "created_at",
|
|
updatedAt: false
|
|
})
|
|
export default class OperationLog extends Model {
|
|
@Column({
|
|
type: DataType.BIGINT,
|
|
autoIncrement: true,
|
|
primaryKey: true
|
|
})
|
|
id!: number;
|
|
|
|
@Column({
|
|
type: DataType.BIGINT,
|
|
field: "user_id",
|
|
comment: "操作用户ID"
|
|
})
|
|
userId!: number;
|
|
|
|
@Column({
|
|
type: DataType.STRING(50),
|
|
field: "username",
|
|
comment: "操作人用户名"
|
|
})
|
|
username!: string;
|
|
|
|
@Column({
|
|
type: DataType.STRING(255),
|
|
allowNull: false,
|
|
field: "action",
|
|
comment: "操作描述"
|
|
})
|
|
action!: string;
|
|
|
|
@Column({
|
|
type: DataType.STRING(50),
|
|
field: "module",
|
|
comment: "操作模块"
|
|
})
|
|
module!: string;
|
|
|
|
@Column({
|
|
type: DataType.STRING(10),
|
|
field: "method",
|
|
comment: "请求方法(GET/POST/PUT/DELETE等)"
|
|
})
|
|
method!: string;
|
|
|
|
@Column({
|
|
type: DataType.STRING(500),
|
|
field: "url",
|
|
comment: "请求URL"
|
|
})
|
|
url!: string;
|
|
|
|
@Column({
|
|
type: DataType.STRING(45),
|
|
field: "ip_address",
|
|
comment: "IP地址(支持IPv6)"
|
|
})
|
|
ipAddress!: string;
|
|
|
|
@Column({
|
|
type: DataType.STRING(500),
|
|
field: "user_agent",
|
|
comment: "浏览器UA"
|
|
})
|
|
userAgent!: string;
|
|
|
|
@Column({
|
|
type: DataType.TEXT,
|
|
field: "request_params",
|
|
comment: "请求参数(JSON格式)"
|
|
})
|
|
requestParams!: string;
|
|
|
|
@Column({
|
|
type: DataType.TEXT,
|
|
field: "response_data",
|
|
comment: "响应数据(JSON格式)"
|
|
})
|
|
responseData!: string;
|
|
|
|
@Column({
|
|
type: DataType.INTEGER,
|
|
field: "status_code",
|
|
comment: "HTTP响应状态码"
|
|
})
|
|
statusCode!: number;
|
|
|
|
@Column({
|
|
type: DataType.INTEGER,
|
|
field: "duration",
|
|
comment: "请求耗时(毫秒)"
|
|
})
|
|
duration!: number;
|
|
|
|
@Column({
|
|
type: DataType.TEXT,
|
|
field: "error_message",
|
|
comment: "错误信息(仅失败时记录)"
|
|
})
|
|
errorMessage!: string;
|
|
|
|
@CreatedAt
|
|
created_at!: Date;
|
|
}
|