chore(content): merge content full implementation into main
Merge feat/content-ai09 with complete content service
This commit is contained in:
@@ -1,23 +1,41 @@
|
||||
import {
|
||||
mysqlTable,
|
||||
char,
|
||||
varchar,
|
||||
text,
|
||||
int,
|
||||
tinyint,
|
||||
timestamp,
|
||||
json,
|
||||
index,
|
||||
} from "drizzle-orm/mysql-core";
|
||||
|
||||
export const questions = mysqlTable("content_questions", {
|
||||
id: char("id", { length: 36 }).notNull().primaryKey(),
|
||||
knowledgePointId: char("knowledge_point_id", { length: 36 }).notNull(),
|
||||
type: varchar("type", { length: 50 }).notNull(),
|
||||
content: text("content").notNull(),
|
||||
answer: text("answer"),
|
||||
explanation: text("explanation"),
|
||||
difficulty: int("difficulty").default(3),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow().onUpdateNow(),
|
||||
});
|
||||
export const questions = mysqlTable(
|
||||
"content_questions",
|
||||
{
|
||||
id: varchar("id", { length: 32 }).notNull().primaryKey(),
|
||||
knowledgePointId: varchar("knowledge_point_id", { length: 32 }).notNull(),
|
||||
type: varchar("type", { length: 32 }).notNull(),
|
||||
content: text("content").notNull(),
|
||||
options: json("options").$type<Record<string, unknown> | null>(),
|
||||
answer: text("answer").notNull(),
|
||||
explanation: text("explanation"),
|
||||
difficulty: tinyint("difficulty").notNull().default(3),
|
||||
status: varchar("status", { length: 32 }).notNull().default("draft"),
|
||||
source: varchar("source", { length: 32 }).notNull().default("manual"),
|
||||
createdBy: varchar("created_by", { length: 32 }).notNull(),
|
||||
metadata: json("metadata").$type<Record<string, unknown> | null>(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow().onUpdateNow(),
|
||||
},
|
||||
(table) => ({
|
||||
kpIdx: index("idx_questions_kp").on(table.knowledgePointId),
|
||||
typeDifficultyIdx: index("idx_questions_type_difficulty").on(
|
||||
table.type,
|
||||
table.difficulty,
|
||||
),
|
||||
statusIdx: index("idx_questions_status").on(table.status),
|
||||
sourceIdx: index("idx_questions_source").on(table.source),
|
||||
}),
|
||||
);
|
||||
|
||||
export type Question = typeof questions.$inferSelect;
|
||||
export type NewQuestion = typeof questions.$inferInsert;
|
||||
|
||||
Reference in New Issue
Block a user