diff --git a/controller/park.go b/controller/park.go index bc62d61..99db254 100644 --- a/controller/park.go +++ b/controller/park.go @@ -79,8 +79,8 @@ type _ParkInfoFormData struct { Area decimal.NullDecimal `json:"area" from:"area"` Capacity decimal.NullDecimal `json:"capacity" from:"capacity"` TenementQuantity decimal.NullDecimal `json:"tenement" from:"tenement"` - Category int `json:"category" form:"category"` - SubmeterType int `json:"submeter" form:"submeter"` + Category int8 `json:"category" form:"category"` + SubmeterType int8 `json:"submeter" form:"submeter"` } func createNewPark(c *gin.Context) { diff --git a/model/park.go b/model/park.go index c681cc8..1700804 100644 --- a/model/park.go +++ b/model/park.go @@ -31,8 +31,8 @@ type Park struct { Area decimal.NullDecimal `json:"area"` TenementQuantity decimal.NullDecimal `json:"tenement"` Capacity decimal.NullDecimal `json:"capacity"` - Category int8 `bun:"type:smallint,notnull,default:0" json:"category"` - SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull,default:0" json:"meter04kvType"` + Category int8 `bun:"type:smallint,notnull" json:"category"` + SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull" json:"meter04kvType"` Region *string `json:"region"` Address *string `json:"address"` Contact *string `json:"contact"` diff --git a/service/park.go b/service/park.go index b73ce2f..992fa86 100644 --- a/service/park.go +++ b/service/park.go @@ -34,7 +34,7 @@ func (_ParkService) SaveNewPark(park model.Park) error { func (_ParkService) UpdateParkInfo(park *model.Park) error { ctx, cancel := global.TimeoutContext() defer cancel() - res, err := global.DB.NewUpdate().Model(&park). + res, err := global.DB.NewUpdate().Model(park). Where("id = ?", park.Id). Where("user_id = ?", park.UserId). Column("name", "abbr", "region", "address", "contact", "phone", "capacity", "tenement_quantity", "category", "meter_04kv_type"). @@ -126,7 +126,7 @@ func (_ParkService) FetchParkDetail(pid string) (*model.Park, error) { ctx, cancel := global.TimeoutContext() defer cancel() var park = new(model.Park) - err := global.DB.NewSelect().Model(&park). + err := global.DB.NewSelect().Model(park). Where("id = ?", pid). Scan(ctx) if err != nil {