feat: #13 公开商品 API 补充 code/barcode/batch.quantity,报错反馈携带商品和门店信息
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ type submitErrorRequest struct {
|
||||
ShopID uint64 `json:"shop_id"`
|
||||
ShopNo string `json:"shop_no"`
|
||||
Role string `json:"role"`
|
||||
ProductInfo string `json:"product_info"`
|
||||
ErrorMsg string `json:"error_msg" binding:"required"`
|
||||
StackTrace string `json:"stack_trace"`
|
||||
OccurredAt int64 `json:"occurred_at"` // Unix 毫秒
|
||||
@@ -56,6 +57,7 @@ func (h *ErrorReportHandler) Submit(c *gin.Context) {
|
||||
ShopID: req.ShopID,
|
||||
ShopNo: req.ShopNo,
|
||||
Role: req.Role,
|
||||
ProductInfo: req.ProductInfo,
|
||||
ClientIP: c.ClientIP(),
|
||||
ErrorMsg: req.ErrorMsg,
|
||||
StackTrace: stack,
|
||||
|
||||
@@ -72,6 +72,7 @@ func (h *PublicHandler) GetProduct(c *gin.Context) {
|
||||
"production_date": pdStr,
|
||||
"batch_no": inv.BatchNo,
|
||||
"in_stock_date": inv.CreatedAt.Format("2006-01-02"),
|
||||
"quantity": inv.Quantity,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +101,8 @@ func (h *PublicHandler) GetProduct(c *gin.Context) {
|
||||
"data": gin.H{
|
||||
"id": product.ID,
|
||||
"name": product.Name,
|
||||
"code": product.Code,
|
||||
"barcode": product.Barcode,
|
||||
"series": product.Series,
|
||||
"spec": product.Spec,
|
||||
"brand": product.Brand,
|
||||
|
||||
@@ -13,6 +13,7 @@ type ErrorReport struct {
|
||||
ShopID uint64 `gorm:"index" json:"shop_id"`
|
||||
ShopNo string `gorm:"size:50" json:"shop_no"`
|
||||
Role string `gorm:"size:20" json:"role"`
|
||||
ProductInfo string `gorm:"size:200" json:"product_info"`
|
||||
ClientIP string `gorm:"size:60" json:"client_ip"`
|
||||
ErrorMsg string `gorm:"type:text;not null" json:"error_msg"`
|
||||
StackTrace string `gorm:"type:text" json:"stack_trace"`
|
||||
|
||||
@@ -70,13 +70,22 @@ class _PublicProductScreenState extends State<PublicProductScreen> {
|
||||
title: title,
|
||||
hint: hint,
|
||||
onSubmit: (msg) async {
|
||||
final shopNo = (_data?['shop'] as Map<String, dynamic>?)?['code'] as String? ?? '';
|
||||
final productName = _data?['name'] as String? ?? '';
|
||||
final productCode = _data?['code'] as String? ?? '';
|
||||
final productInfo = [
|
||||
if (productName.isNotEmpty) productName,
|
||||
if (productCode.isNotEmpty) productCode,
|
||||
if (widget.publicId.isNotEmpty) widget.publicId,
|
||||
].join(' / ');
|
||||
await _dio.post(
|
||||
'${AppConfig.apiBaseUrl}/public/errors',
|
||||
data: {
|
||||
'error_type': errorType,
|
||||
'error_msg': msg,
|
||||
'platform': 'web-scan',
|
||||
'shop_no': (_data?['shop'] as Map<String, dynamic>?)?['code'] as String? ?? '',
|
||||
'shop_no': shopNo,
|
||||
if (productInfo.isNotEmpty) 'product_info': productInfo,
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user