Jelajahi Sumber

♻️ refactor(schemas): update module imports to use explicit schema paths

- 修改delivery-address-module中UserSchema和getAreaSchema的导入路径,添加/schemas后缀
- 更新goods-module中SupplierSchema、FileSchema和MerchantSchema的导入路径,添加/schemas后缀
- 调整goods-category.schema.ts中FileSchema的导入路径,添加/schemas后缀

♻️ refactor(admin): optimize category id parameter handling

- 移除GoodsCategories.tsx中不必要的zod导入
- 将categoryToDelete和editingCategory.id的toString()转换移除,直接传递数字类型id
yourname 1 bulan lalu
induk
melakukan
e9d085a9d3

+ 2 - 2
packages/delivery-address-module/src/schemas/admin-delivery-address.schema.ts

@@ -1,6 +1,6 @@
 import { z } from '@hono/zod-openapi';
-import { UserSchema } from '@d8d/user-module';
-import { getAreaSchema } from '@d8d/geo-areas';
+import { UserSchema } from '@d8d/user-module/schemas';
+import { getAreaSchema } from '@d8d/geo-areas/schemas';
 
 // 状态枚举
 export const DeliveryAddressStatusEnum = {

+ 2 - 2
packages/delivery-address-module/src/schemas/delivery-address.schema.ts

@@ -1,6 +1,6 @@
 import { z } from '@hono/zod-openapi';
-import { UserSchema } from '@d8d/user-module';
-import { getAreaSchema } from '@d8d/geo-areas';
+import { UserSchema } from '@d8d/user-module/schemas';
+import { getAreaSchema } from '@d8d/geo-areas/schemas';
 
 // 状态枚举
 export const DeliveryAddressStatusEnum = {

+ 2 - 2
packages/delivery-address-module/src/schemas/user-delivery-address.schema.ts

@@ -1,6 +1,6 @@
 import { z } from '@hono/zod-openapi';
-import { UserSchema } from '@d8d/user-module';
-import { getAreaSchema } from '@d8d/geo-areas';
+import { UserSchema } from '@d8d/user-module/schemas';
+import { getAreaSchema } from '@d8d/geo-areas/schemas';
 
 // 状态枚举
 export const DeliveryAddressStatusEnum = {

+ 3 - 3
packages/goods-module/src/schemas/admin-goods.schema.ts

@@ -1,8 +1,8 @@
 import { z } from '@hono/zod-openapi';
 import { GoodsCategorySchema } from './goods-category.schema.js';
-import { SupplierSchema } from '@d8d/supplier-module';
-import { FileSchema } from '@d8d/file-module';
-import { MerchantSchema } from '@d8d/merchant-module';
+import { SupplierSchema } from '@d8d/supplier-module/schemas';
+import { FileSchema } from '@d8d/file-module/schemas';
+import { MerchantSchema } from '@d8d/merchant-module/schemas';
 
 // 管理员专用商品Schema - 保留完整权限字段
 export const AdminGoodsSchema = z.object({

+ 1 - 1
packages/goods-module/src/schemas/goods-category.schema.ts

@@ -1,5 +1,5 @@
 import { z } from '@hono/zod-openapi';
-import { FileSchema } from '@d8d/file-module';
+import { FileSchema } from '@d8d/file-module/schemas';
 
 export const GoodsCategorySchema = z.object({
   id: z.number().int().positive().openapi({ description: '类别ID' }),

+ 3 - 3
packages/goods-module/src/schemas/goods.schema.ts

@@ -1,8 +1,8 @@
 import { z } from '@hono/zod-openapi';
 import { GoodsCategorySchema } from './goods-category.schema.js';
-import { SupplierSchema } from '@d8d/supplier-module';
-import { FileSchema } from '@d8d/file-module';
-import { MerchantSchema } from '@d8d/merchant-module';
+import { SupplierSchema } from '@d8d/supplier-module/schemas';
+import { FileSchema } from '@d8d/file-module/schemas';
+import { MerchantSchema } from '@d8d/merchant-module/schemas';
 
 export const GoodsSchema = z.object({
   id: z.number().int().positive().openapi({ description: '商品ID' }),

+ 3 - 3
packages/goods-module/src/schemas/public-goods.schema.ts

@@ -1,8 +1,8 @@
 import { z } from '@hono/zod-openapi';
 import { GoodsCategorySchema } from './goods-category.schema.js';
-import { SupplierSchema } from '@d8d/supplier-module';
-import { FileSchema } from '@d8d/file-module';
-import { MerchantSchema } from '@d8d/merchant-module';
+import { SupplierSchema } from '@d8d/supplier-module/schemas';
+import { FileSchema } from '@d8d/file-module/schemas';
+import { MerchantSchema } from '@d8d/merchant-module/schemas';
 
 // 公开商品Schema - 只读查询,仅包含可用状态的商品
 // 响应schema保持完整字段,但只支持查询操作

+ 3 - 3
packages/goods-module/src/schemas/user-goods.schema.ts

@@ -1,8 +1,8 @@
 import { z } from '@hono/zod-openapi';
 import { GoodsCategorySchema } from './goods-category.schema.js';
-import { SupplierSchema } from '@d8d/supplier-module';
-import { FileSchema } from '@d8d/file-module';
-import { MerchantSchema } from '@d8d/merchant-module';
+import { SupplierSchema } from '@d8d/supplier-module/schemas';
+import { FileSchema } from '@d8d/file-module/schemas';
+import { MerchantSchema } from '@d8d/merchant-module/schemas';
 
 // 用户专用商品Schema - 移除请求schema中的用户权限相关字段
 export const UserGoodsSchema = z.object({

+ 2 - 3
web/src/client/admin/pages/GoodsCategories.tsx

@@ -2,7 +2,6 @@ import { useState } from 'react';
 import { useQuery } from '@tanstack/react-query';
 import { useForm } from 'react-hook-form';
 import { zodResolver } from '@hookform/resolvers/zod';
-import { z } from 'zod';
 import { Plus, Search, Edit, Trash2, Folder } from 'lucide-react';
 import { toast } from 'sonner';
 
@@ -117,7 +116,7 @@ export const GoodsCategories = () => {
 
     try {
       const res = await goodsCategoryClient[':id']['$delete']({
-        param: { id: categoryToDelete.toString() },
+        param: { id: categoryToDelete },
       });
 
       if (res.status === 204) {
@@ -150,7 +149,7 @@ export const GoodsCategories = () => {
 
     try {
       const res = await goodsCategoryClient[':id']['$put']({
-        param: { id: editingCategory.id.toString() },
+        param: { id: editingCategory.id },
         json: data,
       });
       if (res.status !== 200) throw new Error('更新失败');