type (
Sale struct {
BaseModel
WareroomID int `json:"wareroom_id"`
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
}
SaleLink struct {
BaseModel
WareroomID int `json:"wareroom_id"`
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
Product Product `json:"product"`
Wareroom Wareroom `json:"wareroom"`
}
)
有时候在返回接口的时候 ,有时候不希望返回 关联表 Product
和 Wareroom
, 有时候又需要, 所以定义了 2 个 struct
, 感觉这样写 好啰嗦, 想请大佬 指导一下, 该如何只优化 这个 struct
, 其他代码不用动呢?
求大佬 指导一下 ????
go
func
的初衷设计模式