diff --git a/database/db/order.go b/database/db/order.go index dafbbdb..2c8399b 100644 --- a/database/db/order.go +++ b/database/db/order.go @@ -2,6 +2,7 @@ package db import ( "context" + "database/sql" "time" "mr.jackpot-backend/database/orm" @@ -79,10 +80,16 @@ func (db *OrderDB) CreateOrder(userid int, order model.Order, info model.AllOrde } if len(menu.OptionId) >= 1 { - menuStruct.Option1ID = int32(menu.OptionId[0]) + menuStruct.Option1ID = sql.NullInt32{ + Int32: int32(menu.OptionId[0]), + Valid: true, + } } if len(menu.OptionId) >= 2 { - menuStruct.Option2ID = int32(menu.OptionId[1]) + menuStruct.Option2ID = sql.NullInt32{ + Int32: int32(menu.OptionId[1]), + Valid: true, + } } if err := db.q.CreateOrderedMenu(ctx, menuStruct); err != nil { diff --git a/database/orm/create_order.sql.go b/database/orm/create_order.sql.go index 2ffdb97..7496c9a 100644 --- a/database/orm/create_order.sql.go +++ b/database/orm/create_order.sql.go @@ -77,8 +77,8 @@ type CreateOrderedMenuParams struct { DinnerID int64 MenutypeID int32 MenuID int32 - Option1ID int32 - Option2ID int32 + Option1ID sql.NullInt32 + Option2ID sql.NullInt32 Count int32 Price sql.NullInt32 } diff --git a/database/orm/models.go b/database/orm/models.go index 7c1b47e..8b3c0ba 100644 --- a/database/orm/models.go +++ b/database/orm/models.go @@ -137,8 +137,8 @@ type OrderedMenu struct { DinnerID int64 MenutypeID int32 MenuID int32 - Option1ID int32 - Option2ID int32 + Option1ID sql.NullInt32 + Option2ID sql.NullInt32 Count int32 Price sql.NullInt32 } diff --git a/database/sql/schema.sql b/database/sql/schema.sql index 3abd38b..2da1220 100644 --- a/database/sql/schema.sql +++ b/database/sql/schema.sql @@ -265,8 +265,8 @@ CREATE TABLE ordered_menu ( dinner_id bigint NOT NULL, menutype_id tinyint NOT NULL, menu_id tinyint NOT NULL, - option1_id tinyint NOT NULL, - option2_id tinyint NOT NULL, + option1_id tinyint, + option2_id tinyint, count tinyint NOT NULL DEFAULT 0, price int, diff --git a/model/format.go b/model/format.go index 1e7d2a2..aa7ea48 100644 --- a/model/format.go +++ b/model/format.go @@ -3,6 +3,6 @@ package model -var TimeDayFormat string = "2006.01.02" +var TimeDayFormat string = "2006.01.02" var TimeMinuteFormat string = "2006.01.02 15:04" var TimeSecondFormat string = "2006.01.02 15:04:05" \ No newline at end of file diff --git a/model/staff.go b/model/staff.go index 0517156..99d37b1 100644 --- a/model/staff.go +++ b/model/staff.go @@ -13,13 +13,23 @@ type Staff struct { Part string } +type StaffResponse struct { + ID int `json:"id"` + Code string `json:"code"` + Name string `json:"name"` + Role string `json:"role"` + Part string `json:"part"` + Score int `json:"score"` + CreatedAt string `json:"createat"` +} + type StaffInfo struct { - ID int - Code string - Name string - Role string - Part string - Score int + ID int + Code string + Name string + Role string + Part string + Score int CreatedAt time.Time } diff --git a/service/order/provider.go b/service/order/provider.go index fc391db..4a2e8cc 100644 --- a/service/order/provider.go +++ b/service/order/provider.go @@ -52,8 +52,8 @@ func (o *OrderManager) GetOrderInfo(userid int) (model.OrderResponse, error) { CouponPrice: info.CouponPrice, CouponName: info.CouponName, - ReserveAt: info.ReserveAt.Format(model.TimeMinuteFormat), - CreatedAt: info.CreatedAt.Format(model.TimeMinuteFormat), + ReserveAt: info.ReserveAt.Format(model.TimeSecondFormat), + CreatedAt: info.CreatedAt.Format(model.TimeSecondFormat), }, }, nil }