diff --git a/Makefile b/Makefile
index 49de15d6a..2f32e5f43 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
# アプリコンテナ=view,api、DBコンテナ=db,minio
+include finansu.env
# アプリコンテナのイメージのビルド
build:
@@ -22,12 +23,20 @@ down:
run-db:
docker compose -f compose.db.yml up -d
+# dbコンテナの起動 + マイグレーション + シードデータ投入
+run-db-init:
+ docker compose -f compose.db.yml up -d
+ ./scripts/wait-for-mysql.sh
+ make migrate
+ make seed-db
+ @echo "Database initialization completed!"
+
# dbコンテナの停止(ずっと起動したくない時はこっちで停止)
stop-db:
docker compose -f compose.db.yml down
-# ビルドと起動
build-run:
+# ビルドと起動
docker compose -f compose.db.yml up -d
docker compose up --build
@@ -37,7 +46,7 @@ del-vol:
# 生成したコンテナ、イメージ、ボリューム、ネットワークを一括削除
del-all:
- compose down --rmi all --volumes --remove-orphans
+ docker compose down --rmi all --volumes --remove-orphans
# ボリューム削除→ビルド→起動
run-rebuild:
@@ -46,7 +55,7 @@ run-rebuild:
# dbとminioの停止とボリューム削除(dbを初期化したい時)
del-db:
- compose -f compose.db.yml down --volumes
+ docker compose -f compose.db.yml down --volumes
# apiの起動(db起動後)
run-api:
@@ -97,7 +106,7 @@ run-swagger:
docker compose -f compose.swagger.yml up -d
run-all:
- make run-db
+ make run-db-init
make run
make run-swagger
@@ -106,3 +115,26 @@ gen-er:
format:
docker compose run --rm view npm run format
+
+# マイグレーションの実行
+migrate:
+ docker compose -f compose.migrate.yml run --rm migrate \
+ --path /migrations \
+ --database "mysql://${NUTMEG_DB_USER}:${NUTMEG_DB_PASSWORD}@tcp(${NUTMEG_DB_HOST}:${NUTMEG_DB_PORT})/${NUTMEG_DB_NAME}" \
+ up
+
+# マイグレーションの実行(ダウングレード)
+migrate-down:
+ docker compose -f compose.migrate.yml run --rm migrate \
+ --path /migrations \
+ --database "mysql://${NUTMEG_DB_USER}:${NUTMEG_DB_PASSWORD}@tcp(${NUTMEG_DB_HOST}:${NUTMEG_DB_PORT})/${NUTMEG_DB_NAME}" \
+ down
+
+# マイグレーションファイルの作成
+create-migration:
+ ./scripts/create_migration.sh
+
+# シードデータの投入
+seed-db:
+ docker compose -f compose.db.yml run --rm db bash ./scripts/seed.sh
+
diff --git a/README.md b/README.md
index 031b0162b..0216b1561 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
# FinanSu
-FinanSuは、NUTFes/NUTMegの財務管理システムです。OpenAPI駆動開発により、Go + Next.jsで構築されています。
+FinanSu は、NUTFes/NUTMeg の財務管理システムです。OpenAPI 駆動開発により、Go + Next.js で構築されています。
## 技術スタック (Tech Stack)
### Backend (API)
+
- **Language**: Go 1.23+ with Echo framework
- **Database**: MySQL 8.0 + GORM
- **Storage**: MinIO (S3-compatible)
@@ -12,6 +13,7 @@ FinanSuは、NUTFes/NUTMegの財務管理システムです。OpenAPI駆動開
- **Testing**: Go test with testfixtures
### Frontend (View)
+
- **Framework**: Next.js 14 + React 18 + TypeScript
- **UI**: Chakra UI + Tailwind CSS
- **State Management**: Recoil with persistence
@@ -19,6 +21,7 @@ FinanSuは、NUTFes/NUTMegの財務管理システムです。OpenAPI駆動開
- **Code Generation**: Orval (OpenAPI to TypeScript)
### Infrastructure
+
- **Container**: Docker + Docker Compose
- **Development**: Hot reload with Air (Go) + Next.js dev server
- **API Documentation**: Swagger UI
@@ -26,18 +29,21 @@ FinanSuは、NUTFes/NUTMegの財務管理システムです。OpenAPI駆動開
## 環境構築 (set up)
### 基本セットアップ
+
```bash
-make run-db # データベース起動 (MySQL + MinIO)
+make run-db-init # データベース起動 (MySQL + MinIO)、マイグレーション実行、シードデータ追加
make build # アプリケーションビルド
make run # アプリケーション起動
```
### 全て一括起動
+
```bash
make run-all # DB + アプリ + Swagger UI
```
-### 直接Docker Composeを使用する場合
+### 直接 Docker Compose を使用する場合
+
```bash
docker compose -f compose.db.yml up -d
docker compose build
@@ -47,6 +53,7 @@ docker compose up
## 開発コマンド (Development Commands)
### コード生成 (重要)
+
```bash
make gen # OpenAPI仕様からAPI/フロントエンドコード生成
make gen-api # Go serverコード生成
@@ -54,6 +61,7 @@ make gen-front-api # TypeScript hooks生成
```
### テスト・品質チェック
+
```bash
make run-test # Go APIテスト実行
make run-eslint # フロントエンドLint実行
@@ -61,6 +69,7 @@ make format # コードフォーマット
```
### その他の便利コマンド
+
```bash
make run-sb # Storybook起動
make ent-db # MySQLシェルへ接続
@@ -71,6 +80,7 @@ make seed # データベースシード実行
## 開発環境詳細
### ポート設定
+
- **Frontend**: http://localhost:3000
- **API**: http://localhost:1323
- **Database**: localhost:3306
@@ -151,12 +161,13 @@ graph TB
### アーキテクチャの特徴
-1. **OpenAPI駆動開発**: 全ての型安全性がOpenAPI仕様から生成
+1. **OpenAPI 駆動開発**: 全ての型安全性が OpenAPI 仕様から生成
2. **Clean Architecture**: バックエンドは依存関係逆転により保守性を確保
3. **型安全性**: フロントエンドからバックエンドまで一貫した型チェック
-4. **コンテナ化**: Docker Composeによる一貫した開発環境
+4. **コンテナ化**: Docker Compose による一貫した開発環境
### プロジェクト構造
+
```
/api/ # Go backend (Clean Architecture)
├── main.go # エントリーポイント
@@ -177,13 +188,15 @@ graph TB
## 開発ワークフロー
-### OpenAPI駆動開発
-1. `/openapi/openapi.yaml` を編集してAPI変更
-2. `make gen` でGo serverコードとTypeScript hooksを再生成
-3. サーバーサイドロジックをcontrollers/use casesで実装
-4. 生成されたhooksをReactコンポーネントで使用
+### OpenAPI 駆動開発
+
+1. `/openapi/openapi.yaml` を編集して API 変更
+2. `make gen` で Go server コードと TypeScript hooks を再生成
+3. サーバーサイドロジックを controllers/use cases で実装
+4. 生成された hooks を React コンポーネントで使用
### 環境管理
+
- **開発**: `compose.yml`
- **ステージング**: `compose.stg.yml`
- **本番**: `compose.prod.yml`
@@ -192,21 +205,25 @@ graph TB
## ドキュメント (Documents)
### プロジェクト概要
+
- [FinanSu について](https://www.notion.so/nutfes-nutmeg/FinanSu-6f207506947b475aad3610210016a8a3) - 背景・目的や技術仕様
- [FinanSu 開発ガイド](https://www.notion.so/nutfes-nutmeg/FinanSu-OK-3a12e725374742608959b6bac61d702c) - 開発全般の情報
### 開発ルール
-- [Git ワークフロー](https://www.notion.so/nutfes-nutmeg/git-clone-41a4a1a2df324c92a56b6d0b1b244747) - 開発時のGit使用手順
+
+- [Git ワークフロー](https://www.notion.so/nutfes-nutmeg/git-clone-41a4a1a2df324c92a56b6d0b1b244747) - 開発時の Git 使用手順
- [Git/GitHub 基本操作](https://www.notion.so/nutfes-nutmeg/Git-Github-478cabf96e3e44909e35b3476fe08886)
- [ブランチルール](https://www.notion.so/nutfes-nutmeg/9d1646b47e184ab1b85b35e02de76e3f)
- [コミットルール](https://www.notion.so/nutfes-nutmeg/f4ace67ac1c14d849aee084327914c0f)
### API・技術仕様
+
- [API 一覧](https://www.notion.so/nutfes-nutmeg/FinanSu-API-92b657ec9ff64157be94486fbfc8382f)
- [OpenAPI 仕様書](http://localhost:1323/swagger/index.html) - 開発中にアクセス可能
- [Storybook](http://localhost:6006) - コンポーネントドキュメント
### 関連記事
+
- [FinanSu タグ記事一覧](https://www.notion.so/nutfes-nutmeg/FinanSu-db5914909df34786b7f1e4a205ebfea7)
## AI 開発支援
@@ -214,16 +231,18 @@ graph TB
このプロジェクトは AI アシスタント(Claude Code、GitHub Copilot)による開発を支援しています。
- **CLAUDE.md** - Claude Code 用の開発ガイダンス
-- **GitHub Copilot** - カスタム指示付きコード支援(日本語ITギャル設定)
+- **GitHub Copilot** - カスタム指示付きコード支援(日本語 IT ギャル設定)
## 重要な注意事項
### コード生成の依存関係
-- OpenAPI仕様を変更したら必ず `make gen` を実行
+
+- OpenAPI 仕様を変更したら必ず `make gen` を実行
- 生成されたコードは手動で編集しない
-- 型安全性はOpenAPI仕様からバックエンド・フロントエンドに流れる
+- 型安全性は OpenAPI 仕様からバックエンド・フロントエンドに流れる
### 品質管理
+
- フロントエンドコミット前に `make run-eslint` と `make format` を実行
-- APIテストは `make run-test` で実行
-- PRは `.github/pull_request_template.md` テンプレートを使用
+- API テストは `make run-test` で実行
+- PR は `.github/pull_request_template.md` テンプレートを使用
diff --git a/api/externals/controller/fund_information_controller.go b/api/externals/controller/fund_information_controller.go
deleted file mode 100644
index 138dbf011..000000000
--- a/api/externals/controller/fund_information_controller.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package controller
-
-import (
- "net/http"
-
- "github.com/NUTFes/FinanSu/api/internals/usecase"
- "github.com/labstack/echo/v4"
-)
-
-type fundInformationController struct {
- u usecase.FundInformationUseCase
-}
-
-type FundInformationController interface {
- IndexFundInformation(echo.Context) error
- ShowFundInformation(echo.Context) error
- CreateFundInformation(echo.Context) error
- UpdateFundInformation(echo.Context) error
- DestroyFundInformation(echo.Context) error
- IndexFundInformationDetails(echo.Context) error
- ShowFundInformationDetailByID(echo.Context) error
- IndexFundInformationDetailsByPeriod(echo.Context) error
-}
-
-func NewFundInformationController(u usecase.FundInformationUseCase) FundInformationController {
- return &fundInformationController{u}
-}
-
-// Index
-func (f *fundInformationController) IndexFundInformation(c echo.Context) error {
- fundInformations, err := f.u.GetFundInformations(c.Request().Context())
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, fundInformations)
-}
-
-// Show
-func (f *fundInformationController) ShowFundInformation(c echo.Context) error {
- id := c.Param("id")
- fundInformation, err := f.u.GetFundInformationByID(c.Request().Context(), id)
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, fundInformation)
-}
-
-// Create
-func (f *fundInformationController) CreateFundInformation(c echo.Context) error {
- userID := c.QueryParam("user_id")
- teacherID := c.QueryParam("teacher_id")
- price := c.QueryParam("price")
- remark := c.QueryParam("remark")
- isFirstCheck := c.QueryParam("is_first_check")
- isLastCheck := c.QueryParam("is_last_check")
- receivedAt := c.QueryParam("received_at")
-
- latastFundInformation, err := f.u.CreateFundInformation(c.Request().Context(), userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt)
- if err != nil {
- return err
- }
- return c.JSON(http.StatusCreated, latastFundInformation)
-}
-
-// Update
-func (f *fundInformationController) UpdateFundInformation(c echo.Context) error {
- id := c.Param("id")
- userID := c.QueryParam("user_id")
- teacherID := c.QueryParam("teacher_id")
- price := c.QueryParam("price")
- remark := c.QueryParam("remark")
- isFirstCheck := c.QueryParam("is_first_check")
- isLastCheck := c.QueryParam("is_last_check")
- receivedAt := c.QueryParam("received_at")
-
- updatedFundInformation, err := f.u.UpdateFundInformation(c.Request().Context(), id, userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt)
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, updatedFundInformation)
-}
-
-// Destroy
-func (f *fundInformationController) DestroyFundInformation(c echo.Context) error {
- id := c.Param("id")
- err := f.u.DestroyFundInformation(c.Request().Context(), id)
- if err != nil {
- return err
- }
- return c.String(http.StatusCreated, "Destroy FundInformation")
-}
-
-// IndexFundInforUserAndTeach
-func (f *fundInformationController) IndexFundInformationDetails(c echo.Context) error {
- fundinforuserandteachers, err := f.u.GetFundInformationDetails(c.Request().Context())
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, fundinforuserandteachers)
-}
-
-func (f *fundInformationController) ShowFundInformationDetailByID(c echo.Context) error {
- id := c.Param("id")
- fundinforuserandteacher, err := f.u.GetFundInformationDetailByID(c.Request().Context(), id)
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, fundinforuserandteacher)
-}
-
-// IndexFundInformationDetailsByPeriod
-func (f *fundInformationController) IndexFundInformationDetailsByPeriod(c echo.Context) error {
- year := c.Param("year")
- fundInformationDetailsByPeriod, err := f.u.GetFundInformationDetailsByPeriod(c.Request().Context(), year)
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, fundInformationDetailsByPeriod)
-}
diff --git a/api/externals/controller/income_expenditure_management_controller.go b/api/externals/controller/income_expenditure_management_controller.go
index 8614be46d..1df5407d4 100644
--- a/api/externals/controller/income_expenditure_management_controller.go
+++ b/api/externals/controller/income_expenditure_management_controller.go
@@ -1,11 +1,16 @@
package controller
import (
+ "encoding/csv"
+ "fmt"
"net/http"
+ "strconv"
"github.com/NUTFes/FinanSu/api/generated"
"github.com/NUTFes/FinanSu/api/internals/usecase"
"github.com/labstack/echo/v4"
+ "golang.org/x/text/encoding/japanese"
+ "golang.org/x/text/transform"
)
type incomeExpenditureManagementController struct {
@@ -15,6 +20,7 @@ type incomeExpenditureManagementController struct {
type IncomeExpenditureManagementController interface {
IndexIncomeExpenditureManagements(echo.Context) error
PutIncomeExpenditureManagementCheck(echo.Context) error
+ DownloadIncomeExpenditureManagementCSV(echo.Context) error
}
func NewIncomeExpenditureManagementController(u usecase.IncomeExpenditureManagementUseCase) IncomeExpenditureManagementController {
@@ -52,3 +58,66 @@ func (i *incomeExpenditureManagementController) PutIncomeExpenditureManagementCh
type (
PutIncomeExpenditureManagementsCheckIdJSONBody = generated.PutIncomeExpenditureManagementsCheckIdJSONBody
)
+
+func (i *incomeExpenditureManagementController) DownloadIncomeExpenditureManagementCSV(c echo.Context) error {
+ ctx := c.Request().Context()
+ year := c.QueryParam("year")
+
+ details, err := i.u.IndexIncomeExpenditureManagements(ctx, year)
+ if err != nil {
+ return err
+ }
+
+ records := make([][]string, 0, len(details.IncomeExpenditureManagements)+1)
+ records = append(records, []string{"日付", "局名 or 収入内容", "購入物品名 or 会社名", "受取方法", "金額", "残高", "チェック"})
+ for _, d := range details.IncomeExpenditureManagements {
+ detail := ""
+ if d.Detail != nil {
+ detail = *d.Detail
+ }
+ receive := ""
+ if d.ReceiveOption != nil {
+ receive = *d.ReceiveOption
+ }
+ checked := "未"
+ if d.IsChecked {
+ checked = "済"
+ }
+ records = append(records, []string{
+ d.Date,
+ d.Content,
+ detail,
+ receive,
+ strconv.Itoa(d.Amount),
+ strconv.Itoa(d.CurrentBalance),
+ checked,
+ })
+ }
+
+ w := c.Response().Writer
+ fileName := fmt.Sprintf("income_expenditure_management_%s.csv", year)
+ attachment := fmt.Sprintf(`attachment; filename="%s"`, fileName)
+ w.Header().Set("Content-Type", "text/csv; charset=Shift_JIS")
+ w.Header().Set("Content-Disposition", attachment)
+
+ return makeIncomeExpenditureManagementCSV(w, records)
+}
+
+func makeIncomeExpenditureManagementCSV(writer http.ResponseWriter, records [][]string) error {
+ encoder := japanese.ShiftJIS.NewEncoder()
+ shiftJISWriter := transform.NewWriter(writer, encoder)
+ csvWriter := csv.NewWriter(shiftJISWriter)
+
+ for _, record := range records {
+ if err := csvWriter.Write(record); err != nil {
+ http.Error(writer, "CSVの書き込み中にエラーが発生しました", http.StatusInternalServerError)
+ return err
+ }
+ }
+ csvWriter.Flush()
+ if err := csvWriter.Error(); err != nil {
+ http.Error(writer, "CSVのフラッシュ中にエラーが発生しました", http.StatusInternalServerError)
+ return err
+ }
+ return nil
+}
diff --git a/api/externals/repository/fund_information_repository.go b/api/externals/repository/fund_information_repository.go
deleted file mode 100644
index 1d5f4e060..000000000
--- a/api/externals/repository/fund_information_repository.go
+++ /dev/null
@@ -1,203 +0,0 @@
-package repository
-
-import (
- "context"
- "database/sql"
-
- "github.com/NUTFes/FinanSu/api/drivers/db"
- "github.com/NUTFes/FinanSu/api/externals/repository/abstract"
-)
-
-type fundInformationRepository struct {
- client db.Client
- crud abstract.Crud
-}
-
-type FundInformationRepository interface {
- All(context.Context) (*sql.Rows, error)
- Find(context.Context, string) (*sql.Row, error)
- Create(context.Context, string, string, string, string, string, string, string) error
- Update(context.Context, string, string, string, string, string, string, string, string) error
- Delete(context.Context, string) error
- FindDetails(context.Context) (*sql.Rows, error)
- FindDetailByID(context.Context, string) (*sql.Row, error)
- FindLatestRecord(context.Context) (*sql.Row, error)
- AllDetailsByPeriod(context.Context, string) (*sql.Rows, error)
-}
-
-func NewFundInformationRepository(c db.Client, ac abstract.Crud) FundInformationRepository {
- return &fundInformationRepository{c, ac}
-}
-
-// 全件取得
-func (fir *fundInformationRepository) All(c context.Context) (*sql.Rows, error) {
- query := `SELECT * FROM fund_informations`
- return fir.crud.Read(c, query)
-}
-
-// 1件取得
-func (fir *fundInformationRepository) Find(c context.Context, id string) (*sql.Row, error) {
- query := `SELECT * FROM fund_informations WHERE id =` + id
- return fir.crud.ReadByID(c, query)
-}
-
-// 作成
-func (fir *fundInformationRepository) Create(
- c context.Context,
- userID string,
- teacherID string,
- price string,
- remark string,
- isFirstCheck string,
- isLastCheck string,
- receivedAt string,
-) error {
- query := `
- INSERT INTO
- fund_informations(
- user_id,
- teacher_id,
- price, remark,
- is_first_check,
- is_last_check,
- received_at
- ) VALUES (
- ` + userID +
- "," + teacherID +
- "," + price +
- ",'" + remark +
- "'," + isFirstCheck +
- "," + isLastCheck +
- ",'" + receivedAt + "')"
- return fir.crud.UpdateDB(c, query)
-}
-
-// 編集
-func (fir *fundInformationRepository) Update(
- c context.Context,
- id string,
- userID string,
- teacherID string,
- price string,
- remark string,
- isFirstCheck string,
- isLastCheck string,
- receivedAt string,
-) error {
- query := `
- UPDATE
- fund_informations
- SET
- user_id = ` + userID +
- ", teacher_id = " + teacherID +
- ", price = " + price +
- ", remark ='" + remark +
- "', is_first_check = " + isFirstCheck +
- ", is_last_check = " + isLastCheck +
- ", received_at = " + receivedAt +
- " WHERE id = " + id
- return fir.crud.UpdateDB(c, query)
-}
-
-// 削除
-func (fir *fundInformationRepository) Delete(c context.Context, id string) error {
- query := "DELETE FROM fund_informations WHERE id = " + id
- return fir.crud.UpdateDB(c, query)
-}
-
-// fund_informationに紐づくuserとteacherを全件取得する
-func (fir *fundInformationRepository) FindDetails(c context.Context) (*sql.Rows, error) {
- query := `
- SELECT
- *
- FROM
- fund_informations
- INNER JOIN
- users
- ON
- fund_informations.user_id = users.id
- INNER JOIN
- teachers
- ON
- fund_informations.teacher_id = teachers.id
- INNER JOIN
- departments
- ON
- teachers.department_id = departments.id;`
- return fir.crud.Read(c, query)
-}
-
-// IDを指定してfund_informationに紐づくuserとteacherを取得する
-func (fir *fundInformationRepository) FindDetailByID(c context.Context, id string) (*sql.Row, error) {
- query := `
- SELECT
- *
- FROM
- fund_informations
- INNER JOIN
- users
- ON
- fund_informations.user_id = users.id
- INNER JOIN
- teachers
- ON
- fund_informations.teacher_id = teachers.id
- INNER JOIN
- departments
- ON
- teachers.department_id = departments.id
- WHERE fund_informations.id = ` + id
- return fir.crud.ReadByID(c, query)
-}
-
-// 最新のfund_informationを取得する
-func (fir *fundInformationRepository) FindLatestRecord(c context.Context) (*sql.Row, error) {
- query := `
- SELECT
- *
- FROM
- fund_informations
- ORDER BY
- id
- DESC LIMIT 1
- `
- return fir.crud.ReadByID(c, query)
-}
-
-// 年度別のfund_informationに紐づくuserとteacherを取得する
-func (fir *fundInformationRepository) AllDetailsByPeriod(c context.Context, year string) (*sql.Rows, error) {
- query := `
- SELECT
- fund_informations.*,
- users.*,
- teachers.*,
- departments.*
- FROM
- fund_informations
- INNER JOIN
- users
- ON
- fund_informations.user_id = users.id
- INNER JOIN
- teachers
- ON
- fund_informations.teacher_id = teachers.id
- INNER JOIN
- departments
- ON
- teachers.department_id = departments.id
- INNER JOIN
- year_periods
- ON
- fund_informations.created_at > year_periods.started_at
- AND
- fund_informations.created_at < year_periods.ended_at
- INNER JOIN
- years
- ON
- year_periods.year_id = years.id
- WHERE
- years.year = ` + year +
- " ORDER BY fund_informations.updated_at DESC;"
- return fir.crud.Read(c, query)
-}
diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go
index 76a4b4f09..442313fba 100644
--- a/api/generated/openapi_gen.go
+++ b/api/generated/openapi_gen.go
@@ -511,52 +511,10 @@ type GetFinancialRecordsCsvDownloadParams struct {
Year int `form:"year" json:"year"`
}
-// PostFundInformationsParams defines parameters for PostFundInformations.
-type PostFundInformationsParams struct {
- // UserId user_id
- UserId int `form:"user_id" json:"user_id"`
-
- // TeacherId teacher_id
- TeacherId int `form:"teacher_id" json:"teacher_id"`
-
- // Price price
- Price int `form:"price" json:"price"`
-
- // Remark remark
- Remark *string `form:"remark,omitempty" json:"remark,omitempty"`
-
- // IsFirstCheck is_first_check
- IsFirstCheck *bool `form:"is_first_check,omitempty" json:"is_first_check,omitempty"`
-
- // IsLastCheck is_last_check
- IsLastCheck *bool `form:"is_last_check,omitempty" json:"is_last_check,omitempty"`
-
- // ReceivedAt received_at
- ReceivedAt *string `form:"received_at,omitempty" json:"received_at,omitempty"`
-}
-
-// PutFundInformationsIdParams defines parameters for PutFundInformationsId.
-type PutFundInformationsIdParams struct {
- // UserId user_id
- UserId int `form:"user_id" json:"user_id"`
-
- // TeacherId teacher_id
- TeacherId int `form:"teacher_id" json:"teacher_id"`
-
- // Price price
- Price int `form:"price" json:"price"`
-
- // Remark remark
- Remark *string `form:"remark,omitempty" json:"remark,omitempty"`
-
- // IsFirstCheck is_first_check
- IsFirstCheck *bool `form:"is_first_check,omitempty" json:"is_first_check,omitempty"`
-
- // IsLastCheck is_last_check
- IsLastCheck *bool `form:"is_last_check,omitempty" json:"is_last_check,omitempty"`
-
- // ReceivedAt received_at
- ReceivedAt *string `form:"received_at,omitempty" json:"received_at,omitempty"`
+// GetIncomeExpenditureManagementCsvDownloadParams defines parameters for GetIncomeExpenditureManagementCsvDownload.
+type GetIncomeExpenditureManagementCsvDownloadParams struct {
+ // Year year
+ Year *int `form:"year,omitempty" json:"year,omitempty"`
}
// GetIncomeExpenditureManagementsParams defines parameters for GetIncomeExpenditureManagements.
@@ -993,29 +951,8 @@ type ServerInterface interface {
// (PUT /financial_records/{id})
PutFinancialRecordsId(ctx echo.Context, id int) error
- // (GET /fund_informations)
- GetFundInformations(ctx echo.Context) error
-
- // (POST /fund_informations)
- PostFundInformations(ctx echo.Context, params PostFundInformationsParams) error
-
- // (GET /fund_informations/details)
- GetFundInformationsDetails(ctx echo.Context) error
-
- // (GET /fund_informations/details/{year})
- GetFundInformationsDetailsYear(ctx echo.Context, year int) error
-
- // (DELETE /fund_informations/{id})
- DeleteFundInformationsId(ctx echo.Context, id int) error
-
- // (GET /fund_informations/{id})
- GetFundInformationsId(ctx echo.Context, id int) error
-
- // (PUT /fund_informations/{id})
- PutFundInformationsId(ctx echo.Context, id int, params PutFundInformationsIdParams) error
-
- // (GET /fund_informations/{id}/details)
- GetFundInformationsIdDetails(ctx echo.Context, id int) error
+ // (GET /income_expenditure_management/csv/download)
+ GetIncomeExpenditureManagementCsvDownload(ctx echo.Context, params GetIncomeExpenditureManagementCsvDownloadParams) error
// (GET /income_expenditure_managements)
GetIncomeExpenditureManagements(ctx echo.Context, params GetIncomeExpenditureManagementsParams) error
@@ -2417,212 +2354,21 @@ func (w *ServerInterfaceWrapper) PutFinancialRecordsId(ctx echo.Context) error {
return err
}
-// GetFundInformations converts echo context to params.
-func (w *ServerInterfaceWrapper) GetFundInformations(ctx echo.Context) error {
- var err error
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.GetFundInformations(ctx)
- return err
-}
-
-// PostFundInformations converts echo context to params.
-func (w *ServerInterfaceWrapper) PostFundInformations(ctx echo.Context) error {
+// GetIncomeExpenditureManagementCsvDownload converts echo context to params.
+func (w *ServerInterfaceWrapper) GetIncomeExpenditureManagementCsvDownload(ctx echo.Context) error {
var err error
// Parameter object where we will unmarshal all parameters from the context
- var params PostFundInformationsParams
- // ------------- Required query parameter "user_id" -------------
-
- err = runtime.BindQueryParameter("form", true, true, "user_id", ctx.QueryParams(), ¶ms.UserId)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter user_id: %s", err))
- }
-
- // ------------- Required query parameter "teacher_id" -------------
-
- err = runtime.BindQueryParameter("form", true, true, "teacher_id", ctx.QueryParams(), ¶ms.TeacherId)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter teacher_id: %s", err))
- }
-
- // ------------- Required query parameter "price" -------------
-
- err = runtime.BindQueryParameter("form", true, true, "price", ctx.QueryParams(), ¶ms.Price)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter price: %s", err))
- }
-
- // ------------- Optional query parameter "remark" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "remark", ctx.QueryParams(), ¶ms.Remark)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter remark: %s", err))
- }
-
- // ------------- Optional query parameter "is_first_check" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "is_first_check", ctx.QueryParams(), ¶ms.IsFirstCheck)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter is_first_check: %s", err))
- }
-
- // ------------- Optional query parameter "is_last_check" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "is_last_check", ctx.QueryParams(), ¶ms.IsLastCheck)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter is_last_check: %s", err))
- }
-
- // ------------- Optional query parameter "received_at" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "received_at", ctx.QueryParams(), ¶ms.ReceivedAt)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter received_at: %s", err))
- }
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.PostFundInformations(ctx, params)
- return err
-}
-
-// GetFundInformationsDetails converts echo context to params.
-func (w *ServerInterfaceWrapper) GetFundInformationsDetails(ctx echo.Context) error {
- var err error
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.GetFundInformationsDetails(ctx)
- return err
-}
-
-// GetFundInformationsDetailsYear converts echo context to params.
-func (w *ServerInterfaceWrapper) GetFundInformationsDetailsYear(ctx echo.Context) error {
- var err error
- // ------------- Path parameter "year" -------------
- var year int
+ var params GetIncomeExpenditureManagementCsvDownloadParams
+ // ------------- Optional query parameter "year" -------------
- err = runtime.BindStyledParameterWithOptions("simple", "year", ctx.Param("year"), &year, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
+ err = runtime.BindQueryParameter("form", true, false, "year", ctx.QueryParams(), ¶ms.Year)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
- err = w.Handler.GetFundInformationsDetailsYear(ctx, year)
- return err
-}
-
-// DeleteFundInformationsId converts echo context to params.
-func (w *ServerInterfaceWrapper) DeleteFundInformationsId(ctx echo.Context) error {
- var err error
- // ------------- Path parameter "id" -------------
- var id int
-
- err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
- }
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.DeleteFundInformationsId(ctx, id)
- return err
-}
-
-// GetFundInformationsId converts echo context to params.
-func (w *ServerInterfaceWrapper) GetFundInformationsId(ctx echo.Context) error {
- var err error
- // ------------- Path parameter "id" -------------
- var id int
-
- err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
- }
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.GetFundInformationsId(ctx, id)
- return err
-}
-
-// PutFundInformationsId converts echo context to params.
-func (w *ServerInterfaceWrapper) PutFundInformationsId(ctx echo.Context) error {
- var err error
- // ------------- Path parameter "id" -------------
- var id int
-
- err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
- }
-
- // Parameter object where we will unmarshal all parameters from the context
- var params PutFundInformationsIdParams
- // ------------- Required query parameter "user_id" -------------
-
- err = runtime.BindQueryParameter("form", true, true, "user_id", ctx.QueryParams(), ¶ms.UserId)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter user_id: %s", err))
- }
-
- // ------------- Required query parameter "teacher_id" -------------
-
- err = runtime.BindQueryParameter("form", true, true, "teacher_id", ctx.QueryParams(), ¶ms.TeacherId)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter teacher_id: %s", err))
- }
-
- // ------------- Required query parameter "price" -------------
-
- err = runtime.BindQueryParameter("form", true, true, "price", ctx.QueryParams(), ¶ms.Price)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter price: %s", err))
- }
-
- // ------------- Optional query parameter "remark" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "remark", ctx.QueryParams(), ¶ms.Remark)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter remark: %s", err))
- }
-
- // ------------- Optional query parameter "is_first_check" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "is_first_check", ctx.QueryParams(), ¶ms.IsFirstCheck)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter is_first_check: %s", err))
- }
-
- // ------------- Optional query parameter "is_last_check" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "is_last_check", ctx.QueryParams(), ¶ms.IsLastCheck)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter is_last_check: %s", err))
- }
-
- // ------------- Optional query parameter "received_at" -------------
-
- err = runtime.BindQueryParameter("form", true, false, "received_at", ctx.QueryParams(), ¶ms.ReceivedAt)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter received_at: %s", err))
- }
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.PutFundInformationsId(ctx, id, params)
- return err
-}
-
-// GetFundInformationsIdDetails converts echo context to params.
-func (w *ServerInterfaceWrapper) GetFundInformationsIdDetails(ctx echo.Context) error {
- var err error
- // ------------- Path parameter "id" -------------
- var id int
-
- err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
- }
-
- // Invoke the callback with all the unmarshaled arguments
- err = w.Handler.GetFundInformationsIdDetails(ctx, id)
+ err = w.Handler.GetIncomeExpenditureManagementCsvDownload(ctx, params)
return err
}
@@ -3657,14 +3403,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
router.DELETE(baseURL+"/financial_records/:id", wrapper.DeleteFinancialRecordsId)
router.GET(baseURL+"/financial_records/:id", wrapper.GetFinancialRecordsId)
router.PUT(baseURL+"/financial_records/:id", wrapper.PutFinancialRecordsId)
- router.GET(baseURL+"/fund_informations", wrapper.GetFundInformations)
- router.POST(baseURL+"/fund_informations", wrapper.PostFundInformations)
- router.GET(baseURL+"/fund_informations/details", wrapper.GetFundInformationsDetails)
- router.GET(baseURL+"/fund_informations/details/:year", wrapper.GetFundInformationsDetailsYear)
- router.DELETE(baseURL+"/fund_informations/:id", wrapper.DeleteFundInformationsId)
- router.GET(baseURL+"/fund_informations/:id", wrapper.GetFundInformationsId)
- router.PUT(baseURL+"/fund_informations/:id", wrapper.PutFundInformationsId)
- router.GET(baseURL+"/fund_informations/:id/details", wrapper.GetFundInformationsIdDetails)
+ router.GET(baseURL+"/income_expenditure_management/csv/download", wrapper.GetIncomeExpenditureManagementCsvDownload)
router.GET(baseURL+"/income_expenditure_managements", wrapper.GetIncomeExpenditureManagements)
router.PUT(baseURL+"/income_expenditure_managements/check/:id", wrapper.PutIncomeExpenditureManagementsCheckId)
router.GET(baseURL+"/incomes", wrapper.GetIncomes)
diff --git a/api/internals/di/di.go b/api/internals/di/di.go
index 3d8708398..d8f5489f2 100644
--- a/api/internals/di/di.go
+++ b/api/internals/di/di.go
@@ -43,7 +43,6 @@ func InitializeServer() (db.Client, *echo.Echo) {
expenseRepository := repository.NewExpenseRepository(client, crud)
festivalItemRepository := repository.NewFestivalItemRepository(client, crud)
financialRecordRepository := repository.NewFinancialRecordRepository(client, crud)
- fundInformationRepository := repository.NewFundInformationRepository(client, crud)
incomeRepository := repository.NewIncomeRepository(client, crud)
incomeExpenditureManagementRepository := repository.NewIncomeExpenditureManagementRepository(client, crud)
mailAuthRepository := repository.NewMailAuthRepository(client, crud)
@@ -77,7 +76,6 @@ func InitializeServer() (db.Client, *echo.Echo) {
expenseUseCase := usecase.NewExpenseUseCase(expenseRepository)
festivalUseCase := usecase.NewFestivalItemUseCase(festivalItemRepository, transactionRepository)
financialRecordUseCase := usecase.NewFinancialRecordUseCase(financialRecordRepository)
- fundInformationUseCase := usecase.NewFundInformationUseCase(fundInformationRepository)
incomeUseCase := usecase.NewIncomeUseCase(incomeRepository, incomeExpenditureManagementRepository, transactionRepository)
incomeExpenditureManagementUseCase := usecase.NewIncomeExpenditureManagementUseCase(incomeExpenditureManagementRepository)
mailAuthUseCase := usecase.NewMailAuthUseCase(mailAuthRepository, sessionRepository)
@@ -117,7 +115,6 @@ func InitializeServer() (db.Client, *echo.Echo) {
expenseController := controller.NewExpenseController(expenseUseCase)
festivalItemController := controller.NewFestivalItemController(festivalUseCase)
financialRecordController := controller.NewFinancialRecordController(financialRecordUseCase)
- fundInformationController := controller.NewFundInformationController(fundInformationUseCase)
healthcheckController := controller.NewHealthCheckController()
incomeController := controller.NewIncomeController(incomeUseCase)
incomeExpenditureManagementController := controller.NewIncomeExpenditureManagementController(incomeExpenditureManagementUseCase)
@@ -151,7 +148,6 @@ func InitializeServer() (db.Client, *echo.Echo) {
expenseController,
festivalItemController,
financialRecordController,
- fundInformationController,
healthcheckController,
incomeController,
incomeExpenditureManagementController,
diff --git a/api/internals/domain/fund_information.go b/api/internals/domain/fund_information.go
deleted file mode 100644
index f4a17c010..000000000
--- a/api/internals/domain/fund_information.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package domain
-
-import (
- "time"
-)
-
-type FundInformation struct {
- ID int `json:"id"`
- UserID int `json:"userID"`
- TeacherID int `json:"teacherID"`
- Price int `json:"price"`
- Remark string `json:"remark"`
- IsFirstCheck bool `json:"isFirstCheck"`
- IsLastCheck bool `json:"isLastCheck"`
- ReceivedAt string `json:"receivedAt"`
- CreatedAt time.Time `json:"createdAt"`
- UpdatedAt time.Time `json:"updatedAt"`
-}
-
-type FundInformationDetail struct {
- FundInformation FundInformation `json:"fundInformation"`
- User User `json:"user"`
- Teacher Teacher `json:"teacher"`
- Department Department `json:"department"`
-}
diff --git a/api/internals/usecase/fund_information_usecase.go b/api/internals/usecase/fund_information_usecase.go
deleted file mode 100644
index 3b5a4f3e1..000000000
--- a/api/internals/usecase/fund_information_usecase.go
+++ /dev/null
@@ -1,327 +0,0 @@
-package usecase
-
-import (
- "context"
- "log"
-
- rep "github.com/NUTFes/FinanSu/api/externals/repository"
- "github.com/NUTFes/FinanSu/api/internals/domain"
-)
-
-type fundInformationUseCase struct {
- rep rep.FundInformationRepository
-}
-
-type FundInformationUseCase interface {
- GetFundInformations(context.Context) ([]domain.FundInformation, error)
- GetFundInformationByID(context.Context, string) (domain.FundInformation, error)
- CreateFundInformation(context.Context, string, string, string, string, string, string, string) (domain.FundInformation, error)
- UpdateFundInformation(context.Context, string, string, string, string, string, string, string, string) (domain.FundInformation, error)
- DestroyFundInformation(context.Context, string) error
- GetFundInformationDetails(context.Context) ([]domain.FundInformationDetail, error)
- GetFundInformationDetailByID(context.Context, string) (domain.FundInformationDetail, error)
- GetFundInformationDetailsByPeriod(context.Context, string) ([]domain.FundInformationDetail, error)
-}
-
-func NewFundInformationUseCase(rep rep.FundInformationRepository) FundInformationUseCase {
- return &fundInformationUseCase{rep}
-}
-
-// FundInformationsの取得(Get)
-func (f *fundInformationUseCase) GetFundInformations(c context.Context) ([]domain.FundInformation, error) {
- fundInformation := domain.FundInformation{}
- var fundInformations []domain.FundInformation
-
- rows, err := f.rep.All(c)
- if err != nil {
- return nil, err
- }
- for rows.Next() {
- err := rows.Scan(
- &fundInformation.ID,
- &fundInformation.UserID,
- &fundInformation.TeacherID,
- &fundInformation.Price,
- &fundInformation.Remark,
- &fundInformation.IsFirstCheck,
- &fundInformation.IsLastCheck,
- &fundInformation.ReceivedAt,
- &fundInformation.CreatedAt,
- &fundInformation.UpdatedAt,
- )
- if err != nil {
- return nil, err
- }
- fundInformations = append(fundInformations, fundInformation)
- }
- return fundInformations, nil
-}
-
-// FundInfomationの取得(Get)
-func (f *fundInformationUseCase) GetFundInformationByID(c context.Context, id string) (domain.FundInformation, error) {
- fundInformation := domain.FundInformation{}
-
- row, err := f.rep.Find(c, id)
- if err != nil {
- return fundInformation, err
- }
-
- err = row.Scan(
- &fundInformation.ID,
- &fundInformation.UserID,
- &fundInformation.TeacherID,
- &fundInformation.Price,
- &fundInformation.Remark,
- &fundInformation.IsFirstCheck,
- &fundInformation.IsLastCheck,
- &fundInformation.ReceivedAt,
- &fundInformation.CreatedAt,
- &fundInformation.UpdatedAt,
- )
- if err != nil {
- return fundInformation, err
- }
- return fundInformation, nil
-}
-
-// FundInfomationの作成(Create)
-func (f *fundInformationUseCase) CreateFundInformation(
- c context.Context,
- userID string,
- teacherID string,
- price string,
- remark string,
- isFirstCheck string,
- isLastCheck string,
- receivedAt string,
-) (domain.FundInformation, error) {
- latastFundInformation := domain.FundInformation{}
- if err := f.rep.Create(c, userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt); err != nil {
- return latastFundInformation, err
- }
-
- row, err := f.rep.FindLatestRecord(c)
- if err != nil {
- return latastFundInformation, err
- }
-
- err = row.Scan(
- &latastFundInformation.ID,
- &latastFundInformation.UserID,
- &latastFundInformation.TeacherID,
- &latastFundInformation.Price,
- &latastFundInformation.Remark,
- &latastFundInformation.IsFirstCheck,
- &latastFundInformation.IsLastCheck,
- &latastFundInformation.ReceivedAt,
- &latastFundInformation.CreatedAt,
- &latastFundInformation.UpdatedAt,
- )
- if err != nil {
- return latastFundInformation, err
- }
- return latastFundInformation, err
-}
-
-// FundInformationの修正(Update)
-func (f *fundInformationUseCase) UpdateFundInformation(
- c context.Context,
- id string,
- userID string,
- teacherID string,
- price string,
- remark string,
- isFirstCheck string,
- isLastCheck string,
- receivedAt string,
-) (domain.FundInformation, error) {
- updatedFundInformation := domain.FundInformation{}
- if err := f.rep.Update(c, id, userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt); err != nil {
- return updatedFundInformation, err
- }
-
- row, err := f.rep.Find(c, id)
- if err != nil {
- return updatedFundInformation, err
- }
-
- err = row.Scan(
- &updatedFundInformation.ID,
- &updatedFundInformation.UserID,
- &updatedFundInformation.TeacherID,
- &updatedFundInformation.Price,
- &updatedFundInformation.Remark,
- &updatedFundInformation.IsFirstCheck,
- &updatedFundInformation.IsLastCheck,
- &updatedFundInformation.ReceivedAt,
- &updatedFundInformation.CreatedAt,
- &updatedFundInformation.UpdatedAt,
- )
- if err != nil {
- return updatedFundInformation, err
- }
- return updatedFundInformation, err
-}
-
-// funcInformationの削除(delete)
-func (f *fundInformationUseCase) DestroyFundInformation(c context.Context, id string) error {
- err := f.rep.Delete(c, id)
- return err
-}
-
-// fund_informations-api(GETS)
-func (f *fundInformationUseCase) GetFundInformationDetails(c context.Context) ([]domain.FundInformationDetail, error) {
- fundInformationDetail := domain.FundInformationDetail{}
- var fundInformationDetails []domain.FundInformationDetail
-
- rows, err := f.rep.FindDetails(c)
- if err != nil {
- return nil, err
- }
- for rows.Next() {
- err := rows.Scan(
- &fundInformationDetail.FundInformation.ID,
- &fundInformationDetail.FundInformation.UserID,
- &fundInformationDetail.FundInformation.TeacherID,
- &fundInformationDetail.FundInformation.Price,
- &fundInformationDetail.FundInformation.Remark,
- &fundInformationDetail.FundInformation.IsFirstCheck,
- &fundInformationDetail.FundInformation.IsLastCheck,
- &fundInformationDetail.FundInformation.ReceivedAt,
- &fundInformationDetail.FundInformation.CreatedAt,
- &fundInformationDetail.FundInformation.UpdatedAt,
- &fundInformationDetail.User.ID,
- &fundInformationDetail.User.Name,
- &fundInformationDetail.User.BureauID,
- &fundInformationDetail.User.RoleID,
- &fundInformationDetail.User.IsDeleted,
- &fundInformationDetail.User.CreatedAt,
- &fundInformationDetail.User.UpdatedAt,
- &fundInformationDetail.Teacher.ID,
- &fundInformationDetail.Teacher.Name,
- &fundInformationDetail.Teacher.Position,
- &fundInformationDetail.Teacher.DepartmentID,
- &fundInformationDetail.Teacher.Room,
- &fundInformationDetail.Teacher.IsBlack,
- &fundInformationDetail.Teacher.Remark,
- &fundInformationDetail.Teacher.IsDeleted,
- &fundInformationDetail.Teacher.CreatedAt,
- &fundInformationDetail.Teacher.UpdatedAt,
- &fundInformationDetail.Department.ID,
- &fundInformationDetail.Department.Name,
- &fundInformationDetail.Department.CreatedAt,
- &fundInformationDetail.Department.UpdatedAt,
- )
- if err != nil {
- return nil, err
- }
- fundInformationDetails = append(fundInformationDetails, fundInformationDetail)
-
- }
- return fundInformationDetails, nil
-}
-
-// fund_information-api(GET)
-func (f *fundInformationUseCase) GetFundInformationDetailByID(c context.Context, id string) (domain.FundInformationDetail, error) {
- var fundInformationDetail domain.FundInformationDetail
-
- row, err := f.rep.FindDetailByID(c, id)
- if err != nil {
- return fundInformationDetail, err
- }
-
- err = row.Scan(
- &fundInformationDetail.FundInformation.ID,
- &fundInformationDetail.FundInformation.UserID,
- &fundInformationDetail.FundInformation.TeacherID,
- &fundInformationDetail.FundInformation.Price,
- &fundInformationDetail.FundInformation.Remark,
- &fundInformationDetail.FundInformation.IsFirstCheck,
- &fundInformationDetail.FundInformation.IsLastCheck,
- &fundInformationDetail.FundInformation.ReceivedAt,
- &fundInformationDetail.FundInformation.CreatedAt,
- &fundInformationDetail.FundInformation.UpdatedAt,
- &fundInformationDetail.User.ID,
- &fundInformationDetail.User.Name,
- &fundInformationDetail.User.BureauID,
- &fundInformationDetail.User.RoleID,
- &fundInformationDetail.User.IsDeleted,
- &fundInformationDetail.User.CreatedAt,
- &fundInformationDetail.User.UpdatedAt,
- &fundInformationDetail.Teacher.ID,
- &fundInformationDetail.Teacher.Name,
- &fundInformationDetail.Teacher.Position,
- &fundInformationDetail.Teacher.DepartmentID,
- &fundInformationDetail.Teacher.Room,
- &fundInformationDetail.Teacher.IsBlack,
- &fundInformationDetail.Teacher.Remark,
- &fundInformationDetail.Teacher.IsDeleted,
- &fundInformationDetail.Teacher.CreatedAt,
- &fundInformationDetail.Teacher.UpdatedAt,
- &fundInformationDetail.Department.ID,
- &fundInformationDetail.Department.Name,
- &fundInformationDetail.Department.CreatedAt,
- &fundInformationDetail.Department.UpdatedAt,
- )
- if err != nil {
- return fundInformationDetail, err
- }
- return fundInformationDetail, nil
-}
-
-// fund_informations_byyear-api(GETS)
-func (f *fundInformationUseCase) GetFundInformationDetailsByPeriod(c context.Context, year string) ([]domain.FundInformationDetail, error) {
- fundInformationDetail := domain.FundInformationDetail{}
- var fundInformationDetails []domain.FundInformationDetail
-
- rows, err := f.rep.AllDetailsByPeriod(c, year)
- if err != nil {
- return nil, err
- }
- defer func() {
- if err := rows.Close(); err != nil {
- log.Println(err)
- }
- }()
-
- for rows.Next() {
- err := rows.Scan(
- &fundInformationDetail.FundInformation.ID,
- &fundInformationDetail.FundInformation.UserID,
- &fundInformationDetail.FundInformation.TeacherID,
- &fundInformationDetail.FundInformation.Price,
- &fundInformationDetail.FundInformation.Remark,
- &fundInformationDetail.FundInformation.IsFirstCheck,
- &fundInformationDetail.FundInformation.IsLastCheck,
- &fundInformationDetail.FundInformation.ReceivedAt,
- &fundInformationDetail.FundInformation.CreatedAt,
- &fundInformationDetail.FundInformation.UpdatedAt,
- &fundInformationDetail.User.ID,
- &fundInformationDetail.User.Name,
- &fundInformationDetail.User.BureauID,
- &fundInformationDetail.User.RoleID,
- &fundInformationDetail.User.IsDeleted,
- &fundInformationDetail.User.CreatedAt,
- &fundInformationDetail.User.UpdatedAt,
- &fundInformationDetail.Teacher.ID,
- &fundInformationDetail.Teacher.Name,
- &fundInformationDetail.Teacher.Position,
- &fundInformationDetail.Teacher.DepartmentID,
- &fundInformationDetail.Teacher.Room,
- &fundInformationDetail.Teacher.IsBlack,
- &fundInformationDetail.Teacher.Remark,
- &fundInformationDetail.Teacher.IsDeleted,
- &fundInformationDetail.Teacher.CreatedAt,
- &fundInformationDetail.Teacher.UpdatedAt,
- &fundInformationDetail.Department.ID,
- &fundInformationDetail.Department.Name,
- &fundInformationDetail.Department.CreatedAt,
- &fundInformationDetail.Department.UpdatedAt,
- )
- if err != nil {
- return nil, err
- }
- fundInformationDetails = append(fundInformationDetails, fundInformationDetail)
- }
- return fundInformationDetails, nil
-}
diff --git a/api/router/router.go b/api/router/router.go
index 9ef4f0545..8d6ef5ad5 100644
--- a/api/router/router.go
+++ b/api/router/router.go
@@ -17,7 +17,6 @@ type router struct {
festivalItemController controller.FestivalItemController
financialRecordController controller.FinancialRecordController
divisionController controller.DivisionController
- fundInformationController controller.FundInformationController
healthcheckController controller.HealthcheckController
incomeController controller.IncomeController
incomeExpenditureManagementController controller.IncomeExpenditureManagementController
@@ -52,7 +51,6 @@ func NewRouter(
expenseController controller.ExpenseController,
festivalItemController controller.FestivalItemController,
financialRecordController controller.FinancialRecordController,
- fundInformationController controller.FundInformationController,
healthController controller.HealthcheckController,
incomeController controller.IncomeController,
incomeExpenditureManagementController controller.IncomeExpenditureManagementController,
@@ -82,7 +80,6 @@ func NewRouter(
festivalItemController,
financialRecordController,
divisionController,
- fundInformationController,
healthController,
incomeController,
incomeExpenditureManagementController,
@@ -211,22 +208,6 @@ func (r router) ProvideRouter(e *echo.Echo) {
e.DELETE("/financial_records/:id", r.financialRecordController.DestroyFinancialRecord)
e.GET("/financial_records/csv/download", r.financialRecordController.DownloadFinancialRecordsCSV)
- // fund informations
- e.GET("/fund_informations", r.fundInformationController.IndexFundInformation)
- e.GET("/fund_informations/:id", r.fundInformationController.ShowFundInformation)
- e.POST("/fund_informations", r.fundInformationController.CreateFundInformation)
- e.PUT("/fund_informations/:id", r.fundInformationController.UpdateFundInformation)
- e.DELETE("/fund_informations/:id", r.fundInformationController.DestroyFundInformation)
- e.GET("/fund_informations/details", r.fundInformationController.IndexFundInformationDetails)
- e.GET(
- "/fund_informations/:id/details",
- r.fundInformationController.ShowFundInformationDetailByID,
- )
- e.GET(
- "/fund_informations/details/:year",
- r.fundInformationController.IndexFundInformationDetailsByPeriod,
- )
-
// incomes
e.GET("/incomes", r.incomeController.IndexIncome)
e.POST("/incomes", r.incomeController.PostIncome)
@@ -237,6 +218,7 @@ func (r router) ProvideRouter(e *echo.Echo) {
// income_expenditure_managements
e.GET("income_expenditure_managements", r.incomeExpenditureManagementController.IndexIncomeExpenditureManagements)
e.PUT("/income_expenditure_managements/check/:id", r.incomeExpenditureManagementController.PutIncomeExpenditureManagementCheck)
+ e.GET("/income_expenditure_management/csv/download", r.incomeExpenditureManagementController.DownloadIncomeExpenditureManagementCSV)
// mail auth
e.POST("/mail_auth/signup", r.mailAuthController.SignUp)
diff --git a/compose.db.yml b/compose.db.yml
index 1054d8bb9..795dfbe93 100644
--- a/compose.db.yml
+++ b/compose.db.yml
@@ -2,16 +2,16 @@ services:
db:
image: mysql:8.0
container_name: "nutfes-finansu-db"
- volumes:
- - ./mysql/db:/docker-entrypoint-initdb.d # 初期データ
- - ./mysql/testdb:/docker-entrypoint-testdb.d # テスト用初期データ
- - ./my.cnf:/etc/mysql/conf.d/my.cnf
environment:
MYSQL_DATABASE: finansu_db
MYSQL_USER: finansu
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
TZ: "Asia/Tokyo"
+ volumes:
+ - ./mysql/seed:/seed # 初期データ
+ - ./scripts:/scripts # スクリプト
+ - ./my.cnf:/etc/mysql/conf.d/my.cnf
ports:
- "3306:3306"
restart: always
diff --git a/compose.migrate.yml b/compose.migrate.yml
new file mode 100644
index 000000000..7f3c2567d
--- /dev/null
+++ b/compose.migrate.yml
@@ -0,0 +1,9 @@
+services:
+ migrate:
+ image: migrate/migrate:latest
+ container_name: "nutfes-finansu-migrate"
+ command: "migrate -version"
+ env_file:
+ - finansu.env
+ volumes:
+ - ./mysql/migrations:/migrations
diff --git a/er/columns.html b/er/columns.html
index 4c1d6144a..aefec7d31 100644
--- a/er/columns.html
+++ b/er/columns.html
@@ -978,6 +978,160 @@
Columns
"defaultValue": "CURRENT_TIMESTAMP",
"comments": ""
},
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "primaryKey",
+ "keyTitle": "Primary Key",
+ "name": "id",
+ "type": "INT UNSIGNED",
+ "length": 10,
+ "nullable": "",
+ "autoUpdated": "√",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "user_id",
+ "type": "INT",
+ "length": 10,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "teacher_id",
+ "type": "INT",
+ "length": 10,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "foreignKey",
+ "keyTitle": "Foreign Key",
+ "name": "year_id",
+ "type": "INT UNSIGNED",
+ "length": 10,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "price",
+ "type": "INT",
+ "length": 10,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "remark",
+ "type": "VARCHAR",
+ "length": 255,
+ "nullable": "√",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "is_first_check",
+ "type": "BIT",
+ "length": 1,
+ "nullable": "√",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "is_last_check",
+ "type": "BIT",
+ "length": 1,
+ "nullable": "√",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "received_at",
+ "type": "VARCHAR",
+ "length": 255,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "null",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "created_at",
+ "type": "DATETIME",
+ "length": 19,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "CURRENT_TIMESTAMP",
+ "comments": ""
+ },
+ {
+ "tableName": "campus_donations",
+ "tableFileName": "campus_donations",
+ "tableType": "Table",
+ "keyClass": "",
+ "keyTitle": "",
+ "name": "updated_at",
+ "type": "DATETIME",
+ "length": 19,
+ "nullable": "",
+ "autoUpdated": "",
+ "defaultValue": "CURRENT_TIMESTAMP",
+ "comments": ""
+ },
{
"tableName": "departments",
"tableFileName": "departments",
@@ -1328,146 +1482,6 @@ Columns
"defaultValue": "CURRENT_TIMESTAMP",
"comments": ""
},
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "primaryKey",
- "keyTitle": "Primary Key",
- "name": "id",
- "type": "INT UNSIGNED",
- "length": 10,
- "nullable": "",
- "autoUpdated": "√",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "user_id",
- "type": "INT",
- "length": 10,
- "nullable": "",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "teacher_id",
- "type": "INT",
- "length": 10,
- "nullable": "",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "price",
- "type": "INT",
- "length": 10,
- "nullable": "",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "remark",
- "type": "VARCHAR",
- "length": 255,
- "nullable": "√",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "is_first_check",
- "type": "BIT",
- "length": 1,
- "nullable": "√",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "is_last_check",
- "type": "BIT",
- "length": 1,
- "nullable": "√",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "received_at",
- "type": "VARCHAR",
- "length": 255,
- "nullable": "",
- "autoUpdated": "",
- "defaultValue": "null",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "created_at",
- "type": "DATETIME",
- "length": 19,
- "nullable": "",
- "autoUpdated": "",
- "defaultValue": "CURRENT_TIMESTAMP",
- "comments": ""
- },
- {
- "tableName": "fund_informations",
- "tableFileName": "fund_informations",
- "tableType": "Table",
- "keyClass": "",
- "keyTitle": "",
- "name": "updated_at",
- "type": "DATETIME",
- "length": 19,
- "nullable": "",
- "autoUpdated": "",
- "defaultValue": "CURRENT_TIMESTAMP",
- "comments": ""
- },
{
"tableName": "income_expenditure_managements",
"tableFileName": "income_expenditure_managements",
diff --git a/er/constraints.html b/er/constraints.html
index 4aa05faa4..f823eeaaa 100644
--- a/er/constraints.html
+++ b/er/constraints.html
@@ -80,7 +80,7 @@ Constraints