Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[予算管理]局APIの作成 #907

Merged
merged 10 commits into from
Jan 12, 2025

Conversation

Kubosaka
Copy link
Collaborator

@Kubosaka Kubosaka commented Jan 8, 2025

resolve #903

概要

  • 予算管理で必要な局のAPIを作成した
  • openapiの定義修正
    • GETでクエリパラメータ追加 year

作成したAPI

  • GET
    • yearで指定した年度のデータを全件取得
    • (yearなしだと全件)
    • id、name、year、bedget、expense、balanceを返す
    • totalのbedget、expense、balanceを返す
  • POST
    • name、year_idをbodyパラメータでfinancial_recordのレコードを作成する
  • PUT
    • idをパスパラメータ
    • name、year_idをbodyパラメータでfinancial_recordのレコードを修正する
  • DELETE
    • パスパラメータでidを指定して削除する

画面スクリーンショット等

スクリーンショット 2025-01-08 16 04 34

テスト項目

  • swaggerでfinancial_recordのAPIを叩く
  • POSTでデータが作成できるか
  • PUTでデータが修正できるか
  • DELETEでデータの削除ができるか
  • GETでデータの取得ができるか
  • divisions、festival_items、item_budgets、buy_reportsにデータを取得し、GETで集計ができているか確認する

備考

@Kubosaka Kubosaka changed the base branch from develop to feat/kubosaka/intro-orval-generate January 8, 2025 07:05
@Kubosaka Kubosaka requested review from hikahana and KazumaSun January 8, 2025 07:14
@Kubosaka Kubosaka self-assigned this Jan 8, 2025
Comment on lines +1083 to +1088
parameters:
- name: year
in: query
description: year
schema:
type: integer
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

クエリパラメータでyearを追加しました
全件取得もできるようにrequiredはつけていないです

@@ -35,3 +35,6 @@ yarn-error.log*

# typescript
*.tsbuildinfo

# genereated
/src/generated
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

生成したコードがgithub actionsのworkflowで整形されると差分が大きくなるので、自動生成分はignoreに入れました

Comment on lines +39 to +41
goqu.COALESCE(goqu.SUM("item_budgets.amount"), 0).As("budget"),
goqu.COALESCE(goqu.SUM("buy_reports.amount"), 0).As("expense"),
goqu.COALESCE(goqu.L("SUM(item_budgets.amount) - SUM(buy_reports.amount)"), 0).As("balance")).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

データがNULLの時に0にしたいため、COALESCEを使いました

@Kubosaka Kubosaka changed the title Feat/kubosaka/create api financial record [予算管理]局APIの作成 Jan 8, 2025
Base automatically changed from feat/kubosaka/intro-orval-generate to develop January 8, 2025 08:24
}

type FinancialRecordUseCase interface {
GetFinancialRecords(context.Context) (generated.FinancialRecordDetails, error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo]
何回も呼ばれるから一番下とかにgenerated省略したのて定義したい派閥です。

type FinancialRecordDetails = generated.FinancialRecordDetails

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確かに👍
型名省略

c context.Context,
) (generated.FinancialRecordDetails, error) {
var financialRecordDetails generated.FinancialRecordDetails
var financialRecordList []generated.FinancialRecordWithBalance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

financialRecordBalancesfinancialRecordsとかでも伝わりそう

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kubosaka Kubosaka requested a review from hikahana January 9, 2025 06:44
return &financialRecordUseCase{rep}
}

type FinancialRecordDetails = generated.FinancialRecordDetails
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo]
個人的ですが一番上か一番下に置いた方が好き。直さなくても〇。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そのほうが読みやすくなるからですか?
これはマージして次から一番下にします

Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Kubosaka Kubosaka merged commit 3366ff1 into develop Jan 12, 2025
2 checks passed
@Kubosaka Kubosaka deleted the feat/kubosaka/create-api-financial-record branch January 12, 2025 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[予算管理]局 API作成
2 participants