Itsscb/issue_add-http-server-5 (#18)

This commit is contained in:
itsscb 2023-09-21 22:46:11 +02:00 committed by GitHub
parent b88be701bb
commit 0202c74edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 328 additions and 193 deletions

View File

@ -39,4 +39,7 @@ test:
coverage:
go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out
.PHONY: postgres migratenew createdb dropdb migrateup migratedown sqlc sqlcinit test
server:
go run main.go
.PHONY: postgres migratenew createdb dropdb migrateup migratedown sqlc sqlcinit test server

7
api/account.go Normal file
View File

@ -0,0 +1,7 @@
package api
import "github.com/gin-gonic/gin"
func (server *Server) createAccount(ctx *gin.Context) {
}

32
api/server.go Normal file
View File

@ -0,0 +1,32 @@
package api
import (
"github.com/gin-gonic/gin"
db "github.com/itsscb/df/db/sqlc"
)
// Server serves HTTP requests for df service
type Server struct {
store *db.Store
router *gin.Engine
}
// NewServer creates a new HTTP server and sets up routing
func NewServer(store *db.Store) *Server {
server := &Server{
store: store,
}
router := gin.Default()
server.router = router
return server
}
func (server *Server) Start(address string) error {
return server.router.Run(address)
}
func errorResponse(err error) gin.H {
return gin.H{"error": err.Error()}
}

View File

@ -5,7 +5,7 @@ DROP TABLE IF EXISTS "documents";
DROP TABLE IF EXISTS "mails";
DROP TABLE IF EXISTS "persons";
DROP TABLE IF EXISTS "providers";
DROP TABLE IF EXISTS "customers";
DROP TABLE IF EXISTS "accounts";

View File

@ -12,9 +12,8 @@ CREATE TABLE "mails" (
"changed" timestamptz NOT NULL DEFAULT (now())
);
CREATE TABLE "customers" (
CREATE TABLE "accounts" (
"ID" bigserial UNIQUE PRIMARY KEY NOT NULL,
"username" varchar UNIQUE NOT NULL,
"passwordhash" varchar NOT NULL,
"firstname" varchar NOT NULL,
"lastname" varchar NOT NULL,
@ -38,7 +37,7 @@ CREATE TABLE "customers" (
CREATE TABLE "persons" (
"ID" bigserial UNIQUE PRIMARY KEY NOT NULL,
"customerID" bigint NOT NULL,
"accountID" bigint NOT NULL,
"firstname" varchar NOT NULL,
"lastname" varchar NOT NULL,
"birthday" timestamptz NOT NULL,
@ -71,7 +70,7 @@ CREATE TABLE "documents" (
CREATE TABLE "payments" (
"ID" bigserial UNIQUE PRIMARY KEY NOT NULL,
"customerID" bigint NOT NULL,
"accountID" bigint NOT NULL,
"paymentCategory" varchar NOT NULL,
"bankname" varchar,
"IBAN" varchar,
@ -124,13 +123,13 @@ CREATE TABLE "returnsLog" (
"changed" timestamptz NOT NULL DEFAULT (now())
);
ALTER TABLE "persons" ADD FOREIGN KEY ("customerID") REFERENCES "customers" ("ID");
ALTER TABLE "persons" ADD FOREIGN KEY ("accountID") REFERENCES "accounts" ("ID");
ALTER TABLE "documents" ADD FOREIGN KEY ("personID") REFERENCES "persons" ("ID");
ALTER TABLE "documents" ADD FOREIGN KEY ("mailID") REFERENCES "mails" ("ID");
ALTER TABLE "payments" ADD FOREIGN KEY ("customerID") REFERENCES "customers" ("ID");
ALTER TABLE "payments" ADD FOREIGN KEY ("accountID") REFERENCES "accounts" ("ID");
ALTER TABLE "returns" ADD FOREIGN KEY ("personID") REFERENCES "persons" ("ID");

View File

@ -1,10 +1,9 @@
-- name: GetCustomer :one
SELECT * FROM customers
-- name: GetAccount :one
SELECT * FROM accounts
WHERE "ID" = $1 LIMIT 1;
-- name: CreateCustomer :one
INSERT INTO customers (
username,
-- name: CreateAccount :one
INSERT INTO accounts (
passwordhash,
firstname,
lastname,
@ -18,19 +17,18 @@ INSERT INTO customers (
creator,
changer
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $11
) RETURNING *;
-- name: ListCustomers :many
SELECT * FROM customers
ORDER BY username
-- name: ListAccounts :many
SELECT * FROM accounts
ORDER BY lastname, firstname
LIMIT $1
OFFSET $2;
-- name: UpdateCustomer :one
UPDATE customers
-- name: UpdateAccount :one
UPDATE accounts
SET
username = COALESCE(sqlc.narg(username), username),
passwordhash = COALESCE(sqlc.narg(passwordhash), passwordhash),
firstname = COALESCE(sqlc.narg(firstname), firstname),
lastname = COALESCE(sqlc.narg(lastname), lastname),
@ -46,6 +44,6 @@ SET
WHERE "ID" = $1
RETURNING *;
-- name: DeleteCustomer :exec
DELETE FROM customers
-- name: DeleteAccount :exec
DELETE FROM accounts
WHERE "ID" = $1;

View File

@ -4,7 +4,7 @@ WHERE "ID" = $1 LIMIT 1;
-- name: CreatePayment :one
INSERT INTO payments (
"customerID",
"accountID",
"paymentCategory",
bankname,
"IBAN",
@ -28,7 +28,7 @@ OFFSET $2;
-- name: UpdatePayment :one
UPDATE payments
SET
"customerID" = COALESCE(sqlc.narg(customerID), "customerID"),
"accountID" = COALESCE(sqlc.narg(accountID), "accountID"),
"paymentCategory" = COALESCE(sqlc.narg(paymentCategory), "paymentCategory"),
bankname = COALESCE(sqlc.narg(bankname), bankname),
"IBAN" = COALESCE(sqlc.narg(IBAN), "IBAN"),

View File

@ -4,7 +4,7 @@ WHERE "ID" = $1 LIMIT 1;
-- name: CreatePerson :one
INSERT INTO persons (
"customerID",
"accountID",
firstname,
lastname,
birthday,
@ -27,7 +27,7 @@ OFFSET $2;
-- name: UpdatePerson :one
UPDATE persons
SET
"customerID" = COALESCE(sqlc.narg(customerID), "customerID"),
"accountID" = COALESCE(sqlc.narg(accountID), "accountID"),
firstname = COALESCE(sqlc.narg(firstname), firstname),
lastname = COALESCE(sqlc.narg(lastname), lastname),
birthday = COALESCE(sqlc.narg(birthday), birthday),

View File

@ -1,7 +1,7 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.21.0
// source: customer.sql
// source: account.sql
package db
@ -11,9 +11,8 @@ import (
"time"
)
const createCustomer = `-- name: CreateCustomer :one
INSERT INTO customers (
username,
const createAccount = `-- name: CreateAccount :one
INSERT INTO accounts (
passwordhash,
firstname,
lastname,
@ -27,12 +26,11 @@ INSERT INTO customers (
creator,
changer
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13
) RETURNING "ID", username, passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $11
) RETURNING "ID", passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed
`
type CreateCustomerParams struct {
Username string `json:"username"`
type CreateAccountParams struct {
Passwordhash string `json:"passwordhash"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
@ -44,12 +42,10 @@ type CreateCustomerParams struct {
Street string `json:"street"`
Country string `json:"country"`
Creator string `json:"creator"`
Changer string `json:"changer"`
}
func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams) (Customer, error) {
row := q.db.QueryRowContext(ctx, createCustomer,
arg.Username,
func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error) {
row := q.db.QueryRowContext(ctx, createAccount,
arg.Passwordhash,
arg.Firstname,
arg.Lastname,
@ -61,12 +57,10 @@ func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams)
arg.Street,
arg.Country,
arg.Creator,
arg.Changer,
)
var i Customer
var i Account
err := row.Scan(
&i.ID,
&i.Username,
&i.Passwordhash,
&i.Firstname,
&i.Lastname,
@ -90,27 +84,26 @@ func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams)
return i, err
}
const deleteCustomer = `-- name: DeleteCustomer :exec
DELETE FROM customers
const deleteAccount = `-- name: DeleteAccount :exec
DELETE FROM accounts
WHERE "ID" = $1
`
func (q *Queries) DeleteCustomer(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteCustomer, id)
func (q *Queries) DeleteAccount(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteAccount, id)
return err
}
const getCustomer = `-- name: GetCustomer :one
SELECT "ID", username, passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed FROM customers
const getAccount = `-- name: GetAccount :one
SELECT "ID", passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed FROM accounts
WHERE "ID" = $1 LIMIT 1
`
func (q *Queries) GetCustomer(ctx context.Context, id int64) (Customer, error) {
row := q.db.QueryRowContext(ctx, getCustomer, id)
var i Customer
func (q *Queries) GetAccount(ctx context.Context, id int64) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccount, id)
var i Account
err := row.Scan(
&i.ID,
&i.Username,
&i.Passwordhash,
&i.Firstname,
&i.Lastname,
@ -134,30 +127,29 @@ func (q *Queries) GetCustomer(ctx context.Context, id int64) (Customer, error) {
return i, err
}
const listCustomers = `-- name: ListCustomers :many
SELECT "ID", username, passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed FROM customers
ORDER BY username
const listAccounts = `-- name: ListAccounts :many
SELECT "ID", passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed FROM accounts
ORDER BY lastname, firstname
LIMIT $1
OFFSET $2
`
type ListCustomersParams struct {
type ListAccountsParams struct {
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
func (q *Queries) ListCustomers(ctx context.Context, arg ListCustomersParams) ([]Customer, error) {
rows, err := q.db.QueryContext(ctx, listCustomers, arg.Limit, arg.Offset)
func (q *Queries) ListAccounts(ctx context.Context, arg ListAccountsParams) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, listAccounts, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Customer{}
items := []Account{}
for rows.Next() {
var i Customer
var i Account
if err := rows.Scan(
&i.ID,
&i.Username,
&i.Passwordhash,
&i.Firstname,
&i.Lastname,
@ -191,30 +183,28 @@ func (q *Queries) ListCustomers(ctx context.Context, arg ListCustomersParams) ([
return items, nil
}
const updateCustomer = `-- name: UpdateCustomer :one
UPDATE customers
const updateAccount = `-- name: UpdateAccount :one
UPDATE accounts
SET
username = COALESCE($3, username),
passwordhash = COALESCE($4, passwordhash),
firstname = COALESCE($5, firstname),
lastname = COALESCE($6, lastname),
birthday = COALESCE($7, birthday),
email = COALESCE($8, email),
phone = COALESCE($9, phone),
city = COALESCE($10, city),
zip = COALESCE($11, zip),
street = COALESCE($12, street),
country = COALESCE($13, country),
passwordhash = COALESCE($3, passwordhash),
firstname = COALESCE($4, firstname),
lastname = COALESCE($5, lastname),
birthday = COALESCE($6, birthday),
email = COALESCE($7, email),
phone = COALESCE($8, phone),
city = COALESCE($9, city),
zip = COALESCE($10, zip),
street = COALESCE($11, street),
country = COALESCE($12, country),
changer = $2,
changed = now()
WHERE "ID" = $1
RETURNING "ID", username, passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed
RETURNING "ID", passwordhash, firstname, lastname, birthday, "privacyAccepted", "privacyAcceptedDate", email, phone, city, zip, street, country, token, "tokenValid", "tokenExpiration", creator, created, changer, changed
`
type UpdateCustomerParams struct {
type UpdateAccountParams struct {
ID int64 `json:"ID"`
Changer string `json:"changer"`
Username sql.NullString `json:"username"`
Passwordhash sql.NullString `json:"passwordhash"`
Firstname sql.NullString `json:"firstname"`
Lastname sql.NullString `json:"lastname"`
@ -227,11 +217,10 @@ type UpdateCustomerParams struct {
Country sql.NullString `json:"country"`
}
func (q *Queries) UpdateCustomer(ctx context.Context, arg UpdateCustomerParams) (Customer, error) {
row := q.db.QueryRowContext(ctx, updateCustomer,
func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error) {
row := q.db.QueryRowContext(ctx, updateAccount,
arg.ID,
arg.Changer,
arg.Username,
arg.Passwordhash,
arg.Firstname,
arg.Lastname,
@ -243,10 +232,9 @@ func (q *Queries) UpdateCustomer(ctx context.Context, arg UpdateCustomerParams)
arg.Street,
arg.Country,
)
var i Customer
var i Account
err := row.Scan(
&i.ID,
&i.Username,
&i.Passwordhash,
&i.Firstname,
&i.Lastname,

View File

@ -10,12 +10,11 @@ import (
"github.com/stretchr/testify/require"
)
func createRandomCustomer(t *testing.T) Customer {
func createRandomAccount(t *testing.T) Account {
creator := util.RandomUser()
arg := CreateCustomerParams{
Username: util.RandomUser(),
arg := CreateAccountParams{
Passwordhash: util.RandomString(30),
Firstname: util.RandomUser(),
Lastname: util.RandomUser(),
@ -30,14 +29,12 @@ func createRandomCustomer(t *testing.T) Customer {
Street: util.RandomString(20),
Country: util.RandomString(15),
Creator: creator,
Changer: creator,
}
account, err := testQueries.CreateCustomer(context.Background(), arg)
account, err := testQueries.CreateAccount(context.Background(), arg)
require.NoError(t, err)
require.NotEmpty(t, account)
require.Equal(t, arg.Username, account.Username)
require.Equal(t, arg.Passwordhash, account.Passwordhash)
require.Equal(t, arg.Firstname, account.Firstname)
require.Equal(t, arg.Lastname, account.Lastname)
@ -49,7 +46,7 @@ func createRandomCustomer(t *testing.T) Customer {
require.Equal(t, arg.Street, account.Street)
require.Equal(t, arg.Country, account.Country)
require.Equal(t, arg.Creator, account.Creator)
require.Equal(t, arg.Changer, account.Changer)
require.Equal(t, arg.Creator, account.Changer)
require.NotZero(t, account.ID)
require.NotZero(t, account.Created)
@ -57,19 +54,18 @@ func createRandomCustomer(t *testing.T) Customer {
return account
}
func TestCreateCustomer(t *testing.T) {
createRandomCustomer(t)
func TestCreateAccount(t *testing.T) {
createRandomAccount(t)
}
func TestGetCustomer(t *testing.T) {
newAccount := createRandomCustomer(t)
func TestGetAccount(t *testing.T) {
newAccount := createRandomAccount(t)
require.NotEmpty(t, newAccount)
account, err := testQueries.GetCustomer(context.Background(), newAccount.ID)
account, err := testQueries.GetAccount(context.Background(), newAccount.ID)
require.NoError(t, err)
require.NotEmpty(t, account)
require.Equal(t, newAccount.Username, account.Username)
require.Equal(t, newAccount.Passwordhash, account.Passwordhash)
require.Equal(t, newAccount.Firstname, account.Firstname)
require.Equal(t, newAccount.Lastname, account.Lastname)
@ -86,22 +82,22 @@ func TestGetCustomer(t *testing.T) {
require.WithinDuration(t, newAccount.Created, account.Created, time.Second)
}
func TestDeleteCustomer(t *testing.T) {
account1 := createRandomCustomer(t)
err := testQueries.DeleteCustomer(context.Background(), account1.ID)
func TestDeleteAccount(t *testing.T) {
account1 := createRandomAccount(t)
err := testQueries.DeleteAccount(context.Background(), account1.ID)
require.NoError(t, err)
account2, err := testQueries.GetCustomer(context.Background(), account1.ID)
account2, err := testQueries.GetAccount(context.Background(), account1.ID)
require.Error(t, err)
require.EqualError(t, err, sql.ErrNoRows.Error())
require.Empty(t, account2)
}
func TestUpdateCustomer(t *testing.T) {
account1 := createRandomCustomer(t)
func TestUpdateAccount(t *testing.T) {
account1 := createRandomAccount(t)
require.NotEmpty(t, account1)
arg := UpdateCustomerParams{
arg := UpdateAccountParams{
ID: account1.ID,
Phone: sql.NullString{
String: util.RandomPhone(),
@ -109,27 +105,27 @@ func TestUpdateCustomer(t *testing.T) {
},
}
account2, err := testQueries.UpdateCustomer(context.Background(), arg)
account2, err := testQueries.UpdateAccount(context.Background(), arg)
require.NoError(t, err)
require.NotEmpty(t, account2)
require.Equal(t, account1.ID, account2.ID)
require.Equal(t, account1.Username, account2.Username)
require.Equal(t, account1.Lastname, account2.Lastname)
require.NotEqual(t, account1.Phone, account2.Phone)
require.NotEqual(t, account1.Changer, account2.Changer)
}
func TestListCustomers(t *testing.T) {
func TestListAccounts(t *testing.T) {
for i := 0; i < 10; i++ {
createRandomCustomer(t)
createRandomAccount(t)
}
arg := ListCustomersParams{
arg := ListAccountsParams{
Limit: 5,
Offset: 5,
}
accounts, err := testQueries.ListCustomers(context.Background(), arg)
accounts, err := testQueries.ListAccounts(context.Background(), arg)
require.NoError(t, err)
require.Len(t, accounts, 5)

View File

@ -9,9 +9,8 @@ import (
"time"
)
type Customer struct {
type Account struct {
ID int64 `json:"ID"`
Username string `json:"username"`
Passwordhash string `json:"passwordhash"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
@ -66,7 +65,7 @@ type Mail struct {
type Payment struct {
ID int64 `json:"ID"`
CustomerID int64 `json:"customerID"`
AccountID int64 `json:"accountID"`
PaymentCategory string `json:"paymentCategory"`
Bankname sql.NullString `json:"bankname"`
IBAN sql.NullString `json:"IBAN"`
@ -82,19 +81,19 @@ type Payment struct {
}
type Person struct {
ID int64 `json:"ID"`
CustomerID int64 `json:"customerID"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Birthday time.Time `json:"birthday"`
City string `json:"city"`
Zip string `json:"zip"`
Street string `json:"street"`
Country string `json:"country"`
Creator string `json:"creator"`
Created time.Time `json:"created"`
Changer string `json:"changer"`
Changed time.Time `json:"changed"`
ID int64 `json:"ID"`
AccountID int64 `json:"accountID"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Birthday time.Time `json:"birthday"`
City string `json:"city"`
Zip string `json:"zip"`
Street string `json:"street"`
Country string `json:"country"`
Creator string `json:"creator"`
Created time.Time `json:"created"`
Changer string `json:"changer"`
Changed time.Time `json:"changed"`
}
type Provider struct {

View File

@ -12,7 +12,7 @@ import (
const createPayment = `-- name: CreatePayment :one
INSERT INTO payments (
"customerID",
"accountID",
"paymentCategory",
bankname,
"IBAN",
@ -25,11 +25,11 @@ INSERT INTO payments (
changer
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
) RETURNING "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed
) RETURNING "ID", "accountID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed
`
type CreatePaymentParams struct {
CustomerID int64 `json:"customerID"`
AccountID int64 `json:"accountID"`
PaymentCategory string `json:"paymentCategory"`
Bankname sql.NullString `json:"bankname"`
IBAN sql.NullString `json:"IBAN"`
@ -44,7 +44,7 @@ type CreatePaymentParams struct {
func (q *Queries) CreatePayment(ctx context.Context, arg CreatePaymentParams) (Payment, error) {
row := q.db.QueryRowContext(ctx, createPayment,
arg.CustomerID,
arg.AccountID,
arg.PaymentCategory,
arg.Bankname,
arg.IBAN,
@ -59,7 +59,7 @@ func (q *Queries) CreatePayment(ctx context.Context, arg CreatePaymentParams) (P
var i Payment
err := row.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.PaymentCategory,
&i.Bankname,
&i.IBAN,
@ -87,7 +87,7 @@ func (q *Queries) DeletePayment(ctx context.Context, id int64) error {
}
const getPayment = `-- name: GetPayment :one
SELECT "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed FROM payments
SELECT "ID", "accountID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed FROM payments
WHERE "ID" = $1 LIMIT 1
`
@ -96,7 +96,7 @@ func (q *Queries) GetPayment(ctx context.Context, id int64) (Payment, error) {
var i Payment
err := row.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.PaymentCategory,
&i.Bankname,
&i.IBAN,
@ -114,7 +114,7 @@ func (q *Queries) GetPayment(ctx context.Context, id int64) (Payment, error) {
}
const listPayments = `-- name: ListPayments :many
SELECT "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed FROM payments
SELECT "ID", "accountID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed FROM payments
ORDER BY "paymentCategory"
LIMIT $1
OFFSET $2
@ -136,7 +136,7 @@ func (q *Queries) ListPayments(ctx context.Context, arg ListPaymentsParams) ([]P
var i Payment
if err := rows.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.PaymentCategory,
&i.Bankname,
&i.IBAN,
@ -166,7 +166,7 @@ func (q *Queries) ListPayments(ctx context.Context, arg ListPaymentsParams) ([]P
const updatePayment = `-- name: UpdatePayment :one
UPDATE payments
SET
"customerID" = COALESCE($3, "customerID"),
"accountID" = COALESCE($3, "accountID"),
"paymentCategory" = COALESCE($4, "paymentCategory"),
bankname = COALESCE($5, bankname),
"IBAN" = COALESCE($6, "IBAN"),
@ -178,13 +178,13 @@ SET
changer = $2,
changed = now()
WHERE "ID" = $1
RETURNING "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed
RETURNING "ID", "accountID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed
`
type UpdatePaymentParams struct {
ID int64 `json:"ID"`
Changer string `json:"changer"`
Customerid sql.NullInt64 `json:"customerid"`
Accountid sql.NullInt64 `json:"accountid"`
Paymentcategory sql.NullString `json:"paymentcategory"`
Bankname sql.NullString `json:"bankname"`
Iban sql.NullString `json:"iban"`
@ -199,7 +199,7 @@ func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (P
row := q.db.QueryRowContext(ctx, updatePayment,
arg.ID,
arg.Changer,
arg.Customerid,
arg.Accountid,
arg.Paymentcategory,
arg.Bankname,
arg.Iban,
@ -212,7 +212,7 @@ func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (P
var i Payment
err := row.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.PaymentCategory,
&i.Bankname,
&i.IBAN,

View File

@ -11,13 +11,13 @@ import (
)
func createRandomPayment(t *testing.T) Payment {
account := createRandomCustomer(t)
account := createRandomAccount(t)
require.NotEmpty(t, account)
creator := util.RandomUser()
arg := CreatePaymentParams{
CustomerID: account.ID,
AccountID: account.ID,
PaymentCategory: util.RandomUser(),
Bankname: sql.NullString{
Valid: true,
@ -54,7 +54,7 @@ func createRandomPayment(t *testing.T) Payment {
require.Equal(t, arg.PaymentCategory, person.PaymentCategory)
require.Equal(t, arg.Bankname, person.Bankname)
require.Equal(t, arg.CustomerID, person.CustomerID)
require.Equal(t, arg.AccountID, person.AccountID)
require.Equal(t, arg.IBAN, person.IBAN)
require.Equal(t, arg.BIC, person.BIC)
require.Equal(t, arg.PaypalAccount, person.PaypalAccount)
@ -83,7 +83,7 @@ func TestGetPayment(t *testing.T) {
require.Equal(t, newperson.PaymentCategory, person.PaymentCategory)
require.Equal(t, newperson.Bankname, person.Bankname)
require.Equal(t, newperson.CustomerID, person.CustomerID)
require.Equal(t, newperson.AccountID, person.AccountID)
require.Equal(t, newperson.IBAN, person.IBAN)
require.Equal(t, newperson.BIC, person.BIC)
require.Equal(t, newperson.PaypalAccount, person.PaypalAccount)

View File

@ -13,7 +13,7 @@ import (
const createPerson = `-- name: CreatePerson :one
INSERT INTO persons (
"customerID",
"accountID",
firstname,
lastname,
birthday,
@ -25,25 +25,25 @@ INSERT INTO persons (
changer
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10
) RETURNING "ID", "customerID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed
) RETURNING "ID", "accountID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed
`
type CreatePersonParams struct {
CustomerID int64 `json:"customerID"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Birthday time.Time `json:"birthday"`
City string `json:"city"`
Zip string `json:"zip"`
Street string `json:"street"`
Country string `json:"country"`
Creator string `json:"creator"`
Changer string `json:"changer"`
AccountID int64 `json:"accountID"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Birthday time.Time `json:"birthday"`
City string `json:"city"`
Zip string `json:"zip"`
Street string `json:"street"`
Country string `json:"country"`
Creator string `json:"creator"`
Changer string `json:"changer"`
}
func (q *Queries) CreatePerson(ctx context.Context, arg CreatePersonParams) (Person, error) {
row := q.db.QueryRowContext(ctx, createPerson,
arg.CustomerID,
arg.AccountID,
arg.Firstname,
arg.Lastname,
arg.Birthday,
@ -57,7 +57,7 @@ func (q *Queries) CreatePerson(ctx context.Context, arg CreatePersonParams) (Per
var i Person
err := row.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.Firstname,
&i.Lastname,
&i.Birthday,
@ -84,7 +84,7 @@ func (q *Queries) DeletePerson(ctx context.Context, id int64) error {
}
const getPerson = `-- name: GetPerson :one
SELECT "ID", "customerID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed FROM persons
SELECT "ID", "accountID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed FROM persons
WHERE "ID" = $1 LIMIT 1
`
@ -93,7 +93,7 @@ func (q *Queries) GetPerson(ctx context.Context, id int64) (Person, error) {
var i Person
err := row.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.Firstname,
&i.Lastname,
&i.Birthday,
@ -110,7 +110,7 @@ func (q *Queries) GetPerson(ctx context.Context, id int64) (Person, error) {
}
const listPersons = `-- name: ListPersons :many
SELECT "ID", "customerID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed FROM persons
SELECT "ID", "accountID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed FROM persons
ORDER BY lastname, firstname
LIMIT $1
OFFSET $2
@ -132,7 +132,7 @@ func (q *Queries) ListPersons(ctx context.Context, arg ListPersonsParams) ([]Per
var i Person
if err := rows.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.Firstname,
&i.Lastname,
&i.Birthday,
@ -161,7 +161,7 @@ func (q *Queries) ListPersons(ctx context.Context, arg ListPersonsParams) ([]Per
const updatePerson = `-- name: UpdatePerson :one
UPDATE persons
SET
"customerID" = COALESCE($3, "customerID"),
"accountID" = COALESCE($3, "accountID"),
firstname = COALESCE($4, firstname),
lastname = COALESCE($5, lastname),
birthday = COALESCE($6, birthday),
@ -172,27 +172,27 @@ SET
changer = $2,
changed = now()
WHERE "ID" = $1
RETURNING "ID", "customerID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed
RETURNING "ID", "accountID", firstname, lastname, birthday, city, zip, street, country, creator, created, changer, changed
`
type UpdatePersonParams struct {
ID int64 `json:"ID"`
Changer string `json:"changer"`
Customerid sql.NullInt64 `json:"customerid"`
Firstname sql.NullString `json:"firstname"`
Lastname sql.NullString `json:"lastname"`
Birthday sql.NullTime `json:"birthday"`
City sql.NullString `json:"city"`
Zip sql.NullString `json:"zip"`
Street sql.NullString `json:"street"`
Country sql.NullString `json:"country"`
ID int64 `json:"ID"`
Changer string `json:"changer"`
Accountid sql.NullInt64 `json:"accountid"`
Firstname sql.NullString `json:"firstname"`
Lastname sql.NullString `json:"lastname"`
Birthday sql.NullTime `json:"birthday"`
City sql.NullString `json:"city"`
Zip sql.NullString `json:"zip"`
Street sql.NullString `json:"street"`
Country sql.NullString `json:"country"`
}
func (q *Queries) UpdatePerson(ctx context.Context, arg UpdatePersonParams) (Person, error) {
row := q.db.QueryRowContext(ctx, updatePerson,
arg.ID,
arg.Changer,
arg.Customerid,
arg.Accountid,
arg.Firstname,
arg.Lastname,
arg.Birthday,
@ -204,7 +204,7 @@ func (q *Queries) UpdatePerson(ctx context.Context, arg UpdatePersonParams) (Per
var i Person
err := row.Scan(
&i.ID,
&i.CustomerID,
&i.AccountID,
&i.Firstname,
&i.Lastname,
&i.Birthday,

View File

@ -11,29 +11,29 @@ import (
)
func createRandomPerson(t *testing.T) Person {
account := createRandomCustomer(t)
account := createRandomAccount(t)
require.NotEmpty(t, account)
creator := util.RandomUser()
arg := CreatePersonParams{
CustomerID: account.ID,
Firstname: util.RandomUser(),
Lastname: util.RandomUser(),
Birthday: time.Date(1990, 1, 1, 0, 0, 0, 0, time.UTC),
City: util.RandomString(15),
Zip: util.RandomString(5),
Street: util.RandomString(20),
Country: util.RandomString(15),
Creator: creator,
Changer: creator,
AccountID: account.ID,
Firstname: util.RandomUser(),
Lastname: util.RandomUser(),
Birthday: time.Date(1990, 1, 1, 0, 0, 0, 0, time.UTC),
City: util.RandomString(15),
Zip: util.RandomString(5),
Street: util.RandomString(20),
Country: util.RandomString(15),
Creator: creator,
Changer: creator,
}
person, err := testQueries.CreatePerson(context.Background(), arg)
require.NoError(t, err)
require.NotEmpty(t, person)
require.Equal(t, arg.CustomerID, person.CustomerID)
require.Equal(t, arg.AccountID, person.AccountID)
require.Equal(t, arg.Firstname, person.Firstname)
require.Equal(t, arg.Lastname, person.Lastname)
require.Equal(t, arg.Birthday, person.Birthday)

View File

@ -22,7 +22,7 @@ INSERT INTO "returnsLog" (
$2,
$3,
$4,
$5
$4
) RETURNING "ID", "returnID", "mailID", status, creator, created, changer, changed
`
@ -31,7 +31,6 @@ type CreateReturnsLogParams struct {
Mailid int64 `json:"mailid"`
Status sql.NullString `json:"status"`
Creator string `json:"creator"`
Changer string `json:"changer"`
}
func (q *Queries) CreateReturnsLog(ctx context.Context, arg CreateReturnsLogParams) (ReturnsLog, error) {
@ -40,7 +39,6 @@ func (q *Queries) CreateReturnsLog(ctx context.Context, arg CreateReturnsLogPara
arg.Mailid,
arg.Status,
arg.Creator,
arg.Changer,
)
var i ReturnsLog
err := row.Scan(

View File

@ -25,7 +25,6 @@ func createRandomReturnsLog(t *testing.T) ReturnsLog {
String: util.RandomString(7),
},
Creator: creator,
Changer: creator,
}
returnsLog, err := testQueries.CreateReturnsLog(context.Background(), arg)

28
go.mod
View File

@ -11,20 +11,42 @@ require (
)
require (
github.com/bytedance/sonic v1.10.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.4 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

69
go.sum
View File

@ -38,7 +38,17 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc=
github.com/bytedance/sonic v1.10.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@ -59,9 +69,23 @@ github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0X
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@ -87,6 +111,7 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@ -98,8 +123,10 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@ -124,9 +151,15 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@ -135,14 +168,25 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -165,16 +209,23 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@ -185,6 +236,9 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@ -192,6 +246,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@ -257,6 +313,8 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -312,8 +370,12 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -325,6 +387,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -467,6 +531,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -484,6 +551,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

27
main.go
View File

@ -1,5 +1,30 @@
package main
func main() {
import (
"database/sql"
"log"
"github.com/itsscb/df/api"
db "github.com/itsscb/df/db/sqlc"
"github.com/itsscb/df/util"
_ "github.com/lib/pq"
)
func main() {
config, err := util.LoadConfig(".")
if err != nil {
log.Fatal("cannot load config:", err)
}
conn, err := sql.Open(config.DBDriver, config.DBSource)
if err != nil {
log.Fatalf("could not connect to DB: %s", err)
}
store := db.NewStore(conn)
server := api.NewServer(store)
err = server.Start(config.ServerAddress)
if err != nil {
log.Fatal("cannot start server:", err)
}
}