refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
1.6 KiB
1.6 KiB
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:
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.goto include theDescriptionfield. - DAO: Update
internal/repository/mysql/dao/products.gen.goto include theDescriptionfield definition and mapping.
3. Service Layer Update
Update internal/service/product/product.go to handle the new field.
- Input Structs: Add
DescriptiontoCreateProductInputandModifyProductInput. - Business Logic:
- Update
CreateProductto save the description. - Update
ModifyProductto update the description. - Update
GetDetailForAppto populate theDescriptionfield from the database instead of returning an empty string.
- Update
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
descriptionfield tocreateProductRequestandmodifyProductRequest. - Handlers: Pass the
descriptionfrom the request to the service layer.
5. App API Verification
- File:
internal/api/app/product.go - The
GetProductDetailForAppfunction already returns aDescriptionfield in the response. By updating the service layer to populate this field, the App API will automatically return the correct data.