Fix up and export food service
This commit is contained in:
10
app.go
10
app.go
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
@@ -21,11 +20,6 @@ func (a *App) startup(ctx context.Context) {
|
|||||||
a.ctx = ctx
|
a.ctx = ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
// Greet returns a greeting for the given name
|
func (a *App) GetFood() ([]Food, error) {
|
||||||
func (a *App) Greet(name string) string {
|
return foodService.GetRecent()
|
||||||
return fmt.Sprintf("Hello %s, It's show time!", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *App) Foo() string {
|
|
||||||
return "bar"
|
|
||||||
}
|
}
|
@@ -42,7 +42,6 @@ func (s *FoodService) GetRecent() ([]Food, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows []Food
|
|
||||||
for row.Next() {
|
for row.Next() {
|
||||||
var food Food
|
var food Food
|
||||||
err := row.Scan(&food.rowid, &food.date, &food.food, &food.descripton, &food.amount, &food.per100, &food.energy)
|
err := row.Scan(&food.rowid, &food.date, &food.food, &food.descripton, &food.amount, &food.per100, &food.energy)
|
||||||
@@ -51,11 +50,9 @@ func (s *FoodService) GetRecent() ([]Food, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, food)
|
res = append(res, food)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%++v", rows)
|
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +147,6 @@ func (s *FoodService) GetDaily() ([]AggregatedFood, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows []AggregatedFood
|
|
||||||
for row.Next() {
|
for row.Next() {
|
||||||
var food AggregatedFood
|
var food AggregatedFood
|
||||||
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
||||||
@@ -159,11 +155,9 @@ func (s *FoodService) GetDaily() ([]AggregatedFood, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, food)
|
res = append(res, food)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%++v", rows)
|
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +173,6 @@ func (s *FoodService) GetWeekly() ([]AggregatedFood, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows []AggregatedFood
|
|
||||||
for row.Next() {
|
for row.Next() {
|
||||||
var food AggregatedFood
|
var food AggregatedFood
|
||||||
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
||||||
@@ -188,11 +181,9 @@ func (s *FoodService) GetWeekly() ([]AggregatedFood, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, food)
|
res = append(res, food)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%++v", rows)
|
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +199,6 @@ func (s *FoodService) GetMonthly() ([]AggregatedFood, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows []AggregatedFood
|
|
||||||
for row.Next() {
|
for row.Next() {
|
||||||
var food AggregatedFood
|
var food AggregatedFood
|
||||||
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
||||||
@@ -217,11 +207,9 @@ func (s *FoodService) GetMonthly() ([]AggregatedFood, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, food)
|
res = append(res, food)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%++v", rows)
|
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +225,6 @@ func (s *FoodService) GetYearly() ([]AggregatedFood, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows []AggregatedFood
|
|
||||||
for row.Next() {
|
for row.Next() {
|
||||||
var food AggregatedFood
|
var food AggregatedFood
|
||||||
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
err := row.Scan(&food.period, &food.amount, &food.avgPer100, &food.energy)
|
||||||
@@ -246,10 +233,8 @@ func (s *FoodService) GetYearly() ([]AggregatedFood, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, food)
|
res = append(res, food)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%++v", rows)
|
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
Reference in New Issue
Block a user