Skip to content

Commit

Permalink
fix menuid error
Browse files Browse the repository at this point in the history
  • Loading branch information
mulmuri committed Nov 26, 2022
1 parent 2936da1 commit d4e3287
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
11 changes: 9 additions & 2 deletions database/db/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"context"
"database/sql"
"time"

"mr.jackpot-backend/database/orm"
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions database/orm/create_order.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions database/orm/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions database/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion model/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
22 changes: 16 additions & 6 deletions model/staff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions service/order/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d4e3287

Please sign in to comment.