type Bom struct { basedto.BaseEntity `gorm:"-"` /* BOM标识 */ Id int32 `gorm:"column:id;type:int(11);PRIMARY_KEY;comment:'BOM标识 '" json:"id"` /* 来源 0--采购1--生产 */ Source basemodel.BitField `gorm:"column:source;type:bit(1);comment:'来源 0--采购1--生产'" json:"source"` /
package basemodel import ( "database/sql/driver" "fmt" "strconv" ) type BitField bool func (t *BitField) MarshalJSON() ([]byte, error) { var value bool if *t { value = true } else { value = false } return []byte(strconv.FormatBool(value)), nil } func (t *BitField) UnmarshalJSON(data []byte) error { if string(data) == "null" { return nil } b, _ := strconv.ParseBool(string(data)) if b { *t = true } el