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

[マイページ]部門予算・詳細取得 #915

Open
wants to merge 3 commits into
base: feat/kubosaka/intro-minio-client-go
Choose a base branch
from

Conversation

Kubosaka
Copy link
Collaborator

@Kubosaka Kubosaka commented Jan 31, 2025

resolve #914

概要

  • ここの一覧表示のAPIです
    スクリーンショット 2025-01-31 11 28 32
  • usecaseの処理が長くなったので、1つだけで出します
  • GET /festival_items/details/{user_id}
    • userが属する部門(division)の予算・支出をなどを返します
    • クエリパラメータでyearを渡すと、年度のものを返します
[
  {
    "divisionTotal": {
      "budget": 100000,
      "expense": 10000,
      "balance": 90000
    },
    "financialRecordName": "企画局",
    "divisionName": "ビンゴ部門",
    "festivalItems": [
      {
        "festivalItemTotal": {
          "budget": 100000,
          "expense": 10000,
          "balance": 90000
        },
        "festivalItemName": "ビンゴ景品",
        "buyReports": [
          {
            "id": 1,
            "buyReportName": "段ボール",
            "amount": 1000,
            "reportDate": "2024-01-01",
            "status": "確認中"
          }
        ]
      }
    ]
  }
]

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

  • URL
    スクリーンショット

テスト項目

備考

  • 動作確認のためにテーブルにデータ追加する必要があります
    • financial_records
    • divisions
    • user_groups
    • festival_items
    • item_budgets
    • buy_reports
    • buy_status

@Kubosaka Kubosaka changed the base branch from develop to feat/kubosaka/intro-minio-client-go January 31, 2025 02:37
@Kubosaka Kubosaka self-assigned this Jan 31, 2025
Comment on lines +237 to +261
var selectFestivalItemForMypageQuery = dialect.Select(
goqu.I("users.name").As("userName"),
goqu.I("financial_records.name").As("financialRecordName"),
goqu.I("divisions.id").As("divisionId"),
goqu.I("divisions.name").As("divisionName"),
goqu.I("festival_items.id").As("festivalItemId"),
goqu.I("festival_items.name").As("festivalItemName"),
goqu.I("years.year"),
goqu.COALESCE(goqu.I("item_budgets.amount"), 0).As("budgetAmount"),
goqu.COALESCE(goqu.I("buy_reports.id"), 0).As("buyReportId"),
goqu.COALESCE(goqu.I("buy_reports.paid_by"), "").As("paidBy"),
goqu.COALESCE(goqu.I("buy_reports.amount"), 0).As("reportAmount"),
goqu.COALESCE(goqu.I("buy_reports.created_at"), "2025-01-29 20:53:44").As("reportDate"),
goqu.COALESCE(goqu.I("buy_statuses.is_packed"), 0).As("isPacked"),
goqu.COALESCE(goqu.I("buy_statuses.is_settled"), 0).As("isSettled")).
From("festival_items").
InnerJoin(goqu.I("divisions"), goqu.On(goqu.I("festival_items.division_id").Eq(goqu.I("divisions.id")))).
InnerJoin(goqu.I("financial_records"), goqu.On(goqu.I("divisions.financial_record_id").Eq(goqu.I("financial_records.id")))).
InnerJoin(goqu.I("user_groups"), goqu.On(goqu.I("divisions.id").Eq(goqu.I("user_groups.group_id")))).
InnerJoin(goqu.I("users"), goqu.On(goqu.I("users.id").Eq(goqu.I("user_groups.user_id")))).
InnerJoin(goqu.I("years"), goqu.On(goqu.I("financial_records.year_id").Eq(goqu.I("years.id")))).
LeftJoin(goqu.I("item_budgets"), goqu.On(goqu.I("festival_items.id").Eq(goqu.I("item_budgets.festival_item_id")))).
LeftJoin(goqu.I("buy_reports"), goqu.On(goqu.I("festival_items.id").Eq(goqu.I("buy_reports.festival_item_id")))).
LeftJoin(goqu.I("buy_statuses"), goqu.On(goqu.I("buy_reports.id").Eq(goqu.I("buy_statuses.buy_report_id")))).
Order(goqu.I("festival_items.id").Desc())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

これで必要なデータとってくる

Comment on lines +16 to +31
type FestivalItemForMyPageColumn struct {
UserName string
FinancialRecordName string
DivisionId int
DivisionName string
FestivalItemId int
FestivalItemName string
Year int
BudgetAmount int
BuyReportId int
PaidBy string
ReportAmount int
ReportDate string
IsPacked bool
IsSettled bool
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

取得したdbのデータを入れる用の型

festivalItemForMyPageColumns = append(festivalItemForMyPageColumns, festivalItemForMyPageColumn)
}

festivalItemDetailsList = convertColumnToGenerated(festivalItemForMyPageColumns)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

この関数内でdbから取得したデータを整形

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant