From 111498a65f3c5da0986446fa72d00bea1c947e66 Mon Sep 17 00:00:00 2001 From: liangxu Date: Thu, 2 Apr 2026 11:38:08 +0800 Subject: [PATCH] feat: Refactor template handling and brand management - Removed schema_json from article templates and related queries. - Updated brand service to include website field in requests and responses. - Simplified template wizard view by eliminating unused schema fields and related logic. - Added tests for ark text format handling. - Created migrations for dropping schema_json and adding website to brands. --- .gitignore | 2 +- apps/admin-web/src/i18n/messages/en-US.ts | 1 + apps/admin-web/src/i18n/messages/zh-CN.ts | 1 + apps/admin-web/src/views/BrandsView.vue | 179 ++++++++++++------ .../src/views/TemplateWizardView.vue | 173 +---------------- packages/shared-types/src/index.ts | 19 +- server/cmd/dev-seed/main.go | 19 +- server/internal/shared/llm/ark.go | 58 +++--- server/internal/shared/llm/ark_test.go | 65 +++++++ server/internal/tenant/app/brand_service.go | 53 ++++-- .../internal/tenant/app/template_service.go | 17 +- .../tenant/domain/article_template.go | 1 - server/internal/tenant/domain/brand.go | 1 + .../tenant/repository/generated/models.go | 1 - .../tenant/repository/generated/querier.go | 1 - .../repository/generated/template.sql.go | 27 +-- .../tenant/repository/queries/template.sql | 9 +- .../tenant/repository/template_cache_repo.go | 4 - .../tenant/repository/template_repo.go | 23 --- server/internal/tenant/transport/router.go | 1 - .../tenant/transport/template_handler.go | 14 -- ...drop_article_template_schema_json.down.sql | 2 + ...0_drop_article_template_schema_json.up.sql | 2 + .../20260402113000_add_brand_website.down.sql | 2 + .../20260402113000_add_brand_website.up.sql | 2 + 25 files changed, 298 insertions(+), 379 deletions(-) create mode 100644 server/internal/shared/llm/ark_test.go create mode 100644 server/migrations/20260402110000_drop_article_template_schema_json.down.sql create mode 100644 server/migrations/20260402110000_drop_article_template_schema_json.up.sql create mode 100644 server/migrations/20260402113000_add_brand_website.down.sql create mode 100644 server/migrations/20260402113000_add_brand_website.up.sql diff --git a/.gitignore b/.gitignore index adebf2d..e1e0ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ dist/ .env.local apps/*/dist/ apps/*/node_modules/ - +.claude \ No newline at end of file diff --git a/apps/admin-web/src/i18n/messages/en-US.ts b/apps/admin-web/src/i18n/messages/en-US.ts index 670a238..cec8ac1 100644 --- a/apps/admin-web/src/i18n/messages/en-US.ts +++ b/apps/admin-web/src/i18n/messages/en-US.ts @@ -447,6 +447,7 @@ const enUS = { }, form: { brandName: "Brand name", + brandWebsite: "Company website (optional)", brandDescription: "Brand description", keywordName: "Keyword", questionText: "Question text", diff --git a/apps/admin-web/src/i18n/messages/zh-CN.ts b/apps/admin-web/src/i18n/messages/zh-CN.ts index 5d93a09..a402f38 100644 --- a/apps/admin-web/src/i18n/messages/zh-CN.ts +++ b/apps/admin-web/src/i18n/messages/zh-CN.ts @@ -454,6 +454,7 @@ const zhCN = { }, form: { brandName: "品牌名称", + brandWebsite: "公司官网(选填)", brandDescription: "品牌描述", keywordName: "关键词名称", questionText: "问题内容", diff --git a/apps/admin-web/src/views/BrandsView.vue b/apps/admin-web/src/views/BrandsView.vue index b0b0d09..299d344 100644 --- a/apps/admin-web/src/views/BrandsView.vue +++ b/apps/admin-web/src/views/BrandsView.vue @@ -12,7 +12,6 @@ import type { TableColumnsType } from "ant-design-vue"; import { computed, reactive, ref, watch } from "vue"; import { useI18n } from "vue-i18n"; -import PageHero from "@/components/PageHero.vue"; import { brandsApi } from "@/lib/api"; import { formatError } from "@/lib/errors"; @@ -36,6 +35,7 @@ const editingCompetitorId = ref(null); const brandForm = reactive({ name: "", + website: "", description: "", }); @@ -60,12 +60,6 @@ const brandListQuery = useQuery({ queryFn: () => brandsApi.list(), }); -const brandDetailQuery = useQuery({ - queryKey: computed(() => ["brands", "detail", selectedBrandId.value]), - enabled: computed(() => Boolean(selectedBrandId.value)), - queryFn: () => brandsApi.detail(selectedBrandId.value as number), -}); - const keywordsQuery = useQuery({ queryKey: computed(() => ["brands", selectedBrandId.value, "keywords"]), enabled: computed(() => Boolean(selectedBrandId.value)), @@ -101,6 +95,7 @@ const brandMutations = { mutationFn: () => brandsApi.create({ name: brandForm.name.trim(), + website: brandForm.website.trim() || null, description: brandForm.description.trim() || null, }), onSuccess: async (brand) => { @@ -118,6 +113,7 @@ const brandMutations = { mutationFn: () => brandsApi.update(editingBrandId.value as number, { name: brandForm.name.trim(), + website: brandForm.website.trim() || null, description: brandForm.description.trim() || null, }), onSuccess: async () => { @@ -274,7 +270,6 @@ const competitorMutations = { }), }; -const selectedBrand = computed(() => brandDetailQuery.data.value); const selectedKeyword = computed(() => keywordsQuery.data.value?.find((item) => item.id === selectedKeywordId.value) ?? null, ); @@ -345,6 +340,7 @@ function stringifyProductLines(value: unknown): string { function openBrandModal(brand?: Brand): void { editingBrandId.value = brand?.id ?? null; brandForm.name = brand?.name ?? ""; + brandForm.website = brand?.website ?? ""; brandForm.description = brand?.description ?? ""; brandModalOpen.value = true; } @@ -439,18 +435,21 @@ async function submitCompetitor(): Promise {