diff --git a/furniture-3d-system/prisma/migrations/20260828174500_complete_store_account_profiles/migration.sql b/furniture-3d-system/prisma/migrations/20260828100000_extend_store_account_profiles/migration.sql similarity index 62% rename from furniture-3d-system/prisma/migrations/20260828174500_complete_store_account_profiles/migration.sql rename to furniture-3d-system/prisma/migrations/20260828100000_extend_store_account_profiles/migration.sql index 3a4f4bfc..4b28f58c 100644 --- a/furniture-3d-system/prisma/migrations/20260828174500_complete_store_account_profiles/migration.sql +++ b/furniture-3d-system/prisma/migrations/20260828100000_extend_store_account_profiles/migration.sql @@ -1,6 +1,6 @@ ALTER TABLE "StoreAccount" -ADD COLUMN "subject" TEXT NOT NULL DEFAULT '', -ADD COLUMN "boundBankAccountNumberCiphertext" TEXT NOT NULL DEFAULT ''; + ADD COLUMN "subject" TEXT NOT NULL DEFAULT '', + ADD COLUMN "boundBankAccountNumberCiphertext" TEXT NOT NULL DEFAULT ''; CREATE TABLE "StoreAccountStoreProfile" ( "id" TEXT NOT NULL, @@ -17,11 +17,6 @@ CREATE TABLE "StoreAccountStoreProfile" ( CONSTRAINT "StoreAccountStoreProfile_pkey" PRIMARY KEY ("id") ); -CREATE UNIQUE INDEX "StoreAccountStoreProfile_storeName_platform_key" -ON "StoreAccountStoreProfile"("storeName", "platform"); - -CREATE INDEX "StoreAccountStoreProfile_storeName_idx" -ON "StoreAccountStoreProfile"("storeName"); - -CREATE INDEX "StoreAccountStoreProfile_platform_idx" -ON "StoreAccountStoreProfile"("platform"); +CREATE UNIQUE INDEX "StoreAccountStoreProfile_storeName_platform_key" ON "StoreAccountStoreProfile"("storeName", "platform"); +CREATE INDEX "StoreAccountStoreProfile_storeName_idx" ON "StoreAccountStoreProfile"("storeName"); +CREATE INDEX "StoreAccountStoreProfile_platform_idx" ON "StoreAccountStoreProfile"("platform"); diff --git a/furniture-3d-system/prisma/schema.prisma b/furniture-3d-system/prisma/schema.prisma index a909525f..b7eeb60b 100644 --- a/furniture-3d-system/prisma/schema.prisma +++ b/furniture-3d-system/prisma/schema.prisma @@ -3492,15 +3492,15 @@ model StoreAccount { operationDepartmentHead String @default("") operationDirector String @default("") profitCenter String @default("") - subject String @default("") accountType String account String passwordCiphertext String @default("") @db.Text - boundBankAccountNumberCiphertext String @default("") @db.Text boundPhone String @default("") verificationContact String @default("") jstOrderService String @default("") accountGroupName String @default("") + subject String @default("") + boundBankAccountNumberCiphertext String @default("") @db.Text createdById String? updatedById String? createdAt DateTime @default(now()) diff --git a/furniture-3d-system/src/app/api/supply-chain/store-account-management/profiles/route.ts b/furniture-3d-system/src/app/api/supply-chain/store-account-management/profiles/route.ts index c843dff3..bb86a40e 100644 --- a/furniture-3d-system/src/app/api/supply-chain/store-account-management/profiles/route.ts +++ b/furniture-3d-system/src/app/api/supply-chain/store-account-management/profiles/route.ts @@ -15,6 +15,13 @@ const profileSchema = z.object({ }).strict(), }).strict() +export async function GET(request: NextRequest) { + return handleRequest(request, async (ctx) => { + const storeName = request.nextUrl.searchParams.get('storeName') ?? '' + return jsonSuccess(await storeAccountManagementService.listStoreProfiles(storeName, ctx.user), 200, ctx.requestId) + }, { requireAuth: true }) +} + export async function PATCH(request: NextRequest) { return handleRequest(request, async (ctx) => { const body = await request.json().catch(() => null) diff --git a/furniture-3d-system/src/app/users/page.tsx b/furniture-3d-system/src/app/users/page.tsx index 0b03ec09..a96f6a77 100644 --- a/furniture-3d-system/src/app/users/page.tsx +++ b/furniture-3d-system/src/app/users/page.tsx @@ -5,7 +5,7 @@ import { RequireAuth } from '@/components/auth/RequireAuth' import { PermissionGuard } from '@/components/auth/PermissionGuard' import { UserPermissionCenter } from './components/UserPermissionCenter' -export function UserPermissionManagementPage({ +function UserPermissionManagementPage({ backHref: _backHref = '/intake', backLabel: _backLabel = '产品开发', }: { diff --git a/furniture-3d-system/src/server/repositories/store-account-management.repository.ts b/furniture-3d-system/src/server/repositories/store-account-management.repository.ts index 412ee071..6f713d6f 100644 --- a/furniture-3d-system/src/server/repositories/store-account-management.repository.ts +++ b/furniture-3d-system/src/server/repositories/store-account-management.repository.ts @@ -8,15 +8,27 @@ export type StoreAccountRecord = { operationDepartmentHead: string operationDirector: string profitCenter: string - subject: string accountType: string account: string passwordCiphertext: string - boundBankAccountNumberCiphertext: string boundPhone: string verificationContact: string jstOrderService: string accountGroupName: string + subject: string + boundBankAccountNumberCiphertext: string + createdAt: Date + updatedAt: Date +} + +export type StoreAccountProfileRecord = { + id: string + storeName: string + platform: string + merchantNumber: string + secondaryMerchantNumber: string + merchantStoreId: string + companyId: string createdAt: Date updatedAt: Date } @@ -45,15 +57,27 @@ const ACCOUNT_SELECT = { operationDepartmentHead: true, operationDirector: true, profitCenter: true, - subject: true, accountType: true, account: true, passwordCiphertext: true, - boundBankAccountNumberCiphertext: true, boundPhone: true, verificationContact: true, jstOrderService: true, accountGroupName: true, + subject: true, + boundBankAccountNumberCiphertext: true, + createdAt: true, + updatedAt: true, +} as const + +const PROFILE_SELECT = { + id: true, + storeName: true, + platform: true, + merchantNumber: true, + secondaryMerchantNumber: true, + merchantStoreId: true, + companyId: true, createdAt: true, updatedAt: true, } as const @@ -164,6 +188,42 @@ export class StoreAccountManagementRepository { }) } + async listProfiles(storeName: string) { + return prisma.storeAccountStoreProfile.findMany({ + where: { storeName }, + select: PROFILE_SELECT, + orderBy: { platform: 'asc' }, + }) + } + + async upsertProfile(data: { + storeName: string + platform: string + values: Record + actorId: string + }) { + return prisma.storeAccountStoreProfile.upsert({ + where: { + storeName_platform: { + storeName: data.storeName, + platform: data.platform, + }, + }, + create: { + ...data.values, + storeName: data.storeName, + platform: data.platform, + createdById: data.actorId, + updatedById: data.actorId, + }, + update: { + ...data.values, + updatedById: data.actorId, + }, + select: PROFILE_SELECT, + }) + } + async upsertByKey(data: { storeName: string accountType: string @@ -179,45 +239,6 @@ export class StoreAccountManagementRepository { }) } - async listProfiles(storeName: string) { - return prisma.storeAccountStoreProfile.findMany({ - where: { storeName }, - orderBy: { platform: 'asc' }, - }) - } - - async upsertProfile(data: { - storeName: string - platform: string - values: { - merchantNumber: string - secondaryMerchantNumber: string - merchantStoreId: string - companyId: string - } - actorId: string - }) { - return prisma.storeAccountStoreProfile.upsert({ - where: { - storeName_platform: { - storeName: data.storeName, - platform: data.platform, - }, - }, - create: { - storeName: data.storeName, - platform: data.platform, - ...data.values, - createdById: data.actorId, - updatedById: data.actorId, - }, - update: { - ...data.values, - updatedById: data.actorId, - }, - }) - } - async createLog(data: { storeAccountId: string | null; storeName: string; operation: string; actorId: string; actorName: string; changes: unknown }) { return prisma.storeAccountChangeLog.create({ data: { ...data, changes: data.changes as object } }) }