From 4047f87e8c8353a6548f81f34ffa23d53344332a Mon Sep 17 00:00:00 2001 From: xiaoquan <838115837@qq.com> Date: Wed, 22 Apr 2026 00:34:13 +0800 Subject: [PATCH] dev --- apps/miniapp/src/api/merchant.ts | 85 + apps/miniapp/src/api/seller-auth.ts | 54 + apps/miniapp/src/pages.json | 18 + apps/miniapp/src/pages/merchant/home.vue | 291 +- apps/miniapp/src/pages/mine/index.vue | 28 +- .../src/pages/seller-register/index.vue | 453 + apps/miniapp/src/pages/shop-create/index.vue | 392 + apps/miniapp/src/pages/shop-edit/index.vue | 408 + apps/miniapp/src/store/seller.ts | 41 + apps/miniapp/src/utils/request.ts | 10 +- apps/server/package.json | 2 +- apps/server/src/app.module.ts | 2 + .../decorators/current-seller.decorator.ts | 7 + .../common/guards/seller-jwt-auth.guard.ts | 42 + apps/server/src/common/index.ts | 2 + apps/server/src/entities/index.ts | 1 + apps/server/src/entities/merchant.entity.ts | 16 +- apps/server/src/entities/seller.entity.ts | 39 + apps/server/src/entities/user.entity.ts | 4 - apps/server/src/modules/auth/auth.service.ts | 4 +- .../src/modules/merchant/dto/merchant.dto.ts | 5 + .../modules/merchant/merchant.controller.ts | 22 +- .../src/modules/merchant/merchant.service.ts | 18 +- .../src/modules/order/order.controller.ts | 24 +- .../src/modules/room/room.controller.ts | 25 +- .../seller-auth/dto/seller-auth.dto.ts | 55 + .../seller-auth/seller-auth.controller.ts | 44 + .../modules/seller-auth/seller-auth.module.ts | 30 + .../seller-auth/seller-auth.service.ts | 211 + database/migrations/001_init_schema.sql | 63 +- database/modules.md | 72 +- database/seeds/001_init_data.sql | 10 + database/skills.md | 227 +- package.json | 3 + packages/shared-types/src/index.ts | 75 +- pnpm-lock.yaml | 17675 +++++++++------- 36 files changed, 12265 insertions(+), 8193 deletions(-) create mode 100644 apps/miniapp/src/api/merchant.ts create mode 100644 apps/miniapp/src/api/seller-auth.ts create mode 100644 apps/miniapp/src/pages/seller-register/index.vue create mode 100644 apps/miniapp/src/pages/shop-create/index.vue create mode 100644 apps/miniapp/src/pages/shop-edit/index.vue create mode 100644 apps/miniapp/src/store/seller.ts create mode 100644 apps/server/src/common/decorators/current-seller.decorator.ts create mode 100644 apps/server/src/common/guards/seller-jwt-auth.guard.ts create mode 100644 apps/server/src/entities/seller.entity.ts create mode 100644 apps/server/src/modules/seller-auth/dto/seller-auth.dto.ts create mode 100644 apps/server/src/modules/seller-auth/seller-auth.controller.ts create mode 100644 apps/server/src/modules/seller-auth/seller-auth.module.ts create mode 100644 apps/server/src/modules/seller-auth/seller-auth.service.ts diff --git a/apps/miniapp/src/api/merchant.ts b/apps/miniapp/src/api/merchant.ts new file mode 100644 index 0000000..af859a1 --- /dev/null +++ b/apps/miniapp/src/api/merchant.ts @@ -0,0 +1,85 @@ +import { post, get, put, request } from '@/utils/request'; + +export interface ApplyMerchantParams { + shopName: string; + phone: string; + province?: string; + city?: string; + district?: string; + address?: string; + businessLicense: string; + licenseNo?: string; + legalPerson?: string; + description?: string; +} + +export interface UpdateMerchantParams { + shopName?: string; + logo?: string; + phone?: string; + description?: string; + province?: string; + city?: string; + district?: string; + address?: string; +} + +export interface MerchantInfo { + id: number; + sellerId: number; + shopName: string; + logo: string; + description: string; + phone: string; + province: string; + city: string; + district: string; + address: string; + longitude: number; + latitude: number; + businessLicense: string; + licenseNo: string; + legalPerson: string; + status: 'pending' | 'approved' | 'rejected' | 'frozen'; + rejectReason: string; + deposit: number; + rating: number; + reviewCount: number; + autoConfirm: boolean; + createdAt: string; + updatedAt: string; +} + +// 申请创建店铺(需要商家token) +export function applyMerchant(data: ApplyMerchantParams) { + return request<{ message: string; merchant: MerchantInfo }>({ + url: '/merchant/apply', + method: 'POST', + data, + useSellerToken: true, + }); +} + +// 获取我的店铺信息(需要商家token) +export function getMyMerchant() { + return request({ + url: '/merchant/mine', + method: 'GET', + useSellerToken: true, + }); +} + +// 更新店铺信息(需要商家token) +export function updateMerchant(data: UpdateMerchantParams) { + return request({ + url: '/merchant/update', + method: 'PUT', + data, + useSellerToken: true, + }); +} + +// 获取商家详情(公开) +export function getMerchantById(id: number) { + return get(`/merchant/${id}`); +} \ No newline at end of file diff --git a/apps/miniapp/src/api/seller-auth.ts b/apps/miniapp/src/api/seller-auth.ts new file mode 100644 index 0000000..f64dee8 --- /dev/null +++ b/apps/miniapp/src/api/seller-auth.ts @@ -0,0 +1,54 @@ +import { post, get, request } from '@/utils/request'; + +export interface SellerRegisterParams { + phone: string; + code: string; + contactName: string; + email?: string; + password?: string; +} + +export interface SellerLoginParams { + phone: string; + code?: string; + password?: string; +} + +export interface SellerLoginResult { + accessToken: string; + refreshToken: string; + sellerInfo: { + id: number; + phone: string; + contactName: string; + email?: string; + status: string; + merchantId?: number; + merchantStatus?: string; + }; +} + +// 发送商家验证码 +export function sellerSendCode(phone: string) { + return post('/seller-auth/send-code', { phone }); +} + +// 商家注册(验证码) +export function sellerRegister(data: SellerRegisterParams) { + return post('/seller-auth/register', data); +} + +// 商家登录(验证码或密码) +export function sellerLogin(data: SellerLoginParams) { + return post('/seller-auth/login', data); +} + +// 刷新商家令牌 +export function sellerRefreshToken(refreshToken: string) { + return post('/seller-auth/refresh', { refreshToken }); +} + +// 获取商家信息(需要商家token) +export function getSellerProfile() { + return request({ url: '/seller-auth/profile', method: 'GET', useSellerToken: true }); +} \ No newline at end of file diff --git a/apps/miniapp/src/pages.json b/apps/miniapp/src/pages.json index bcd8696..e51ffb2 100644 --- a/apps/miniapp/src/pages.json +++ b/apps/miniapp/src/pages.json @@ -48,6 +48,24 @@ "style": { "navigationBarTitleText": "商家中心" } + }, + { + "path": "pages/seller-register/index", + "style": { + "navigationBarTitleText": "商家入驻" + } + }, + { + "path": "pages/shop-create/index", + "style": { + "navigationBarTitleText": "创建店铺" + } + }, + { + "path": "pages/shop-edit/index", + "style": { + "navigationBarTitleText": "修改店铺" + } } ], "globalStyle": { diff --git a/apps/miniapp/src/pages/merchant/home.vue b/apps/miniapp/src/pages/merchant/home.vue index d1b919b..b230148 100644 --- a/apps/miniapp/src/pages/merchant/home.vue +++ b/apps/miniapp/src/pages/merchant/home.vue @@ -1,28 +1,66 @@ + + \ No newline at end of file diff --git a/apps/miniapp/src/pages/shop-create/index.vue b/apps/miniapp/src/pages/shop-create/index.vue new file mode 100644 index 0000000..1728d06 --- /dev/null +++ b/apps/miniapp/src/pages/shop-create/index.vue @@ -0,0 +1,392 @@ +