Rearrange folders, and separate functionality
This commit is contained in:
parent
dc58253ad9
commit
d26e7b8345
0
cmd/main.go
Normal file
0
cmd/main.go
Normal file
8
internal/controllers/routes.go
Normal file
8
internal/controllers/routes.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
router := gin.Default()
|
||||||
|
router.GET("/test", runTest)
|
||||||
|
|
||||||
|
router.Run("localhost:8080")
|
||||||
|
}
|
|
@ -12,69 +12,10 @@ import (
|
||||||
|
|
||||||
var ProductsTable = ksql.NewTable("products", "product_id")
|
var ProductsTable = ksql.NewTable("products", "product_id")
|
||||||
|
|
||||||
type Product struct {
|
|
||||||
id int `ksql:"id"`
|
|
||||||
system string `ksql:"system"`
|
|
||||||
barcode string `ksql:"barcode"`
|
|
||||||
created_at time.Time `ksql:"created_at,timeNowUTC"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var UserClaimsTable = ksql.NewTable("user_claims", "user_claim_id")
|
var UserClaimsTable = ksql.NewTable("user_claims", "user_claim_id")
|
||||||
|
|
||||||
type UserClaim struct {
|
|
||||||
id int `ksql:"id"`
|
|
||||||
product_id int `ksql:"product_id"`
|
|
||||||
evidence_type EvidenceType `ksql:"evidence_type"`
|
|
||||||
evidence struct{} `ksql:"evidence,json"`
|
|
||||||
claim Claim `ksql:"claim"`
|
|
||||||
counter_claim Claim `ksql:"counter_claim"`
|
|
||||||
created_at time.Time `ksql:"created_at,timeNowUTC"`
|
|
||||||
created_by string `ksql:"created_by"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type EvidenceType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
ManufactureWebsite EvidenceType = iota
|
|
||||||
IngredientsList
|
|
||||||
)
|
|
||||||
|
|
||||||
var AutomatedClaimsTable = ksql.NewTable("automated_claims", "automated_claim_id")
|
var AutomatedClaimsTable = ksql.NewTable("automated_claims", "automated_claim_id")
|
||||||
|
|
||||||
type AutomatedClaim struct {
|
|
||||||
id int `ksql:"id"`
|
|
||||||
product_id int `ksql:"product_id"`
|
|
||||||
worker_type WorkerType `ksql:"worker_type"`
|
|
||||||
evidence struct{} `ksql:"evidence,json"`
|
|
||||||
claim Claim `ksql:"claim"`
|
|
||||||
counter_claim Claim `ksql:"counter_claim"`
|
|
||||||
created_at time.Time `ksql:"created_at,timeNowUTC"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WorkerType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
Barnivore WorkerType = iota
|
|
||||||
)
|
|
||||||
|
|
||||||
type Claim int
|
|
||||||
|
|
||||||
const (
|
|
||||||
ContainsMeat Claim = iota
|
|
||||||
ContainsFish
|
|
||||||
ContainsEggs
|
|
||||||
ContainsMilk
|
|
||||||
ContainsHoney
|
|
||||||
ContainsWax
|
|
||||||
ContainsFur
|
|
||||||
ContainsLeather
|
|
||||||
ContainsAnimalFibers
|
|
||||||
ContainsWool
|
|
||||||
ContainsFeathers
|
|
||||||
AnimalTesting
|
|
||||||
MonkeySlavery
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
@ -92,6 +33,9 @@ func main() {
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTables(db) {
|
||||||
_, err = db.Exec(ctx, `
|
_, err = db.Exec(ctx, `
|
||||||
CREATE TABLE IF NOT EXISTS products (
|
CREATE TABLE IF NOT EXISTS products (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
64
internal/database/models.go
Normal file
64
internal/database/models.go
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vingarcia/ksql"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Product struct {
|
||||||
|
id int `ksql:"id"`
|
||||||
|
system string `ksql:"system"`
|
||||||
|
barcode string `ksql:"barcode"`
|
||||||
|
created_at time.Time `ksql:"created_at,timeNowUTC"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WorkerType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
Barnivore WorkerType = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
type EvidenceType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ManufactureWebsite EvidenceType = iota
|
||||||
|
IngredientsList
|
||||||
|
)
|
||||||
|
|
||||||
|
type Claim int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ContainsMeat Claim = iota
|
||||||
|
ContainsFish
|
||||||
|
ContainsEggs
|
||||||
|
ContainsMilk
|
||||||
|
ContainsHoney
|
||||||
|
ContainsWax
|
||||||
|
ContainsFur
|
||||||
|
ContainsLeather
|
||||||
|
ContainsAnimalFibers
|
||||||
|
ContainsWool
|
||||||
|
ContainsFeathers
|
||||||
|
AnimalTesting
|
||||||
|
MonkeySlavery
|
||||||
|
)
|
||||||
|
|
||||||
|
type AutomatedClaim struct {
|
||||||
|
id int `ksql:"id"`
|
||||||
|
product_id int `ksql:"product_id"`
|
||||||
|
worker_type WorkerType `ksql:"worker_type"`
|
||||||
|
evidence struct{} `ksql:"evidence,json"`
|
||||||
|
claim Claim `ksql:"claim"`
|
||||||
|
counter_claim Claim `ksql:"counter_claim"`
|
||||||
|
created_at time.Time `ksql:"created_at,timeNowUTC"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserClaim struct {
|
||||||
|
id int `ksql:"id"`
|
||||||
|
product_id int `ksql:"product_id"`
|
||||||
|
evidence_type EvidenceType `ksql:"evidence_type"`
|
||||||
|
evidence struct{} `ksql:"evidence,json"`
|
||||||
|
claim Claim `ksql:"claim"`
|
||||||
|
counter_claim Claim `ksql:"counter_claim"`
|
||||||
|
created_at time.Time `ksql:"created_at,timeNowUTC"`
|
||||||
|
created_by string `ksql:"created_by"`
|
||||||
|
}
|
1
internal/services/userService.go
Normal file
1
internal/services/userService.go
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package main
|
Loading…
Reference in a new issue