```
type WarehouseCheckGoods struct {
ID int64 `gorm:"column:id" db:"column:id" json:"id" form:"id"`
GoodsId int64 `gorm:"column:goods_id" db:"column:goods_id" json:"goods_id" form:"goods_id"`
SkuCode string `gorm:"column:sku_code" db:"column:sku_code" json:"sku_code" form:"sku_code"`
Remarks string `gorm:"column:remarks" db:"column:remarks" json:"remarks" form:"remarks"`
RealNumber int64 `gorm:"column:real_number" db:"column:real_number" json:"real_number" form:"real_number"`
BookNumber int64 `gorm:"column:book_number" db:"column:book_number" json:"book_number" form:"book_number"`
AdjustNumber int64 `gorm:"column:adjust_number" db:"column:adjust_number" json:"adjust_number" form:"adjust_number"`
WarehouseCheckId int64 `gorm:"column:warehouse_check_id" db:"column:warehouse_check_id" json:"warehouse_check_id" form:"warehouse_check_id"`
ThreeWarehouse AutoGenerated `gorm:"column:three_warehouse" db:"column:three_warehouse" json:"three_warehouse" form:"three_warehouse"`
CreatedAt time.Time `gorm:"column:created_at" db:"column:created_at" json:"created_at" form:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at" db:"column:updated_at" json:"updated_at" form:"updated_at"`
}
type AutoGenerated []struct {
WarehouseID int `json:"warehouse_id"`
BookNumber string `json:"book_number"`
AdjustNumber string `json:"adjust_number"`
}
func (j *AutoGenerated) Scan(value interface{}) error {
bytes, _ := value.([]uint8)
var lins AutoGenerated
json.Unmarshal([]byte(bytes), &lins)
//打印lins ,输出正常
j = &lins
// 把值赋给 指针,输出是null
return nil
}
func (j AutoGenerated) Value() (driver.Value, error) {
return j, nil
}
```
其中ThreeWarehouse 这个字段为json 数组格式的字符
格式
```
[{"warehouse_id":1,"book_number":"0","adjust_number":"15"}]
```
然后我自定义的类型AutoGenerated,代码如上方,我把json绑定到结构体,打印都正常,但是赋值给指针,后接口请求不正常;哪位大神知道下,我这种怎么处理,谢谢🙏
有疑问加站长微信联系(非本文作者)