# Add Product Description Field for App Detail ## 1. Database Migration We need to add a `description` column to the `products` table to store the product details. **SQL Statement:** ```sql ALTER TABLE products ADD COLUMN description TEXT COMMENT '商品详情'; ``` ## 2. Backend Model Update Update the GORM model and DAO to reflect the database change. * **Model**: Update `internal/repository/mysql/model/products.gen.go` to include the `Description` field. * **DAO**: Update `internal/repository/mysql/dao/products.gen.go` to include the `Description` field definition and mapping. ## 3. Service Layer Update Update `internal/service/product/product.go` to handle the new field. * **Input Structs**: Add `Description` to `CreateProductInput` and `ModifyProductInput`. * **Business Logic**: * Update `CreateProduct` to save the description. * Update `ModifyProduct` to update the description. * Update `GetDetailForApp` to populate the `Description` field from the database instead of returning an empty string. ## 4. Admin API Update Update the Admin API to allow creating and editing products with a description. * **File**: `internal/api/admin/product_create.go` * **Request Structs**: Add `description` field to `createProductRequest` and `modifyProductRequest`. * **Handlers**: Pass the `description` from the request to the service layer. ## 5. App API Verification * **File**: `internal/api/app/product.go` * The `GetProductDetailForApp` function already returns a `Description` field in the response. By updating the service layer to populate this field, the App API will automatically return the correct data.