109 lines
3.9 KiB
Go
109 lines
3.9 KiB
Go
package response
|
|
|
|
import (
|
|
"encoding/json"
|
|
"psi/models"
|
|
)
|
|
|
|
// ProductBookListResponse 商品反射列表响应
|
|
type ProductBookListResponse struct {
|
|
List []ProductBookItem `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"pageSize"`
|
|
}
|
|
|
|
// ProductBookItem 商品反射项
|
|
type ProductBookItem struct {
|
|
ID int64 `json:"id"`
|
|
CategoryID int64 `json:"category_id"`
|
|
AboutId int64 `json:"about_id"`
|
|
WarehouseID int64 `json:"warehouse_id"`
|
|
WarehouseName string `json:"warehouse_name"`
|
|
LocationID int64 `json:"location_id"`
|
|
LocationName string `json:"location_name"`
|
|
StandardProductID int64 `json:"standard_product_id"`
|
|
Fid int64 `json:"fid"`
|
|
Type int8 `json:"type"`
|
|
ISBN string `json:"isbn"`
|
|
FISBN string `json:"f_isbn"`
|
|
BookName string `json:"book_name"`
|
|
FBookName string `json:"f_book_name"`
|
|
Author string `json:"author"`
|
|
Publishing string `json:"publishing"`
|
|
PublicationTime int64 `json:"publication_time"`
|
|
Binding string `json:"binding"`
|
|
PagesCount int64 `json:"pages_count"`
|
|
WordsCount int64 `json:"words_count"`
|
|
Format int64 `json:"format"`
|
|
CatID interface{} `json:"cat_id"`
|
|
Name string `json:"name"`
|
|
Appearance int64 `json:"appearance"`
|
|
Barcode string `json:"barcode"`
|
|
Price int64 `json:"price"`
|
|
SalePrice int64 `json:"sale_price"`
|
|
Cost int64 `json:"cost"`
|
|
Stock int64 `json:"stock"`
|
|
SelfID int64 `json:"self_id"`
|
|
TotalPrice int64 `json:"total_price"` // 售价+运费总和
|
|
LiveImage []string `json:"live_image"`
|
|
IsBatchManaged int8 `json:"is_batch_managed"`
|
|
IsShelfLifeManaged int8 `json:"is_shelf_life_managed"`
|
|
Status int8 `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// ConvertProductBookToItem 转换模型为响应项
|
|
func ConvertProductBookToItem(book models.ProductBook) ProductBookItem {
|
|
var liveImage []string
|
|
if len(book.LiveImage) > 0 {
|
|
json.Unmarshal(book.LiveImage, &liveImage)
|
|
}
|
|
|
|
var catID interface{}
|
|
if len(book.CatID) > 0 {
|
|
json.Unmarshal(book.CatID, &catID)
|
|
}
|
|
|
|
return ProductBookItem{
|
|
ID: book.ID,
|
|
CategoryID: book.CategoryID,
|
|
AboutId: book.AboutId,
|
|
WarehouseID: book.WarehouseID,
|
|
WarehouseName: book.WarehouseName,
|
|
LocationID: book.LocationID,
|
|
LocationName: book.LocationName,
|
|
StandardProductID: book.StandardProductID,
|
|
Fid: book.Fid,
|
|
Type: book.Type,
|
|
ISBN: book.ISBN,
|
|
FISBN: book.FISBN,
|
|
BookName: book.BookName,
|
|
FBookName: book.FBookName,
|
|
Author: book.Author,
|
|
Publishing: book.Publishing,
|
|
PublicationTime: book.PublicationTime,
|
|
Binding: book.Binding,
|
|
PagesCount: book.PagesCount,
|
|
WordsCount: book.WordsCount,
|
|
Format: book.Format,
|
|
CatID: catID,
|
|
Name: book.Name,
|
|
Appearance: book.Appearance,
|
|
Barcode: book.Barcode,
|
|
Price: book.Price,
|
|
SalePrice: book.SalePrice,
|
|
Cost: book.Cost,
|
|
Stock: book.Stock,
|
|
SelfID: book.SelfID,
|
|
TotalPrice: book.SalePrice + book.Cost,
|
|
LiveImage: liveImage,
|
|
IsBatchManaged: book.IsBatchManaged,
|
|
IsShelfLifeManaged: book.IsShelfLifeManaged,
|
|
Status: book.Status,
|
|
CreatedAt: book.CreatedAt,
|
|
UpdatedAt: book.UpdatedAt,
|
|
}
|
|
}
|