diff --git a/graph/accounting.graphqls b/graph/accounting.graphqls new file mode 100644 index 0000000..dcf1955 --- /dev/null +++ b/graph/accounting.graphqls @@ -0,0 +1,32 @@ +type AccountTable { + StartAdvance: Float!, + AcceptedAdvance: Int!, + OrderedMeals: Float!, + EndAdvance: Float! +} + +type CashAdvance { + Id: ID!, + Date: Int!, + VariableSymbol: Int!, + Amount: Int!, + Notice: String! +} + +type MenuOrders2 { + Date: Int!, + PriceLvlGroupId: Int!, + GroupName: String!, + PriceLvlId: Int!, + PriceLvlName: String!, + PriceLvlAmount: Int!, + PriceLvlCommission: Float!, + Count: Int!, + Amount: Float! +} + +extend type Query { + adminGetAccountTable(restaurant_id: Int!, from: Int!, to: Int!): AccountTable! + adminGetCashAdvances(restaurant_id: Int!, from: Int!, to: Int!): [CashAdvance]! + adminGetMenuOrders2(restaurant_id: Int!, from: Int!, to: Int!): [MenuOrders2]! +} \ No newline at end of file diff --git a/graph/accounting.resolvers.go b/graph/accounting.resolvers.go new file mode 100644 index 0000000..da9d8d1 --- /dev/null +++ b/graph/accounting.resolvers.go @@ -0,0 +1,44 @@ +package graph + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.40 + +import ( + "context" + "delta-eats/graph/model" + "time" +) + +// AdminGetAccountTable is the resolver for the adminGetAccountTable field. +func (r *queryResolver) AdminGetAccountTable(ctx context.Context, restaurantID int, from int, to int) (*model.AccountTable, error) { + dateFrom := time.Unix(int64(from), 0) + dateTo := time.Unix(int64(to), 0) + accountTable, err := r.AccountingUsecase.GetAccountTable(ctx, restaurantID, dateFrom, dateTo) + if err != nil { + return nil, err + } + return r.Mapper.MapAccountTable(*accountTable), nil +} + +// AdminGetCashAdvances is the resolver for the adminGetCashAdvances field. +func (r *queryResolver) AdminGetCashAdvances(ctx context.Context, restaurantID int, from int, to int) ([]*model.CashAdvance, error) { + dateFrom := time.Unix(int64(from), 0) + dateTo := time.Unix(int64(to), 0) + cashAdvances, err := r.AccountingUsecase.GetCashAdvances(ctx, restaurantID, dateFrom, dateTo) + if err != nil { + return nil, err + } + return r.Mapper.MapCashAdvances(cashAdvances), nil +} + +// AdminGetMenuOrders2 is the resolver for the adminGetMenuOrders2 field. +func (r *queryResolver) AdminGetMenuOrders2(ctx context.Context, restaurantID int, from int, to int) ([]*model.MenuOrders2, error) { + dateFrom := time.Unix(int64(from), 0) + dateTo := time.Unix(int64(to), 0) + menuOrders2, err := r.AccountingUsecase.GetMenuOrders2(ctx, restaurantID, dateFrom, dateTo) + if err != nil { + return nil, err + } + return r.Mapper.MapMenuOrders2(menuOrders2), nil +} diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 247ee32..d2bb297 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -50,6 +50,13 @@ type ComplexityRoot struct { Ok func(childComplexity int) int } + AccountTable struct { + AcceptedAdvance func(childComplexity int) int + EndAdvance func(childComplexity int) int + OrderedMeals func(childComplexity int) int + StartAdvance func(childComplexity int) int + } + AdminMenu struct { Count func(childComplexity int) int Date func(childComplexity int) int @@ -60,6 +67,19 @@ type ComplexityRoot struct { Soup func(childComplexity int) int } + CashAdvance struct { + Amount func(childComplexity int) int + Date func(childComplexity int) int + ID func(childComplexity int) int + Notice func(childComplexity int) int + VariableSymbol func(childComplexity int) int + } + + DateMenu struct { + Date func(childComplexity int) int + Menus func(childComplexity int) int + } + FoodPriceLevel struct { ID func(childComplexity int) int Name func(childComplexity int) int @@ -76,6 +96,18 @@ type ComplexityRoot struct { Soup func(childComplexity int) int } + MenuOrders2 struct { + Amount func(childComplexity int) int + Count func(childComplexity int) int + Date func(childComplexity int) int + GroupName func(childComplexity int) int + PriceLvlAmount func(childComplexity int) int + PriceLvlCommission func(childComplexity int) int + PriceLvlGroupID func(childComplexity int) int + PriceLvlID func(childComplexity int) int + PriceLvlName func(childComplexity int) int + } + Mutation struct { ActivateOrder func(childComplexity int, orderID string) int AddminDeleteDomain func(childComplexity int, domainID string) int @@ -110,6 +142,7 @@ type ComplexityRoot struct { } PriceLevelGroup struct { + Commission func(childComplexity int) int FoodPriceLevel func(childComplexity int) int ID func(childComplexity int) int Price func(childComplexity int) int @@ -124,12 +157,16 @@ type ComplexityRoot struct { } Query struct { + AdminGetAccountTable func(childComplexity int, restaurantID int, from int, to int) int AdminGetAllFoodPriceLvls func(childComplexity int) int AdminGetAllPriceLvlGroups func(childComplexity int) int AdminGetAllUserGroups func(childComplexity int) int + AdminGetCashAdvances func(childComplexity int, restaurantID int, from int, to int) int AdminGetDrinks func(childComplexity int) int AdminGetMainDishes func(childComplexity int) int AdminGetMenuOrders func(childComplexity int, from int, to int) int + AdminGetMenuOrders2 func(childComplexity int, restaurantID int, from int, to int) int + AdminGetMenusByDate func(childComplexity int, from int, to int) int AdminGetSoups func(childComplexity int) int AdminGetUsersByGroup func(childComplexity int, groupID string) int CheckVersion func(childComplexity int, current string) int @@ -211,10 +248,14 @@ type MutationResolver interface { } type QueryResolver interface { Ping(ctx context.Context) (string, error) + AdminGetAccountTable(ctx context.Context, restaurantID int, from int, to int) (*model.AccountTable, error) + AdminGetCashAdvances(ctx context.Context, restaurantID int, from int, to int) ([]*model.CashAdvance, error) + AdminGetMenuOrders2(ctx context.Context, restaurantID int, from int, to int) ([]*model.MenuOrders2, error) AdminGetMainDishes(ctx context.Context) ([]string, error) AdminGetSoups(ctx context.Context) ([]string, error) AdminGetDrinks(ctx context.Context) ([]string, error) AdminGetMenuOrders(ctx context.Context, from int, to int) ([]*model.AdminMenu, error) + AdminGetMenusByDate(ctx context.Context, from int, to int) ([]*model.DateMenu, error) GetMenusByDate(ctx context.Context, from int, to int) ([]*model.Menu, error) GetMenuByID(ctx context.Context, id string) (*model.Menu, error) MyOrders(ctx context.Context, from int, to int) ([]*model.Order, error) @@ -256,6 +297,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ACK.Ok(childComplexity), true + case "AccountTable.AcceptedAdvance": + if e.complexity.AccountTable.AcceptedAdvance == nil { + break + } + + return e.complexity.AccountTable.AcceptedAdvance(childComplexity), true + + case "AccountTable.EndAdvance": + if e.complexity.AccountTable.EndAdvance == nil { + break + } + + return e.complexity.AccountTable.EndAdvance(childComplexity), true + + case "AccountTable.OrderedMeals": + if e.complexity.AccountTable.OrderedMeals == nil { + break + } + + return e.complexity.AccountTable.OrderedMeals(childComplexity), true + + case "AccountTable.StartAdvance": + if e.complexity.AccountTable.StartAdvance == nil { + break + } + + return e.complexity.AccountTable.StartAdvance(childComplexity), true + case "AdminMenu.Count": if e.complexity.AdminMenu.Count == nil { break @@ -305,6 +374,55 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.AdminMenu.Soup(childComplexity), true + case "CashAdvance.Amount": + if e.complexity.CashAdvance.Amount == nil { + break + } + + return e.complexity.CashAdvance.Amount(childComplexity), true + + case "CashAdvance.Date": + if e.complexity.CashAdvance.Date == nil { + break + } + + return e.complexity.CashAdvance.Date(childComplexity), true + + case "CashAdvance.Id": + if e.complexity.CashAdvance.ID == nil { + break + } + + return e.complexity.CashAdvance.ID(childComplexity), true + + case "CashAdvance.Notice": + if e.complexity.CashAdvance.Notice == nil { + break + } + + return e.complexity.CashAdvance.Notice(childComplexity), true + + case "CashAdvance.VariableSymbol": + if e.complexity.CashAdvance.VariableSymbol == nil { + break + } + + return e.complexity.CashAdvance.VariableSymbol(childComplexity), true + + case "DateMenu.date": + if e.complexity.DateMenu.Date == nil { + break + } + + return e.complexity.DateMenu.Date(childComplexity), true + + case "DateMenu.menus": + if e.complexity.DateMenu.Menus == nil { + break + } + + return e.complexity.DateMenu.Menus(childComplexity), true + case "FoodPriceLevel.id": if e.complexity.FoodPriceLevel.ID == nil { break @@ -375,6 +493,69 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Menu.Soup(childComplexity), true + case "MenuOrders2.Amount": + if e.complexity.MenuOrders2.Amount == nil { + break + } + + return e.complexity.MenuOrders2.Amount(childComplexity), true + + case "MenuOrders2.Count": + if e.complexity.MenuOrders2.Count == nil { + break + } + + return e.complexity.MenuOrders2.Count(childComplexity), true + + case "MenuOrders2.Date": + if e.complexity.MenuOrders2.Date == nil { + break + } + + return e.complexity.MenuOrders2.Date(childComplexity), true + + case "MenuOrders2.GroupName": + if e.complexity.MenuOrders2.GroupName == nil { + break + } + + return e.complexity.MenuOrders2.GroupName(childComplexity), true + + case "MenuOrders2.PriceLvlAmount": + if e.complexity.MenuOrders2.PriceLvlAmount == nil { + break + } + + return e.complexity.MenuOrders2.PriceLvlAmount(childComplexity), true + + case "MenuOrders2.PriceLvlCommission": + if e.complexity.MenuOrders2.PriceLvlCommission == nil { + break + } + + return e.complexity.MenuOrders2.PriceLvlCommission(childComplexity), true + + case "MenuOrders2.PriceLvlGroupId": + if e.complexity.MenuOrders2.PriceLvlGroupID == nil { + break + } + + return e.complexity.MenuOrders2.PriceLvlGroupID(childComplexity), true + + case "MenuOrders2.PriceLvlId": + if e.complexity.MenuOrders2.PriceLvlID == nil { + break + } + + return e.complexity.MenuOrders2.PriceLvlID(childComplexity), true + + case "MenuOrders2.PriceLvlName": + if e.complexity.MenuOrders2.PriceLvlName == nil { + break + } + + return e.complexity.MenuOrders2.PriceLvlName(childComplexity), true + case "Mutation.activateOrder": if e.complexity.Mutation.ActivateOrder == nil { break @@ -674,6 +855,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Order.UserID(childComplexity), true + case "PriceLevelGroup.Commission": + if e.complexity.PriceLevelGroup.Commission == nil { + break + } + + return e.complexity.PriceLevelGroup.Commission(childComplexity), true + case "PriceLevelGroup.FoodPriceLevel": if e.complexity.PriceLevelGroup.FoodPriceLevel == nil { break @@ -730,6 +918,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PriceLvl.Name(childComplexity), true + case "Query.adminGetAccountTable": + if e.complexity.Query.AdminGetAccountTable == nil { + break + } + + args, err := ec.field_Query_adminGetAccountTable_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.AdminGetAccountTable(childComplexity, args["restaurant_id"].(int), args["from"].(int), args["to"].(int)), true + case "Query.adminGetAllFoodPriceLvls": if e.complexity.Query.AdminGetAllFoodPriceLvls == nil { break @@ -751,6 +951,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.AdminGetAllUserGroups(childComplexity), true + case "Query.adminGetCashAdvances": + if e.complexity.Query.AdminGetCashAdvances == nil { + break + } + + args, err := ec.field_Query_adminGetCashAdvances_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.AdminGetCashAdvances(childComplexity, args["restaurant_id"].(int), args["from"].(int), args["to"].(int)), true + case "Query.adminGetDrinks": if e.complexity.Query.AdminGetDrinks == nil { break @@ -777,6 +989,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.AdminGetMenuOrders(childComplexity, args["from"].(int), args["to"].(int)), true + case "Query.adminGetMenuOrders2": + if e.complexity.Query.AdminGetMenuOrders2 == nil { + break + } + + args, err := ec.field_Query_adminGetMenuOrders2_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.AdminGetMenuOrders2(childComplexity, args["restaurant_id"].(int), args["from"].(int), args["to"].(int)), true + + case "Query.adminGetMenusByDate": + if e.complexity.Query.AdminGetMenusByDate == nil { + break + } + + args, err := ec.field_Query_adminGetMenusByDate_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.AdminGetMenusByDate(childComplexity, args["from"].(int), args["to"].(int)), true + case "Query.adminGetSoups": if e.complexity.Query.AdminGetSoups == nil { break @@ -1167,6 +1403,38 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ + {Name: "../accounting.graphqls", Input: `type AccountTable { + StartAdvance: Float!, + AcceptedAdvance: Int!, + OrderedMeals: Float!, + EndAdvance: Float! +} + +type CashAdvance { + Id: ID!, + Date: Int!, + VariableSymbol: Int!, + Amount: Int!, + Notice: String! +} + +type MenuOrders2 { + Date: Int!, + PriceLvlGroupId: Int!, + GroupName: String!, + PriceLvlId: Int!, + PriceLvlName: String!, + PriceLvlAmount: Int!, + PriceLvlCommission: Float!, + Count: Int!, + Amount: Float! +} + +extend type Query { + adminGetAccountTable(restaurant_id: Int!, from: Int!, to: Int!): AccountTable! + adminGetCashAdvances(restaurant_id: Int!, from: Int!, to: Int!): [CashAdvance]! + adminGetMenuOrders2(restaurant_id: Int!, from: Int!, to: Int!): [MenuOrders2]! +}`, BuiltIn: false}, {Name: "../menu.graphqls", Input: `type Menu { id: ID! date: Int! @@ -1193,6 +1461,11 @@ type PriceLvl { name: String! } +type DateMenu { + date: Int! + menus: [Menu]! +} + input UpdateMenus{ id:ID! date: Int! @@ -1217,6 +1490,7 @@ extend type Query { adminGetSoups: [String!]! adminGetDrinks: [String!]! adminGetMenuOrders(from: Int!, to: Int!): [AdminMenu!]! + adminGetMenusByDate(from: Int!, to: Int!): [DateMenu!]! getMenusByDate(from: Int!, to:Int!): [Menu!]! getMenuById(id: ID!): Menu! @@ -1271,6 +1545,7 @@ type PriceLevelGroup { price: Int! FoodPriceLevel: FoodPriceLevel! UserGroup: UserGroup! + Commission: Float! } type UserGroup { @@ -1295,6 +1570,7 @@ input CreatePriceLevelGroup { Price: Int! FoodPriceLevelID: ID! UserGroupID: ID! + Commission: Float! } input UpdateUserGroup { @@ -1311,6 +1587,7 @@ input UpdatePriceLvlGroup{ Price: Int! FoodPriceLevelID: ID! UserGroupID: ID! + Commission: Float! } extend type Query { @@ -1799,6 +2076,105 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_adminGetAccountTable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["restaurant_id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("restaurant_id")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["restaurant_id"] = arg0 + var arg1 int + if tmp, ok := rawArgs["from"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from")) + arg1, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["from"] = arg1 + var arg2 int + if tmp, ok := rawArgs["to"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to")) + arg2, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["to"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_adminGetCashAdvances_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["restaurant_id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("restaurant_id")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["restaurant_id"] = arg0 + var arg1 int + if tmp, ok := rawArgs["from"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from")) + arg1, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["from"] = arg1 + var arg2 int + if tmp, ok := rawArgs["to"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to")) + arg2, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["to"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_adminGetMenuOrders2_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["restaurant_id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("restaurant_id")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["restaurant_id"] = arg0 + var arg1 int + if tmp, ok := rawArgs["from"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from")) + arg1, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["from"] = arg1 + var arg2 int + if tmp, ok := rawArgs["to"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to")) + arg2, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["to"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_adminGetMenuOrders_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1823,6 +2199,30 @@ func (ec *executionContext) field_Query_adminGetMenuOrders_args(ctx context.Cont return args, nil } +func (ec *executionContext) field_Query_adminGetMenusByDate_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["from"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["from"] = arg0 + var arg1 int + if tmp, ok := rawArgs["to"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to")) + arg1, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["to"] = arg1 + return args, nil +} + func (ec *executionContext) field_Query_adminGetUsersByGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2058,8 +2458,8 @@ func (ec *executionContext) fieldContext_ACK_ok(ctx context.Context, field graph return fc, nil } -func (ec *executionContext) _AdminMenu_id(ctx context.Context, field graphql.CollectedField, obj *model.AdminMenu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AdminMenu_id(ctx, field) +func (ec *executionContext) _AccountTable_StartAdvance(ctx context.Context, field graphql.CollectedField, obj *model.AccountTable) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AccountTable_StartAdvance(ctx, field) if err != nil { return graphql.Null } @@ -2072,7 +2472,7 @@ func (ec *executionContext) _AdminMenu_id(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.StartAdvance, nil }) if err != nil { ec.Error(ctx, err) @@ -2084,26 +2484,26 @@ func (ec *executionContext) _AdminMenu_id(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(float64) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AdminMenu_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AccountTable_StartAdvance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "AdminMenu", + Object: "AccountTable", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } -func (ec *executionContext) _AdminMenu_date(ctx context.Context, field graphql.CollectedField, obj *model.AdminMenu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AdminMenu_date(ctx, field) +func (ec *executionContext) _AccountTable_AcceptedAdvance(ctx context.Context, field graphql.CollectedField, obj *model.AccountTable) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AccountTable_AcceptedAdvance(ctx, field) if err != nil { return graphql.Null } @@ -2116,7 +2516,7 @@ func (ec *executionContext) _AdminMenu_date(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Date, nil + return obj.AcceptedAdvance, nil }) if err != nil { ec.Error(ctx, err) @@ -2133,9 +2533,9 @@ func (ec *executionContext) _AdminMenu_date(ctx context.Context, field graphql.C return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AdminMenu_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AccountTable_AcceptedAdvance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "AdminMenu", + Object: "AccountTable", Field: field, IsMethod: false, IsResolver: false, @@ -2146,8 +2546,8 @@ func (ec *executionContext) fieldContext_AdminMenu_date(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _AdminMenu_meal(ctx context.Context, field graphql.CollectedField, obj *model.AdminMenu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AdminMenu_meal(ctx, field) +func (ec *executionContext) _AccountTable_OrderedMeals(ctx context.Context, field graphql.CollectedField, obj *model.AccountTable) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AccountTable_OrderedMeals(ctx, field) if err != nil { return graphql.Null } @@ -2160,7 +2560,7 @@ func (ec *executionContext) _AdminMenu_meal(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Meal, nil + return obj.OrderedMeals, nil }) if err != nil { ec.Error(ctx, err) @@ -2172,14 +2572,190 @@ func (ec *executionContext) _AdminMenu_meal(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(string) + res := resTmp.(float64) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AdminMenu_meal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AccountTable_OrderedMeals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "AdminMenu", + Object: "AccountTable", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AccountTable_EndAdvance(ctx context.Context, field graphql.CollectedField, obj *model.AccountTable) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AccountTable_EndAdvance(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EndAdvance, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(float64) + fc.Result = res + return ec.marshalNFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_AccountTable_EndAdvance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AccountTable", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AdminMenu_id(ctx context.Context, field graphql.CollectedField, obj *model.AdminMenu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AdminMenu_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_AdminMenu_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AdminMenu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AdminMenu_date(ctx context.Context, field graphql.CollectedField, obj *model.AdminMenu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AdminMenu_date(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Date, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_AdminMenu_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AdminMenu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AdminMenu_meal(ctx context.Context, field graphql.CollectedField, obj *model.AdminMenu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AdminMenu_meal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Meal, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_AdminMenu_meal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AdminMenu", Field: field, IsMethod: false, IsResolver: false, @@ -2366,8 +2942,8 @@ func (ec *executionContext) fieldContext_AdminMenu_Count(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _FoodPriceLevel_id(ctx context.Context, field graphql.CollectedField, obj *model.FoodPriceLevel) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_FoodPriceLevel_id(ctx, field) +func (ec *executionContext) _CashAdvance_Id(ctx context.Context, field graphql.CollectedField, obj *model.CashAdvance) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CashAdvance_Id(ctx, field) if err != nil { return graphql.Null } @@ -2397,9 +2973,9 @@ func (ec *executionContext) _FoodPriceLevel_id(ctx context.Context, field graphq return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_FoodPriceLevel_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CashAdvance_Id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "FoodPriceLevel", + Object: "CashAdvance", Field: field, IsMethod: false, IsResolver: false, @@ -2410,8 +2986,8 @@ func (ec *executionContext) fieldContext_FoodPriceLevel_id(ctx context.Context, return fc, nil } -func (ec *executionContext) _FoodPriceLevel_name(ctx context.Context, field graphql.CollectedField, obj *model.FoodPriceLevel) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_FoodPriceLevel_name(ctx, field) +func (ec *executionContext) _CashAdvance_Date(ctx context.Context, field graphql.CollectedField, obj *model.CashAdvance) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CashAdvance_Date(ctx, field) if err != nil { return graphql.Null } @@ -2424,7 +3000,7 @@ func (ec *executionContext) _FoodPriceLevel_name(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Date, nil }) if err != nil { ec.Error(ctx, err) @@ -2436,26 +3012,26 @@ func (ec *executionContext) _FoodPriceLevel_name(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_FoodPriceLevel_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CashAdvance_Date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "FoodPriceLevel", + Object: "CashAdvance", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Menu_id(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_id(ctx, field) +func (ec *executionContext) _CashAdvance_VariableSymbol(ctx context.Context, field graphql.CollectedField, obj *model.CashAdvance) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CashAdvance_VariableSymbol(ctx, field) if err != nil { return graphql.Null } @@ -2468,7 +3044,7 @@ func (ec *executionContext) _Menu_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.VariableSymbol, nil }) if err != nil { ec.Error(ctx, err) @@ -2480,26 +3056,26 @@ func (ec *executionContext) _Menu_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CashAdvance_VariableSymbol(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "CashAdvance", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Menu_date(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_date(ctx, field) +func (ec *executionContext) _CashAdvance_Amount(ctx context.Context, field graphql.CollectedField, obj *model.CashAdvance) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CashAdvance_Amount(ctx, field) if err != nil { return graphql.Null } @@ -2512,7 +3088,7 @@ func (ec *executionContext) _Menu_date(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Date, nil + return obj.Amount, nil }) if err != nil { ec.Error(ctx, err) @@ -2529,9 +3105,9 @@ func (ec *executionContext) _Menu_date(ctx context.Context, field graphql.Collec return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CashAdvance_Amount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "CashAdvance", Field: field, IsMethod: false, IsResolver: false, @@ -2542,8 +3118,8 @@ func (ec *executionContext) fieldContext_Menu_date(ctx context.Context, field gr return fc, nil } -func (ec *executionContext) _Menu_meal(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_meal(ctx, field) +func (ec *executionContext) _CashAdvance_Notice(ctx context.Context, field graphql.CollectedField, obj *model.CashAdvance) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CashAdvance_Notice(ctx, field) if err != nil { return graphql.Null } @@ -2556,7 +3132,7 @@ func (ec *executionContext) _Menu_meal(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Meal, nil + return obj.Notice, nil }) if err != nil { ec.Error(ctx, err) @@ -2573,9 +3149,9 @@ func (ec *executionContext) _Menu_meal(ctx context.Context, field graphql.Collec return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_meal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CashAdvance_Notice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "CashAdvance", Field: field, IsMethod: false, IsResolver: false, @@ -2586,8 +3162,8 @@ func (ec *executionContext) fieldContext_Menu_meal(ctx context.Context, field gr return fc, nil } -func (ec *executionContext) _Menu_drink(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_drink(ctx, field) +func (ec *executionContext) _DateMenu_date(ctx context.Context, field graphql.CollectedField, obj *model.DateMenu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DateMenu_date(ctx, field) if err != nil { return graphql.Null } @@ -2600,7 +3176,7 @@ func (ec *executionContext) _Menu_drink(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Drink, nil + return obj.Date, nil }) if err != nil { ec.Error(ctx, err) @@ -2612,26 +3188,26 @@ func (ec *executionContext) _Menu_drink(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_drink(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DateMenu_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "DateMenu", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Menu_soup(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_soup(ctx, field) +func (ec *executionContext) _DateMenu_menus(ctx context.Context, field graphql.CollectedField, obj *model.DateMenu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DateMenu_menus(ctx, field) if err != nil { return graphql.Null } @@ -2644,7 +3220,7 @@ func (ec *executionContext) _Menu_soup(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Soup, nil + return obj.Menus, nil }) if err != nil { ec.Error(ctx, err) @@ -2656,26 +3232,748 @@ func (ec *executionContext) _Menu_soup(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*model.Menu) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNMenu2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenu(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_soup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DateMenu_menus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "DateMenu", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Menu_id(ctx, field) + case "date": + return ec.fieldContext_Menu_date(ctx, field) + case "meal": + return ec.fieldContext_Menu_meal(ctx, field) + case "drink": + return ec.fieldContext_Menu_drink(ctx, field) + case "soup": + return ec.fieldContext_Menu_soup(ctx, field) + case "price": + return ec.fieldContext_Menu_price(ctx, field) + case "Order": + return ec.fieldContext_Menu_Order(ctx, field) + case "priceLvlId": + return ec.fieldContext_Menu_priceLvlId(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Menu", field.Name) }, } return fc, nil } -func (ec *executionContext) _Menu_price(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_price(ctx, field) +func (ec *executionContext) _FoodPriceLevel_id(ctx context.Context, field graphql.CollectedField, obj *model.FoodPriceLevel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FoodPriceLevel_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FoodPriceLevel_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FoodPriceLevel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _FoodPriceLevel_name(ctx context.Context, field graphql.CollectedField, obj *model.FoodPriceLevel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FoodPriceLevel_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FoodPriceLevel_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FoodPriceLevel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_id(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_date(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_date(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Date, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_meal(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_meal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Meal, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_meal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_drink(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_drink(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Drink, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_drink(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_soup(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_soup(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Soup, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_soup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_price(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_price(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Price, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_price(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_Order(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_Order(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Order, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_Order(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Menu_priceLvlId(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Menu_priceLvlId(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PriceLvlID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Menu_priceLvlId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Menu", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_Date(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_Date(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Date, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MenuOrders2_Date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MenuOrders2", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_PriceLvlGroupId(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_PriceLvlGroupId(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PriceLvlGroupID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MenuOrders2_PriceLvlGroupId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MenuOrders2", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_GroupName(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_GroupName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GroupName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MenuOrders2_GroupName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MenuOrders2", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_PriceLvlId(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_PriceLvlId(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PriceLvlID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MenuOrders2_PriceLvlId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MenuOrders2", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_PriceLvlName(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_PriceLvlName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PriceLvlName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MenuOrders2_PriceLvlName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MenuOrders2", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_PriceLvlAmount(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_PriceLvlAmount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PriceLvlAmount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MenuOrders2_PriceLvlAmount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MenuOrders2", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MenuOrders2_PriceLvlCommission(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_PriceLvlCommission(ctx, field) if err != nil { return graphql.Null } @@ -2688,7 +3986,7 @@ func (ec *executionContext) _Menu_price(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Price, nil + return obj.PriceLvlCommission, nil }) if err != nil { ec.Error(ctx, err) @@ -2700,26 +3998,26 @@ func (ec *executionContext) _Menu_price(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(int) + res := resTmp.(float64) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_price(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MenuOrders2_PriceLvlCommission(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "MenuOrders2", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Menu_Order(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_Order(ctx, field) +func (ec *executionContext) _MenuOrders2_Count(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_Count(ctx, field) if err != nil { return graphql.Null } @@ -2732,7 +4030,7 @@ func (ec *executionContext) _Menu_Order(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Order, nil + return obj.Count, nil }) if err != nil { ec.Error(ctx, err) @@ -2749,9 +4047,9 @@ func (ec *executionContext) _Menu_Order(ctx context.Context, field graphql.Colle return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_Order(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MenuOrders2_Count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "MenuOrders2", Field: field, IsMethod: false, IsResolver: false, @@ -2762,8 +4060,8 @@ func (ec *executionContext) fieldContext_Menu_Order(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Menu_priceLvlId(ctx context.Context, field graphql.CollectedField, obj *model.Menu) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Menu_priceLvlId(ctx, field) +func (ec *executionContext) _MenuOrders2_Amount(ctx context.Context, field graphql.CollectedField, obj *model.MenuOrders2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MenuOrders2_Amount(ctx, field) if err != nil { return graphql.Null } @@ -2776,7 +4074,7 @@ func (ec *executionContext) _Menu_priceLvlId(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PriceLvlID, nil + return obj.Amount, nil }) if err != nil { ec.Error(ctx, err) @@ -2788,19 +4086,19 @@ func (ec *executionContext) _Menu_priceLvlId(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.(float64) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Menu_priceLvlId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MenuOrders2_Amount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Menu", + Object: "MenuOrders2", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil @@ -3442,6 +4740,8 @@ func (ec *executionContext) fieldContext_Mutation_adminCreatePriceLvlGroup(ctx c return ec.fieldContext_PriceLevelGroup_FoodPriceLevel(ctx, field) case "UserGroup": return ec.fieldContext_PriceLevelGroup_UserGroup(ctx, field) + case "Commission": + return ec.fieldContext_PriceLevelGroup_Commission(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PriceLevelGroup", field.Name) }, @@ -4712,6 +6012,50 @@ func (ec *executionContext) fieldContext_PriceLevelGroup_UserGroup(ctx context.C return fc, nil } +func (ec *executionContext) _PriceLevelGroup_Commission(ctx context.Context, field graphql.CollectedField, obj *model.PriceLevelGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PriceLevelGroup_Commission(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Commission, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(float64) + fc.Result = res + return ec.marshalNFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PriceLevelGroup_Commission(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PriceLevelGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _PriceLvl_id(ctx context.Context, field graphql.CollectedField, obj *model.PriceLvl) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PriceLvl_id(ctx, field) if err != nil { @@ -4844,6 +6188,213 @@ func (ec *executionContext) fieldContext_Query_ping(ctx context.Context, field g return fc, nil } +func (ec *executionContext) _Query_adminGetAccountTable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_adminGetAccountTable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().AdminGetAccountTable(rctx, fc.Args["restaurant_id"].(int), fc.Args["from"].(int), fc.Args["to"].(int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.AccountTable) + fc.Result = res + return ec.marshalNAccountTable2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐAccountTable(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_adminGetAccountTable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "StartAdvance": + return ec.fieldContext_AccountTable_StartAdvance(ctx, field) + case "AcceptedAdvance": + return ec.fieldContext_AccountTable_AcceptedAdvance(ctx, field) + case "OrderedMeals": + return ec.fieldContext_AccountTable_OrderedMeals(ctx, field) + case "EndAdvance": + return ec.fieldContext_AccountTable_EndAdvance(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type AccountTable", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_adminGetAccountTable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_adminGetCashAdvances(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_adminGetCashAdvances(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().AdminGetCashAdvances(rctx, fc.Args["restaurant_id"].(int), fc.Args["from"].(int), fc.Args["to"].(int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.CashAdvance) + fc.Result = res + return ec.marshalNCashAdvance2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐCashAdvance(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_adminGetCashAdvances(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "Id": + return ec.fieldContext_CashAdvance_Id(ctx, field) + case "Date": + return ec.fieldContext_CashAdvance_Date(ctx, field) + case "VariableSymbol": + return ec.fieldContext_CashAdvance_VariableSymbol(ctx, field) + case "Amount": + return ec.fieldContext_CashAdvance_Amount(ctx, field) + case "Notice": + return ec.fieldContext_CashAdvance_Notice(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CashAdvance", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_adminGetCashAdvances_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_adminGetMenuOrders2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_adminGetMenuOrders2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().AdminGetMenuOrders2(rctx, fc.Args["restaurant_id"].(int), fc.Args["from"].(int), fc.Args["to"].(int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.MenuOrders2) + fc.Result = res + return ec.marshalNMenuOrders22ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenuOrders2(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_adminGetMenuOrders2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "Date": + return ec.fieldContext_MenuOrders2_Date(ctx, field) + case "PriceLvlGroupId": + return ec.fieldContext_MenuOrders2_PriceLvlGroupId(ctx, field) + case "GroupName": + return ec.fieldContext_MenuOrders2_GroupName(ctx, field) + case "PriceLvlId": + return ec.fieldContext_MenuOrders2_PriceLvlId(ctx, field) + case "PriceLvlName": + return ec.fieldContext_MenuOrders2_PriceLvlName(ctx, field) + case "PriceLvlAmount": + return ec.fieldContext_MenuOrders2_PriceLvlAmount(ctx, field) + case "PriceLvlCommission": + return ec.fieldContext_MenuOrders2_PriceLvlCommission(ctx, field) + case "Count": + return ec.fieldContext_MenuOrders2_Count(ctx, field) + case "Amount": + return ec.fieldContext_MenuOrders2_Amount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MenuOrders2", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_adminGetMenuOrders2_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query_adminGetMainDishes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_adminGetMainDishes(ctx, field) if err != nil { @@ -5030,7 +6581,68 @@ func (ec *executionContext) fieldContext_Query_adminGetMenuOrders(ctx context.Co case "Count": return ec.fieldContext_AdminMenu_Count(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AdminMenu", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AdminMenu", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_adminGetMenuOrders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_adminGetMenusByDate(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_adminGetMenusByDate(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().AdminGetMenusByDate(rctx, fc.Args["from"].(int), fc.Args["to"].(int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.DateMenu) + fc.Result = res + return ec.marshalNDateMenu2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐDateMenuᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_adminGetMenusByDate(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "date": + return ec.fieldContext_DateMenu_date(ctx, field) + case "menus": + return ec.fieldContext_DateMenu_menus(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DateMenu", field.Name) }, } defer func() { @@ -5040,7 +6652,7 @@ func (ec *executionContext) fieldContext_Query_adminGetMenuOrders(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_adminGetMenuOrders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_adminGetMenusByDate_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -5478,6 +7090,8 @@ func (ec *executionContext) fieldContext_Query_adminGetAllPriceLvlGroups(ctx con return ec.fieldContext_PriceLevelGroup_FoodPriceLevel(ctx, field) case "UserGroup": return ec.fieldContext_PriceLevelGroup_UserGroup(ctx, field) + case "Commission": + return ec.fieldContext_PriceLevelGroup_Commission(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PriceLevelGroup", field.Name) }, @@ -8767,7 +10381,7 @@ func (ec *executionContext) unmarshalInputCreatePriceLevelGroup(ctx context.Cont asMap[k] = v } - fieldsInOrder := [...]string{"ValidFrom", "ValidTo", "Price", "FoodPriceLevelID", "UserGroupID"} + fieldsInOrder := [...]string{"ValidFrom", "ValidTo", "Price", "FoodPriceLevelID", "UserGroupID", "Commission"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -8819,6 +10433,15 @@ func (ec *executionContext) unmarshalInputCreatePriceLevelGroup(ctx context.Cont return it, err } it.UserGroupID = data + case "Commission": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Commission")) + data, err := ec.unmarshalNFloat2float64(ctx, v) + if err != nil { + return it, err + } + it.Commission = data } } @@ -8982,7 +10605,7 @@ func (ec *executionContext) unmarshalInputUpdatePriceLvlGroup(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"ValidFrom", "ValidTo", "Price", "FoodPriceLevelID", "UserGroupID"} + fieldsInOrder := [...]string{"ValidFrom", "ValidTo", "Price", "FoodPriceLevelID", "UserGroupID", "Commission"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -9034,6 +10657,15 @@ func (ec *executionContext) unmarshalInputUpdatePriceLvlGroup(ctx context.Contex return it, err } it.UserGroupID = data + case "Commission": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Commission")) + data, err := ec.unmarshalNFloat2float64(ctx, v) + if err != nil { + return it, err + } + it.Commission = data } } @@ -9210,6 +10842,60 @@ func (ec *executionContext) _ACK(ctx context.Context, sel ast.SelectionSet, obj return out } +var accountTableImplementors = []string{"AccountTable"} + +func (ec *executionContext) _AccountTable(ctx context.Context, sel ast.SelectionSet, obj *model.AccountTable) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, accountTableImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AccountTable") + case "StartAdvance": + out.Values[i] = ec._AccountTable_StartAdvance(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "AcceptedAdvance": + out.Values[i] = ec._AccountTable_AcceptedAdvance(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "OrderedMeals": + out.Values[i] = ec._AccountTable_OrderedMeals(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "EndAdvance": + out.Values[i] = ec._AccountTable_EndAdvance(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var adminMenuImplementors = []string{"AdminMenu"} func (ec *executionContext) _AdminMenu(ctx context.Context, sel ast.SelectionSet, obj *model.AdminMenu) graphql.Marshaler { @@ -9279,6 +10965,109 @@ func (ec *executionContext) _AdminMenu(ctx context.Context, sel ast.SelectionSet return out } +var cashAdvanceImplementors = []string{"CashAdvance"} + +func (ec *executionContext) _CashAdvance(ctx context.Context, sel ast.SelectionSet, obj *model.CashAdvance) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, cashAdvanceImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CashAdvance") + case "Id": + out.Values[i] = ec._CashAdvance_Id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Date": + out.Values[i] = ec._CashAdvance_Date(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "VariableSymbol": + out.Values[i] = ec._CashAdvance_VariableSymbol(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Amount": + out.Values[i] = ec._CashAdvance_Amount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Notice": + out.Values[i] = ec._CashAdvance_Notice(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var dateMenuImplementors = []string{"DateMenu"} + +func (ec *executionContext) _DateMenu(ctx context.Context, sel ast.SelectionSet, obj *model.DateMenu) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, dateMenuImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DateMenu") + case "date": + out.Values[i] = ec._DateMenu_date(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "menus": + out.Values[i] = ec._DateMenu_menus(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var foodPriceLevelImplementors = []string{"FoodPriceLevel"} func (ec *executionContext) _FoodPriceLevel(ctx context.Context, sel ast.SelectionSet, obj *model.FoodPriceLevel) graphql.Marshaler { @@ -9397,6 +11186,85 @@ func (ec *executionContext) _Menu(ctx context.Context, sel ast.SelectionSet, obj return out } +var menuOrders2Implementors = []string{"MenuOrders2"} + +func (ec *executionContext) _MenuOrders2(ctx context.Context, sel ast.SelectionSet, obj *model.MenuOrders2) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, menuOrders2Implementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MenuOrders2") + case "Date": + out.Values[i] = ec._MenuOrders2_Date(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "PriceLvlGroupId": + out.Values[i] = ec._MenuOrders2_PriceLvlGroupId(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "GroupName": + out.Values[i] = ec._MenuOrders2_GroupName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "PriceLvlId": + out.Values[i] = ec._MenuOrders2_PriceLvlId(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "PriceLvlName": + out.Values[i] = ec._MenuOrders2_PriceLvlName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "PriceLvlAmount": + out.Values[i] = ec._MenuOrders2_PriceLvlAmount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "PriceLvlCommission": + out.Values[i] = ec._MenuOrders2_PriceLvlCommission(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Count": + out.Values[i] = ec._MenuOrders2_Count(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Amount": + out.Values[i] = ec._MenuOrders2_Amount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -9695,6 +11563,11 @@ func (ec *executionContext) _PriceLevelGroup(ctx context.Context, sel ast.Select if out.Values[i] == graphql.Null { out.Invalids++ } + case "Commission": + out.Values[i] = ec._PriceLevelGroup_Commission(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -9759,29 +11632,95 @@ func (ec *executionContext) _PriceLvl(ctx context.Context, sel ast.SelectionSet, }) } - return out -} + return out +} + +var queryImplementors = []string{"Query"} + +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "ping": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_ping(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "adminGetAccountTable": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_adminGetAccountTable(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } -var queryImplementors = []string{"Query"} + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "adminGetCashAdvances": + field := field -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_adminGetCashAdvances(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "ping": + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "adminGetMenuOrders2": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -9790,7 +11729,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_ping(ctx, field) + res = ec._Query_adminGetMenuOrders2(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -9890,6 +11829,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "adminGetMenusByDate": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_adminGetMenusByDate(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "getMenusByDate": field := field @@ -10857,6 +12818,20 @@ func (ec *executionContext) marshalNACK2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐAck(ct return ec._ACK(ctx, sel, v) } +func (ec *executionContext) marshalNAccountTable2deltaᚑeatsᚋgraphᚋmodelᚐAccountTable(ctx context.Context, sel ast.SelectionSet, v model.AccountTable) graphql.Marshaler { + return ec._AccountTable(ctx, sel, &v) +} + +func (ec *executionContext) marshalNAccountTable2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐAccountTable(ctx context.Context, sel ast.SelectionSet, v *model.AccountTable) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._AccountTable(ctx, sel, v) +} + func (ec *executionContext) marshalNAdminMenu2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐAdminMenuᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.AdminMenu) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -10926,6 +12901,44 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } +func (ec *executionContext) marshalNCashAdvance2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐCashAdvance(ctx context.Context, sel ast.SelectionSet, v []*model.CashAdvance) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOCashAdvance2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐCashAdvance(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) unmarshalNCreateMenuInput2deltaᚑeatsᚋgraphᚋmodelᚐCreateMenuInput(ctx context.Context, v interface{}) (model.CreateMenuInput, error) { res, err := ec.unmarshalInputCreateMenuInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -10963,6 +12976,75 @@ func (ec *executionContext) unmarshalNCreateUserGroup2deltaᚑeatsᚋgraphᚋmod return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNDateMenu2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐDateMenuᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.DateMenu) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNDateMenu2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐDateMenu(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNDateMenu2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐDateMenu(ctx context.Context, sel ast.SelectionSet, v *model.DateMenu) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._DateMenu(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) { + res, err := graphql.UnmarshalFloatContext(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + res := graphql.MarshalFloatContext(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + func (ec *executionContext) marshalNFoodPriceLevel2deltaᚑeatsᚋgraphᚋmodelᚐFoodPriceLevel(ctx context.Context, sel ast.SelectionSet, v model.FoodPriceLevel) graphql.Marshaler { return ec._FoodPriceLevel(ctx, sel, &v) } @@ -11055,6 +13137,44 @@ func (ec *executionContext) marshalNMenu2deltaᚑeatsᚋgraphᚋmodelᚐMenu(ctx return ec._Menu(ctx, sel, &v) } +func (ec *executionContext) marshalNMenu2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenu(ctx context.Context, sel ast.SelectionSet, v []*model.Menu) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOMenu2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenu(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalNMenu2ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenuᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Menu) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -11109,6 +13229,44 @@ func (ec *executionContext) marshalNMenu2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenu( return ec._Menu(ctx, sel, v) } +func (ec *executionContext) marshalNMenuOrders22ᚕᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenuOrders2(ctx context.Context, sel ast.SelectionSet, v []*model.MenuOrders2) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOMenuOrders22ᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenuOrders2(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalNOrder2deltaᚑeatsᚋgraphᚋmodelᚐOrder(ctx context.Context, sel ast.SelectionSet, v model.Order) graphql.Marshaler { return ec._Order(ctx, sel, &v) } @@ -11836,6 +13994,27 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) marshalOCashAdvance2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐCashAdvance(ctx context.Context, sel ast.SelectionSet, v *model.CashAdvance) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CashAdvance(ctx, sel, v) +} + +func (ec *executionContext) marshalOMenu2ᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenu(ctx context.Context, sel ast.SelectionSet, v *model.Menu) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Menu(ctx, sel, v) +} + +func (ec *executionContext) marshalOMenuOrders22ᚖdeltaᚑeatsᚋgraphᚋmodelᚐMenuOrders2(ctx context.Context, sel ast.SelectionSet, v *model.MenuOrders2) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MenuOrders2(ctx, sel, v) +} + func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { if v == nil { return nil, nil diff --git a/graph/inputMapper.go b/graph/inputMapper.go index 4e4ecee..654bb30 100644 --- a/graph/inputMapper.go +++ b/graph/inputMapper.go @@ -70,6 +70,7 @@ func (i InputMapper) MapCreatePriceLvlGroup(input model.CreatePriceLevelGroup) ( Price: int64(input.Price), FoodPriceLevelID: foodPriceLvlID, UserGroupID: userGroupId, + Commission: float64(input.Commission), }, nil } @@ -88,6 +89,7 @@ func (i InputMapper) MapUpdatePriceLvlGroup(input model.UpdatePriceLvlGroup) (do Price: int64(input.Price), FoodPriceLevelID: foodPriceLvlID, UserGroupID: userGroupId, + Commission: float64(input.Commission), }, nil } diff --git a/graph/mapper.go b/graph/mapper.go index 238531b..5db96c0 100644 --- a/graph/mapper.go +++ b/graph/mapper.go @@ -92,6 +92,21 @@ func (m Mapper) MapAdminMenus(adminMenus []domain.AdminMenu) []*model.AdminMenu return result } +func (m Mapper) MapDateAdminMenu(dateAdminMenu domain.DateMenu) *model.DateMenu { + return &model.DateMenu{ + Date: int(dateAdminMenu.Date), + Menus: m.MapMenus(dateAdminMenu.Menus), + } +} + +func (m Mapper) MapDateAdminMenus(dateAdminMenus []domain.DateMenu) []*model.DateMenu { + var result []*model.DateMenu + for _, dateMenu := range dateAdminMenus { + result = append(result, m.MapDateAdminMenu(dateMenu)) + } + return result +} + func (m Mapper) MapUserGroup(userGroup domain.UserGroup) *model.UserGroup { return &model.UserGroup{ ID: strconv.Itoa(int(userGroup.ID)), @@ -146,6 +161,7 @@ func (m Mapper) MapPriceLvlGroup(priceLvlGroup domain.PriceLevelGroup) *model.Pr Price: int(priceLvlGroup.Price), FoodPriceLevel: m.MapFoodPriceLevel(priceLvlGroup.FoodPriceLevel), UserGroup: m.MapUserGroup(priceLvlGroup.UserGroup), + Commission: float64(priceLvlGroup.Commission), } } @@ -163,3 +179,52 @@ func (m Mapper) MapVersion(version domain.Version) *model.Version { CurrentVersion: version.VersionNumber, } } + +func (m Mapper) MapAccountTable(accountTable domain.AccountTable) *model.AccountTable { + return &model.AccountTable{ + StartAdvance: accountTable.StartAdvance, + AcceptedAdvance: accountTable.AcceptedAdvance, + OrderedMeals: accountTable.OrderedMeals, + EndAdvance: accountTable.EndAdvance, + } +} + +func (m Mapper) MapCashAdvance(cashAdvance *domain.CashAdvance) *model.CashAdvance { + return &model.CashAdvance{ + ID: strconv.Itoa(int(cashAdvance.Id)), + Date: int(cashAdvance.Date.Unix()), + VariableSymbol: int(cashAdvance.VariableSymbol), + Amount: int(cashAdvance.Amount), + Notice: cashAdvance.Notice, + } +} + +func (m Mapper) MapCashAdvances(cashAdvances []*domain.CashAdvance) []*model.CashAdvance { + var result []*model.CashAdvance + for _, cashAdvance := range cashAdvances { + result = append(result, m.MapCashAdvance(cashAdvance)) + } + return result +} + +func (m Mapper) MapMenuOrder2(menuOrder2 *domain.MenuOrder2) *model.MenuOrders2 { + return &model.MenuOrders2{ + Date: int(menuOrder2.Date.Unix()), + PriceLvlGroupID: int(menuOrder2.GroupId), + GroupName: menuOrder2.GroupName, + PriceLvlID: int(menuOrder2.PriceLvlId), + PriceLvlName: menuOrder2.PriceLvlName, + PriceLvlAmount: int(menuOrder2.UnitAmount), + PriceLvlCommission: menuOrder2.Commission, + Count: int(menuOrder2.Count), + Amount: float64(menuOrder2.Amount), + } +} + +func (m Mapper) MapMenuOrders2(menuOrders2 []*domain.MenuOrder2) []*model.MenuOrders2 { + var result []*model.MenuOrders2 + for _, menuOrder2 := range menuOrders2 { + result = append(result, m.MapMenuOrder2(menuOrder2)) + } + return result +} diff --git a/graph/menu.graphqls b/graph/menu.graphqls index 164ea83..e7983d3 100644 --- a/graph/menu.graphqls +++ b/graph/menu.graphqls @@ -24,6 +24,11 @@ type PriceLvl { name: String! } +type DateMenu { + date: Int! + menus: [Menu]! +} + input UpdateMenus{ id:ID! date: Int! @@ -48,6 +53,7 @@ extend type Query { adminGetSoups: [String!]! adminGetDrinks: [String!]! adminGetMenuOrders(from: Int!, to: Int!): [AdminMenu!]! + adminGetMenusByDate(from: Int!, to: Int!): [DateMenu!]! getMenusByDate(from: Int!, to:Int!): [Menu!]! getMenuById(id: ID!): Menu! diff --git a/graph/menu.resolvers.go b/graph/menu.resolvers.go index a9aeee6..b64acc0 100644 --- a/graph/menu.resolvers.go +++ b/graph/menu.resolvers.go @@ -160,6 +160,17 @@ func (r *queryResolver) AdminGetMenuOrders(ctx context.Context, from int, to int return r.Mapper.MapAdminMenus(menus), nil } +// AdminGetMenusByDate is the resolver for the adminGetMenusByDate field. +func (r *queryResolver) AdminGetMenusByDate(ctx context.Context, from int, to int) ([]*model.DateMenu, error) { + dateFrom := time.Unix(int64(from), 0) + dateTo := time.Unix(int64(to), 0) + menus, err := r.MenuUsecase.AdminGetDateMenusByDate(ctx, dateFrom, dateTo) + if err != nil { + return nil, err + } + return r.Mapper.MapDateAdminMenus(menus), nil +} + // GetMenusByDate is the resolver for the getMenusByDate field. func (r *queryResolver) GetMenusByDate(ctx context.Context, from int, to int) ([]*model.Menu, error) { dateFrom := time.Unix(int64(from), 0) diff --git a/graph/model/models_gen.go b/graph/model/models_gen.go index 8f68fb9..27cbb74 100644 --- a/graph/model/models_gen.go +++ b/graph/model/models_gen.go @@ -12,6 +12,13 @@ type Ack struct { Ok bool `json:"ok"` } +type AccountTable struct { + StartAdvance float64 `json:"StartAdvance"` + AcceptedAdvance int `json:"AcceptedAdvance"` + OrderedMeals float64 `json:"OrderedMeals"` + EndAdvance float64 `json:"EndAdvance"` +} + type AdminMenu struct { ID string `json:"id"` Date int `json:"date"` @@ -22,6 +29,14 @@ type AdminMenu struct { Count int `json:"Count"` } +type CashAdvance struct { + ID string `json:"Id"` + Date int `json:"Date"` + VariableSymbol int `json:"VariableSymbol"` + Amount int `json:"Amount"` + Notice string `json:"Notice"` +} + type CreateMenuInput struct { Date int `json:"date"` Meal string `json:"meal"` @@ -32,11 +47,12 @@ type CreateMenuInput struct { } type CreatePriceLevelGroup struct { - ValidFrom int `json:"ValidFrom"` - ValidTo int `json:"ValidTo"` - Price int `json:"Price"` - FoodPriceLevelID string `json:"FoodPriceLevelID"` - UserGroupID string `json:"UserGroupID"` + ValidFrom int `json:"ValidFrom"` + ValidTo int `json:"ValidTo"` + Price int `json:"Price"` + FoodPriceLevelID string `json:"FoodPriceLevelID"` + UserGroupID string `json:"UserGroupID"` + Commission float64 `json:"Commission"` } type CreateUserGroup struct { @@ -44,6 +60,11 @@ type CreateUserGroup struct { EmailHandles []string `json:"emailHandles,omitempty"` } +type DateMenu struct { + Date int `json:"date"` + Menus []*Menu `json:"menus"` +} + type FoodPriceLevel struct { ID string `json:"id"` Name string `json:"name"` @@ -60,6 +81,18 @@ type Menu struct { PriceLvlID string `json:"priceLvlId"` } +type MenuOrders2 struct { + Date int `json:"Date"` + PriceLvlGroupID int `json:"PriceLvlGroupId"` + GroupName string `json:"GroupName"` + PriceLvlID int `json:"PriceLvlId"` + PriceLvlName string `json:"PriceLvlName"` + PriceLvlAmount int `json:"PriceLvlAmount"` + PriceLvlCommission float64 `json:"PriceLvlCommission"` + Count int `json:"Count"` + Amount float64 `json:"Amount"` +} + type Order struct { ID string `json:"id"` MenuID string `json:"menuId"` @@ -74,6 +107,7 @@ type PriceLevelGroup struct { Price int `json:"price"` FoodPriceLevel *FoodPriceLevel `json:"FoodPriceLevel"` UserGroup *UserGroup `json:"UserGroup"` + Commission float64 `json:"Commission"` } type PriceLvl struct { @@ -100,11 +134,12 @@ type UpdateMenus struct { } type UpdatePriceLvlGroup struct { - ValidFrom int `json:"ValidFrom"` - ValidTo int `json:"ValidTo"` - Price int `json:"Price"` - FoodPriceLevelID string `json:"FoodPriceLevelID"` - UserGroupID string `json:"UserGroupID"` + ValidFrom int `json:"ValidFrom"` + ValidTo int `json:"ValidTo"` + Price int `json:"Price"` + FoodPriceLevelID string `json:"FoodPriceLevelID"` + UserGroupID string `json:"UserGroupID"` + Commission float64 `json:"Commission"` } type UpdateUserGroup struct { diff --git a/graph/priceLvls.graphqls b/graph/priceLvls.graphqls index 202aeee..8b3e548 100644 --- a/graph/priceLvls.graphqls +++ b/graph/priceLvls.graphqls @@ -10,6 +10,7 @@ type PriceLevelGroup { price: Int! FoodPriceLevel: FoodPriceLevel! UserGroup: UserGroup! + Commission: Float! } type UserGroup { @@ -34,6 +35,7 @@ input CreatePriceLevelGroup { Price: Int! FoodPriceLevelID: ID! UserGroupID: ID! + Commission: Float! } input UpdateUserGroup { @@ -50,6 +52,7 @@ input UpdatePriceLvlGroup{ Price: Int! FoodPriceLevelID: ID! UserGroupID: ID! + Commission: Float! } extend type Query { diff --git a/graph/resolver.go b/graph/resolver.go index 0536624..52eb7c1 100644 --- a/graph/resolver.go +++ b/graph/resolver.go @@ -1,6 +1,7 @@ package graph import ( + "delta-eats/internal/usecases/accounting" "delta-eats/internal/usecases/auth" mailusecase "delta-eats/internal/usecases/financeUsecase" "delta-eats/internal/usecases/menu" @@ -15,13 +16,14 @@ import ( // It serves as dependency injection for your app, add any dependencies you require here. type Resolver struct { - UserUsecase *users.UserUsecase - AuthUsecase *auth.AuthUsecase - MenuUsecase *menu.MenuUsecase - OrderUsecase *orders.OrdersUsecase - MailUsecase *mailusecase.FinanceUsecase - PriceLvlsUsecase *pricelvls.PriceLvlUsecase - VersionUsecase *version.VersionUsecase + UserUsecase *users.UserUsecase + AuthUsecase *auth.AuthUsecase + MenuUsecase *menu.MenuUsecase + OrderUsecase *orders.OrdersUsecase + MailUsecase *mailusecase.FinanceUsecase + PriceLvlsUsecase *pricelvls.PriceLvlUsecase + VersionUsecase *version.VersionUsecase + AccountingUsecase *accounting.AccountingUsecase InputMapper InputMapper Mapper Mapper diff --git a/internal/domain/accounting.go b/internal/domain/accounting.go new file mode 100644 index 0000000..923c86e --- /dev/null +++ b/internal/domain/accounting.go @@ -0,0 +1,30 @@ +package domain + +import "time" + +type AccountTable struct { + StartAdvance float64 + AcceptedAdvance int + OrderedMeals float64 + EndAdvance float64 +} + +type CashAdvance struct { + Id int64 + Date time.Time + VariableSymbol int64 + Amount int64 + Notice string +} + +type MenuOrder2 struct { + Date time.Time + GroupId int64 + GroupName string + PriceLvlId int64 + PriceLvlName string + UnitAmount int64 + Commission float64 + Count int64 + Amount float64 +} diff --git a/internal/domain/menu.go b/internal/domain/menu.go index b060644..aafd74c 100644 --- a/internal/domain/menu.go +++ b/internal/domain/menu.go @@ -51,6 +51,11 @@ type AdminMenu struct { Count int64 } +type DateMenu struct { + Date int64 + Menus []Menu +} + type MenusByGroup map[int64][]Menu type MenuByGroup map[int64]Menu diff --git a/internal/domain/priceLvls.go b/internal/domain/priceLvls.go index c1a66c9..4473865 100644 --- a/internal/domain/priceLvls.go +++ b/internal/domain/priceLvls.go @@ -22,6 +22,7 @@ type PriceLevelGroup struct { Price int64 FoodPriceLevel FoodPriceLevel UserGroup UserGroup + Commission float64 } type CreatePriceLevelGroupInput struct { @@ -30,6 +31,7 @@ type CreatePriceLevelGroupInput struct { Price int64 FoodPriceLevelID int64 UserGroupID int64 + Commission float64 } type CompactPriceLevelGroup struct { diff --git a/internal/ports/database/accounting/accounting.go b/internal/ports/database/accounting/accounting.go new file mode 100644 index 0000000..c01cbf4 --- /dev/null +++ b/internal/ports/database/accounting/accounting.go @@ -0,0 +1,210 @@ +package accounting + +import ( + "context" + "database/sql" + "delta-eats/internal/domain" + "delta-eats/internal/ports/database/gen/delta-eats/public/model" + "delta-eats/internal/ports/database/gen/delta-eats/public/table" + "time" + + "github.com/go-jet/jet/v2/postgres" +) + +type AccountingDatabaseStore struct { + DB *sql.DB +} + +func NewAccountingDatabaseStore(db *sql.DB) *AccountingDatabaseStore { + return &AccountingDatabaseStore{ + DB: db, + } +} + +func (adbs *AccountingDatabaseStore) GetOrderedMealsPrices(ctx context.Context, dateFrom time.Time, dateTo time.Time) (float64, error) { + stmt := postgres.SELECT(postgres.SUM(postgres.CAST(table.Pricelvlgroup.Amount).AS_DECIMAL().SUB(table.Pricelvlgroup.Commission))). + FROM(table.Orders, table.Menu, table.Pricelvlgroup, table.Users). + WHERE(postgres.AND( + table.Orders.MenuID.EQ(table.Menu.ID), + table.Orders.UserID.EQ(table.Users.ID), + table.Users.GroupID.EQ(table.Pricelvlgroup.GroupID), + table.Pricelvlgroup.Datefrom.LT(table.Menu.Date), + postgres.OR( + table.Pricelvlgroup.Dateto.GT(table.Menu.Date), + table.Pricelvlgroup.Dateto.IS_NULL(), + ), + table.Menu.Date.BETWEEN(postgres.Date(dateFrom.Year(), dateFrom.Month(), dateFrom.Day()), postgres.Date(dateTo.Year(), dateTo.Month(), dateTo.Day())))) + var dest []float64 + err := stmt.QueryContext(ctx, adbs.DB, &dest) + if err != nil { + return 0, err + } + if len(dest) == 0 { + return 0, nil + } + return dest[0], nil +} + +func (adbs *AccountingDatabaseStore) GetAcceptedAdvance(ctx context.Context, dateFrom time.Time, dateTo time.Time) (int, error) { + stmt := postgres.SELECT(postgres.SUM(table.Bankapi.Amount)). + FROM(table.Bankapi). + WHERE(table.Bankapi.Amount.GT(postgres.Int(0)).AND(table.Bankapi.Date.BETWEEN(postgres.Date(dateFrom.Year(), dateFrom.Month(), dateFrom.Day()), postgres.Date(dateTo.Year(), dateTo.Month(), dateTo.Day())))) + var dest []int + err := stmt.QueryContext(ctx, adbs.DB, &dest) + if err != nil { + return 0, err + } + if len(dest) == 0 { + return 0, nil + } + return dest[0], nil +} + +func (adbs *AccountingDatabaseStore) GetStartAdvance(ctx context.Context, dateFrom time.Time) (float64, error) { + stmtP := postgres.SELECT(postgres.SUM(table.Bankapi.Amount)). + FROM(table.Bankapi). + WHERE(postgres.AND( + table.Bankapi.Date.LT_EQ(postgres.Date(dateFrom.Year(), dateFrom.Month(), dateFrom.Day())), + // TODO: retaurant id + )) + var payments []int + errP := stmtP.QueryContext(ctx, adbs.DB, &payments) + if errP != nil { + return 0, errP + } + if len(payments) == 0 { + payments = append(payments, 0) + } + + stmtL := postgres.SELECT(postgres.SUM(postgres.CAST(table.Pricelvlgroup.Amount).AS_DECIMAL().SUB(table.Pricelvlgroup.Commission))). + FROM(table.Menu, table.Orders, table.Users, table.Pricelvlgroup). + WHERE(postgres.AND( + table.Menu.Date.LT(postgres.Date(dateFrom.Year(), dateFrom.Month(), dateFrom.Day())), + table.Menu.ID.EQ(table.Orders.MenuID), + table.Orders.UserID.EQ(table.Users.ID), + table.Users.GroupID.EQ(table.Pricelvlgroup.GroupID), + table.Menu.PricelvlID.EQ(table.Pricelvlgroup.PricelvlID), + postgres.AND( + postgres.OR( + table.Menu.Date.BETWEEN(table.Pricelvlgroup.Datefrom, table.Pricelvlgroup.Dateto), + postgres.AND( + table.Menu.Date.GT_EQ(table.Pricelvlgroup.Datefrom), + table.Pricelvlgroup.Dateto.IS_NULL(), + ), + ), + ), + )) + var lunches []float64 + errL := stmtL.QueryContext(ctx, adbs.DB, &lunches) + if errL != nil { + return 0, errL + } + if len(lunches) == 0 { + lunches = append(lunches, 0) + } + + return float64(payments[0]) - lunches[0], nil +} + +func (adbs *AccountingDatabaseStore) GetCashAdvances(ctx context.Context, dateFrom time.Time, dateTo time.Time) ([]*domain.CashAdvance, error) { + stmt := postgres.SELECT(table.Bankapi.ID, table.Bankapi.Date, table.Bankapi.Variablesym, table.Bankapi.Amount, table.Bankapi.Notice). + FROM(table.Bankapi). + WHERE(postgres.AND( + table.Bankapi.Date.BETWEEN(postgres.Date(dateFrom.Year(), dateFrom.Month(), dateFrom.Day()), postgres.Date(dateTo.Year(), dateTo.Month(), dateTo.Day())))). + ORDER_BY(table.Bankapi.Date) + var dest []model.Bankapi + err := stmt.QueryContext(ctx, adbs.DB, &dest) + if err != nil { + return nil, err + } + var result []*domain.CashAdvance + for _, cashAdvance := range dest { + result = append(result, mapCashAdvanceFromDB(cashAdvance)) + } + return result, nil +} + +type MenuOrder2 struct { + Date time.Time + GroupId int64 + GroupName string + PriceLvlId int64 + PriceLvlName string + UnitAmount int64 + Commission float64 + Count int64 + Amount float64 +} + +func (adbs *AccountingDatabaseStore) GetMenuOrders2(ctx context.Context, dateFrom time.Time, dateTo time.Time) ([]*domain.MenuOrder2, error) { + stmt := postgres.SELECT( + table.Menu.Date.AS("MenuOrder2.Date"), + table.Pricelvlgroup.GroupID.AS("MenuOrder2.GroupId"), + table.Groups.Name.AS("MenuOrder2.GroupName"), + table.Pricelvl.ID.AS("MenuOrder2.PriceLvlId"), + table.Pricelvl.Name.AS("MenuOrder2.PriceLvlName"), + table.Pricelvlgroup.Amount.AS("MenuOrder2.UnitAmount"), + table.Pricelvlgroup.Commission.AS("MenuOrder2.Commission"), + postgres.COUNT(postgres.String("*")).AS("MenuOrder2.Count"), + postgres.SUM(postgres.CAST(table.Pricelvlgroup.Amount).AS_DECIMAL().SUB(table.Pricelvlgroup.Commission)).AS("MenuOrder2.Amount")). + FROM(table.Orders, table.Menu, table.Pricelvl, table.Groups, table.Users, table.Pricelvlgroup). + WHERE(postgres.AND( + table.Menu.Date.BETWEEN(postgres.Date(dateFrom.Year(), dateFrom.Month(), dateFrom.Day()), postgres.Date(dateTo.Year(), dateTo.Month(), dateTo.Day())), + table.Menu.ID.EQ(table.Orders.MenuID), + table.Menu.PricelvlID.EQ(table.Pricelvl.ID), + table.Menu.Date.GT(table.Pricelvlgroup.Datefrom), + postgres.OR( + table.Menu.Date.LT_EQ(table.Pricelvlgroup.Dateto), + table.Pricelvlgroup.Dateto.IS_NULL(), + ), + table.Orders.UserID.EQ(table.Users.ID), + table.Users.GroupID.EQ(table.Groups.ID), + table.Groups.ID.EQ(table.Pricelvlgroup.GroupID), + table.Pricelvlgroup.PricelvlID.EQ(table.Pricelvl.ID), + )). + GROUP_BY(table.Menu.Date, table.Pricelvlgroup.GroupID, table.Groups.Name, table.Pricelvl.ID, table.Pricelvl.Name, table.Pricelvlgroup.Amount, table.Pricelvlgroup.Commission). + ORDER_BY(table.Menu.Date, table.Groups.Name, table.Pricelvl.ID) + var dest []MenuOrder2 + err := stmt.QueryContext(ctx, adbs.DB, &dest) + if err != nil { + return nil, err + } + var result []*domain.MenuOrder2 + for _, menuOrder2 := range dest { + result = append(result, mapMenuOrder2FromDB(menuOrder2)) + } + return result, nil +} + +func mapMenuOrder2FromDB(menuOrder2 MenuOrder2) *domain.MenuOrder2 { + return &domain.MenuOrder2{ + Date: menuOrder2.Date, + GroupId: menuOrder2.GroupId, + GroupName: menuOrder2.GroupName, + PriceLvlId: menuOrder2.PriceLvlId, + PriceLvlName: menuOrder2.PriceLvlName, + UnitAmount: menuOrder2.UnitAmount, + Commission: menuOrder2.Commission, + Count: menuOrder2.Count, + Amount: menuOrder2.Amount, + } +} + +// crashes when notice is null - they are nullable +func mapCashAdvanceFromDB(cashAdvance model.Bankapi) *domain.CashAdvance { + return &domain.CashAdvance{ + Id: int64(cashAdvance.ID), + Date: *cashAdvance.Date, + VariableSymbol: int64(*cashAdvance.Variablesym), + Amount: int64(cashAdvance.Amount), + Notice: getStringOrNil(cashAdvance.Notice), + } +} + +// this prevents crashes +func getStringOrNil(value *string) string { + if value == nil { + return "" + } + return (*value) +} diff --git a/internal/ports/database/ports.go b/internal/ports/database/ports.go index 6bddd4e..73605aa 100644 --- a/internal/ports/database/ports.go +++ b/internal/ports/database/ports.go @@ -79,3 +79,12 @@ type PriceLvlStoreInterface interface { type VersionStoreInterface interface { GetVersion(ctx context.Context) (*domain.Version, error) } + +type AccountingStoreInterface interface { + GetOrderedMealsPrices(ctx context.Context, dateFrom time.Time, dateTo time.Time) (float64, error) + GetAcceptedAdvance(ctx context.Context, dateFrom time.Time, dateTo time.Time) (int, error) + GetStartAdvance(ctx context.Context, dateFrom time.Time) (float64, error) + + GetCashAdvances(ctx context.Context, dateFrom time.Time, dateTo time.Time) ([]*domain.CashAdvance, error) + GetMenuOrders2(ctx context.Context, dateFrom time.Time, dateTo time.Time) ([]*domain.MenuOrder2, error) +} diff --git a/internal/ports/database/priceLvls/pricelvls.go b/internal/ports/database/priceLvls/pricelvls.go index 7861168..77bc24e 100644 --- a/internal/ports/database/priceLvls/pricelvls.go +++ b/internal/ports/database/priceLvls/pricelvls.go @@ -240,6 +240,7 @@ func (pls *PriceLvlStore) UpdatePriceLvlGroup(ctx context.Context, id int64, pri Amount: int32(priceLvlGroupUpdate.Price), PricelvlID: int32(priceLvlGroupUpdate.FoodPriceLevelID), GroupID: int32(priceLvlGroupUpdate.UserGroupID), + Commission: float64(priceLvlGroupUpdate.Commission), } stmt := table.Pricelvlgroup.UPDATE(table.Pricelvlgroup.AllColumns.Except(table.Pricelvlgroup.ID)).MODEL(model).WHERE(table.Pricelvlgroup.ID.EQ(postgres.Int(id))) r, err := stmt.ExecContext(ctx, pls.DB) @@ -328,6 +329,7 @@ func (pls *PriceLvlStore) CreatePriceLvlGroup(ctx context.Context, priceLvlGroup Amount: int32(priceLvlGroup.Price), PricelvlID: int32(priceLvlGroup.FoodPriceLevelID), GroupID: int32(priceLvlGroup.UserGroupID), + Commission: float64(priceLvlGroup.Commission), } stmt := table.Pricelvlgroup.INSERT(table.Pricelvlgroup.AllColumns.Except(table.Pricelvlgroup.ID)).MODEL(&insertModel).RETURNING(table.Pricelvlgroup.ID) dest := model.Pricelvlgroup{} @@ -356,6 +358,7 @@ func mapPricelvlGroupFromDB(priceLvlGroup PriceLvlGroup) domain.PriceLevelGroup Groups: priceLvlGroup.Groups, Domains: priceLvlGroup.GroupDomains, }), + Commission: float64(priceLvlGroup.Commission), } } diff --git a/internal/setup/graphDepenencies.go b/internal/setup/graphDepenencies.go index e623b08..fe6e27f 100644 --- a/internal/setup/graphDepenencies.go +++ b/internal/setup/graphDepenencies.go @@ -4,6 +4,7 @@ import ( "database/sql" "delta-eats/graph" "delta-eats/internal/config" + "delta-eats/internal/ports/database/accounting" "delta-eats/internal/ports/database/balance" "delta-eats/internal/ports/database/menu" "delta-eats/internal/ports/database/orders" @@ -13,6 +14,7 @@ import ( "delta-eats/internal/ports/fio" mailsender "delta-eats/internal/ports/mailSender" "delta-eats/internal/ports/tokens" + accountingUsecases "delta-eats/internal/usecases/accounting" "delta-eats/internal/usecases/auth" mailusecase "delta-eats/internal/usecases/financeUsecase" menuUsecases "delta-eats/internal/usecases/menu" @@ -44,16 +46,19 @@ func NewResolver(dbConn *sql.DB, config config.Config) (*graph.Resolver, error) priceLvlUsecase := pricelvls.NewPriceLvlUsecase(priceLvlStore) versionStore := version.NewVersionDatabaseStore(dbConn) versionUsecase := versionUsecases.NewVersionUsecase(versionStore) + accountingStore := accounting.NewAccountingDatabaseStore(dbConn) + accountingUsecase := accountingUsecases.NewVersionUsecase(accountingStore) return &graph.Resolver{ - UserUsecase: userUsecase, - AuthUsecase: authUsecase, - MenuUsecase: menuUsecase, - OrderUsecase: orderUsecsae, - MailUsecase: mailUsecase, - PriceLvlsUsecase: priceLvlUsecase, - VersionUsecase: versionUsecase, - InputMapper: inputMapper, - Mapper: mapper, + UserUsecase: userUsecase, + AuthUsecase: authUsecase, + MenuUsecase: menuUsecase, + OrderUsecase: orderUsecsae, + MailUsecase: mailUsecase, + PriceLvlsUsecase: priceLvlUsecase, + VersionUsecase: versionUsecase, + AccountingUsecase: accountingUsecase, + InputMapper: inputMapper, + Mapper: mapper, }, nil } diff --git a/internal/usecases/accounting/accounting.go b/internal/usecases/accounting/accounting.go new file mode 100644 index 0000000..38acddc --- /dev/null +++ b/internal/usecases/accounting/accounting.go @@ -0,0 +1,81 @@ +package accounting + +import ( + "context" + "delta-eats/internal/domain" + "delta-eats/internal/middleware" + "delta-eats/internal/ports/database" + "delta-eats/internal/ports/database/accounting" + "time" +) + +type AccountingUsecase struct { + accountingStore database.AccountingStoreInterface +} + +func NewVersionUsecase(asi *accounting.AccountingDatabaseStore) *AccountingUsecase { + return &AccountingUsecase{ + accountingStore: asi, + } +} + +func (au *AccountingUsecase) GetAccountTable(ctx context.Context, restaurant_id int, dateFrom time.Time, dateTo time.Time) (*domain.AccountTable, error) { + usr, ok := middleware.GetUser(ctx) + if !ok { + return nil, domain.Unauthorized + } + if usr.Role != domain.AdminRole { + return nil, domain.Forbidden + } + orderedMeals, err := au.accountingStore.GetOrderedMealsPrices(ctx, dateFrom, dateTo) + if err != nil { + return nil, err + } + + acceptedAdvance, err := au.accountingStore.GetAcceptedAdvance(ctx, dateFrom, dateTo) + if err != nil { + return nil, err + } + + startAdvance, err := au.accountingStore.GetStartAdvance(ctx, dateFrom) + if err != nil { + return nil, err + } + + return &domain.AccountTable{ + StartAdvance: startAdvance, + AcceptedAdvance: acceptedAdvance, + OrderedMeals: -orderedMeals, + EndAdvance: startAdvance + float64(acceptedAdvance) - orderedMeals, + }, nil +} + +func (au *AccountingUsecase) GetCashAdvances(ctx context.Context, restaurantID int, dateFrom time.Time, dateTo time.Time) ([]*domain.CashAdvance, error) { + usr, ok := middleware.GetUser(ctx) + if !ok { + return nil, domain.Unauthorized + } + if usr.Role != domain.AdminRole { + return nil, domain.Forbidden + } + cashAdvances, err := au.accountingStore.GetCashAdvances(ctx, dateFrom, dateTo) + if err != nil { + return nil, err + } + return cashAdvances, nil +} + +func (au *AccountingUsecase) GetMenuOrders2(ctx context.Context, restaurantId int, dateFrom time.Time, dateTo time.Time) ([]*domain.MenuOrder2, error) { + usr, ok := middleware.GetUser(ctx) + if !ok { + return nil, domain.Unauthorized + } + if usr.Role != domain.AdminRole { + return nil, domain.Forbidden + } + menuOrders2, err := au.accountingStore.GetMenuOrders2(ctx, dateFrom, dateTo) + if err != nil { + return nil, err + } + return menuOrders2, nil +} diff --git a/internal/usecases/menu/menu.go b/internal/usecases/menu/menu.go index 468bcc5..b5c52da 100644 --- a/internal/usecases/menu/menu.go +++ b/internal/usecases/menu/menu.go @@ -6,6 +6,7 @@ import ( "delta-eats/internal/middleware" "delta-eats/internal/ports/database" "delta-eats/internal/ports/database/menu" + "slices" "time" ) @@ -63,6 +64,61 @@ func (mu *MenuUsecase) GetMenusByDate(ctx context.Context, dateFrom, dateTo time return menus, nil } +func (mu *MenuUsecase) AdminGetDateMenusByDate(ctx context.Context, dateFrom, dateTo time.Time) ([]domain.DateMenu, error) { + usr, ok := middleware.GetUser(ctx) + if !ok { + return nil, domain.Unauthorized + } + if usr.Role != "admin" { + return nil, domain.Forbidden + } + menusWithGroups, err := mu.menuStore.GetMenusByDate(ctx, dateFrom, dateTo) + if err != nil { + return nil, err + } + menus, ok := menusWithGroups[usr.GroupId] + if !ok { + menus, ok = menusWithGroups[domain.DefaultUserGroup] + if !ok { + return nil, domain.MenuNotFound + } + } + + dates := make([]int64, 0, int(dateTo.Sub(dateFrom).Hours()/24)) + + for menu := range menus { + timestamp := menus[menu].Date.Unix() + if !slices.Contains(dates, timestamp) { + dates = append(dates, timestamp) + } + } + + menuMap := make(map[int64]*domain.DateMenu) + for _, menu := range menus { + if _, ok := menuMap[menu.Date.Unix()]; !ok { + menuMap[menu.Date.Unix()] = &domain.DateMenu{ + Date: int64(menu.Date.Unix()), + Menus: []domain.Menu{}, + } + } + menuMap[menu.Date.Unix()].Menus = append(menuMap[menu.Date.Unix()].Menus, menu) + } + + daysWithMenus := make([]domain.DateMenu, 0, len(dates)) + for _, day := range dates { + if menu, ok := menuMap[day]; ok { + daysWithMenus = append(daysWithMenus, *menu) + } else { + daysWithMenus = append(daysWithMenus, domain.DateMenu{ + Date: int64(day), + Menus: []domain.Menu{}, + }) + } + } + + return daysWithMenus, nil +} + func (mu *MenuUsecase) DeleteMenu(ctx context.Context, id int64) error { return mu.menuStore.DeleteMenu(ctx, id) } diff --git a/migrations/20231227115904_add_commission.sql b/migrations/20231227115904_add_commission.sql new file mode 100644 index 0000000..1668ac9 --- /dev/null +++ b/migrations/20231227115904_add_commission.sql @@ -0,0 +1,11 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE pricelvlgroup ADD COLUMN commission decimal(4,2) NOT NULL DEFAULT 0; + +UPDATE pricelvlgroup SET commission=6 WHERE group_id IN (4,5); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +ALTER TABLE pricelvlgroup DROP COLUMN commission IF EXISTS; +-- +goose StatementEnd