rf/improves *_id uint64 handling
This commit is contained in:
parent
8733dec355
commit
f25bbb347c
@ -510,7 +510,7 @@ func (mr *MockStoreMockRecorder) GetReturn(arg0, arg1 any) *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetReturns mocks base method.
|
// GetReturns mocks base method.
|
||||||
func (m *MockStore) GetReturns(arg0 context.Context, arg1 int64) ([]db.Return, error) {
|
func (m *MockStore) GetReturns(arg0 context.Context, arg1 uint64) ([]db.Return, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "GetReturns", arg0, arg1)
|
ret := m.ctrl.Call(m, "GetReturns", arg0, arg1)
|
||||||
ret0, _ := ret[0].([]db.Return)
|
ret0, _ := ret[0].([]db.Return)
|
||||||
@ -615,7 +615,7 @@ func (mr *MockStoreMockRecorder) ListMails(arg0, arg1 any) *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListPayments mocks base method.
|
// ListPayments mocks base method.
|
||||||
func (m *MockStore) ListPayments(arg0 context.Context, arg1 int64) ([]db.Payment, error) {
|
func (m *MockStore) ListPayments(arg0 context.Context, arg1 uint64) ([]db.Payment, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "ListPayments", arg0, arg1)
|
ret := m.ctrl.Call(m, "ListPayments", arg0, arg1)
|
||||||
ret0, _ := ret[0].([]db.Payment)
|
ret0, _ := ret[0].([]db.Payment)
|
||||||
@ -630,7 +630,7 @@ func (mr *MockStoreMockRecorder) ListPayments(arg0, arg1 any) *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListPersons mocks base method.
|
// ListPersons mocks base method.
|
||||||
func (m *MockStore) ListPersons(arg0 context.Context, arg1 int64) ([]db.Person, error) {
|
func (m *MockStore) ListPersons(arg0 context.Context, arg1 uint64) ([]db.Person, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "ListPersons", arg0, arg1)
|
ret := m.ctrl.Call(m, "ListPersons", arg0, arg1)
|
||||||
ret0, _ := ret[0].([]db.Person)
|
ret0, _ := ret[0].([]db.Person)
|
||||||
|
@ -10,9 +10,10 @@ INSERT INTO documents (
|
|||||||
"path",
|
"path",
|
||||||
"url",
|
"url",
|
||||||
"creator",
|
"creator",
|
||||||
"changer"
|
"changer",
|
||||||
|
"mail_id"
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5, $6, $7
|
$1, $2, $3, $4, $5, $6, $7, NULL
|
||||||
) RETURNING *;
|
) RETURNING *;
|
||||||
|
|
||||||
-- name: CreateDocumentMail :one
|
-- name: CreateDocumentMail :one
|
||||||
@ -23,9 +24,10 @@ INSERT INTO documents (
|
|||||||
"path",
|
"path",
|
||||||
"url",
|
"url",
|
||||||
"creator",
|
"creator",
|
||||||
"changer"
|
"changer",
|
||||||
|
"person_id"
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5, $6, $7
|
$1, $2, $3, $4, $5, $6, $7, NULL
|
||||||
) RETURNING *;
|
) RETURNING *;
|
||||||
|
|
||||||
-- name: ListDocuments :many
|
-- name: ListDocuments :many
|
||||||
@ -37,7 +39,6 @@ OFFSET $2;
|
|||||||
-- name: UpdateDocument :one
|
-- name: UpdateDocument :one
|
||||||
UPDATE documents
|
UPDATE documents
|
||||||
SET
|
SET
|
||||||
"person_id" = COALESCE(sqlc.narg(person_id), "person_id"),
|
|
||||||
"name" = COALESCE(sqlc.narg(name), "name"),
|
"name" = COALESCE(sqlc.narg(name), "name"),
|
||||||
"type" = COALESCE(sqlc.narg(type), "type"),
|
"type" = COALESCE(sqlc.narg(type), "type"),
|
||||||
"path" = COALESCE(sqlc.narg(path), "path"),
|
"path" = COALESCE(sqlc.narg(path), "path"),
|
||||||
|
@ -27,7 +27,6 @@ ORDER BY "payment_category";
|
|||||||
-- name: UpdatePayment :one
|
-- name: UpdatePayment :one
|
||||||
UPDATE payments
|
UPDATE payments
|
||||||
SET
|
SET
|
||||||
"account_id" = COALESCE(sqlc.narg(account_id), "account_id"),
|
|
||||||
"payment_category" = COALESCE(sqlc.narg(payment_category), "payment_category"),
|
"payment_category" = COALESCE(sqlc.narg(payment_category), "payment_category"),
|
||||||
"bankname" = COALESCE(sqlc.narg(bankname), "bankname"),
|
"bankname" = COALESCE(sqlc.narg(bankname), "bankname"),
|
||||||
"IBAN" = COALESCE(sqlc.narg(IBAN), "IBAN"),
|
"IBAN" = COALESCE(sqlc.narg(IBAN), "IBAN"),
|
||||||
@ -36,9 +35,9 @@ SET
|
|||||||
"paypal_id" = COALESCE(sqlc.narg(paypal_id), "paypal_id"),
|
"paypal_id" = COALESCE(sqlc.narg(paypal_id), "paypal_id"),
|
||||||
"payment_system" = COALESCE(sqlc.narg(payment_system), "payment_system"),
|
"payment_system" = COALESCE(sqlc.narg(payment_system), "payment_system"),
|
||||||
"type" = COALESCE(sqlc.narg(type), "type"),
|
"type" = COALESCE(sqlc.narg(type), "type"),
|
||||||
"changer" = $2,
|
"changer" = sqlc.arg(changer),
|
||||||
"changed" = now()
|
"changed" = now()
|
||||||
WHERE "id" = $1
|
WHERE "id" = sqlc.arg(id)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- name: DeletePayment :exec
|
-- name: DeletePayment :exec
|
||||||
|
@ -26,7 +26,6 @@ ORDER BY "lastname", "firstname";
|
|||||||
-- name: UpdatePerson :one
|
-- name: UpdatePerson :one
|
||||||
UPDATE persons
|
UPDATE persons
|
||||||
SET
|
SET
|
||||||
"account_id" = COALESCE(sqlc.narg(account_id), "account_id"),
|
|
||||||
"firstname" = COALESCE(sqlc.narg(firstname), "firstname"),
|
"firstname" = COALESCE(sqlc.narg(firstname), "firstname"),
|
||||||
"lastname" = COALESCE(sqlc.narg(lastname), "lastname"),
|
"lastname" = COALESCE(sqlc.narg(lastname), "lastname"),
|
||||||
"birthday" = COALESCE(sqlc.narg(birthday), "birthday"),
|
"birthday" = COALESCE(sqlc.narg(birthday), "birthday"),
|
||||||
|
@ -34,8 +34,6 @@ OFFSET $2;
|
|||||||
-- name: UpdateReturn :one
|
-- name: UpdateReturn :one
|
||||||
UPDATE returns
|
UPDATE returns
|
||||||
SET
|
SET
|
||||||
"person_id" = COALESCE(sqlc.narg(person_id), "person_id"),
|
|
||||||
"provider_id" = COALESCE(sqlc.narg(provider_id), "provider_id"),
|
|
||||||
"name" = COALESCE(sqlc.narg(name), "name"),
|
"name" = COALESCE(sqlc.narg(name), "name"),
|
||||||
"description" = COALESCE(sqlc.narg(description), "description"),
|
"description" = COALESCE(sqlc.narg(description), "description"),
|
||||||
"category" = COALESCE(sqlc.narg(category), "category"),
|
"category" = COALESCE(sqlc.narg(category), "category"),
|
||||||
|
@ -26,8 +26,6 @@ OFFSET $2;
|
|||||||
-- name: UpdateReturnsLog :one
|
-- name: UpdateReturnsLog :one
|
||||||
UPDATE "returnsLog"
|
UPDATE "returnsLog"
|
||||||
SET
|
SET
|
||||||
"return_id" = COALESCE(sqlc.narg(return_id), "return_id"),
|
|
||||||
"mail_id" = COALESCE(sqlc.narg(mail_id), "mail_id"),
|
|
||||||
"status" = COALESCE(sqlc.narg(status), "status"),
|
"status" = COALESCE(sqlc.narg(status), "status"),
|
||||||
"changer" = $1,
|
"changer" = $1,
|
||||||
"changed" = now()
|
"changed" = now()
|
||||||
|
@ -18,9 +18,10 @@ INSERT INTO documents (
|
|||||||
"path",
|
"path",
|
||||||
"url",
|
"url",
|
||||||
"creator",
|
"creator",
|
||||||
"changer"
|
"changer",
|
||||||
|
"person_id"
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5, $6, $7
|
$1, $2, $3, $4, $5, $6, $7, NULL
|
||||||
) RETURNING id, person_id, name, type, path, url, valid, valid_date, validated_by, mail_id, creator, created, changer, changed
|
) RETURNING id, person_id, name, type, path, url, valid, valid_date, validated_by, mail_id, creator, created, changer, changed
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -72,9 +73,10 @@ INSERT INTO documents (
|
|||||||
"path",
|
"path",
|
||||||
"url",
|
"url",
|
||||||
"creator",
|
"creator",
|
||||||
"changer"
|
"changer",
|
||||||
|
"mail_id"
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5, $6, $7
|
$1, $2, $3, $4, $5, $6, $7, NULL
|
||||||
) RETURNING id, person_id, name, type, path, url, valid, valid_date, validated_by, mail_id, creator, created, changer, changed
|
) RETURNING id, person_id, name, type, path, url, valid, valid_date, validated_by, mail_id, creator, created, changer, changed
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -247,11 +249,10 @@ func (q *Queries) ListDocuments(ctx context.Context, arg ListDocumentsParams) ([
|
|||||||
const updateDocument = `-- name: UpdateDocument :one
|
const updateDocument = `-- name: UpdateDocument :one
|
||||||
UPDATE documents
|
UPDATE documents
|
||||||
SET
|
SET
|
||||||
"person_id" = COALESCE($3, "person_id"),
|
"name" = COALESCE($3, "name"),
|
||||||
"name" = COALESCE($4, "name"),
|
"type" = COALESCE($4, "type"),
|
||||||
"type" = COALESCE($5, "type"),
|
"path" = COALESCE($5, "path"),
|
||||||
"path" = COALESCE($6, "path"),
|
"url" = COALESCE($6, "url"),
|
||||||
"url" = COALESCE($7, "url"),
|
|
||||||
changer = $2,
|
changer = $2,
|
||||||
changed = now()
|
changed = now()
|
||||||
WHERE "id" = $1
|
WHERE "id" = $1
|
||||||
@ -259,20 +260,18 @@ RETURNING id, person_id, name, type, path, url, valid, valid_date, validated_by,
|
|||||||
`
|
`
|
||||||
|
|
||||||
type UpdateDocumentParams struct {
|
type UpdateDocumentParams struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Changer string `json:"changer"`
|
Changer string `json:"changer"`
|
||||||
PersonID sql.NullInt64 `json:"person_id"`
|
Name sql.NullString `json:"name"`
|
||||||
Name sql.NullString `json:"name"`
|
Type sql.NullString `json:"type"`
|
||||||
Type sql.NullString `json:"type"`
|
Path sql.NullString `json:"path"`
|
||||||
Path sql.NullString `json:"path"`
|
Url sql.NullString `json:"url"`
|
||||||
Url sql.NullString `json:"url"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) UpdateDocument(ctx context.Context, arg UpdateDocumentParams) (Document, error) {
|
func (q *Queries) UpdateDocument(ctx context.Context, arg UpdateDocumentParams) (Document, error) {
|
||||||
row := q.db.QueryRowContext(ctx, updateDocument,
|
row := q.db.QueryRowContext(ctx, updateDocument,
|
||||||
arg.ID,
|
arg.ID,
|
||||||
arg.Changer,
|
arg.Changer,
|
||||||
arg.PersonID,
|
|
||||||
arg.Name,
|
arg.Name,
|
||||||
arg.Type,
|
arg.Type,
|
||||||
arg.Path,
|
arg.Path,
|
||||||
|
@ -65,7 +65,7 @@ type Mail struct {
|
|||||||
|
|
||||||
type Payment struct {
|
type Payment struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
AccountID int64 `json:"account_id"`
|
AccountID uint64 `json:"account_id"`
|
||||||
PaymentCategory string `json:"payment_category"`
|
PaymentCategory string `json:"payment_category"`
|
||||||
Bankname sql.NullString `json:"bankname"`
|
Bankname sql.NullString `json:"bankname"`
|
||||||
IBAN sql.NullString `json:"IBAN"`
|
IBAN sql.NullString `json:"IBAN"`
|
||||||
@ -82,7 +82,7 @@ type Payment struct {
|
|||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
AccountID int64 `json:"account_id"`
|
AccountID uint64 `json:"account_id"`
|
||||||
Firstname string `json:"firstname"`
|
Firstname string `json:"firstname"`
|
||||||
Lastname string `json:"lastname"`
|
Lastname string `json:"lastname"`
|
||||||
Birthday time.Time `json:"birthday"`
|
Birthday time.Time `json:"birthday"`
|
||||||
@ -110,8 +110,8 @@ type Provider struct {
|
|||||||
|
|
||||||
type Return struct {
|
type Return struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
PersonID int64 `json:"person_id"`
|
PersonID uint64 `json:"person_id"`
|
||||||
ProviderID int64 `json:"provider_id"`
|
ProviderID uint64 `json:"provider_id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
@ -125,8 +125,8 @@ type Return struct {
|
|||||||
|
|
||||||
type ReturnsLog struct {
|
type ReturnsLog struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
ReturnID int64 `json:"return_id"`
|
ReturnID uint64 `json:"return_id"`
|
||||||
MailID int64 `json:"mail_id"`
|
MailID uint64 `json:"mail_id"`
|
||||||
Status sql.NullString `json:"status"`
|
Status sql.NullString `json:"status"`
|
||||||
Creator string `json:"creator"`
|
Creator string `json:"creator"`
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
|
@ -29,7 +29,7 @@ INSERT INTO payments (
|
|||||||
`
|
`
|
||||||
|
|
||||||
type CreatePaymentParams struct {
|
type CreatePaymentParams struct {
|
||||||
AccountID int64 `json:"account_id"`
|
AccountID uint64 `json:"account_id"`
|
||||||
PaymentCategory string `json:"payment_category"`
|
PaymentCategory string `json:"payment_category"`
|
||||||
Bankname sql.NullString `json:"bankname"`
|
Bankname sql.NullString `json:"bankname"`
|
||||||
IBAN sql.NullString `json:"IBAN"`
|
IBAN sql.NullString `json:"IBAN"`
|
||||||
@ -119,7 +119,7 @@ WHERE "account_id" = $1
|
|||||||
ORDER BY "payment_category"
|
ORDER BY "payment_category"
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) ListPayments(ctx context.Context, accountID int64) ([]Payment, error) {
|
func (q *Queries) ListPayments(ctx context.Context, accountID uint64) ([]Payment, error) {
|
||||||
rows, err := q.db.QueryContext(ctx, listPayments, accountID)
|
rows, err := q.db.QueryContext(ctx, listPayments, accountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -160,25 +160,21 @@ func (q *Queries) ListPayments(ctx context.Context, accountID int64) ([]Payment,
|
|||||||
const updatePayment = `-- name: UpdatePayment :one
|
const updatePayment = `-- name: UpdatePayment :one
|
||||||
UPDATE payments
|
UPDATE payments
|
||||||
SET
|
SET
|
||||||
"account_id" = COALESCE($3, "account_id"),
|
"payment_category" = COALESCE($1, "payment_category"),
|
||||||
"payment_category" = COALESCE($4, "payment_category"),
|
"bankname" = COALESCE($2, "bankname"),
|
||||||
"bankname" = COALESCE($5, "bankname"),
|
"IBAN" = COALESCE($3, "IBAN"),
|
||||||
"IBAN" = COALESCE($6, "IBAN"),
|
"BIC" = COALESCE($4, "BIC"),
|
||||||
"BIC" = COALESCE($7, "BIC"),
|
"paypal_account" = COALESCE($5, "paypal_account"),
|
||||||
"paypal_account" = COALESCE($8, "paypal_account"),
|
"paypal_id" = COALESCE($6, "paypal_id"),
|
||||||
"paypal_id" = COALESCE($9, "paypal_id"),
|
"payment_system" = COALESCE($7, "payment_system"),
|
||||||
"payment_system" = COALESCE($10, "payment_system"),
|
"type" = COALESCE($8, "type"),
|
||||||
"type" = COALESCE($11, "type"),
|
"changer" = $9,
|
||||||
"changer" = $2,
|
|
||||||
"changed" = now()
|
"changed" = now()
|
||||||
WHERE "id" = $1
|
WHERE "id" = $10
|
||||||
RETURNING id, account_id, payment_category, bankname, "IBAN", "BIC", paypal_account, paypal_id, payment_system, type, creator, created, changer, changed
|
RETURNING id, account_id, payment_category, bankname, "IBAN", "BIC", paypal_account, paypal_id, payment_system, type, creator, created, changer, changed
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdatePaymentParams struct {
|
type UpdatePaymentParams struct {
|
||||||
ID uint64 `json:"id"`
|
|
||||||
Changer string `json:"changer"`
|
|
||||||
AccountID sql.NullInt64 `json:"account_id"`
|
|
||||||
PaymentCategory sql.NullString `json:"payment_category"`
|
PaymentCategory sql.NullString `json:"payment_category"`
|
||||||
Bankname sql.NullString `json:"bankname"`
|
Bankname sql.NullString `json:"bankname"`
|
||||||
Iban sql.NullString `json:"iban"`
|
Iban sql.NullString `json:"iban"`
|
||||||
@ -187,13 +183,12 @@ type UpdatePaymentParams struct {
|
|||||||
PaypalID sql.NullString `json:"paypal_id"`
|
PaypalID sql.NullString `json:"paypal_id"`
|
||||||
PaymentSystem sql.NullString `json:"payment_system"`
|
PaymentSystem sql.NullString `json:"payment_system"`
|
||||||
Type sql.NullString `json:"type"`
|
Type sql.NullString `json:"type"`
|
||||||
|
Changer string `json:"changer"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (Payment, error) {
|
func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (Payment, error) {
|
||||||
row := q.db.QueryRowContext(ctx, updatePayment,
|
row := q.db.QueryRowContext(ctx, updatePayment,
|
||||||
arg.ID,
|
|
||||||
arg.Changer,
|
|
||||||
arg.AccountID,
|
|
||||||
arg.PaymentCategory,
|
arg.PaymentCategory,
|
||||||
arg.Bankname,
|
arg.Bankname,
|
||||||
arg.Iban,
|
arg.Iban,
|
||||||
@ -202,6 +197,8 @@ func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (P
|
|||||||
arg.PaypalID,
|
arg.PaypalID,
|
||||||
arg.PaymentSystem,
|
arg.PaymentSystem,
|
||||||
arg.Type,
|
arg.Type,
|
||||||
|
arg.Changer,
|
||||||
|
arg.ID,
|
||||||
)
|
)
|
||||||
var i Payment
|
var i Payment
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
|
@ -10,6 +10,27 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestUpdatePayment(t *testing.T) {
|
||||||
|
payment1 := createRandomPayment(t)
|
||||||
|
require.NotEmpty(t, payment1)
|
||||||
|
|
||||||
|
arg := UpdatePaymentParams{
|
||||||
|
ID: payment1.ID,
|
||||||
|
Bankname: sql.NullString{
|
||||||
|
String: util.RandomName(),
|
||||||
|
Valid: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
payment2, err := testQueries.UpdatePayment(context.Background(), arg)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotEmpty(t, payment2)
|
||||||
|
|
||||||
|
require.Equal(t, payment1.ID, payment2.ID)
|
||||||
|
require.Equal(t, payment1.PaymentCategory, payment2.PaymentCategory)
|
||||||
|
require.NotEqual(t, payment1.Bankname, payment2.Bankname)
|
||||||
|
}
|
||||||
|
|
||||||
func createRandomPayment(t *testing.T) Payment {
|
func createRandomPayment(t *testing.T) Payment {
|
||||||
account := createRandomAccount(t)
|
account := createRandomAccount(t)
|
||||||
require.NotEmpty(t, account)
|
require.NotEmpty(t, account)
|
||||||
@ -17,7 +38,7 @@ func createRandomPayment(t *testing.T) Payment {
|
|||||||
creator := util.RandomName()
|
creator := util.RandomName()
|
||||||
|
|
||||||
arg := CreatePaymentParams{
|
arg := CreatePaymentParams{
|
||||||
AccountID: int64(account.ID),
|
AccountID: account.ID,
|
||||||
PaymentCategory: util.RandomName(),
|
PaymentCategory: util.RandomName(),
|
||||||
Bankname: sql.NullString{
|
Bankname: sql.NullString{
|
||||||
Valid: true,
|
Valid: true,
|
||||||
@ -48,25 +69,25 @@ func createRandomPayment(t *testing.T) Payment {
|
|||||||
Changer: creator,
|
Changer: creator,
|
||||||
}
|
}
|
||||||
|
|
||||||
person, err := testQueries.CreatePayment(context.Background(), arg)
|
payment, err := testQueries.CreatePayment(context.Background(), arg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEmpty(t, person)
|
require.NotEmpty(t, payment)
|
||||||
|
|
||||||
require.Equal(t, arg.PaymentCategory, person.PaymentCategory)
|
require.Equal(t, arg.PaymentCategory, payment.PaymentCategory)
|
||||||
require.Equal(t, arg.Bankname, person.Bankname)
|
require.Equal(t, arg.Bankname, payment.Bankname)
|
||||||
require.Equal(t, arg.AccountID, person.AccountID)
|
require.Equal(t, arg.AccountID, payment.AccountID)
|
||||||
require.Equal(t, arg.IBAN, person.IBAN)
|
require.Equal(t, arg.IBAN, payment.IBAN)
|
||||||
require.Equal(t, arg.BIC, person.BIC)
|
require.Equal(t, arg.BIC, payment.BIC)
|
||||||
require.Equal(t, arg.PaypalAccount, person.PaypalAccount)
|
require.Equal(t, arg.PaypalAccount, payment.PaypalAccount)
|
||||||
require.Equal(t, arg.PaymentSystem, person.PaymentSystem)
|
require.Equal(t, arg.PaymentSystem, payment.PaymentSystem)
|
||||||
require.Equal(t, arg.PaypalID, person.PaypalID)
|
require.Equal(t, arg.PaypalID, payment.PaypalID)
|
||||||
require.Equal(t, arg.Creator, person.Creator)
|
require.Equal(t, arg.Creator, payment.Creator)
|
||||||
require.Equal(t, arg.Type, person.Type)
|
require.Equal(t, arg.Type, payment.Type)
|
||||||
|
|
||||||
require.NotZero(t, person.ID)
|
require.NotZero(t, payment.ID)
|
||||||
require.NotZero(t, person.Created)
|
require.NotZero(t, payment.Created)
|
||||||
|
|
||||||
return person
|
return payment
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreatePayment(t *testing.T) {
|
func TestCreatePayment(t *testing.T) {
|
||||||
@ -74,55 +95,34 @@ func TestCreatePayment(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetPayment(t *testing.T) {
|
func TestGetPayment(t *testing.T) {
|
||||||
newperson := createRandomPayment(t)
|
newpayment := createRandomPayment(t)
|
||||||
require.NotEmpty(t, newperson)
|
require.NotEmpty(t, newpayment)
|
||||||
|
|
||||||
person, err := testQueries.GetPayment(context.Background(), newperson.ID)
|
payment, err := testQueries.GetPayment(context.Background(), newpayment.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEmpty(t, person)
|
require.NotEmpty(t, payment)
|
||||||
|
|
||||||
require.Equal(t, newperson.PaymentCategory, person.PaymentCategory)
|
require.Equal(t, newpayment.PaymentCategory, payment.PaymentCategory)
|
||||||
require.Equal(t, newperson.Bankname, person.Bankname)
|
require.Equal(t, newpayment.Bankname, payment.Bankname)
|
||||||
require.Equal(t, newperson.AccountID, person.AccountID)
|
require.Equal(t, newpayment.AccountID, payment.AccountID)
|
||||||
require.Equal(t, newperson.IBAN, person.IBAN)
|
require.Equal(t, newpayment.IBAN, payment.IBAN)
|
||||||
require.Equal(t, newperson.BIC, person.BIC)
|
require.Equal(t, newpayment.BIC, payment.BIC)
|
||||||
require.Equal(t, newperson.PaypalAccount, person.PaypalAccount)
|
require.Equal(t, newpayment.PaypalAccount, payment.PaypalAccount)
|
||||||
require.Equal(t, newperson.PaymentSystem, person.PaymentSystem)
|
require.Equal(t, newpayment.PaymentSystem, payment.PaymentSystem)
|
||||||
require.Equal(t, newperson.PaypalID, person.PaypalID)
|
require.Equal(t, newpayment.PaypalID, payment.PaypalID)
|
||||||
require.Equal(t, newperson.Creator, person.Creator)
|
require.Equal(t, newpayment.Creator, payment.Creator)
|
||||||
require.Equal(t, newperson.Type, person.Type)
|
require.Equal(t, newpayment.Type, payment.Type)
|
||||||
|
|
||||||
require.WithinDuration(t, newperson.Created, person.Created, time.Second)
|
require.WithinDuration(t, newpayment.Created, payment.Created, time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeletePayment(t *testing.T) {
|
func TestDeletePayment(t *testing.T) {
|
||||||
person1 := createRandomPayment(t)
|
payment1 := createRandomPayment(t)
|
||||||
err := testQueries.DeletePayment(context.Background(), person1.ID)
|
err := testQueries.DeletePayment(context.Background(), payment1.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
person2, err := testQueries.GetPayment(context.Background(), person1.ID)
|
payment2, err := testQueries.GetPayment(context.Background(), payment1.ID)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.EqualError(t, err, sql.ErrNoRows.Error())
|
require.EqualError(t, err, sql.ErrNoRows.Error())
|
||||||
require.Empty(t, person2)
|
require.Empty(t, payment2)
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdatePayment(t *testing.T) {
|
|
||||||
person1 := createRandomPayment(t)
|
|
||||||
require.NotEmpty(t, person1)
|
|
||||||
|
|
||||||
arg := UpdatePaymentParams{
|
|
||||||
ID: person1.ID,
|
|
||||||
Bankname: sql.NullString{
|
|
||||||
String: util.RandomName(),
|
|
||||||
Valid: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
person2, err := testQueries.UpdatePayment(context.Background(), arg)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotEmpty(t, person2)
|
|
||||||
|
|
||||||
require.Equal(t, person1.ID, person2.ID)
|
|
||||||
require.Equal(t, person1.PaymentCategory, person2.PaymentCategory)
|
|
||||||
require.NotEqual(t, person1.Bankname, person2.Bankname)
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ INSERT INTO persons (
|
|||||||
`
|
`
|
||||||
|
|
||||||
type CreatePersonParams struct {
|
type CreatePersonParams struct {
|
||||||
AccountID int64 `json:"account_id"`
|
AccountID uint64 `json:"account_id"`
|
||||||
Firstname string `json:"firstname"`
|
Firstname string `json:"firstname"`
|
||||||
Lastname string `json:"lastname"`
|
Lastname string `json:"lastname"`
|
||||||
Birthday time.Time `json:"birthday"`
|
Birthday time.Time `json:"birthday"`
|
||||||
@ -114,7 +114,7 @@ SELECT id, person_id, provider_id, name, description, category, email, status, c
|
|||||||
WHERE "person_id" = $1
|
WHERE "person_id" = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) GetReturns(ctx context.Context, id int64) ([]Return, error) {
|
func (q *Queries) GetReturns(ctx context.Context, id uint64) ([]Return, error) {
|
||||||
rows, err := q.db.QueryContext(ctx, getReturns, id)
|
rows, err := q.db.QueryContext(ctx, getReturns, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -156,7 +156,7 @@ WHERE "account_id" = $1
|
|||||||
ORDER BY "lastname", "firstname"
|
ORDER BY "lastname", "firstname"
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) ListPersons(ctx context.Context, accountID int64) ([]Person, error) {
|
func (q *Queries) ListPersons(ctx context.Context, accountID uint64) ([]Person, error) {
|
||||||
rows, err := q.db.QueryContext(ctx, listPersons, accountID)
|
rows, err := q.db.QueryContext(ctx, listPersons, accountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -196,14 +196,13 @@ func (q *Queries) ListPersons(ctx context.Context, accountID int64) ([]Person, e
|
|||||||
const updatePerson = `-- name: UpdatePerson :one
|
const updatePerson = `-- name: UpdatePerson :one
|
||||||
UPDATE persons
|
UPDATE persons
|
||||||
SET
|
SET
|
||||||
"account_id" = COALESCE($3, "account_id"),
|
"firstname" = COALESCE($3, "firstname"),
|
||||||
"firstname" = COALESCE($4, "firstname"),
|
"lastname" = COALESCE($4, "lastname"),
|
||||||
"lastname" = COALESCE($5, "lastname"),
|
"birthday" = COALESCE($5, "birthday"),
|
||||||
"birthday" = COALESCE($6, "birthday"),
|
"city" = COALESCE($6, "city"),
|
||||||
"city" = COALESCE($7, "city"),
|
"zip" = COALESCE($7, "zip"),
|
||||||
"zip" = COALESCE($8, "zip"),
|
"street" = COALESCE($8, "street"),
|
||||||
"street" = COALESCE($9, "street"),
|
"country" = COALESCE($9, "country"),
|
||||||
"country" = COALESCE($10, "country"),
|
|
||||||
"changer" = $2,
|
"changer" = $2,
|
||||||
"changed" = now()
|
"changed" = now()
|
||||||
WHERE "id" = $1
|
WHERE "id" = $1
|
||||||
@ -213,7 +212,6 @@ RETURNING id, account_id, firstname, lastname, birthday, city, zip, street, coun
|
|||||||
type UpdatePersonParams struct {
|
type UpdatePersonParams struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Changer string `json:"changer"`
|
Changer string `json:"changer"`
|
||||||
AccountID sql.NullInt64 `json:"account_id"`
|
|
||||||
Firstname sql.NullString `json:"firstname"`
|
Firstname sql.NullString `json:"firstname"`
|
||||||
Lastname sql.NullString `json:"lastname"`
|
Lastname sql.NullString `json:"lastname"`
|
||||||
Birthday sql.NullTime `json:"birthday"`
|
Birthday sql.NullTime `json:"birthday"`
|
||||||
@ -227,7 +225,6 @@ func (q *Queries) UpdatePerson(ctx context.Context, arg UpdatePersonParams) (Per
|
|||||||
row := q.db.QueryRowContext(ctx, updatePerson,
|
row := q.db.QueryRowContext(ctx, updatePerson,
|
||||||
arg.ID,
|
arg.ID,
|
||||||
arg.Changer,
|
arg.Changer,
|
||||||
arg.AccountID,
|
|
||||||
arg.Firstname,
|
arg.Firstname,
|
||||||
arg.Lastname,
|
arg.Lastname,
|
||||||
arg.Birthday,
|
arg.Birthday,
|
||||||
|
@ -17,7 +17,7 @@ func createRandomPerson(t *testing.T) Person {
|
|||||||
creator := util.RandomName()
|
creator := util.RandomName()
|
||||||
|
|
||||||
arg := CreatePersonParams{
|
arg := CreatePersonParams{
|
||||||
AccountID: int64(account.ID),
|
AccountID: account.ID,
|
||||||
Firstname: util.RandomName(),
|
Firstname: util.RandomName(),
|
||||||
Lastname: util.RandomName(),
|
Lastname: util.RandomName(),
|
||||||
Birthday: time.Date(1990, 1, 1, 0, 0, 0, 0, time.UTC),
|
Birthday: time.Date(1990, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||||
|
@ -53,15 +53,15 @@ type Querier interface {
|
|||||||
GetPerson(ctx context.Context, id uint64) (Person, error)
|
GetPerson(ctx context.Context, id uint64) (Person, error)
|
||||||
GetProvider(ctx context.Context, id uint64) (Provider, error)
|
GetProvider(ctx context.Context, id uint64) (Provider, error)
|
||||||
GetReturn(ctx context.Context, id uint64) (Return, error)
|
GetReturn(ctx context.Context, id uint64) (Return, error)
|
||||||
GetReturns(ctx context.Context, id int64) ([]Return, error)
|
GetReturns(ctx context.Context, id uint64) ([]Return, error)
|
||||||
GetReturnsLog(ctx context.Context, id uint64) (ReturnsLog, error)
|
GetReturnsLog(ctx context.Context, id uint64) (ReturnsLog, error)
|
||||||
GetSession(ctx context.Context, id uuid.UUID) (Session, error)
|
GetSession(ctx context.Context, id uuid.UUID) (Session, error)
|
||||||
InvalidateDocument(ctx context.Context, arg InvalidateDocumentParams) (Document, error)
|
InvalidateDocument(ctx context.Context, arg InvalidateDocumentParams) (Document, error)
|
||||||
ListAccounts(ctx context.Context, arg ListAccountsParams) ([]Account, error)
|
ListAccounts(ctx context.Context, arg ListAccountsParams) ([]Account, error)
|
||||||
ListDocuments(ctx context.Context, arg ListDocumentsParams) ([]Document, error)
|
ListDocuments(ctx context.Context, arg ListDocumentsParams) ([]Document, error)
|
||||||
ListMails(ctx context.Context, arg ListMailsParams) ([]Mail, error)
|
ListMails(ctx context.Context, arg ListMailsParams) ([]Mail, error)
|
||||||
ListPayments(ctx context.Context, accountID int64) ([]Payment, error)
|
ListPayments(ctx context.Context, accountID uint64) ([]Payment, error)
|
||||||
ListPersons(ctx context.Context, accountID int64) ([]Person, error)
|
ListPersons(ctx context.Context, accountID uint64) ([]Person, error)
|
||||||
ListProviders(ctx context.Context, arg ListProvidersParams) ([]Provider, error)
|
ListProviders(ctx context.Context, arg ListProvidersParams) ([]Provider, error)
|
||||||
ListReturns(ctx context.Context, arg ListReturnsParams) ([]Return, error)
|
ListReturns(ctx context.Context, arg ListReturnsParams) ([]Return, error)
|
||||||
ListReturnsLogs(ctx context.Context, arg ListReturnsLogsParams) ([]ReturnsLog, error)
|
ListReturnsLogs(ctx context.Context, arg ListReturnsLogsParams) ([]ReturnsLog, error)
|
||||||
|
@ -37,7 +37,7 @@ FROM providers
|
|||||||
|
|
||||||
type CloneProvidersParams struct {
|
type CloneProvidersParams struct {
|
||||||
Creator string `json:"creator"`
|
Creator string `json:"creator"`
|
||||||
PersonID int64 `json:"person_id"`
|
PersonID uint64 `json:"person_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) CloneProviders(ctx context.Context, arg CloneProvidersParams) error {
|
func (q *Queries) CloneProviders(ctx context.Context, arg CloneProvidersParams) error {
|
||||||
@ -70,8 +70,8 @@ INSERT INTO returns (
|
|||||||
`
|
`
|
||||||
|
|
||||||
type CreateReturnParams struct {
|
type CreateReturnParams struct {
|
||||||
PersonID int64 `json:"person_id"`
|
PersonID uint64 `json:"person_id"`
|
||||||
ProviderID int64 `json:"provider_id"`
|
ProviderID uint64 `json:"provider_id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
@ -197,22 +197,18 @@ func (q *Queries) ListReturns(ctx context.Context, arg ListReturnsParams) ([]Ret
|
|||||||
const updateReturn = `-- name: UpdateReturn :one
|
const updateReturn = `-- name: UpdateReturn :one
|
||||||
UPDATE returns
|
UPDATE returns
|
||||||
SET
|
SET
|
||||||
"person_id" = COALESCE($1, "person_id"),
|
"name" = COALESCE($1, "name"),
|
||||||
"provider_id" = COALESCE($2, "provider_id"),
|
"description" = COALESCE($2, "description"),
|
||||||
"name" = COALESCE($3, "name"),
|
"category" = COALESCE($3, "category"),
|
||||||
"description" = COALESCE($4, "description"),
|
"email" = COALESCE($4, "email"),
|
||||||
"category" = COALESCE($5, "category"),
|
"status" = COALESCE($5, "status"),
|
||||||
"email" = COALESCE($6, "email"),
|
"changer" = $6,
|
||||||
"status" = COALESCE($7, "status"),
|
|
||||||
"changer" = $8,
|
|
||||||
"changed" = now()
|
"changed" = now()
|
||||||
WHERE "id" = $9
|
WHERE "id" = $7
|
||||||
RETURNING id, person_id, provider_id, name, description, category, email, status, creator, created, changer, changed
|
RETURNING id, person_id, provider_id, name, description, category, email, status, creator, created, changer, changed
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdateReturnParams struct {
|
type UpdateReturnParams struct {
|
||||||
PersonID sql.NullInt64 `json:"person_id"`
|
|
||||||
ProviderID sql.NullInt64 `json:"provider_id"`
|
|
||||||
Name sql.NullString `json:"name"`
|
Name sql.NullString `json:"name"`
|
||||||
Description sql.NullString `json:"description"`
|
Description sql.NullString `json:"description"`
|
||||||
Category sql.NullString `json:"category"`
|
Category sql.NullString `json:"category"`
|
||||||
@ -224,8 +220,6 @@ type UpdateReturnParams struct {
|
|||||||
|
|
||||||
func (q *Queries) UpdateReturn(ctx context.Context, arg UpdateReturnParams) (Return, error) {
|
func (q *Queries) UpdateReturn(ctx context.Context, arg UpdateReturnParams) (Return, error) {
|
||||||
row := q.db.QueryRowContext(ctx, updateReturn,
|
row := q.db.QueryRowContext(ctx, updateReturn,
|
||||||
arg.PersonID,
|
|
||||||
arg.ProviderID,
|
|
||||||
arg.Name,
|
arg.Name,
|
||||||
arg.Description,
|
arg.Description,
|
||||||
arg.Category,
|
arg.Category,
|
||||||
|
@ -18,8 +18,8 @@ func createRandomReturn(t *testing.T) Return {
|
|||||||
creator := util.RandomName()
|
creator := util.RandomName()
|
||||||
|
|
||||||
arg := CreateReturnParams{
|
arg := CreateReturnParams{
|
||||||
PersonID: int64(person.ID),
|
PersonID: person.ID,
|
||||||
ProviderID: int64(provider.ID),
|
ProviderID: provider.ID,
|
||||||
Status: util.RandomString(7),
|
Status: util.RandomString(7),
|
||||||
Name: util.RandomName(),
|
Name: util.RandomName(),
|
||||||
Description: util.RandomString(30),
|
Description: util.RandomString(30),
|
||||||
|
@ -27,8 +27,8 @@ INSERT INTO "returnsLog" (
|
|||||||
`
|
`
|
||||||
|
|
||||||
type CreateReturnsLogParams struct {
|
type CreateReturnsLogParams struct {
|
||||||
ReturnID int64 `json:"return_id"`
|
ReturnID uint64 `json:"return_id"`
|
||||||
MailID int64 `json:"mail_id"`
|
MailID uint64 `json:"mail_id"`
|
||||||
Status sql.NullString `json:"status"`
|
Status sql.NullString `json:"status"`
|
||||||
Creator string `json:"creator"`
|
Creator string `json:"creator"`
|
||||||
}
|
}
|
||||||
@ -132,31 +132,21 @@ func (q *Queries) ListReturnsLogs(ctx context.Context, arg ListReturnsLogsParams
|
|||||||
const updateReturnsLog = `-- name: UpdateReturnsLog :one
|
const updateReturnsLog = `-- name: UpdateReturnsLog :one
|
||||||
UPDATE "returnsLog"
|
UPDATE "returnsLog"
|
||||||
SET
|
SET
|
||||||
"return_id" = COALESCE($2, "return_id"),
|
"status" = COALESCE($2, "status"),
|
||||||
"mail_id" = COALESCE($3, "mail_id"),
|
|
||||||
"status" = COALESCE($4, "status"),
|
|
||||||
"changer" = $1,
|
"changer" = $1,
|
||||||
"changed" = now()
|
"changed" = now()
|
||||||
WHERE "id" = $5
|
WHERE "id" = $3
|
||||||
RETURNING id, return_id, mail_id, status, creator, created, changer, changed
|
RETURNING id, return_id, mail_id, status, creator, created, changer, changed
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdateReturnsLogParams struct {
|
type UpdateReturnsLogParams struct {
|
||||||
Changer string `json:"changer"`
|
Changer string `json:"changer"`
|
||||||
ReturnID sql.NullInt64 `json:"return_id"`
|
Status sql.NullString `json:"status"`
|
||||||
MailID sql.NullInt64 `json:"mail_id"`
|
ID uint64 `json:"id"`
|
||||||
Status sql.NullString `json:"status"`
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) UpdateReturnsLog(ctx context.Context, arg UpdateReturnsLogParams) (ReturnsLog, error) {
|
func (q *Queries) UpdateReturnsLog(ctx context.Context, arg UpdateReturnsLogParams) (ReturnsLog, error) {
|
||||||
row := q.db.QueryRowContext(ctx, updateReturnsLog,
|
row := q.db.QueryRowContext(ctx, updateReturnsLog, arg.Changer, arg.Status, arg.ID)
|
||||||
arg.Changer,
|
|
||||||
arg.ReturnID,
|
|
||||||
arg.MailID,
|
|
||||||
arg.Status,
|
|
||||||
arg.ID,
|
|
||||||
)
|
|
||||||
var i ReturnsLog
|
var i ReturnsLog
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
|
@ -18,8 +18,8 @@ func createRandomReturnsLog(t *testing.T) ReturnsLog {
|
|||||||
creator := util.RandomName()
|
creator := util.RandomName()
|
||||||
|
|
||||||
arg := CreateReturnsLogParams{
|
arg := CreateReturnsLogParams{
|
||||||
ReturnID: int64(ret.ID),
|
ReturnID: ret.ID,
|
||||||
MailID: int64(mail.ID),
|
MailID: mail.ID,
|
||||||
Status: sql.NullString{
|
Status: sql.NullString{
|
||||||
Valid: true,
|
Valid: true,
|
||||||
String: util.RandomString(7),
|
String: util.RandomString(7),
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CreatePersonTxParams struct {
|
type CreatePersonTxParams struct {
|
||||||
AccountID int64 `json:"account_id"`
|
AccountID uint64 `json:"account_id"`
|
||||||
Firstname string `json:"firstname"`
|
Firstname string `json:"firstname"`
|
||||||
Lastname string `json:"lastname"`
|
Lastname string `json:"lastname"`
|
||||||
Birthday time.Time `json:"birthday"`
|
Birthday time.Time `json:"birthday"`
|
||||||
@ -35,7 +35,7 @@ func (store *SQLStore) CreatePersonTx(ctx context.Context, arg CreatePersonTxPar
|
|||||||
|
|
||||||
err = q.CloneProviders(ctx, CloneProvidersParams{
|
err = q.CloneProviders(ctx, CloneProvidersParams{
|
||||||
Creator: arg.Creator,
|
Creator: arg.Creator,
|
||||||
PersonID: int64(result.Person.ID),
|
PersonID: result.Person.ID,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
@ -1015,7 +1015,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "int64"
|
"format": "uint64"
|
||||||
},
|
},
|
||||||
"deleted": {
|
"deleted": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -1032,7 +1032,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "int64"
|
"format": "uint64"
|
||||||
},
|
},
|
||||||
"deleted": {
|
"deleted": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -38,9 +38,8 @@ func (server *Server) CreatePayment(ctx context.Context, req *pb.CreatePaymentRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(req.GetAccountId())
|
|
||||||
arg := db.CreatePaymentParams{
|
arg := db.CreatePaymentParams{
|
||||||
AccountID: accountID,
|
AccountID: req.GetAccountId(),
|
||||||
PaymentCategory: req.GetPaymentCategory(),
|
PaymentCategory: req.GetPaymentCategory(),
|
||||||
Bankname: sql.NullString{
|
Bankname: sql.NullString{
|
||||||
Valid: req.GetBankname() != "",
|
Valid: req.GetBankname() != "",
|
||||||
|
@ -38,9 +38,8 @@ func (server *Server) CreatePerson(ctx context.Context, req *pb.CreatePersonRequ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(req.GetAccountId())
|
|
||||||
arg := db.CreatePersonTxParams{
|
arg := db.CreatePersonTxParams{
|
||||||
AccountID: accountID,
|
AccountID: account.ID,
|
||||||
Firstname: req.GetFirstname(),
|
Firstname: req.GetFirstname(),
|
||||||
Lastname: req.GetLastname(),
|
Lastname: req.GetLastname(),
|
||||||
Birthday: req.GetBirthday().AsTime(),
|
Birthday: req.GetBirthday().AsTime(),
|
||||||
|
@ -44,10 +44,7 @@ func (server *Server) DeletePayment(ctx context.Context, req *pb.DeletePaymentRe
|
|||||||
return nil, status.Errorf(codes.Internal, "failed to get payment")
|
return nil, status.Errorf(codes.Internal, "failed to get payment")
|
||||||
}
|
}
|
||||||
|
|
||||||
paymentID := int64(req.GetId())
|
if payment.AccountID != account.ID {
|
||||||
accountID := int64(account.ID)
|
|
||||||
|
|
||||||
if payment.AccountID != accountID {
|
|
||||||
if !server.isAdmin(ctx, authPayload) {
|
if !server.isAdmin(ctx, authPayload) {
|
||||||
return nil, status.Error(codes.NotFound, "payment not found")
|
return nil, status.Error(codes.NotFound, "payment not found")
|
||||||
}
|
}
|
||||||
@ -60,7 +57,7 @@ func (server *Server) DeletePayment(ctx context.Context, req *pb.DeletePaymentRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
rsp := &pb.DeletePaymentResponse{
|
rsp := &pb.DeletePaymentResponse{
|
||||||
Id: paymentID,
|
Id: payment.ID,
|
||||||
Deleted: true,
|
Deleted: true,
|
||||||
}
|
}
|
||||||
return rsp, nil
|
return rsp, nil
|
||||||
|
@ -44,10 +44,7 @@ func (server *Server) DeletePerson(ctx context.Context, req *pb.DeletePersonRequ
|
|||||||
return nil, status.Errorf(codes.Internal, "failed to get person")
|
return nil, status.Errorf(codes.Internal, "failed to get person")
|
||||||
}
|
}
|
||||||
|
|
||||||
personID := int64(person.ID)
|
if person.AccountID != account.ID {
|
||||||
accountID := int64(account.ID)
|
|
||||||
|
|
||||||
if person.AccountID != accountID {
|
|
||||||
if !server.isAdmin(ctx, authPayload) {
|
if !server.isAdmin(ctx, authPayload) {
|
||||||
return nil, status.Error(codes.NotFound, "person not found")
|
return nil, status.Error(codes.NotFound, "person not found")
|
||||||
}
|
}
|
||||||
@ -60,7 +57,7 @@ func (server *Server) DeletePerson(ctx context.Context, req *pb.DeletePersonRequ
|
|||||||
}
|
}
|
||||||
|
|
||||||
rsp := &pb.DeletePersonResponse{
|
rsp := &pb.DeletePersonResponse{
|
||||||
Id: personID,
|
Id: person.ID,
|
||||||
Deleted: true,
|
Deleted: true,
|
||||||
}
|
}
|
||||||
return rsp, nil
|
return rsp, nil
|
||||||
|
@ -44,9 +44,7 @@ func (server *Server) GetPayment(ctx context.Context, req *pb.GetPaymentRequest)
|
|||||||
return nil, status.Error(codes.NotFound, "failed to get payments")
|
return nil, status.Error(codes.NotFound, "failed to get payments")
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(account.ID)
|
if account.ID != payment.AccountID {
|
||||||
|
|
||||||
if accountID != payment.AccountID {
|
|
||||||
if !server.isAdmin(ctx, authPayload) {
|
if !server.isAdmin(ctx, authPayload) {
|
||||||
return nil, status.Error(codes.NotFound, "account not found")
|
return nil, status.Error(codes.NotFound, "account not found")
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,7 @@ func (server *Server) GetPerson(ctx context.Context, req *pb.GetPersonRequest) (
|
|||||||
return nil, status.Error(codes.NotFound, "failed to get persons")
|
return nil, status.Error(codes.NotFound, "failed to get persons")
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(account.ID)
|
if account.ID != person.AccountID {
|
||||||
|
|
||||||
if accountID != person.AccountID {
|
|
||||||
if !server.isAdmin(ctx, authPayload) {
|
if !server.isAdmin(ctx, authPayload) {
|
||||||
return nil, status.Error(codes.NotFound, "account not found")
|
return nil, status.Error(codes.NotFound, "account not found")
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,7 @@ func (server *Server) ListPayments(ctx context.Context, req *pb.ListPaymentsRequ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(account.ID)
|
dbPayments, err := server.store.ListPayments(ctx, account.ID)
|
||||||
|
|
||||||
dbPayments, err := server.store.ListPayments(ctx, accountID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return nil, status.Error(codes.NotFound, "no payments found")
|
return nil, status.Error(codes.NotFound, "no payments found")
|
||||||
|
@ -42,9 +42,7 @@ func (server *Server) ListPersons(ctx context.Context, req *pb.ListPersonsReques
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(account.ID)
|
dbPersons, err := server.store.ListPersons(ctx, account.ID)
|
||||||
|
|
||||||
dbPersons, err := server.store.ListPersons(ctx, accountID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return nil, status.Error(codes.NotFound, "no persons found")
|
return nil, status.Error(codes.NotFound, "no persons found")
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"log/slog"
|
||||||
|
|
||||||
db "github.com/itsscb/df/bff/db/sqlc"
|
db "github.com/itsscb/df/bff/db/sqlc"
|
||||||
"github.com/itsscb/df/bff/pb"
|
"github.com/itsscb/df/bff/pb"
|
||||||
@ -46,9 +47,7 @@ func (server *Server) UpdatePayment(ctx context.Context, req *pb.UpdatePaymentRe
|
|||||||
return nil, status.Error(codes.Internal, "failed to get payment")
|
return nil, status.Error(codes.Internal, "failed to get payment")
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID := int64(account.ID)
|
if dbPayment.AccountID != account.ID {
|
||||||
|
|
||||||
if dbPayment.AccountID != accountID {
|
|
||||||
if !server.isAdmin(ctx, authPayload) {
|
if !server.isAdmin(ctx, authPayload) {
|
||||||
return nil, status.Error(codes.NotFound, "payment not found")
|
return nil, status.Error(codes.NotFound, "payment not found")
|
||||||
}
|
}
|
||||||
@ -93,6 +92,7 @@ func (server *Server) UpdatePayment(ctx context.Context, req *pb.UpdatePaymentRe
|
|||||||
|
|
||||||
payment, err := server.store.UpdatePayment(ctx, arg)
|
payment, err := server.store.UpdatePayment(ctx, arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
slog.Error("Update Payment", slog.Int64("id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||||
return nil, status.Error(codes.Internal, "failed to update payment")
|
return nil, status.Error(codes.Internal, "failed to update payment")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ type DeletePaymentResponse struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
Deleted bool `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
Deleted bool `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DeletePaymentResponse) Reset() {
|
func (x *DeletePaymentResponse) Reset() {
|
||||||
@ -109,7 +109,7 @@ func (*DeletePaymentResponse) Descriptor() ([]byte, []int) {
|
|||||||
return file_rpc_delete_payment_proto_rawDescGZIP(), []int{1}
|
return file_rpc_delete_payment_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DeletePaymentResponse) GetId() int64 {
|
func (x *DeletePaymentResponse) GetId() uint64 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Id
|
return x.Id
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ var file_rpc_delete_payment_proto_rawDesc = []byte{
|
|||||||
0x01, 0x02, 0x69, 0x64, 0x32, 0x0b, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22,
|
0x01, 0x02, 0x69, 0x64, 0x32, 0x0b, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22,
|
||||||
0x7d, 0x22, 0x7f, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x79, 0x6d, 0x65,
|
0x7d, 0x22, 0x7f, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x79, 0x6d, 0x65,
|
||||||
0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65,
|
||||||
0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c,
|
0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c,
|
||||||
0x65, 0x74, 0x65, 0x64, 0x3a, 0x3c, 0x92, 0x41, 0x39, 0x0a, 0x19, 0x2a, 0x17, 0x44, 0x65, 0x6c,
|
0x65, 0x74, 0x65, 0x64, 0x3a, 0x3c, 0x92, 0x41, 0x39, 0x0a, 0x19, 0x2a, 0x17, 0x44, 0x65, 0x6c,
|
||||||
0x65, 0x74, 0x65, 0x20, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x52, 0x65, 0x73, 0x70,
|
0x65, 0x74, 0x65, 0x20, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x52, 0x65, 0x73, 0x70,
|
||||||
|
@ -73,8 +73,8 @@ type DeletePersonResponse struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
Deleted bool `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
Deleted bool `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DeletePersonResponse) Reset() {
|
func (x *DeletePersonResponse) Reset() {
|
||||||
@ -109,7 +109,7 @@ func (*DeletePersonResponse) Descriptor() ([]byte, []int) {
|
|||||||
return file_rpc_delete_person_proto_rawDescGZIP(), []int{1}
|
return file_rpc_delete_person_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DeletePersonResponse) GetId() int64 {
|
func (x *DeletePersonResponse) GetId() uint64 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Id
|
return x.Id
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ var file_rpc_delete_person_proto_rawDesc = []byte{
|
|||||||
0x32, 0x0b, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x7d, 0x22, 0x7d, 0x0a,
|
0x32, 0x0b, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x7d, 0x22, 0x7d, 0x0a,
|
||||||
0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x52, 0x65, 0x73,
|
0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x52, 0x65, 0x73,
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64,
|
0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64,
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x3a,
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x3a,
|
||||||
0x3b, 0x92, 0x41, 0x38, 0x0a, 0x18, 0x2a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x50,
|
0x3b, 0x92, 0x41, 0x38, 0x0a, 0x18, 0x2a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x50,
|
||||||
0x65, 0x72, 0x73, 0x6f, 0x6e, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x1c,
|
0x65, 0x72, 0x73, 0x6f, 0x6e, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x1c,
|
||||||
|
@ -27,6 +27,6 @@ message DeletePaymentResponse {
|
|||||||
};
|
};
|
||||||
example: "{\"id\": \"1\", \"deleted\": true}"
|
example: "{\"id\": \"1\", \"deleted\": true}"
|
||||||
};
|
};
|
||||||
int64 id = 1;
|
uint64 id = 1;
|
||||||
bool deleted = 2;
|
bool deleted = 2;
|
||||||
}
|
}
|
@ -27,6 +27,6 @@ message DeletePersonResponse {
|
|||||||
};
|
};
|
||||||
example: "{\"id\": \"1\", \"deleted\": true}"
|
example: "{\"id\": \"1\", \"deleted\": true}"
|
||||||
};
|
};
|
||||||
int64 id = 1;
|
uint64 id = 1;
|
||||||
bool deleted = 2;
|
bool deleted = 2;
|
||||||
}
|
}
|
@ -15,8 +15,19 @@ sql:
|
|||||||
overrides:
|
overrides:
|
||||||
- db_type: "bigserial"
|
- db_type: "bigserial"
|
||||||
go_type: "uint64"
|
go_type: "uint64"
|
||||||
- db_type: "bigint"
|
- column: "payments.account_id"
|
||||||
null: false
|
go_type: "uint64"
|
||||||
|
- column: "persons.account_id"
|
||||||
|
go_type: "uint64"
|
||||||
|
- column: "documents.account_id"
|
||||||
|
go_type: "uint64"
|
||||||
|
- column: "returnsLog.return_id"
|
||||||
|
go_type: "uint64"
|
||||||
|
- column: "returnsLog.mail_id"
|
||||||
|
go_type: "uint64"
|
||||||
|
- column: "returns.provider_id"
|
||||||
|
go_type: "uint64"
|
||||||
|
- column: "returns.person_id"
|
||||||
go_type: "uint64"
|
go_type: "uint64"
|
||||||
- db_type: "timestamptz"
|
- db_type: "timestamptz"
|
||||||
go_type: "time.Time"
|
go_type: "time.Time"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user