Skip to content

Commit

Permalink
型名省略
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubosaka committed Jan 8, 2025
1 parent 1918da3 commit 767b068
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
17 changes: 9 additions & 8 deletions api/externals/repository/festival_item_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ type festivalItemRepository struct {
crud abstract.Crud
}

type FestivalItem = generated.FestivalItem
type FestivalItemRepository interface {
All(context.Context) (*sql.Rows, error)
AllByPeriod(context.Context, string) (*sql.Rows, error)
AllByPeriodAndDivision(context.Context, string, string) (*sql.Rows, error)
GetById(context.Context, string) (*sql.Row, error)
CreateFestivalItem(context.Context, *sql.Tx, generated.FestivalItem) error
CreateItemBudget(context.Context, *sql.Tx, generated.FestivalItem) error
UpdateFestivalItem(context.Context, *sql.Tx, string, generated.FestivalItem) error
UpdateItemBudget(context.Context, *sql.Tx, string, generated.FestivalItem) error
CreateFestivalItem(context.Context, *sql.Tx, FestivalItem) error
CreateItemBudget(context.Context, *sql.Tx, FestivalItem) error
UpdateFestivalItem(context.Context, *sql.Tx, string, FestivalItem) error
UpdateItemBudget(context.Context, *sql.Tx, string, FestivalItem) error
DeleteFestivalItem(context.Context, *sql.Tx, string) error
DeleteItemBudget(context.Context, *sql.Tx, string) error
FindLatestRecord(context.Context) (*sql.Row, error)
Expand Down Expand Up @@ -162,7 +163,7 @@ func (fir *festivalItemRepository) GetById(
func (fir *festivalItemRepository) CreateFestivalItem(
c context.Context,
tx *sql.Tx,
festivalItem generated.FestivalItem,
festivalItem FestivalItem,
) error {
ds := dialect.Insert("festival_items").
Rows(goqu.Record{"name": festivalItem.Name, "memo": festivalItem.Memo, "division_id": festivalItem.DivisionId})
Expand All @@ -178,7 +179,7 @@ func (fir *festivalItemRepository) CreateFestivalItem(
func (fir *festivalItemRepository) CreateItemBudget(
c context.Context,
tx *sql.Tx,
festivalItem generated.FestivalItem,
festivalItem FestivalItem,
) error {
ds := dialect.Insert("item_budgets").
Rows(goqu.Record{"amount": festivalItem.Amount, "festival_item_id": goqu.L("LAST_INSERT_ID()")})
Expand All @@ -196,7 +197,7 @@ func (fir *festivalItemRepository) UpdateFestivalItem(
c context.Context,
tx *sql.Tx,
id string,
festivalItem generated.FestivalItem,
festivalItem FestivalItem,
) error {
ds := dialect.Update("festival_items").
Set(goqu.Record{"name": festivalItem.Name, "memo": festivalItem.Memo, "division_id": festivalItem.DivisionId}).
Expand All @@ -214,7 +215,7 @@ func (fir *festivalItemRepository) UpdateItemBudget(
c context.Context,
tx *sql.Tx,
id string,
festivalItem generated.FestivalItem,
festivalItem FestivalItem,
) error {
ds := dialect.Update("item_budgets").
Set(goqu.Record{"amount": festivalItem.Amount}).
Expand Down
47 changes: 26 additions & 21 deletions api/internals/usecase/financial_record_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ type financialRecordUseCase struct {
rep rep.FinancialRecordRepository
}

type FinancialRecordDetails = generated.FinancialRecordDetails
type FinancialRecord = generated.FinancialRecord
type FinancialRecordWithBalance = generated.FinancialRecordWithBalance
type Total = generated.Total

type FinancialRecordUseCase interface {
GetFinancialRecords(context.Context) (generated.FinancialRecordDetails, error)
GetFinancialRecordsByYears(context.Context, string) (generated.FinancialRecordDetails, error)
GetFinancialRecords(context.Context) (FinancialRecordDetails, error)
GetFinancialRecordsByYears(context.Context, string) (FinancialRecordDetails, error)
CreateFinancialRecord(
context.Context,
generated.FinancialRecord,
) (generated.FinancialRecordWithBalance, error)
FinancialRecord,
) (FinancialRecordWithBalance, error)
UpdateFinancialRecord(
context.Context,
string,
generated.FinancialRecord,
) (generated.FinancialRecordWithBalance, error)
FinancialRecord,
) (FinancialRecordWithBalance, error)
DestroyFinancialRecord(context.Context, string) error
}

Expand All @@ -33,10 +38,10 @@ func NewFinancialRecordUseCase(rep rep.FinancialRecordRepository) FinancialRecor

func (fru *financialRecordUseCase) GetFinancialRecords(
c context.Context,
) (generated.FinancialRecordDetails, error) {
var financialRecordDetails generated.FinancialRecordDetails
var financialRecordList []generated.FinancialRecordWithBalance
var total generated.Total
) (FinancialRecordDetails, error) {
var financialRecordDetails FinancialRecordDetails
var financialRecordList []FinancialRecordWithBalance
var total Total

rows, err := fru.rep.All(c)
if err != nil {
Expand All @@ -46,7 +51,7 @@ func (fru *financialRecordUseCase) GetFinancialRecords(
defer rows.Close()

for rows.Next() {
var financialRecord generated.FinancialRecordWithBalance
var financialRecord FinancialRecordWithBalance
err := rows.Scan(
&financialRecord.Id,
&financialRecord.Name,
Expand Down Expand Up @@ -87,9 +92,9 @@ func (fru *financialRecordUseCase) GetFinancialRecordsByYears(
c context.Context,
year string,
) (generated.FinancialRecordDetails, error) {
var financialRecordDetails generated.FinancialRecordDetails
var financialRecordList []generated.FinancialRecordWithBalance
var total generated.Total
var financialRecordDetails FinancialRecordDetails
var financialRecordList []FinancialRecordWithBalance
var total Total

rows, err := fru.rep.AllByPeriod(c, year)
if err != nil {
Expand All @@ -99,7 +104,7 @@ func (fru *financialRecordUseCase) GetFinancialRecordsByYears(
defer rows.Close()

for rows.Next() {
var financialRecord generated.FinancialRecordWithBalance
var financialRecord FinancialRecordWithBalance
err := rows.Scan(
&financialRecord.Id,
&financialRecord.Name,
Expand Down Expand Up @@ -138,9 +143,9 @@ func (fru *financialRecordUseCase) GetFinancialRecordsByYears(

func (fru *financialRecordUseCase) CreateFinancialRecord(
c context.Context,
financialRecord generated.FinancialRecord,
) (generated.FinancialRecordWithBalance, error) {
latastFinancialRecordWithBalance := generated.FinancialRecordWithBalance{}
financialRecord FinancialRecord,
) (FinancialRecordWithBalance, error) {
latastFinancialRecordWithBalance := FinancialRecordWithBalance{}
err := fru.rep.Create(c, financialRecord)
if err != nil {
return latastFinancialRecordWithBalance, err
Expand All @@ -166,9 +171,9 @@ func (fru *financialRecordUseCase) CreateFinancialRecord(
func (fru *financialRecordUseCase) UpdateFinancialRecord(
c context.Context,
id string,
financialRecord generated.FinancialRecord,
) (generated.FinancialRecordWithBalance, error) {
updateFinancialRecord := generated.FinancialRecordWithBalance{}
financialRecord FinancialRecord,
) (FinancialRecordWithBalance, error) {
updateFinancialRecord := FinancialRecordWithBalance{}

if err := fru.rep.Update(c, id, financialRecord); err != nil {
return updateFinancialRecord, err
Expand Down

0 comments on commit 767b068

Please sign in to comment.