|
1 | | -import { del, get, post, put } from "@/utils/request"; |
2 | | -import type { ApiResponse } from "@/types/request.types"; |
| 1 | +import { del, get, post, put } from '@/utils/request' |
| 2 | +import type { ApiResponse } from '@/types/request.types' |
3 | 3 |
|
4 | | -export type GoodsStatus = "0" | "1"; |
5 | | -export type GoodsType = "0" | "1" | "2"; |
6 | | -export type GoodsCurrencyType = "0" | "1"; |
7 | | -export type GoodsLimitType = "0" | "1"; |
| 4 | +export type GoodsStatus = '0' | '1' |
| 5 | +export type GoodsType = '0' | '1' | '2' |
| 6 | +export type GoodsCurrencyType = '0' | '1' |
| 7 | +export type GoodsLimitType = '0' | '1' |
8 | 8 |
|
9 | 9 | export interface ManageGoodsItem { |
10 | | - id: string; |
11 | | - name: string; |
12 | | - price: number; |
13 | | - amount: number; |
14 | | - type: GoodsType; |
15 | | - currencyType: GoodsCurrencyType; |
16 | | - status: GoodsStatus; |
17 | | - intro: string; |
18 | | - imageUrl: string; |
19 | | - imageUrlUrl?: string; |
20 | | - limitNum: number; |
21 | | - limitType: GoodsLimitType; |
22 | | - barcode?: string; |
23 | | - quantifier?: string; |
| 10 | + id: string |
| 11 | + name: string |
| 12 | + price: number |
| 13 | + amount: number |
| 14 | + type: GoodsType |
| 15 | + currencyType: GoodsCurrencyType |
| 16 | + status: GoodsStatus |
| 17 | + intro: string |
| 18 | + imageUrl: string |
| 19 | + imageUrlUrl?: string |
| 20 | + limitNum: number |
| 21 | + limitType: GoodsLimitType |
| 22 | + barcode?: string |
| 23 | + quantifier?: string |
24 | 24 | } |
25 | 25 |
|
26 | 26 | export interface GoodsListParams { |
27 | | - pageNum: number; |
28 | | - pageSize: number; |
29 | | - name?: string; |
| 27 | + pageNum: number |
| 28 | + pageSize: number |
| 29 | + name?: string |
30 | 30 | } |
31 | 31 |
|
32 | 32 | export interface PagedRows<T> extends ApiResponse { |
33 | | - rows: T[]; |
34 | | - total: number; |
| 33 | + rows: T[] |
| 34 | + total: number |
35 | 35 | } |
36 | 36 |
|
37 | 37 | export interface SaveGoodsPayload { |
38 | | - id?: string; |
39 | | - name: string; |
40 | | - price: number; |
41 | | - currencyType: GoodsCurrencyType; |
42 | | - type: GoodsType; |
43 | | - status: GoodsStatus; |
44 | | - barcode: string; |
45 | | - intro: string; |
46 | | - limitNum: number; |
47 | | - limitType: GoodsLimitType; |
48 | | - quantifier: string; |
49 | | - imageUrl: string; |
50 | | - amount?: number; |
| 38 | + id?: string |
| 39 | + name: string |
| 40 | + price: number |
| 41 | + currencyType: GoodsCurrencyType |
| 42 | + type: GoodsType |
| 43 | + status: GoodsStatus |
| 44 | + barcode: string |
| 45 | + intro: string |
| 46 | + limitNum: number |
| 47 | + limitType: GoodsLimitType |
| 48 | + quantifier: string |
| 49 | + imageUrl: string |
| 50 | + amount?: number |
51 | 51 | } |
52 | 52 |
|
53 | 53 | export interface RestockPayload { |
54 | | - goodsId: string; |
55 | | - amount: number; |
| 54 | + goodsId: string |
| 55 | + amount: number |
56 | 56 | } |
57 | 57 |
|
58 | 58 | export interface RestockListParams { |
59 | | - pageNum: number; |
60 | | - pageSize: number; |
| 59 | + pageNum: number |
| 60 | + pageSize: number |
61 | 61 | } |
62 | 62 |
|
63 | 63 | export interface RestockRecordItem { |
64 | | - id: number; |
65 | | - goodsId: number; |
66 | | - name: string; |
67 | | - amount: number; |
68 | | - originAmount: number; |
69 | | - endAmount: number; |
70 | | - imageUrl: string; |
| 64 | + id: number |
| 65 | + goodsId: number |
| 66 | + name: string |
| 67 | + amount: number |
| 68 | + originAmount: number |
| 69 | + endAmount: number |
| 70 | + imageUrl: string |
71 | 71 | } |
72 | 72 |
|
73 | 73 | export interface RestockDetailItem { |
74 | | - id: number; |
75 | | - goodsId: number; |
76 | | - name: string; |
77 | | - amount: number; |
78 | | - originAmount: number; |
79 | | - endAmount: number; |
80 | | - imageUrl: string; |
| 74 | + id: number |
| 75 | + goodsId: number |
| 76 | + name: string |
| 77 | + amount: number |
| 78 | + originAmount: number |
| 79 | + endAmount: number |
| 80 | + imageUrl: string |
81 | 81 | } |
82 | 82 |
|
83 | 83 | interface OssAsset { |
84 | | - ossId: string; |
85 | | - url: string; |
| 84 | + ossId: string |
| 85 | + url: string |
86 | 86 | } |
87 | 87 |
|
88 | 88 | export const manageGoodsApi = { |
89 | | - getGoodsList: (params: GoodsListParams): Promise<PagedRows<ManageGoodsItem>> => |
90 | | - get("/market/goods/list", params).then( |
91 | | - (response) => response as unknown as PagedRows<ManageGoodsItem>, |
92 | | - ), |
| 89 | + getGoodsList: (params: GoodsListParams): Promise<PagedRows<ManageGoodsItem>> => |
| 90 | + get('/market/goods/list', params).then( |
| 91 | + (response) => response as unknown as PagedRows<ManageGoodsItem>, |
| 92 | + ), |
93 | 93 |
|
94 | | - getGoodsDetail: (id: string): Promise<ApiResponse<ManageGoodsItem>> => |
95 | | - get(`/market/goods/${id}`) as Promise<ApiResponse<ManageGoodsItem>>, |
| 94 | + getGoodsDetail: (id: string): Promise<ApiResponse<ManageGoodsItem>> => |
| 95 | + get(`/market/goods/${id}`) as Promise<ApiResponse<ManageGoodsItem>>, |
96 | 96 |
|
97 | | - createGoods: (payload: SaveGoodsPayload): Promise<ApiResponse> => |
98 | | - post("/market/goods", payload), |
| 97 | + createGoods: (payload: SaveGoodsPayload): Promise<ApiResponse> => post('/market/goods', payload), |
99 | 98 |
|
100 | | - updateGoods: (payload: SaveGoodsPayload): Promise<ApiResponse> => |
101 | | - put("/market/goods", payload), |
| 99 | + updateGoods: (payload: SaveGoodsPayload): Promise<ApiResponse> => put('/market/goods', payload), |
102 | 100 |
|
103 | | - deleteGoods: (ids: string[]): Promise<ApiResponse> => |
104 | | - del(`/market/goods/${ids.join(",")}`), |
| 101 | + deleteGoods: (ids: string[]): Promise<ApiResponse> => del(`/market/goods/${ids.join(',')}`), |
105 | 102 |
|
106 | | - restockGoods: (payload: RestockPayload): Promise<ApiResponse> => |
107 | | - post("/market/restock", payload), |
| 103 | + restockGoods: (payload: RestockPayload): Promise<ApiResponse> => post('/market/restock', payload), |
108 | 104 |
|
109 | | - getRestockList: (params: RestockListParams): Promise<PagedRows<RestockRecordItem>> => |
110 | | - get("/market/restock/list", params).then( |
111 | | - (response) => response as unknown as PagedRows<RestockRecordItem>, |
112 | | - ), |
| 105 | + getRestockList: (params: RestockListParams): Promise<PagedRows<RestockRecordItem>> => |
| 106 | + get('/market/restock/list', params).then( |
| 107 | + (response) => response as unknown as PagedRows<RestockRecordItem>, |
| 108 | + ), |
113 | 109 |
|
114 | | - getRestockInfo: (id: number | string): Promise<ApiResponse<RestockDetailItem>> => |
115 | | - get(`/market/restock/info/${id}`) as Promise<ApiResponse<RestockDetailItem>>, |
| 110 | + getRestockInfo: (id: number | string): Promise<ApiResponse<RestockDetailItem>> => |
| 111 | + get(`/market/restock/info/${id}`) as Promise<ApiResponse<RestockDetailItem>>, |
116 | 112 |
|
117 | | - uploadImage: (file: File): Promise<ApiResponse<{ ossId: string }>> => { |
118 | | - const formData = new FormData(); |
119 | | - formData.append("file", file); |
| 113 | + uploadImage: (file: File): Promise<ApiResponse<{ ossId: string }>> => { |
| 114 | + const formData = new FormData() |
| 115 | + formData.append('file', file) |
120 | 116 |
|
121 | | - return post("/resource/oss/upload", formData, { |
122 | | - headers: { |
123 | | - "Content-Type": "multipart/form-data", |
124 | | - }, |
125 | | - }) as Promise<ApiResponse<{ ossId: string }>>; |
126 | | - }, |
| 117 | + return post('/resource/oss/upload', formData, { |
| 118 | + headers: { |
| 119 | + 'Content-Type': 'multipart/form-data', |
| 120 | + }, |
| 121 | + }) as Promise<ApiResponse<{ ossId: string }>> |
| 122 | + }, |
127 | 123 |
|
128 | | - getOssAssets: (ossIds: string): Promise<ApiResponse<OssAsset[]>> => |
129 | | - get(`/resource/oss/listByIds/${ossIds}`) as Promise<ApiResponse<OssAsset[]>>, |
130 | | -}; |
| 124 | + getOssAssets: (ossIds: string): Promise<ApiResponse<OssAsset[]>> => |
| 125 | + get(`/resource/oss/listByIds/${ossIds}`) as Promise<ApiResponse<OssAsset[]>>, |
| 126 | +} |
0 commit comments