change varchar to text

This commit is contained in:
2026-01-08 10:18:05 +08:00
parent a55e763525
commit c7cdf40f2f
5 changed files with 24 additions and 15 deletions

View File

@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE "pairs" ALTER COLUMN "language1" SET DATA TYPE TEXT,
ALTER COLUMN "language2" SET DATA TYPE TEXT;
-- AlterTable
ALTER TABLE "translation_history" ALTER COLUMN "source_language" SET DATA TYPE TEXT,
ALTER COLUMN "target_language" SET DATA TYPE TEXT;

View File

@@ -77,8 +77,8 @@ model Pair {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
text1 String text1 String
text2 String text2 String
language1 String @db.VarChar(20) language1 String
language2 String @db.VarChar(20) language2 String
ipa1 String? ipa1 String?
ipa2 String? ipa2 String?
folderId Int @map("folder_id") folderId Int @map("folder_id")
@@ -194,8 +194,8 @@ model TranslationHistory {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
userId String? @map("user_id") userId String? @map("user_id")
sourceText String @map("source_text") sourceText String @map("source_text")
sourceLanguage String @map("source_language") @db.VarChar(20) sourceLanguage String @map("source_language")
targetLanguage String @map("target_language") @db.VarChar(20) targetLanguage String @map("target_language")
translatedText String @map("translated_text") translatedText String @map("translated_text")
sourceIpa String? @map("source_ipa") sourceIpa String? @map("source_ipa")
targetIpa String? @map("target_ipa") targetIpa String? @map("target_ipa")

View File

@@ -57,8 +57,7 @@ export default function Dictionary() {
const result = await lookUp({ const result = await lookUp({
text: searchQuery, text: searchQuery,
definitionLang: getNativeName(definitionLang), definitionLang: getNativeName(definitionLang),
queryLang: getNativeName(queryLang), queryLang: getNativeName(queryLang)
forceRelook: false
}) })
// 检查是否为错误响应 // 检查是否为错误响应

View File

@@ -3,6 +3,7 @@
import { executeDictionaryLookup } from "./dictionary"; import { executeDictionaryLookup } from "./dictionary";
import { createLookUp, createPhrase, createWord, createPhraseEntry, createWordEntry, selectLastLookUp } from "../services/dictionaryService"; import { createLookUp, createPhrase, createWord, createPhraseEntry, createWordEntry, selectLastLookUp } from "../services/dictionaryService";
import { DictLookUpRequest, DictWordResponse, isDictErrorResponse, isDictPhraseResponse, isDictWordResponse, type DictLookUpResponse } from "@/lib/shared"; import { DictLookUpRequest, DictWordResponse, isDictErrorResponse, isDictPhraseResponse, isDictWordResponse, type DictLookUpResponse } from "@/lib/shared";
import { text } from "node:stream/consumers";
const saveResult = async (req: DictLookUpRequest, res: DictLookUpResponse) => { const saveResult = async (req: DictLookUpRequest, res: DictLookUpResponse) => {
if (isDictErrorResponse(res)) return; if (isDictErrorResponse(res)) return;
@@ -73,13 +74,15 @@ const saveResult = async (req: DictLookUpRequest, res: DictLookUpResponse) => {
* - 阶段5错误处理 * - 阶段5错误处理
* - 阶段6最终输出封装 * - 阶段6最终输出封装
*/ */
export const lookUp = async ({ export const lookUp = async (req: DictLookUpRequest): Promise<DictLookUpResponse> => {
const {
text, text,
queryLang, queryLang,
forceRelook = false,
definitionLang, definitionLang,
userId, userId
forceRelook = false } = req;
}: DictLookUpRequest): Promise<DictLookUpResponse> => {
try { try {
const lastLookUp = await selectLastLookUp({ const lastLookUp = await selectLastLookUp({
text, text,
@@ -136,6 +139,6 @@ export const lookUp = async ({
} }
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return { error: "LOOK_UP_ERROR" }; return { error: "look up error" };
} }
}; };

View File

@@ -3,7 +3,7 @@ export type DictLookUpRequest = {
queryLang: string, queryLang: string,
definitionLang: string, definitionLang: string,
userId?: string, userId?: string,
forceRelook: boolean; forceRelook?: boolean;
}; };
export type DictWordEntry = { export type DictWordEntry = {