From 1e04922cee7ae064ce6ddafbceacc5119c1aeedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Mon, 19 Sep 2022 11:24:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(park):=E5=AE=8C=E6=88=90=E5=9B=AD=E5=8C=BA?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E8=B0=83=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/park.go | 4 ++-- model/park.go | 4 ++-- service/park.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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 {