Compare commits
2 Commits
3d616bff50
...
46c14b63ea
Author | SHA1 | Date | |
---|---|---|---|
|
46c14b63ea | ||
|
c27dfc687f |
@ -24,6 +24,8 @@
|
|||||||
- [2024/10/15](#20241015)
|
- [2024/10/15](#20241015)
|
||||||
- [2024/10/16](#20241016)
|
- [2024/10/16](#20241016)
|
||||||
- [2024/10/17](#20241017)
|
- [2024/10/17](#20241017)
|
||||||
|
- [2024/10/18](#20241018)
|
||||||
|
- [2024/10/19](#20241019)
|
||||||
<!--toc:end-->
|
<!--toc:end-->
|
||||||
|
|
||||||
A tricount like expense-sharing system written in Go
|
A tricount like expense-sharing system written in Go
|
||||||
|
3
go.mod
3
go.mod
@ -16,9 +16,10 @@ require (
|
|||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/spf13/viper v1.19.0
|
github.com/spf13/viper v1.19.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
go.uber.org/mock v0.5.0
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
golang.org/x/crypto v0.27.0
|
golang.org/x/crypto v0.27.0
|
||||||
golang.org/x/net v0.25.0
|
golang.org/x/net v0.26.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
6
go.sum
6
go.sum
@ -142,6 +142,8 @@ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65E
|
|||||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
|
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
|
||||||
|
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
@ -153,8 +155,8 @@ golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
|||||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
|
||||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
|
||||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
97
internal/howmuch/adapter/repo/event.go
Normal file
97
internal/howmuch/adapter/repo/event.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"git.vinchent.xyz/vinchent/howmuch/internal/howmuch/adapter/repo/sqlc"
|
||||||
|
"git.vinchent.xyz/vinchent/howmuch/internal/howmuch/model"
|
||||||
|
"git.vinchent.xyz/vinchent/howmuch/internal/howmuch/usecase/repo"
|
||||||
|
"git.vinchent.xyz/vinchent/howmuch/internal/pkg/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type eventRepository struct {
|
||||||
|
db *sql.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewEventRepository(db *sql.DB) repo.EventRepository {
|
||||||
|
return &eventRepository{
|
||||||
|
db: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create implements repo.EventRepository.
|
||||||
|
func (e *eventRepository) Create(
|
||||||
|
ctx context.Context,
|
||||||
|
evEntity *model.EventEntity,
|
||||||
|
) (*model.EventEntity, error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete implements repo.EventRepository.
|
||||||
|
func (e *eventRepository) Delete() {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID implements repo.EventRepository.
|
||||||
|
func (e *eventRepository) GetByID(ctx context.Context, eventID int) (*model.EventRetrieved, error) {
|
||||||
|
queries := sqlc.New(e.db)
|
||||||
|
eventDTO, err := queries.GetEventByID(ctx, int32(eventID))
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorLog("query error", "err", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// marshal owner and users
|
||||||
|
var owner *model.UserBaseRetrieved
|
||||||
|
err = json.Unmarshal(eventDTO.Owner, owner)
|
||||||
|
if err != nil {
|
||||||
|
// Unexpected
|
||||||
|
log.ErrorLog("json unmarshal error", "err", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var users []*model.UserBaseRetrieved
|
||||||
|
err = json.Unmarshal(eventDTO.Owner, &users)
|
||||||
|
if err != nil {
|
||||||
|
// Unexpected
|
||||||
|
log.ErrorLog("json unmarshal error", "err", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
eventRetrieved := &model.EventRetrieved{
|
||||||
|
ID: int(eventDTO.ID),
|
||||||
|
Name: eventDTO.Name,
|
||||||
|
Description: eventDTO.Description.String,
|
||||||
|
TotalAmount: model.MakeMoney(
|
||||||
|
int(eventDTO.TotalAmount.Int32),
|
||||||
|
model.Currency(eventDTO.DefaultCurrency),
|
||||||
|
),
|
||||||
|
DefaultCurrency: model.Currency(eventDTO.DefaultCurrency),
|
||||||
|
CreatedAt: eventDTO.CreatedAt,
|
||||||
|
UpdatedAt: eventDTO.UpdatedAt,
|
||||||
|
Owner: owner,
|
||||||
|
Users: users,
|
||||||
|
}
|
||||||
|
|
||||||
|
return eventRetrieved, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsByUserID implements repo.EventRepository.
|
||||||
|
func (e *eventRepository) ListEventsByUserID(
|
||||||
|
ctx context.Context,
|
||||||
|
userID int,
|
||||||
|
) ([]model.EventBaseItemEntity, error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListExpensesByUserID implements repo.EventRepository.
|
||||||
|
func (e *eventRepository) ListExpensesByUserID() {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateInfo implements repo.EventRepository.
|
||||||
|
func (e *eventRepository) UpdateInfo() {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
277
internal/howmuch/adapter/repo/mock/mock.go
Normal file
277
internal/howmuch/adapter/repo/mock/mock.go
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: ./internal/howmuch/adapter/repo/sqlc/querier.go
|
||||||
|
//
|
||||||
|
// Generated by this command:
|
||||||
|
//
|
||||||
|
// mockgen -source=./internal/howmuch/adapter/repo/sqlc/querier.go -package=mock
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package mock is a generated GoMock package.
|
||||||
|
package mock
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
|
sqlc "git.vinchent.xyz/vinchent/howmuch/internal/howmuch/adapter/repo/sqlc"
|
||||||
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockQuerier is a mock of Querier interface.
|
||||||
|
type MockQuerier struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockQuerierMockRecorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockQuerierMockRecorder is the mock recorder for MockQuerier.
|
||||||
|
type MockQuerierMockRecorder struct {
|
||||||
|
mock *MockQuerier
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockQuerier creates a new mock instance.
|
||||||
|
func NewMockQuerier(ctrl *gomock.Controller) *MockQuerier {
|
||||||
|
mock := &MockQuerier{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockQuerierMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
|
func (m *MockQuerier) EXPECT() *MockQuerierMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteExpense mocks base method.
|
||||||
|
func (m *MockQuerier) DeleteExpense(ctx context.Context, id int32) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "DeleteExpense", ctx, id)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteExpense indicates an expected call of DeleteExpense.
|
||||||
|
func (mr *MockQuerierMockRecorder) DeleteExpense(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteExpense", reflect.TypeOf((*MockQuerier)(nil).DeleteExpense), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteTransactionsOfExpenseID mocks base method.
|
||||||
|
func (m *MockQuerier) DeleteTransactionsOfExpenseID(ctx context.Context, expenseID int32) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "DeleteTransactionsOfExpenseID", ctx, expenseID)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteTransactionsOfExpenseID indicates an expected call of DeleteTransactionsOfExpenseID.
|
||||||
|
func (mr *MockQuerierMockRecorder) DeleteTransactionsOfExpenseID(ctx, expenseID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTransactionsOfExpenseID", reflect.TypeOf((*MockQuerier)(nil).DeleteTransactionsOfExpenseID), ctx, expenseID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEventByID mocks base method.
|
||||||
|
func (m *MockQuerier) GetEventByID(ctx context.Context, id int32) (sqlc.GetEventByIDRow, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetEventByID", ctx, id)
|
||||||
|
ret0, _ := ret[0].(sqlc.GetEventByIDRow)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEventByID indicates an expected call of GetEventByID.
|
||||||
|
func (mr *MockQuerierMockRecorder) GetEventByID(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEventByID", reflect.TypeOf((*MockQuerier)(nil).GetEventByID), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetExpenseByID mocks base method.
|
||||||
|
func (m *MockQuerier) GetExpenseByID(ctx context.Context, id int32) (sqlc.GetExpenseByIDRow, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetExpenseByID", ctx, id)
|
||||||
|
ret0, _ := ret[0].(sqlc.GetExpenseByIDRow)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetExpenseByID indicates an expected call of GetExpenseByID.
|
||||||
|
func (mr *MockQuerierMockRecorder) GetExpenseByID(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExpenseByID", reflect.TypeOf((*MockQuerier)(nil).GetExpenseByID), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserByEmail mocks base method.
|
||||||
|
func (m *MockQuerier) GetUserByEmail(ctx context.Context, email string) (sqlc.User, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetUserByEmail", ctx, email)
|
||||||
|
ret0, _ := ret[0].(sqlc.User)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserByEmail indicates an expected call of GetUserByEmail.
|
||||||
|
func (mr *MockQuerierMockRecorder) GetUserByEmail(ctx, email any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByEmail", reflect.TypeOf((*MockQuerier)(nil).GetUserByEmail), ctx, email)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserByID mocks base method.
|
||||||
|
func (m *MockQuerier) GetUserByID(ctx context.Context, id int32) (sqlc.User, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetUserByID", ctx, id)
|
||||||
|
ret0, _ := ret[0].(sqlc.User)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserByID indicates an expected call of GetUserByID.
|
||||||
|
func (mr *MockQuerierMockRecorder) GetUserByID(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByID", reflect.TypeOf((*MockQuerier)(nil).GetUserByID), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertEvent mocks base method.
|
||||||
|
func (m *MockQuerier) InsertEvent(ctx context.Context, arg sqlc.InsertEventParams) (sqlc.Event, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "InsertEvent", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(sqlc.Event)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertEvent indicates an expected call of InsertEvent.
|
||||||
|
func (mr *MockQuerierMockRecorder) InsertEvent(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertEvent", reflect.TypeOf((*MockQuerier)(nil).InsertEvent), ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertExpense mocks base method.
|
||||||
|
func (m *MockQuerier) InsertExpense(ctx context.Context, arg sqlc.InsertExpenseParams) (sqlc.Expense, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "InsertExpense", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(sqlc.Expense)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertExpense indicates an expected call of InsertExpense.
|
||||||
|
func (mr *MockQuerierMockRecorder) InsertExpense(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertExpense", reflect.TypeOf((*MockQuerier)(nil).InsertExpense), ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertParticipation mocks base method.
|
||||||
|
func (m *MockQuerier) InsertParticipation(ctx context.Context, arg sqlc.InsertParticipationParams) (sqlc.Participation, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "InsertParticipation", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(sqlc.Participation)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertParticipation indicates an expected call of InsertParticipation.
|
||||||
|
func (mr *MockQuerierMockRecorder) InsertParticipation(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertParticipation", reflect.TypeOf((*MockQuerier)(nil).InsertParticipation), ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertTransaction mocks base method.
|
||||||
|
func (m *MockQuerier) InsertTransaction(ctx context.Context, arg sqlc.InsertTransactionParams) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "InsertTransaction", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertTransaction indicates an expected call of InsertTransaction.
|
||||||
|
func (mr *MockQuerierMockRecorder) InsertTransaction(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertTransaction", reflect.TypeOf((*MockQuerier)(nil).InsertTransaction), ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertUser mocks base method.
|
||||||
|
func (m *MockQuerier) InsertUser(ctx context.Context, arg sqlc.InsertUserParams) (sqlc.User, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "InsertUser", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(sqlc.User)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertUser indicates an expected call of InsertUser.
|
||||||
|
func (mr *MockQuerierMockRecorder) InsertUser(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertUser", reflect.TypeOf((*MockQuerier)(nil).InsertUser), ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsByUserID mocks base method.
|
||||||
|
func (m *MockQuerier) ListEventsByUserID(ctx context.Context, userID int32) ([]sqlc.ListEventsByUserIDRow, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "ListEventsByUserID", ctx, userID)
|
||||||
|
ret0, _ := ret[0].([]sqlc.ListEventsByUserIDRow)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsByUserID indicates an expected call of ListEventsByUserID.
|
||||||
|
func (mr *MockQuerierMockRecorder) ListEventsByUserID(ctx, userID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEventsByUserID", reflect.TypeOf((*MockQuerier)(nil).ListEventsByUserID), ctx, userID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListExpensesByEventID mocks base method.
|
||||||
|
func (m *MockQuerier) ListExpensesByEventID(ctx context.Context, id int32) ([]sqlc.Expense, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "ListExpensesByEventID", ctx, id)
|
||||||
|
ret0, _ := ret[0].([]sqlc.Expense)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListExpensesByEventID indicates an expected call of ListExpensesByEventID.
|
||||||
|
func (mr *MockQuerierMockRecorder) ListExpensesByEventID(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExpensesByEventID", reflect.TypeOf((*MockQuerier)(nil).ListExpensesByEventID), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListExpensesByEventIDByUserID mocks base method.
|
||||||
|
func (m *MockQuerier) ListExpensesByEventIDByUserID(ctx context.Context, id int32) ([]sqlc.Expense, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "ListExpensesByEventIDByUserID", ctx, id)
|
||||||
|
ret0, _ := ret[0].([]sqlc.Expense)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListExpensesByEventIDByUserID indicates an expected call of ListExpensesByEventIDByUserID.
|
||||||
|
func (mr *MockQuerierMockRecorder) ListExpensesByEventIDByUserID(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExpensesByEventIDByUserID", reflect.TypeOf((*MockQuerier)(nil).ListExpensesByEventIDByUserID), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateEventByID mocks base method.
|
||||||
|
func (m *MockQuerier) UpdateEventByID(ctx context.Context, arg sqlc.UpdateEventByIDParams) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UpdateEventByID", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateEventByID indicates an expected call of UpdateEventByID.
|
||||||
|
func (mr *MockQuerierMockRecorder) UpdateEventByID(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateEventByID", reflect.TypeOf((*MockQuerier)(nil).UpdateEventByID), ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateExpenseByID mocks base method.
|
||||||
|
func (m *MockQuerier) UpdateExpenseByID(ctx context.Context, arg sqlc.UpdateExpenseByIDParams) (sqlc.Expense, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UpdateExpenseByID", ctx, arg)
|
||||||
|
ret0, _ := ret[0].(sqlc.Expense)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateExpenseByID indicates an expected call of UpdateExpenseByID.
|
||||||
|
func (mr *MockQuerierMockRecorder) UpdateExpenseByID(ctx, arg any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExpenseByID", reflect.TypeOf((*MockQuerier)(nil).UpdateExpenseByID), ctx, arg)
|
||||||
|
}
|
51
internal/howmuch/adapter/repo/sqlc/querier.go
Normal file
51
internal/howmuch/adapter/repo/sqlc/querier.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.27.0
|
||||||
|
|
||||||
|
package sqlc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Querier interface {
|
||||||
|
DeleteExpense(ctx context.Context, id int32) error
|
||||||
|
DeleteTransactionsOfExpenseID(ctx context.Context, expenseID int32) error
|
||||||
|
GetEventByID(ctx context.Context, id int32) (GetEventByIDRow, error)
|
||||||
|
GetExpenseByID(ctx context.Context, id int32) (GetExpenseByIDRow, error)
|
||||||
|
GetUserByEmail(ctx context.Context, email string) (User, error)
|
||||||
|
GetUserByID(ctx context.Context, id int32) (User, error)
|
||||||
|
InsertEvent(ctx context.Context, arg InsertEventParams) (Event, error)
|
||||||
|
InsertExpense(ctx context.Context, arg InsertExpenseParams) (Expense, error)
|
||||||
|
InsertParticipation(ctx context.Context, arg InsertParticipationParams) (Participation, error)
|
||||||
|
InsertTransaction(ctx context.Context, arg InsertTransactionParams) error
|
||||||
|
// MIT License
|
||||||
|
//
|
||||||
|
// Copyright (c) 2024 vinchent <vinchent@vinchent.xyz>
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
InsertUser(ctx context.Context, arg InsertUserParams) (User, error)
|
||||||
|
ListEventsByUserID(ctx context.Context, userID int32) ([]ListEventsByUserIDRow, error)
|
||||||
|
ListExpensesByEventID(ctx context.Context, id int32) ([]Expense, error)
|
||||||
|
ListExpensesByEventIDByUserID(ctx context.Context, id int32) ([]Expense, error)
|
||||||
|
UpdateEventByID(ctx context.Context, arg UpdateEventByIDParams) error
|
||||||
|
UpdateExpenseByID(ctx context.Context, arg UpdateExpenseByIDParams) (Expense, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ Querier = (*Queries)(nil)
|
@ -61,7 +61,7 @@ type EventInfoResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
// {{{ Entity Persistant Object (Between the service and the repository)
|
// {{{ Entity (DB In)
|
||||||
|
|
||||||
type EventBaseItemEntity struct {
|
type EventBaseItemEntity struct {
|
||||||
ID int
|
ID int
|
||||||
@ -84,10 +84,29 @@ type EventEntity struct {
|
|||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ Retrieved (DB out)
|
||||||
|
|
||||||
|
type EventRetrieved struct {
|
||||||
|
ID int
|
||||||
|
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
|
||||||
|
Users []*UserBaseRetrieved
|
||||||
|
|
||||||
|
TotalAmount Money
|
||||||
|
DefaultCurrency Currency
|
||||||
|
Owner *UserBaseRetrieved
|
||||||
|
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
// {{{ DO Domain Object (Contains the domain service)
|
// {{{ DO Domain Object (Contains the domain service)
|
||||||
|
|
||||||
type EventDO struct {
|
type Event struct {
|
||||||
ID int
|
ID int
|
||||||
|
|
||||||
Name string
|
Name string
|
||||||
|
@ -41,11 +41,7 @@ type UserExistRequest struct {
|
|||||||
// }}}
|
// }}}
|
||||||
// {{{ Response View Object (from service to controller)
|
// {{{ Response View Object (from service to controller)
|
||||||
|
|
||||||
type UserBaseResponse struct {
|
type UserBaseResponse UserBaseRetrieved
|
||||||
ID int `json:"id"`
|
|
||||||
FirstName string `json:"first_name"`
|
|
||||||
LastName string `json:"last_name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserInfoResponse struct {
|
type UserInfoResponse struct {
|
||||||
// UserBaseResponse
|
// UserBaseResponse
|
||||||
@ -59,7 +55,7 @@ type UserInfoResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
// {{{ Entity Persistant Object (Between the service and the repository)
|
// {{{ Entity (DB In)
|
||||||
|
|
||||||
type UserEntity struct {
|
type UserEntity struct {
|
||||||
ID int
|
ID int
|
||||||
@ -73,6 +69,15 @@ type UserEntity struct {
|
|||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ Retrieved (DB out)
|
||||||
|
|
||||||
|
type UserBaseRetrieved struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
FirstName string `json:"first_name"`
|
||||||
|
LastName string `json:"last_name"`
|
||||||
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
// {{{ DO Domain Object (Contains the domain service)
|
// {{{ DO Domain Object (Contains the domain service)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ type EventRepository interface {
|
|||||||
|
|
||||||
Delete() // XXX: Pay attention to the foreign key relationships
|
Delete() // XXX: Pay attention to the foreign key relationships
|
||||||
|
|
||||||
GetByID(ctx context.Context, eventID int) (*model.EventEntity, error)
|
GetByID(ctx context.Context, eventID int) (*model.EventRetrieved, error)
|
||||||
|
|
||||||
ListExpensesByUserID()
|
ListExpensesByUserID()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user