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

-

22 Foreign Key Constraints

+

23 Foreign Key Constraints

@@ -121,6 +121,24 @@

22 Foreign Key Constraints

Cascade on delete + + campus_donations_ibfk_1 + + + + + +
campus_donations.year_id
+ + + + + + +
years.id
+ + Cascade on delete + festival_items_ibfk_1 @@ -266,54 +284,54 @@

22 Foreign Key Constraints

Cascade on delete - item_budgets_ibfk_1 + income_income_expenditure_managements_ibfk_1 - +
item_budgets.festival_item_idincome_income_expenditure_managements.income_expenditure_id
- +
festival_items.idincome_expenditure_managements.id
Cascade on delete - income_income_expenditure_managements_ibfk_1 + income_income_expenditure_managements_ibfk_2 - +
income_income_expenditure_managements.income_expenditure_idincome_income_expenditure_managements.income_id
- +
income_expenditure_managements.idincomes.id
Cascade on delete - income_income_expenditure_managements_ibfk_2 + item_budgets_ibfk_1 - +
income_income_expenditure_managements.income_iditem_budgets.festival_item_id
- +
incomes.idfestival_items.id
diff --git a/er/deletionOrder.txt b/er/deletionOrder.txt index 266a994c5..f7d965ac3 100644 --- a/er/deletionOrder.txt +++ b/er/deletionOrder.txt @@ -10,7 +10,6 @@ purchase_orders purchase_items password_reset_tokens mail_auth -fund_informations departments bureaus budgets @@ -24,6 +23,7 @@ buy_report_income_expenditure_managements spot_sponsor_names payment_receipts item_budgets +campus_donations buy_statuses rooms buy_reports diff --git a/er/diagrams/orphans/orphans.dot b/er/diagrams/orphans/orphans.dot index 6f75cd55f..bbc99954a 100644 --- a/er/diagrams/orphans/orphans.dot +++ b/er/diagrams/orphans/orphans.dot @@ -78,26 +78,6 @@ digraph "orphans" { target="_top" tooltip="departments" ]; - "fund_informations" [ - label=< - - - - - - - - - - - - - -
fund_informations[table]
id
int unsigned[10]
user_id
int[10]
teacher_id
int[10]
price
int[10]
remark
varchar[255]
is_first_check
bit[1]
is_last_check
bit[1]
received_at
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 02 rows0 >
> - URL="tables/fund_informations.html" - target="_top" - tooltip="fund_informations" - ]; "mail_auth" [ label=< @@ -277,7 +257,7 @@ digraph "orphans" { - +
representative
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 03 rows0 >
< 00 rows0 >
> URL="tables/sponsors.html" target="_top" diff --git a/er/diagrams/orphans/orphans.png b/er/diagrams/orphans/orphans.png index a92d087e7..fa6e20148 100644 Binary files a/er/diagrams/orphans/orphans.png and b/er/diagrams/orphans/orphans.png differ diff --git a/er/diagrams/summary/relationships.real.compact.dot b/er/diagrams/summary/relationships.real.compact.dot index dd96e6842..93f9e2a4e 100644 --- a/er/diagrams/summary/relationships.real.compact.dot +++ b/er/diagrams/summary/relationships.real.compact.dot @@ -62,6 +62,19 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="purchase_reports" ]; + "campus_donations" [ + label=< + + + + + + +
campus_donations[table]
id
year_id
...
< 12 rows
> + URL="tables/campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "receipts" [ label=< @@ -147,18 +160,6 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="activity_styles" ]; - "fund_informations" [ - label=< -
- - - - -
fund_informations[table]
id
...
2 rows
> - URL="tables/fund_informations.html" - target="_top" - tooltip="fund_informations" - ]; "user_groups" [ label=< @@ -274,19 +275,6 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="budgets" ]; - "item_budgets" [ - label=< -
- - - - - -
item_budgets[table]
id
festival_item_id
...
< 17 rows
> - URL="tables/item_budgets.html" - target="_top" - tooltip="item_budgets" - ]; "income_income_expenditure_managements" [ label=< @@ -301,6 +289,19 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="income_income_expenditure_managements" ]; + "item_budgets" [ + label=< +
+ + + + + +
item_budgets[table]
id
festival_item_id
...
< 17 rows
> + URL="tables/item_budgets.html" + target="_top" + tooltip="item_budgets" + ]; "session" [ label=< @@ -320,7 +321,7 @@ digraph "compactRelationshipsDiagram" { - +
sponsors[table]
id
...
3 rows
0 rows
> URL="tables/sponsors.html" target="_top" @@ -383,7 +384,7 @@ digraph "compactRelationshipsDiagram" {
years[table]
id
... -
3 rows2 >
+
3 rows3 >
> URL="tables/years.html" target="_top" @@ -468,18 +469,6 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="payment_receipts" ]; - "users" [ - label=< - - - - - -
users[table]
id
...
4 rows1 >
> - URL="tables/users.html" - target="_top" - tooltip="users" - ]; "teachers" [ label=< @@ -492,6 +481,18 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="teachers" ]; + "users" [ + label=< +
+ + + + +
users[table]
id
...
4 rows1 >
> + URL="tables/users.html" + target="_top" + tooltip="users" + ]; "password_reset_tokens" [ label=< @@ -521,6 +522,7 @@ digraph "compactRelationshipsDiagram" { "buy_report_income_expenditure_managements":"income_expenditure_management_id":w -> "income_expenditure_managements":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "buy_reports":"festival_item_id":w -> "festival_items":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "buy_statuses":"buy_report_id":w -> "buy_reports":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "divisions":"financial_record_id":w -> "financial_records":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "festival_items":"division_id":w -> "divisions":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "financial_records":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; diff --git a/er/diagrams/summary/relationships.real.compact.png b/er/diagrams/summary/relationships.real.compact.png index beee0bb69..ca083b79f 100644 Binary files a/er/diagrams/summary/relationships.real.compact.png and b/er/diagrams/summary/relationships.real.compact.png differ diff --git a/er/diagrams/summary/relationships.real.large.dot b/er/diagrams/summary/relationships.real.large.dot index 009f6ac3c..9980a2609 100644 --- a/er/diagrams/summary/relationships.real.large.dot +++ b/er/diagrams/summary/relationships.real.large.dot @@ -85,6 +85,27 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="purchase_reports" ]; + "campus_donations" [ + label=< +
+ + + + + + + + + + + + + +
campus_donations[table]
id
user_id
teacher_id
year_id
price
remark
is_first_check
is_last_check
received_at
created_at
updated_at
< 12 rows
> + URL="tables/campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "receipts" [ label=< @@ -196,26 +217,6 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="activity_styles" ]; - "fund_informations" [ - label=< -
- - - - - - - - - - - - -
fund_informations[table]
id
user_id
teacher_id
price
remark
is_first_check
is_last_check
received_at
created_at
updated_at
2 rows
> - URL="tables/fund_informations.html" - target="_top" - tooltip="fund_informations" - ]; "user_groups" [ label=< @@ -361,21 +362,6 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="budgets" ]; - "item_budgets" [ - label=< -
- - - - - - - -
item_budgets[table]
id
amount
festival_item_id
created_at
updated_at
< 17 rows
> - URL="tables/item_budgets.html" - target="_top" - tooltip="item_budgets" - ]; "income_income_expenditure_managements" [ label=< @@ -391,6 +377,21 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="income_income_expenditure_managements" ]; + "item_budgets" [ + label=< +
+ + + + + + + +
item_budgets[table]
id
amount
festival_item_id
created_at
updated_at
< 17 rows
> + URL="tables/item_budgets.html" + target="_top" + tooltip="item_budgets" + ]; "session" [ label=< @@ -419,7 +420,7 @@ digraph "largeRelationshipsDiagram" { - +
representative
created_at
updated_at
3 rows
0 rows
> URL="tables/sponsors.html" target="_top" @@ -495,7 +496,7 @@ digraph "largeRelationshipsDiagram" {
year
created_at
updated_at
-
3 rows2 >
+
3 rows3 >
> URL="tables/years.html" target="_top" @@ -598,23 +599,6 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="payment_receipts" ]; - "users" [ - label=< - - - - - - - - - - -
users[table]
id
name
bureau_id
role_id
is_deleted
created_at
updated_at
4 rows1 >
> - URL="tables/users.html" - target="_top" - tooltip="users" - ]; "teachers" [ label=< @@ -635,6 +619,23 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="teachers" ]; + "users" [ + label=< +
+ + + + + + + + + +
users[table]
id
name
bureau_id
role_id
is_deleted
created_at
updated_at
4 rows1 >
> + URL="tables/users.html" + target="_top" + tooltip="users" + ]; "password_reset_tokens" [ label=< @@ -669,6 +670,7 @@ digraph "largeRelationshipsDiagram" { "buy_report_income_expenditure_managements":"income_expenditure_management_id":w -> "income_expenditure_managements":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "buy_reports":"festival_item_id":w -> "festival_items":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "buy_statuses":"buy_report_id":w -> "buy_reports":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "divisions":"financial_record_id":w -> "financial_records":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "festival_items":"division_id":w -> "divisions":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "financial_records":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; diff --git a/er/diagrams/summary/relationships.real.large.png b/er/diagrams/summary/relationships.real.large.png index 9608a0220..aa2629ce4 100644 Binary files a/er/diagrams/summary/relationships.real.large.png and b/er/diagrams/summary/relationships.real.large.png differ diff --git a/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.dot b/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.dot index f4099cf36..a3201a4d8 100644 --- a/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.dot +++ b/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.dot @@ -121,7 +121,7 @@ digraph "twoDegreesRelationshipsDiagram" {
- +
years[table]
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.png b/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.png index 6505642da..6352d82a4 100644 Binary files a/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.png and b/er/diagrams/tables/buy_report_income_expenditure_m_26c10aac.2degrees.png differ diff --git a/er/diagrams/tables/campus_donations.1degree.dot b/er/diagrams/tables/campus_donations.1degree.dot new file mode 100644 index 000000000..9d291e53c --- /dev/null +++ b/er/diagrams/tables/campus_donations.1degree.dot @@ -0,0 +1,37 @@ +digraph "oneDegreeRelationshipsDiagram" { + graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; + "campus_donations":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations" [ + label=< + + + + + + + + + + + + + + +
campus_donations[table]
id
int unsigned[10]
user_id
int[10]
teacher_id
int[10]
year_id
int unsigned[10]
price
int[10]
remark
varchar[255]
is_first_check
bit[1]
is_last_check
bit[1]
received_at
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 12 rows0 >
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; + "years" [ + label=< + + + + + +
years[table]
id
...
3 rows3 >
> + URL="years.html" + target="_top" + tooltip="years" + ]; +} diff --git a/er/diagrams/tables/campus_donations.1degree.png b/er/diagrams/tables/campus_donations.1degree.png new file mode 100644 index 000000000..e47f5531a Binary files /dev/null and b/er/diagrams/tables/campus_donations.1degree.png differ diff --git a/er/diagrams/tables/campus_donations.2degrees.dot b/er/diagrams/tables/campus_donations.2degrees.dot new file mode 100644 index 000000000..e39e2f36e --- /dev/null +++ b/er/diagrams/tables/campus_donations.2degrees.dot @@ -0,0 +1,61 @@ +digraph "twoDegreesRelationshipsDiagram" { + graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; + "campus_donations":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "financial_records":"elipses":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "income_expenditure_managements":"elipses":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations" [ + label=< + + + + + + + + + + + + + + +
campus_donations[table]
id
int unsigned[10]
user_id
int[10]
teacher_id
int[10]
year_id
int unsigned[10]
price
int[10]
remark
varchar[255]
is_first_check
bit[1]
is_last_check
bit[1]
received_at
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 12 rows0 >
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; + "financial_records" [ + label=< + + + + +
financial_records[table]
...
< 12 rows1 >
> + URL="financial_records.html" + target="_top" + tooltip="financial_records" + ]; + "income_expenditure_managements" [ + label=< + + + + +
income_expenditure_managements[table]
...
< 19 rows4 >
> + URL="income_expenditure_managements.html" + target="_top" + tooltip="income_expenditure_managements" + ]; + "years" [ + label=< + + + + + +
years[table]
id
...
3 rows3 >
> + URL="years.html" + target="_top" + tooltip="years" + ]; +} diff --git a/er/diagrams/tables/campus_donations.2degrees.png b/er/diagrams/tables/campus_donations.2degrees.png new file mode 100644 index 000000000..79d78cd25 Binary files /dev/null and b/er/diagrams/tables/campus_donations.2degrees.png differ diff --git a/er/diagrams/tables/divisions.2degrees.dot b/er/diagrams/tables/divisions.2degrees.dot index dd348a5de..806417df0 100644 --- a/er/diagrams/tables/divisions.2degrees.dot +++ b/er/diagrams/tables/divisions.2degrees.dot @@ -100,7 +100,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
years[table]
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/divisions.2degrees.png b/er/diagrams/tables/divisions.2degrees.png index 285a56d7f..541b2add8 100644 Binary files a/er/diagrams/tables/divisions.2degrees.png and b/er/diagrams/tables/divisions.2degrees.png differ diff --git a/er/diagrams/tables/financial_records.1degree.dot b/er/diagrams/tables/financial_records.1degree.dot index cf53d0a7a..35073d421 100644 --- a/er/diagrams/tables/financial_records.1degree.dot +++ b/er/diagrams/tables/financial_records.1degree.dot @@ -36,7 +36,7 @@ digraph "oneDegreeRelationshipsDiagram" {
years[table]
id
... -
3 rows2 >
+
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/financial_records.1degree.png b/er/diagrams/tables/financial_records.1degree.png index 35106af7e..307628896 100644 Binary files a/er/diagrams/tables/financial_records.1degree.png and b/er/diagrams/tables/financial_records.1degree.png differ diff --git a/er/diagrams/tables/financial_records.2degrees.dot b/er/diagrams/tables/financial_records.2degrees.dot index 74bb4cab8..b512b74e8 100644 --- a/er/diagrams/tables/financial_records.2degrees.dot +++ b/er/diagrams/tables/financial_records.2degrees.dot @@ -1,10 +1,22 @@ digraph "twoDegreesRelationshipsDiagram" { graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; + "campus_donations":"elipses":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "divisions":"financial_record_id":w -> "financial_records":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; "festival_items":"elipses":w -> "divisions":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "financial_records":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "income_expenditure_managements":"elipses":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "user_groups":"elipses":w -> "divisions":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations" [ + label=< + + + + +
campus_donations[table]
...
< 12 rows
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "divisions" [ label=< @@ -72,7 +84,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
years[table]
id
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/financial_records.2degrees.png b/er/diagrams/tables/financial_records.2degrees.png index 99db662a5..605644a00 100644 Binary files a/er/diagrams/tables/financial_records.2degrees.png and b/er/diagrams/tables/financial_records.2degrees.png differ diff --git a/er/diagrams/tables/income_expenditure_managements.1degree.dot b/er/diagrams/tables/income_expenditure_managements.1degree.dot index a663fcddb..7590c1f9b 100644 --- a/er/diagrams/tables/income_expenditure_managements.1degree.dot +++ b/er/diagrams/tables/income_expenditure_managements.1degree.dot @@ -84,7 +84,7 @@ digraph "oneDegreeRelationshipsDiagram" {
years[table]
id
... -
3 rows2 >
+
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/income_expenditure_managements.1degree.png b/er/diagrams/tables/income_expenditure_managements.1degree.png index 8957dc9f2..afe0e6081 100644 Binary files a/er/diagrams/tables/income_expenditure_managements.1degree.png and b/er/diagrams/tables/income_expenditure_managements.1degree.png differ diff --git a/er/diagrams/tables/income_expenditure_managements.2degrees.dot b/er/diagrams/tables/income_expenditure_managements.2degrees.dot index e58ee7fb6..80fd6f722 100644 --- a/er/diagrams/tables/income_expenditure_managements.2degrees.dot +++ b/er/diagrams/tables/income_expenditure_managements.2degrees.dot @@ -2,6 +2,7 @@ digraph "twoDegreesRelationshipsDiagram" { graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; "buy_report_income_expenditure_managements":"buy_report_id":w -> "buy_reports":"elipses":e [arrowhead=none dir=back arrowtail=crowodot]; "buy_report_income_expenditure_managements":"income_expenditure_management_id":w -> "income_expenditure_managements":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations":"elipses":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "financial_records":"elipses":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "income_expenditure_managements":"year_id":w -> "years":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "income_income_expenditure_managements":"income_expenditure_id":w -> "income_expenditure_managements":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; @@ -45,6 +46,17 @@ digraph "twoDegreesRelationshipsDiagram" { target="_top" tooltip="buy_reports" ]; + "campus_donations" [ + label=< + + + + +
campus_donations[table]
...
< 12 rows
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "financial_records" [ label=< @@ -132,7 +144,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
years[table]
id
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/income_expenditure_managements.2degrees.png b/er/diagrams/tables/income_expenditure_managements.2degrees.png index 943ddb2cc..1e027bfc6 100644 Binary files a/er/diagrams/tables/income_expenditure_managements.2degrees.png and b/er/diagrams/tables/income_expenditure_managements.2degrees.png differ diff --git a/er/diagrams/tables/income_income_expenditure_managements.2degrees.dot b/er/diagrams/tables/income_income_expenditure_managements.2degrees.dot index d6c101c3c..0921137dd 100644 --- a/er/diagrams/tables/income_income_expenditure_managements.2degrees.dot +++ b/er/diagrams/tables/income_income_expenditure_managements.2degrees.dot @@ -84,7 +84,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
years[table]
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/income_income_expenditure_managements.2degrees.png b/er/diagrams/tables/income_income_expenditure_managements.2degrees.png index d87816664..d763f6c03 100644 Binary files a/er/diagrams/tables/income_income_expenditure_managements.2degrees.png and b/er/diagrams/tables/income_income_expenditure_managements.2degrees.png differ diff --git a/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.dot b/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.dot index 64bb59671..0ff5ecbf8 100644 --- a/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.dot +++ b/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.dot @@ -84,7 +84,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
years[table]
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.png b/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.png index 23ec3fde9..e5cf004e2 100644 Binary files a/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.png and b/er/diagrams/tables/sponsor_activity_balance_managements.2degrees.png differ diff --git a/er/diagrams/tables/sponsors.1degree.dot b/er/diagrams/tables/sponsors.1degree.dot index da59502fc..0a6f9575e 100644 --- a/er/diagrams/tables/sponsors.1degree.dot +++ b/er/diagrams/tables/sponsors.1degree.dot @@ -12,7 +12,7 @@ digraph "oneDegreeRelationshipsDiagram" {
representative
varchar[255]
created_at
datetime[19]
updated_at
datetime[19] -
< 03 rows0 >
+
< 00 rows0 >
> URL="sponsors.html" target="_top" diff --git a/er/diagrams/tables/sponsors.1degree.png b/er/diagrams/tables/sponsors.1degree.png index 77682aad2..7bbf19d81 100644 Binary files a/er/diagrams/tables/sponsors.1degree.png and b/er/diagrams/tables/sponsors.1degree.png differ diff --git a/er/diagrams/tables/spot_sponsor_names.2degrees.dot b/er/diagrams/tables/spot_sponsor_names.2degrees.dot index 1fb2394bd..a03a66bb1 100644 --- a/er/diagrams/tables/spot_sponsor_names.2degrees.dot +++ b/er/diagrams/tables/spot_sponsor_names.2degrees.dot @@ -71,7 +71,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
years[table]
...
3 rows2 >
3 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/spot_sponsor_names.2degrees.png b/er/diagrams/tables/spot_sponsor_names.2degrees.png index 4cb04fecb..b49190795 100644 Binary files a/er/diagrams/tables/spot_sponsor_names.2degrees.png and b/er/diagrams/tables/spot_sponsor_names.2degrees.png differ diff --git a/er/diagrams/tables/years.1degree.dot b/er/diagrams/tables/years.1degree.dot index a6c82582b..e8c167177 100644 --- a/er/diagrams/tables/years.1degree.dot +++ b/er/diagrams/tables/years.1degree.dot @@ -1,7 +1,21 @@ digraph "oneDegreeRelationshipsDiagram" { graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; + "campus_donations":"year_id":w -> "years":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; "financial_records":"year_id":w -> "years":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; "income_expenditure_managements":"year_id":w -> "years":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations" [ + label=< + + + + + + +
campus_donations[table]
id
year_id
...
< 12 rows
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "financial_records" [ label=< @@ -36,7 +50,7 @@ digraph "oneDegreeRelationshipsDiagram" { - +
year
int[10]
created_at
datetime[19]
updated_at
datetime[19]
< 03 rows2 >
< 03 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/years.1degree.png b/er/diagrams/tables/years.1degree.png index 581e95432..bbc888a21 100644 Binary files a/er/diagrams/tables/years.1degree.png and b/er/diagrams/tables/years.1degree.png differ diff --git a/er/diagrams/tables/years.2degrees.dot b/er/diagrams/tables/years.2degrees.dot index 9e9d3cdf6..2a985087b 100644 --- a/er/diagrams/tables/years.2degrees.dot +++ b/er/diagrams/tables/years.2degrees.dot @@ -1,6 +1,7 @@ digraph "twoDegreesRelationshipsDiagram" { graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; "buy_report_income_expenditure_managements":"elipses":w -> "income_expenditure_managements":"id":e [arrowhead=none dir=back arrowtail=crowodot]; + "campus_donations":"year_id":w -> "years":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; "divisions":"elipses":w -> "financial_records":"id":e [arrowhead=none dir=back arrowtail=crowodot]; "financial_records":"year_id":w -> "years":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; "income_expenditure_managements":"year_id":w -> "years":"id.type":e [arrowhead=none dir=back arrowtail=crowodot]; @@ -18,6 +19,19 @@ digraph "twoDegreesRelationshipsDiagram" { target="_top" tooltip="buy_report_income_expenditure_managements" ]; + "campus_donations" [ + label=< + + + + + + +
campus_donations[table]
id
year_id
...
< 12 rows
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "divisions" [ label=< @@ -96,7 +110,7 @@ digraph "twoDegreesRelationshipsDiagram" { - +
year
int[10]
created_at
datetime[19]
updated_at
datetime[19]
< 03 rows2 >
< 03 rows3 >
> URL="years.html" target="_top" diff --git a/er/diagrams/tables/years.2degrees.png b/er/diagrams/tables/years.2degrees.png index 01cba42d8..f6aca75a5 100644 Binary files a/er/diagrams/tables/years.2degrees.png and b/er/diagrams/tables/years.2degrees.png differ diff --git a/er/finansu_db.finansu_db.xml b/er/finansu_db.finansu_db.xml index 176040db2..1aa9f60bd 100644 --- a/er/finansu_db.finansu_db.xml +++ b/er/finansu_db.finansu_db.xml @@ -158,6 +158,28 @@ + + + + + + + + + + + + + + + + + + + + + +
@@ -243,22 +265,6 @@
- - - - - - - - - - - - - - - -
@@ -550,7 +556,7 @@
- +
@@ -648,6 +654,7 @@
+ diff --git a/er/index.html b/er/index.html index de71e32cb..e40d83680 100644 --- a/er/index.html +++ b/er/index.html @@ -78,7 +78,7 @@

Tables


SchemaSpy Analysis of finansu_db.finansu_db

-

Generated on Fri May 02 07:50 UTC 2025

+

Generated on Sat May 24 07:39 UTC 2025

@@ -118,7 +118,7 @@

SchemaSpy Analysis of finansu_db.finansu_db

COLUMNS - 254 + 255
@@ -130,7 +130,7 @@

SchemaSpy Analysis of finansu_db.finansu_db

Constraints - 22 + 23
@@ -241,6 +241,15 @@

Tables

+ + + + + + + + + @@ -304,15 +313,6 @@

Tables

- - - - - - - - - @@ -395,20 +395,20 @@

Tables

- + - + - + - + - + - + @@ -426,7 +426,7 @@

Tables

- + @@ -468,7 +468,7 @@

Tables

- + @@ -530,20 +530,20 @@

Tables

- + - - + + - + - - + + diff --git a/er/info-html.txt b/er/info-html.txt index 1446ed1e1..1b760bc64 100644 --- a/er/info-html.txt +++ b/er/info-html.txt @@ -1,4 +1,4 @@ -date=2025-05-02 07:50:56+0000 +date=2025-05-24 07:39:47+0000 os=Linux 5.15.167.4-microsoft-standard-WSL2 schemaspy-version=7.0.2-SNAPSHOT schemaspy-revision=bf4d5fddd535dd213a512a6a521bcadb8260168d diff --git a/er/insertionOrder.txt b/er/insertionOrder.txt index cdbe46d52..aaa6f75c4 100644 --- a/er/insertionOrder.txt +++ b/er/insertionOrder.txt @@ -13,6 +13,7 @@ income_expenditure_managements buy_reports rooms buy_statuses +campus_donations item_budgets payment_receipts spot_sponsor_names @@ -26,7 +27,6 @@ activity_styles budgets bureaus departments -fund_informations mail_auth password_reset_tokens purchase_items diff --git a/er/orphans.html b/er/orphans.html index 3c947df9d..78daa55ee 100644 --- a/er/orphans.html +++ b/er/orphans.html @@ -85,24 +85,23 @@

Orphan Tables

- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +
diff --git a/er/relationships.html b/er/relationships.html index 98aea75d2..4ff7e69c7 100644 --- a/er/relationships.html +++ b/er/relationships.html @@ -93,93 +93,93 @@
By default only columns that are primary keys, foreign keys or indexes are s
- - + + - - + + - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + - + - - - - + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/er/tables/campus_donations.html b/er/tables/campus_donations.html new file mode 100644 index 000000000..f9aad1542 --- /dev/null +++ b/er/tables/campus_donations.html @@ -0,0 +1,441 @@ + + + + + + campus_donations - finansu_db.finansu_db + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + +
+ +
+

campus_donations

2 rows


+
+ +
+
+
+ +

Columns

+
+ + +
+
+
+
Table
campus_donations01112Table
receipts 0 Table
fund_informations00102Table
user_groups 0
item_budgetsincome_income_expenditure_managements 012 570 Table
income_income_expenditure_managementsitem_budgets 021 507 Table
0 0 830 Table
years23 0 4 3
usersteachers 1 074100 Table
teachersusers 1 010074 Table
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ColumnTypeSizeNullsAutoDefaultChildrenParentsComments
idINT UNSIGNED10null + +
+
+ +
+
user_idINT10null + +
+
+ +
+
teacher_idINT10null + +
+
+ +
+
year_idINT UNSIGNED10null + +
+
+ + + + + + +
years.idcampus_donations_ibfk_1C
+
priceINT10null + +
+
+ +
+
remarkVARCHAR255null + +
+
+ +
+
is_first_checkBIT1null + +
+
+ +
+
is_last_checkBIT1null + +
+
+ +
+
received_atVARCHAR255null + +
+
+ +
+
created_atDATETIME19CURRENT_TIMESTAMP + +
+
+ +
+
updated_atDATETIME19CURRENT_TIMESTAMP + +
+
+ +
+
+
+
+
+
+ +

Indexes

+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Constraint NameTypeSortColumn(s)
PRIMARYPrimary keyAscid
year_idPerformanceAscyear_id
+
+
+
+
+ +

Relationships

+
+ + +
+
+
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/er/tables/financial_records.html b/er/tables/financial_records.html index 712833fff..6c5199686 100644 --- a/er/tables/financial_records.html +++ b/er/tables/financial_records.html @@ -276,12 +276,13 @@
Close relationships within degrees of separation
- - - - - - + + + + + + +
diff --git a/er/tables/income_expenditure_managements.html b/er/tables/income_expenditure_managements.html index f5a8ed683..2d7485d18 100644 --- a/er/tables/income_expenditure_managements.html +++ b/er/tables/income_expenditure_managements.html @@ -346,15 +346,16 @@
Close relationships within degrees of separation
- - - - - - - - - + + + + + + + + + +
diff --git a/er/tables/sponsors.html b/er/tables/sponsors.html index 4fa9b8972..148ec60e6 100644 --- a/er/tables/sponsors.html +++ b/er/tables/sponsors.html @@ -73,7 +73,7 @@
-

sponsors

3 rows


+

sponsors

0 rows


diff --git a/er/tables/years.html b/er/tables/years.html index 0b98f1454..9d18e5f29 100644 --- a/er/tables/years.html +++ b/er/tables/years.html @@ -117,6 +117,11 @@

Columns

null + + + + + @@ -245,22 +250,24 @@
Close relationships within degrees of separation
- - - + + + +
- - - - - - - + + + + + + + +
diff --git a/mysql/db/01_years.sql b/mysql/db/01_years.sql deleted file mode 100644 index db2a0eded..000000000 --- a/mysql/db/01_years.sql +++ /dev/null @@ -1,17 +0,0 @@ -use finansu_db; - -CREATE TABLE - years ( - id int(10) unsigned not null auto_increment, - year int(10) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - years (year) -VALUES - (2023), - (2024), - (2025); diff --git a/mysql/db/02_users.sql b/mysql/db/02_users.sql deleted file mode 100644 index 88cf38ac8..000000000 --- a/mysql/db/02_users.sql +++ /dev/null @@ -1,26 +0,0 @@ -use finansu_db; - -CREATE TABLE - users ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - bureau_id int(10) not null, - role_id int(10) not null, - is_deleted boolean DEFAULT false, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - --- ユーザーを一括で挿入 -INSERT INTO - users (name, bureau_id, role_id) -VALUES - -- 一般ユーザー - ('技大太郎1', 1, 1), - -- 管理者ユーザー - ('技大太郎2', 6, 2), - -- 財務局長 - ('技大太郎3', 3, 3), - -- 財務局員 - ('技大太郎4', 3, 4); diff --git a/mysql/db/03_financial_records.sql b/mysql/db/03_financial_records.sql deleted file mode 100644 index acc4613b8..000000000 --- a/mysql/db/03_financial_records.sql +++ /dev/null @@ -1,18 +0,0 @@ -USE finansu_db; - -CREATE TABLE - financial_records ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - name VARCHAR(255) NOT NULL, - year_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY year_id_foreign_key (year_id) REFERENCES years (id) ON DELETE CASCADE - ); - -INSERT INTO - financial_records (name, year_id) -VALUES - ('総務局', 3), - ('渉外局', 3); diff --git a/mysql/db/04_divisions.sql b/mysql/db/04_divisions.sql deleted file mode 100644 index c24713551..000000000 --- a/mysql/db/04_divisions.sql +++ /dev/null @@ -1,21 +0,0 @@ -USE finansu_db; - -CREATE TABLE - divisions ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - name VARCHAR(255) NOT NULL, - financial_record_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY financial_record_id_foreign_key (financial_record_id) REFERENCES financial_records (id) ON DELETE CASCADE - ); - --- データを一括で挿入 -INSERT INTO - divisions (name, financial_record_id) -VALUES - ('衛生管理部門', 1), - ('国際部門', 1), - ('広報部門', 2), - ('ゲスト部門', 2); diff --git a/mysql/db/05_festival_items.sql b/mysql/db/05_festival_items.sql deleted file mode 100644 index 66acb27aa..000000000 --- a/mysql/db/05_festival_items.sql +++ /dev/null @@ -1,24 +0,0 @@ -USE finansu_db; - -CREATE TABLE - festival_items ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - name VARCHAR(255) NOT NULL, - memo VARCHAR(255), - division_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY division_id_foreign_key (division_id) REFERENCES divisions (id) ON DELETE CASCADE - ); - -INSERT INTO - festival_items (name, memo, division_id) -VALUES - ('農ポリ', '', 1), - ('養生テープ', '', 1), - ('ラミ', '', 2), - ('広報物郵送費', '', 3), - ('折込チラシ用費', '', 3), - ('ゲストブッキング費', '', 4), - ('ゲスト用菓子折り費', '', 4); diff --git a/mysql/db/06_item_budgets.sql b/mysql/db/06_item_budgets.sql deleted file mode 100644 index 1cbc6eecb..000000000 --- a/mysql/db/06_item_budgets.sql +++ /dev/null @@ -1,23 +0,0 @@ -USE finansu_db; - -CREATE TABLE - item_budgets ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - amount INT(10) NOT NULL, - festival_item_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY festival_item_id_foreign_key (festival_item_id) REFERENCES festival_items (id) ON DELETE CASCADE - ); - -INSERT INTO - item_budgets (amount, festival_item_id) -VALUES - (10000, 1), - (10000, 2), - (10000, 3), - (20000, 4), - (50000, 5), - (1500000, 6), - (10000, 7); diff --git a/mysql/db/07_user_groups.sql b/mysql/db/07_user_groups.sql deleted file mode 100644 index babb1ca2b..000000000 --- a/mysql/db/07_user_groups.sql +++ /dev/null @@ -1,20 +0,0 @@ -USE finansu_db; - -CREATE TABLE - user_groups ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - user_id INT(10) UNSIGNED NOT NULL, - group_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY user_id_foreign_key (user_id) REFERENCES users (id) ON DELETE CASCADE, - FOREIGN KEY group_id_foreign_key (group_id) REFERENCES divisions (id) ON DELETE CASCADE - ); - -INSERT INTO - user_groups (user_id, group_id) -VALUES - (1, 1), - (1, 2), - (2, 3); diff --git a/mysql/db/08_buy_reports.sql b/mysql/db/08_buy_reports.sql deleted file mode 100644 index aed147817..000000000 --- a/mysql/db/08_buy_reports.sql +++ /dev/null @@ -1,26 +0,0 @@ -USE finansu_db; - -CREATE TABLE - buy_reports ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - festival_item_id INT(10) UNSIGNED NOT NULL, - amount INT(10) NOT NULL, - memo VARCHAR(255) NOT NULL, - paid_by VARCHAR(255) NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY festival_item_id_foreign_key (festival_item_id) REFERENCES festival_items (id) ON DELETE CASCADE - ); - --- データを一括で挿入 -INSERT INTO - buy_reports (festival_item_id, amount, memo, paid_by) -VALUES - (1, 5000, '', 'テスト太郎'), - (1, 4000, '', 'テスト太郎'), - (2, 5000, '', 'テスト太郎'), - (3, 2000, '', 'テスト2太郎'), - (3, 2000, '', 'テスト2太郎'), - (3, 2000, '', 'テスト2太郎'), - (4, 10000, '', 'テスト3太郎'); diff --git a/mysql/db/09_payment_receipts.sql b/mysql/db/09_payment_receipts.sql deleted file mode 100644 index eb8e0147a..000000000 --- a/mysql/db/09_payment_receipts.sql +++ /dev/null @@ -1,22 +0,0 @@ -USE finansu_db; - -CREATE TABLE - payment_receipts ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - buy_report_id INT(10) UNSIGNED NOT NULL, - bucket_name VARCHAR(255) NOT NULL, - file_name VARCHAR(255) NOT NULL, - file_type VARCHAR(255) NOT NULL, - remark VARCHAR(255), - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY buy_report_id_foreign_key (buy_report_id) REFERENCES buy_reports (id) ON DELETE CASCADE - ); - -INSERT INTO - payment_receipts (buy_report_id, bucket_name, file_name, file_type, remark) -VALUES - (1, 'payment-receipts', 'receipt-1.jpg', 'image/jpeg', ''), - (2, 'payment-receipts', 'receipt-2.jpg', 'image/jpeg', ''), - (3, 'payment-receipts', 'receipt-3.jpg', 'image/jpeg', ''); diff --git a/mysql/db/10_buy_statuses.sql b/mysql/db/10_buy_statuses.sql deleted file mode 100644 index d03be71fc..000000000 --- a/mysql/db/10_buy_statuses.sql +++ /dev/null @@ -1,24 +0,0 @@ -USE finansu_db; - -CREATE TABLE - buy_statuses ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - buy_report_id INT(10) UNSIGNED NOT NULL, - is_packed BOOLEAN NOT NULL DEFAULT FALSE, - is_settled BOOLEAN NOT NULL DEFAULT FALSE, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY buy_report_id_foreign_key (buy_report_id) REFERENCES buy_reports (id) ON DELETE CASCADE - ); - -INSERT INTO - buy_statuses (buy_report_id, is_packed, is_settled) -VALUES - (1, TRUE, TRUE), - (2, TRUE, FALSE), - (3, TRUE, FALSE), - (4, FALSE, FALSE), - (5, FALSE, FALSE), - (6, TRUE, FALSE), - (7, FALSE, FALSE); diff --git a/mysql/db/11_income_expenditure_managements.sql b/mysql/db/11_income_expenditure_managements.sql deleted file mode 100644 index dc41a844d..000000000 --- a/mysql/db/11_income_expenditure_managements.sql +++ /dev/null @@ -1,31 +0,0 @@ -USE finansu_db; - -CREATE TABLE - income_expenditure_managements ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - amount INT(10) NOT NULL, - log_category ENUM("income", "expenditure", "sponsor's income") NOT NULL, - year_id INT(10) UNSIGNED NOT NULL, - receive_option ENUM("transfer", "hand"), -- expenditureはNULLを許可する - is_checked BOOLEAN NOT NULL DEFAULT FALSE, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY year_id_foreign_key (year_id) REFERENCES years (id) ON DELETE CASCADE - ); - -USE finansu_db; - --- income_expenditure_managements のシードデータ挿入 -INSERT INTO - income_expenditure_managements (amount, log_category, year_id, receive_option, is_checked, created_at, updated_at) -VALUES - (50000, "income", 3, "hand", FALSE, NOW(), NOW()), - (100000, "sponsor's income", 3, "transfer", FALSE, NOW(), NOW()), - (5000, "expenditure", 3, NULL, FALSE, NOW(), NOW()), - (4000, "expenditure", 3, NULL, FALSE, NOW(), NOW()), - (5000, "expenditure", 3, NULL, FALSE, NOW(), NOW()), - (2000, "expenditure", 3, NULL, FALSE, NOW(), NOW()), - (2000, "expenditure", 3, NULL, FALSE, NOW(), NOW()), - (2000, "expenditure", 3, NULL, FALSE, NOW(), NOW()), - (10000, "expenditure", 3, NULL, FALSE, NOW(), NOW()); diff --git a/mysql/db/12_buy_report_income_expenditure_managements.sql b/mysql/db/12_buy_report_income_expenditure_managements.sql deleted file mode 100644 index 544b48e2e..000000000 --- a/mysql/db/12_buy_report_income_expenditure_managements.sql +++ /dev/null @@ -1,29 +0,0 @@ -USE finansu_db; - --- buy_reportとincome_expenditure_managementsの中間テーブル -CREATE TABLE - buy_report_income_expenditure_managements ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - buy_report_id INT(10) UNSIGNED NOT NULL, - income_expenditure_management_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY buy_report_id_foreign_key (buy_report_id) REFERENCES buy_reports (id) ON DELETE CASCADE, - FOREIGN KEY income_expenditure_management_id_foreign_key (income_expenditure_management_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE - ); - --- シードデータ挿入 --- buy_report_income_expenditure_managements のシードデータ挿入 -INSERT INTO - buy_report_income_expenditure_managements (buy_report_id, income_expenditure_management_id, created_at, updated_at) -VALUES - (1, 3, NOW(), NOW()), -- buy_reports.id: 1 と income_expenditure_managements.id: 3 の対応 - (2, 4, NOW(), NOW()), -- buy_reports.id: 2 と income_expenditure_managements.id: 4 の対応 - (3, 5, NOW(), NOW()), -- buy_reports.id: 3 と income_expenditure_managements.id: 5 の対応 - (4, 6, NOW(), NOW()), -- buy_reports.id: 4 と income_expenditure_managements.id: 6 の対応 - (5, 7, NOW(), NOW()), -- buy_reports.id: 5 と income_expenditure_managements.id: 7 の対応 - (6, 8, NOW(), NOW()), -- buy_reports.id: 6 と income_expenditure_managements.id: 8 の対応 - (7, 9, NOW(), NOW()); - --- buy_reports.id: 7 と income_expenditure_managements.id: 9 の対応 diff --git a/mysql/db/13_activities.sql b/mysql/db/13_activities.sql deleted file mode 100644 index 83d43811e..000000000 --- a/mysql/db/13_activities.sql +++ /dev/null @@ -1,41 +0,0 @@ -use finansu_db; - -CREATE TABLE - activities ( - id int(10) unsigned not null auto_increment, - user_id int(10), - is_done boolean, - sponsor_id int(10), - feature varchar(255), - expense int(10), - remark varchar(255), - design int(10), - url varchar(255), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - activities (user_id, is_done, sponsor_id, feature, expense, remark, design, url) -VALUES - (1, false, 1, "なし", 11, "", 1, ""), - (2, false, 2, "クーポン", 22, "味玉or大盛無料", 1, ""); - -CREATE TABLE - activity_styles ( - id int(10) unsigned not null auto_increment, - activity_id int(10), - sponsor_style_id int(10), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - activity_styles (activity_id, sponsor_style_id) -VALUES - (1, 1), - (2, 2), - (1, 2), - (2, 1); diff --git a/mysql/db/14_sponsor_activity_balance_managements.sql b/mysql/db/14_sponsor_activity_balance_managements.sql deleted file mode 100644 index fb95bbedb..000000000 --- a/mysql/db/14_sponsor_activity_balance_managements.sql +++ /dev/null @@ -1,13 +0,0 @@ -USE finansu_db; - -CREATE TABLE - sponsor_activity_balance_managements ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - sponsor_activity_id INT(10) UNSIGNED NOT NULL, - income_expenditure_management_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY sponsor_activity_id_foreign_key (sponsor_activity_id) REFERENCES activities (id) ON DELETE CASCADE, - FOREIGN KEY income_expenditure_management_id_foreign_key (income_expenditure_management_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE - ); diff --git a/mysql/db/15_activity_informations.sql b/mysql/db/15_activity_informations.sql deleted file mode 100644 index d38bbb010..000000000 --- a/mysql/db/15_activity_informations.sql +++ /dev/null @@ -1,15 +0,0 @@ -use finansu_db; - -CREATE TABLE - activity_informations ( - id int(10) unsigned not null auto_increment, - activity_id int(10), - bucket_name varchar(255), - file_name varchar(255), - file_type varchar(255), - design_progress int(10), - file_information varchar(255), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); diff --git a/mysql/db/16_budgets.sql b/mysql/db/16_budgets.sql deleted file mode 100644 index 5ae22e23f..000000000 --- a/mysql/db/16_budgets.sql +++ /dev/null @@ -1,17 +0,0 @@ -use finansu_db; - -CREATE TABLE - budgets ( - id int(10) unsigned not null auto_increment, - price int(10) not null, - year_id int(10), - source_id int(10), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT into - budgets (price, year_id, source_id) -values - (10000, 1, 1); diff --git a/mysql/db/17_bureau.sql b/mysql/db/17_bureau.sql deleted file mode 100644 index 6b3592301..000000000 --- a/mysql/db/17_bureau.sql +++ /dev/null @@ -1,20 +0,0 @@ -use finansu_db; - -CREATE TABLE - bureaus ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - bureaus (name) -VALUES - ('総務局'), - ('渉外局'), - ('財務局'), - ('企画局'), - ('制作局'), - ('情報局'); diff --git a/mysql/db/18_departments.sql b/mysql/db/18_departments.sql deleted file mode 100644 index 1d010616e..000000000 --- a/mysql/db/18_departments.sql +++ /dev/null @@ -1,27 +0,0 @@ -use finansu_db; - -CREATE TABLE - departments ( - id int(10) unsigned not null auto_increment, - name varchar(255), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - departments (name) -VALUES - ('電気電子情報'), - ('物質生物'), - ('機械創造'), - ('環境社会基盤'), - ('情報・経営システム'), - ('基盤共通教育'), - ('原子力システム安全'), - ('技術科学イノベーション'), - ('システム安全'), - ('技術支援'), - ('その他'), - ('学長・事務'), - ('FL'); diff --git a/mysql/db/20_fund_informations.sql b/mysql/db/20_fund_informations.sql deleted file mode 100644 index 354f3229a..000000000 --- a/mysql/db/20_fund_informations.sql +++ /dev/null @@ -1,22 +0,0 @@ -use finansu_db; - -CREATE TABLE - fund_informations ( - id int(10) unsigned not null auto_increment, - user_id int(10) not null, - teacher_id int(10) not null, - price int(10) not null, - remark varchar(255), - is_first_check boolean, - is_last_check boolean, - received_at varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - fund_informations (user_id, teacher_id, price, remark, is_first_check, is_last_check, received_at) -VALUES - (1, 1, 2000, "nothing", false, false, '2023-02-22'), - (2, 2, 2000, "nothing", false, false, '2022-02-22'); diff --git a/mysql/db/21_mail_auth.sql b/mysql/db/21_mail_auth.sql deleted file mode 100644 index db78bf044..000000000 --- a/mysql/db/21_mail_auth.sql +++ /dev/null @@ -1,20 +0,0 @@ -use finansu_db; - -CREATE TABLE - mail_auth ( - id int(10) unsigned not null unique auto_increment, - email varchar(255) unique, - password varchar(255) not null, - user_id int(10) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - mail_auth (email, password, user_id) -VALUES - ("test1@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 1), - ("test2@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 2), - ("test3@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 3), - ("test4@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 4); diff --git a/mysql/db/22_password_reset_tokens.sql b/mysql/db/22_password_reset_tokens.sql deleted file mode 100644 index 292d827ab..000000000 --- a/mysql/db/22_password_reset_tokens.sql +++ /dev/null @@ -1,11 +0,0 @@ -use finansu_db; - -CREATE TABLE - password_reset_tokens ( - id int(10) unsigned not null unique auto_increment, - user_id int(10) not null, - token varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); diff --git a/mysql/db/23_purcahse_items.sql b/mysql/db/23_purcahse_items.sql deleted file mode 100644 index 6d38ae884..000000000 --- a/mysql/db/23_purcahse_items.sql +++ /dev/null @@ -1,31 +0,0 @@ -use finansu_db; - -CREATE TABLE - purchase_items ( - id int(10) unsigned not null auto_increment, - item varchar(255), - price int(10), - quantity int(10), - detail varchar(255), - url varchar(255), - purchase_order_id int(10), - finance_check boolean, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - purchase_items (item, price, quantity, detail, url, purchase_order_id, finance_check) -VALUES - ('ビンゴ景品', 10000, 1, 'test-detail', 'https://nutfes.net', 1, true), - ('ヒーロースーツ', 20000, 2, 'test-detail2', 'https://nutfes.net', 1, false), - ('ビンゴ用品', 30000, 3, 'test-detail3', 'https://nutfes.net', 2, true), - ('マイク', 10000, 1, 'test-detail', 'https://nutfes.net', 2, true), - ('机', 20000, 2, 'test-detail2', 'https://nutfes.net', 3, true), - ('椅子', 30000, 3, 'test-detail3', 'https://nutfes.net', 3, false), - ('酒', 10000, 10, 'test-detail', 'https://nutfes.net', 4, true), - ('封筒', 100, 100, 'test-detail2', 'https://nutfes.net', 5, false), - ('領収書', 100, 50, 'test-detail3', 'https://nutfes.net', 6, true), - ('封筒', 100, 100, 'test-detail2', 'https://nutfes.net', 8, false), - ('領収書', 100, 50, 'test-detail3', 'https://nutfes.net', 7, true); diff --git a/mysql/db/24_purchase_orders.sql b/mysql/db/24_purchase_orders.sql deleted file mode 100644 index 2621e65c1..000000000 --- a/mysql/db/24_purchase_orders.sql +++ /dev/null @@ -1,25 +0,0 @@ -use finansu_db; - -CREATE TABLE - purchase_orders ( - id int(10) unsigned not null auto_increment, - deadline varchar(255), - user_id int(10), - expense_id int(10), - finance_check boolean, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - purchase_orders (deadline, user_id, expense_id, finance_check, created_at, updated_at) -VALUES - ('2024-2-22', 1, 1, true, DEFAULT, DEFAULT), - ('2024-3-28', 1, 1, true, DEFAULT, DEFAULT), - ('2024-4-6', 1, 2, true, DEFAULT, DEFAULT), - ('2024-3-28', 1, 3, false, DEFAULT, DEFAULT), - ('2024-4-6', 1, 4, true, DEFAULT, DEFAULT), - ('2024-4-6', 1, 5, true, DEFAULT, DEFAULT), - ('2023-4-6', 1, 4, true, DEFAULT, DEFAULT), - ('2023-4-6', 1, 5, true, DEFAULT, DEFAULT); diff --git a/mysql/db/26_purchase_reports.sql b/mysql/db/26_purchase_reports.sql deleted file mode 100644 index a73e2fb88..000000000 --- a/mysql/db/26_purchase_reports.sql +++ /dev/null @@ -1,26 +0,0 @@ -use finansu_db; - -CREATE TABLE - purchase_reports ( - id int(10) unsigned not null auto_increment, - user_id int(10), - discount int(10), - addition int(10), - finance_check boolean, - purchase_order_id int(10), - remark varchar(255), - buyer varchar(255), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - purchase_reports (user_id, discount, addition, finance_check, purchase_order_id, remark, buyer) -VALUES - (1, 100, 200, true, 2, 'test-remark', '技大太郎1'), - (1, 0, 0, false, 1, 'test-remark2', '技大太郎2'), - (1, 400, 800, true, 3, 'test-remark3', '技大太郎3'), - (1, 400, 800, true, 4, 'test-remark3', '技大太郎3'), - (1, 400, 800, true, 5, 'test-remark3', '技大太郎3'), - (1, 400, 800, true, 6, 'test-remark3', '技大太郎1'); diff --git a/mysql/db/27_receipts.sql b/mysql/db/27_receipts.sql deleted file mode 100644 index fd42364be..000000000 --- a/mysql/db/27_receipts.sql +++ /dev/null @@ -1,14 +0,0 @@ -use finansu_db; - -CREATE TABLE - receipts ( - id int(10) unsigned not null auto_increment, - purchase_report_id int(10) not null, - bucket_name varchar(255), - file_name varchar(255), - file_type varchar(255), - remark varchar(255), - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); diff --git a/mysql/db/28_roles.sql b/mysql/db/28_roles.sql deleted file mode 100644 index 42fb67d87..000000000 --- a/mysql/db/28_roles.sql +++ /dev/null @@ -1,18 +0,0 @@ -use finansu_db; - -CREATE TABLE - roles ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - roles (name) -VALUES - ('user'), - ('admin'), - ('Finance Director'), - ('Finance Staff'); diff --git a/mysql/db/29_session.sql b/mysql/db/29_session.sql deleted file mode 100644 index 00aa51af6..000000000 --- a/mysql/db/29_session.sql +++ /dev/null @@ -1,12 +0,0 @@ -use finansu_db; - -CREATE TABLE - session ( - id int(10) unsigned not null unique auto_increment, - auth_id int(10) not null, - user_id int(10) not null, - access_token varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (auth_id) - ); diff --git a/mysql/db/30_sources.sql b/mysql/db/30_sources.sql deleted file mode 100644 index 530e51899..000000000 --- a/mysql/db/30_sources.sql +++ /dev/null @@ -1,15 +0,0 @@ -use finansu_db; - -CREATE TABLE - sources ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT into - sources (name) -values - ('教育振興会費'); diff --git a/mysql/db/31_sponsor_styles.sql b/mysql/db/31_sponsor_styles.sql deleted file mode 100644 index 960a260b0..000000000 --- a/mysql/db/31_sponsor_styles.sql +++ /dev/null @@ -1,26 +0,0 @@ -use finansu_db; - -CREATE TABLE - sponsor_styles ( - id int(10) unsigned not null auto_increment, - style varchar(255) not null, - feature varchar(255) not null, - price int(10), - is_deleted boolean default false, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - sponsor_styles (style, feature, price) -VALUES - ('8分の1', 'モノクロ', 3000), - ('8分の1', 'カラー', 5000), - ('4分の1', 'モノクロ', 8000), - ('4分の1', 'カラー', 10000), - ('2分の1', 'モノクロ', 12000), - ('2分の1', 'カラー', 15000), - ('1ページ', 'モノクロ', 20000), - ('2ページ', 'カラー', 30000), - ('企業ブース', 'なし', 30000); diff --git a/mysql/db/32_sponsors.sql b/mysql/db/32_sponsors.sql deleted file mode 100644 index ee193e82f..000000000 --- a/mysql/db/32_sponsors.sql +++ /dev/null @@ -1,21 +0,0 @@ -use finansu_db; - -CREATE TABLE - sponsors ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - tel varchar(255) not null, - email varchar(255) not null, - address varchar(255) not null, - representative varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - sponsors (name, tel, email, address, representative) -VALUES - ('テスト企業', '00000000000', 'test@nutfes.com', '新潟県長岡市上富岡町', '技大太郎'), - ('テスト企業2', '08000000000', 'test2@nutfes.com', '新潟県長岡市上富岡町', 'いまいまい'), - ('テスト企業3', '09000000000', 'test3@nutfes.com', '新潟県長岡市上富岡町', 'いまいまい2'); diff --git a/mysql/db/33_teachers.sql b/mysql/db/33_teachers.sql deleted file mode 100644 index 7245520b2..000000000 --- a/mysql/db/33_teachers.sql +++ /dev/null @@ -1,22 +0,0 @@ -use finansu_db; - -CREATE TABLE - teachers ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - position varchar(255) not null, - department_id int(10), - room varchar(255), - is_black boolean, - remark varchar(255), - is_deleted boolean default false, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - teachers (name, position, department_id, room, is_black, remark) -VALUES - ('test-name', 'test-position', 1, '605', false, 'test-remark'), - ('test-teacher', 'test-position2', 1, '605', false, 'test-remark'); diff --git a/mysql/db/35_year_periods.sql b/mysql/db/35_year_periods.sql deleted file mode 100644 index 4de210813..000000000 --- a/mysql/db/35_year_periods.sql +++ /dev/null @@ -1,19 +0,0 @@ -use finansu_db; - -CREATE TABLE - year_periods ( - id int(10) unsigned not null auto_increment, - year_id int(10) not null, - started_at datetime not null, - ended_at datetime not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - year_periods (year_id, started_at, ended_at) -VALUES - (1, '2022-11-15 00:00:00', '2023-11-15 00:00:00'), - (2, '2023-11-15 00:00:00', '2024-11-15 00:00:00'), - (3, '2024-11-15 00:00:00', '2025-11-15 00:00:00'); diff --git a/mysql/db/36_incomes.sql b/mysql/db/36_incomes.sql deleted file mode 100644 index eaf263cbe..000000000 --- a/mysql/db/36_incomes.sql +++ /dev/null @@ -1,20 +0,0 @@ -USE finansu_db; - -CREATE TABLE - incomes ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, -- 自動採番のID - name VARCHAR(255) NOT NULL, -- 名前 - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 作成日時 - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- 更新日時 - PRIMARY KEY (id) -- 主キー - ); - -INSERT INTO - incomes (name, created_at, updated_at) -VALUES - ("教育振興会費", NOW(), NOW()), - ("学内募金", NOW(), NOW()), - ("同窓会費", NOW(), NOW()), - ("雑収入", NOW(), NOW()), - ("繰越金", NOW(), NOW()), - ("企業協賛金", NOW(), NOW()); diff --git a/mysql/db/37_ income_income_expenditure_managements.sql b/mysql/db/37_ income_income_expenditure_managements.sql deleted file mode 100644 index 45d9e0c83..000000000 --- a/mysql/db/37_ income_income_expenditure_managements.sql +++ /dev/null @@ -1,20 +0,0 @@ -USE finansu_db; - -CREATE TABLE - income_income_expenditure_managements ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - income_expenditure_id INT(10) UNSIGNED NOT NULL, - income_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY (income_expenditure_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE, - FOREIGN KEY (income_id) REFERENCES incomes (id) ON DELETE CASCADE - ); - --- シードデータ挿入 -INSERT INTO - income_income_expenditure_managements (income_expenditure_id, income_id, created_at, updated_at) -VALUES - (1, 4, NOW(), NOW()), - (2, 6, NOW(), NOW()); diff --git a/mysql/db/38_buildings.sql b/mysql/db/38_buildings.sql deleted file mode 100644 index 0adfb375b..000000000 --- a/mysql/db/38_buildings.sql +++ /dev/null @@ -1,38 +0,0 @@ -use finansu_db; - -CREATE TABLE - buildings ( - id int(10) unsigned not null auto_increment, - name varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); - -INSERT INTO - buildings (name) -VALUES - ('機械・建設棟'), - ('電気棟'), - ('生物棟'), - ('環境・システム棟'), - ('物質・材料経営情報棟'), - ('総合研究棟'), - ('原子力・システム安全棟'), - ('事務局棟'), - ('極限エネルギ密度工学研究センター'), - ('工作センター'), - ('大型実験棟'), - ('分析計測センター'), - ('その他'); - --- INSERT INTO buildings (name) VALUES ('実験実習棟'); --- INSERT INTO buildings (name) VALUES ('博士棟'); --- INSERT INTO buildings (name) VALUES ('ラジオアイソトープセンター'); --- INSERT INTO buildings (name) VALUES ('体育保健センター'); --- INSERT INTO buildings (name) VALUES ('語学センター'); --- INSERT INTO buildings (name) VALUES ('情報処理センター'); --- INSERT INTO buildings (name) VALUES ('マルチメディアセンター'); --- INSERT INTO buildings (name) VALUES ('GX棟'); --- INSERT INTO buildings (name) VALUES ('学長室'); --- INSERT INTO buildings (name) VALUES ('理事室'); diff --git a/mysql/db/39_building_units.sql b/mysql/db/39_building_units.sql deleted file mode 100644 index e811d85f5..000000000 --- a/mysql/db/39_building_units.sql +++ /dev/null @@ -1,32 +0,0 @@ -use finansu_db -CREATE TABLE - building_units ( - id int(10) unsigned not null auto_increment, - building_id int(10) unsigned not null default 1, - unit_number varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id), - FOREIGN KEY (building_id) REFERENCES buildings (id) - ); - -INSERT INTO - building_units (building_id, unit_number) -VALUES - (1, "1号棟"), - (1, "2号棟"), - (1, "3号棟"), - (2, "1号棟"), - (2, "2号棟"), - (3, "1号棟"), - (4, "1号棟"), - (5, "1号棟"), - (5, "2号棟"), - (6, "1号棟"), - (7, "1号棟"), - (8, "1号棟"), - (9, "1号棟"), - (10, "1号棟"), - (11, "1号棟"), - (12, "1号棟"), - (13, "1号棟"); diff --git a/mysql/db/40_floors.sql b/mysql/db/40_floors.sql deleted file mode 100644 index b5ef6fdce..000000000 --- a/mysql/db/40_floors.sql +++ /dev/null @@ -1,16 +0,0 @@ -use finansu_db -CREATE TABLE - floors ( - id int(10) unsigned not null auto_increment, - building_unit_id int(10) unsigned not null, - floor_number varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id), - FOREIGN KEY (building_unit_id) REFERENCES building_units (id) - ); - -INSERT INTO - floors (id, building_unit_id, floor_number) -VALUES - (1, 1, "1F"); diff --git a/mysql/db/41_rooms.sql b/mysql/db/41_rooms.sql deleted file mode 100644 index 7a1faac22..000000000 --- a/mysql/db/41_rooms.sql +++ /dev/null @@ -1,16 +0,0 @@ -use finansu_db -CREATE TABLE - rooms ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - floor_id INT(10) UNSIGNED not null, - room_name varchar(255) NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY (floor_id) REFERENCES floors (id) - ); - -INSERT INTO - rooms (floor_id, room_name) -VALUES - (1, 'test部屋') diff --git a/mysql/db/42_init_create_db.sh b/mysql/db/42_init_create_db.sh deleted file mode 100755 index 740e1c3ca..000000000 --- a/mysql/db/42_init_create_db.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# エラーが発生したらスクリプトを終了 -set -e - -# docker-entrypoint-testdb.d内のSQLファイルを順番に実行 -for sql_file in docker-entrypoint-testdb.d/*.sql; do - if [ -f "$sql_file" ]; then - mysql -u root -p$MYSQL_ROOT_PASSWORD < "$sql_file" - else - echo "SQLファイルが見つかりません: docker-entrypoint-testdb.d" - fi -done - -echo "すべてのSQLファイルを実行" diff --git a/mysql/db/42_room_teachers.sql b/mysql/db/42_room_teachers.sql deleted file mode 100644 index 10cfae34c..000000000 --- a/mysql/db/42_room_teachers.sql +++ /dev/null @@ -1,18 +0,0 @@ -use finansu_db --- roomsとteachersの中間テーブル -CREATE TABLE - room_teachers ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - room_id INT(10) unsigned not null, - teacher_id INT(10) unsigned not null, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY (room_id) REFERENCES rooms (id) ON DELETE CASCADE, - FOREIGN KEY (teacher_id) REFERENCES teachers (id) ON DELETE CASCADE - ); - -INSERT INTO - room_teachers (room_id, teacher_id) -VALUES - (1, 1) diff --git a/mysql/db/99_spot_sponsor_names.sql b/mysql/db/99_spot_sponsor_names.sql deleted file mode 100644 index c9a166d49..000000000 --- a/mysql/db/99_spot_sponsor_names.sql +++ /dev/null @@ -1,21 +0,0 @@ -USE finansu_db; - --- 2025年度の企業協賛の名前を登録するようのspotのテーブル -CREATE TABLE - spot_sponsor_names ( - id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - sponsor_name VARCHAR(255) NOT NULL, - income_expenditure_id INT(10) UNSIGNED NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (id), - FOREIGN KEY (income_expenditure_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE - ); - -USE finansu_db; - --- シードデータ挿入 -INSERT INTO - spot_sponsor_names (sponsor_name, income_expenditure_id, created_at, updated_at) -VALUES - ("株式会社やばたにえん", 3, NOW(), NOW()); diff --git a/mysql/migrations/000001_initial_schema.down.sql b/mysql/migrations/000001_initial_schema.down.sql new file mode 100644 index 000000000..c1054a244 --- /dev/null +++ b/mysql/migrations/000001_initial_schema.down.sql @@ -0,0 +1,70 @@ +-- テーブル削除のSQL文 +DROP TABLE IF EXISTS spot_sponsor_names; + +DROP TABLE IF EXISTS campus_donations; + +DROP TABLE IF EXISTS room_teachers; + +DROP TABLE IF EXISTS rooms; + +DROP TABLE IF EXISTS floors; + +DROP TABLE IF EXISTS building_units; + +DROP TABLE IF EXISTS buildings; + +DROP TABLE IF EXISTS income_income_expenditure_managements; + +DROP TABLE IF EXISTS incomes; + +DROP TABLE IF EXISTS year_periods; + +DROP TABLE IF EXISTS teachers; + +DROP TABLE IF EXISTS sponsors; + +DROP TABLE IF EXISTS sponsor_styles; + +DROP TABLE IF EXISTS session; + +DROP TABLE IF EXISTS roles; + +DROP TABLE IF EXISTS password_reset_tokens; + +DROP TABLE IF EXISTS mail_auth; + +DROP TABLE IF EXISTS departments; + +DROP TABLE IF EXISTS bureaus; + +DROP TABLE IF EXISTS activity_informations; + +DROP TABLE IF EXISTS sponsor_activity_balance_managements; + +DROP TABLE IF EXISTS activity_styles; + +DROP TABLE IF EXISTS activities; + +DROP TABLE IF EXISTS buy_report_income_expenditure_managements; + +DROP TABLE IF EXISTS income_expenditure_managements; + +DROP TABLE IF EXISTS buy_statuses; + +DROP TABLE IF EXISTS payment_receipts; + +DROP TABLE IF EXISTS buy_reports; + +DROP TABLE IF EXISTS user_groups; + +DROP TABLE IF EXISTS item_budgets; + +DROP TABLE IF EXISTS festival_items; + +DROP TABLE IF EXISTS divisions; + +DROP TABLE IF EXISTS financial_records; + +DROP TABLE IF EXISTS users; + +DROP TABLE IF EXISTS years; diff --git a/mysql/migrations/000001_initial_schema.up.sql b/mysql/migrations/000001_initial_schema.up.sql new file mode 100644 index 000000000..1e08caf44 --- /dev/null +++ b/mysql/migrations/000001_initial_schema.up.sql @@ -0,0 +1,445 @@ +-- 年度テーブル +CREATE TABLE + years ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + year INT(10) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- ユーザーテーブル +CREATE TABLE + users ( + id int(10) unsigned not null auto_increment, + name VARCHAR(255) NOT NULL, + bureau_id INT(10) NOT NULL, + role_id INT(10) NOT NULL, + is_deleted BOOLEAN DEFAULT false, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 局・予算テーブル +CREATE TABLE + financial_records ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + year_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY year_id_foreign_key (year_id) REFERENCES years (id) ON DELETE CASCADE + ); + +-- 部門テーブル +CREATE TABLE + divisions ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + financial_record_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY financial_record_id_foreign_key (financial_record_id) REFERENCES financial_records (id) ON DELETE CASCADE + ); + +-- 物品テーブル +CREATE TABLE + festival_items ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + memo VARCHAR(255), + division_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY division_id_foreign_key (division_id) REFERENCES divisions (id) ON DELETE CASCADE + ); + +-- 予算テーブル +CREATE TABLE + item_budgets ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + amount INT(10) NOT NULL, + festival_item_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY festival_item_id_foreign_key (festival_item_id) REFERENCES festival_items (id) ON DELETE CASCADE + ); + +-- ユーザー部門テーブル +CREATE TABLE + user_groups ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + user_id INT(10) UNSIGNED NOT NULL, + group_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY user_id_foreign_key (user_id) REFERENCES users (id) ON DELETE CASCADE, + FOREIGN KEY group_id_foreign_key (group_id) REFERENCES divisions (id) ON DELETE CASCADE + ); + +-- 購入報告テーブル +CREATE TABLE + buy_reports ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + festival_item_id INT(10) UNSIGNED NOT NULL, + amount INT(10) NOT NULL, + memo VARCHAR(255) NOT NULL, + paid_by VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY festival_item_id_foreign_key (festival_item_id) REFERENCES festival_items (id) ON DELETE CASCADE + ); + +-- 購入レシートテーブル +CREATE TABLE + payment_receipts ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + buy_report_id INT(10) UNSIGNED NOT NULL, + bucket_name VARCHAR(255) NOT NULL, + file_name VARCHAR(255) NOT NULL, + file_type VARCHAR(255) NOT NULL, + remark VARCHAR(255), + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY buy_report_id_foreign_key (buy_report_id) REFERENCES buy_reports (id) ON DELETE CASCADE + ); + +-- 購入ステータステーブル +CREATE TABLE + buy_statuses ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + buy_report_id INT(10) UNSIGNED NOT NULL, + is_packed BOOLEAN NOT NULL DEFAULT FALSE, + is_settled BOOLEAN NOT NULL DEFAULT FALSE, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY buy_report_id_foreign_key (buy_report_id) REFERENCES buy_reports (id) ON DELETE CASCADE + ); + +-- 収支管理テーブル +CREATE TABLE + income_expenditure_managements ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + amount INT(10) NOT NULL, + log_category ENUM("income", "expenditure", "sponsor's income") NOT NULL, + year_id INT(10) UNSIGNED NOT NULL, -- expenditureはNULLを許可する + receive_option ENUM("transfer", "hand"), -- expenditureはNULLを許可する + is_checked BOOLEAN NOT NULL DEFAULT FALSE, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY year_id_foreign_key (year_id) REFERENCES years (id) ON DELETE CASCADE + ); + +-- buy_reportとincome_expenditure_managementsの中間テーブル +CREATE TABLE + buy_report_income_expenditure_managements ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + buy_report_id INT(10) UNSIGNED NOT NULL, + income_expenditure_management_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY buy_report_id_foreign_key (buy_report_id) REFERENCES buy_reports (id) ON DELETE CASCADE, + FOREIGN KEY income_expenditure_management_id_foreign_key (income_expenditure_management_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE + ); + +-- 協賛活動テーブル +CREATE TABLE + activities ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + user_id INT(10), + is_done BOOLEAN, + sponsor_id INT(10), + feature VARCHAR(255), + expense INT(10), + remark VARCHAR(255), + design INT(10), + url VARCHAR(255), + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 協賛スタイル中間テーブル +CREATE TABLE + activity_styles ( + id int(10) unsigned not null auto_increment, + activity_id INT(10), + sponsor_style_id INT(10), + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 協賛活動と収支管理の中間テーブル +CREATE TABLE + sponsor_activity_balance_managements ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + sponsor_activity_id INT(10) UNSIGNED NOT NULL, + income_expenditure_management_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY sponsor_activity_id_foreign_key (sponsor_activity_id) REFERENCES activities (id) ON DELETE CASCADE, + FOREIGN KEY income_expenditure_management_id_foreign_key (income_expenditure_management_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE + ); + +-- 協賛活動情報テーブル +CREATE TABLE + activity_informations ( + id int(10) unsigned not null auto_increment, + activity_id INT(10), + bucket_name VARCHAR(255), + file_name VARCHAR(255), + file_type VARCHAR(255), + design_progress INT(10), + file_information VARCHAR(255), + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 局テーブル +CREATE TABLE + bureaus ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 学科・分野テーブル +CREATE TABLE + departments ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255), + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- メール認証テーブル +CREATE TABLE + mail_auth ( + id INT(10) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, + email VARCHAR(255) UNIQUE, + password VARCHAR(255) NOT NULL, + user_id INT(10) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- パスワードリセットトークンテーブル +CREATE TABLE + password_reset_tokens ( + id INT(10) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, + user_id INT(10) NOT NULL, + token VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- ユーザーロールテーブル +CREATE TABLE + roles ( + id int(10) unsigned not null auto_increment, + name VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- セッションテーブル +CREATE TABLE + session ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + auth_id INT(10) NOT NULL, + user_id INT(10) NOT NULL, + access_token VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + UNIQUE KEY (auth_id) -- auth_id がユニークであるべき場合 + ); + +-- 協賛スタイルテーブル +CREATE TABLE + sponsor_styles ( + id int(10) unsigned not null auto_increment, + style VARCHAR(255) NOT NULL, + feature VARCHAR(255) NOT NULL, + price INT(10), + is_deleted BOOLEAN DEFAULT false, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 協賛企業テーブル +CREATE TABLE + sponsors ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + tel VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL, + address VARCHAR(255) NOT NULL, + representative VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 教員テーブル +CREATE TABLE + teachers ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + position VARCHAR(255) NOT NULL, + department_id INT(10), + room VARCHAR(255), + is_black BOOLEAN, + remark VARCHAR(255), + is_deleted BOOLEAN DEFAULT false, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 年度期間テーブル +CREATE TABLE + year_periods ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + year_id INT(10) NOT NULL, + started_at DATETIME NOT NULL, + ended_at DATETIME NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 収入テーブル +CREATE TABLE + incomes ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, -- 自動採番のID + name VARCHAR(255) NOT NULL, -- 名前 + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 作成日時 + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- 更新日時 + PRIMARY KEY (id) -- 主キー + ); + +-- 収支管理と収入の中間テーブル +CREATE TABLE + income_income_expenditure_managements ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + income_expenditure_id INT(10) UNSIGNED NOT NULL, + income_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (income_expenditure_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE, + FOREIGN KEY (income_id) REFERENCES incomes (id) ON DELETE CASCADE + ); + +-- 棟テーブル +CREATE TABLE + buildings ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ); + +-- 号棟テーブル +CREATE TABLE + building_units ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + building_id INT(10) UNSIGNED NOT NULL DEFAULT 1, + unit_number VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (building_id) REFERENCES buildings (id) + ); + +-- 階テーブル +CREATE TABLE + floors ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + building_unit_id INT(10) UNSIGNED NOT NULL, + floor_number VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (building_unit_id) REFERENCES building_units (id) + ); + +-- 部屋テーブル +CREATE TABLE + rooms ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + floor_id INT(10) UNSIGNED NOT NULL, + room_name VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (floor_id) REFERENCES floors (id) + ); + +-- roomsとteachersの中間テーブル +CREATE TABLE + room_teachers ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + room_id INT(10) UNSIGNED NOT NULL, + teacher_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (room_id) REFERENCES rooms (id) ON DELETE CASCADE, + FOREIGN KEY (teacher_id) REFERENCES teachers (id) ON DELETE CASCADE + ); + +-- 学内募金テーブル +CREATE TABLE + campus_donations ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + user_id INT(10) UNSIGNED NOT NULL, + teacher_id INT(10) UNSIGNED NOT NULL, + year_id INT(10) UNSIGNED NOT NULL, + price INT(10) NOT NULL, + remark VARCHAR(255), + is_first_check BOOLEAN, + is_last_check BOOLEAN, + received_at VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (year_id) REFERENCES years (id) ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE, + FOREIGN KEY (teacher_id) REFERENCES teachers (id) ON DELETE CASCADE + ); + +-- 2025年度の企業協賛の名前を登録するようのspotのテーブル +CREATE TABLE + spot_sponsor_names ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + sponsor_name VARCHAR(255) NOT NULL, + income_expenditure_id INT(10) UNSIGNED NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (id), + FOREIGN KEY (income_expenditure_id) REFERENCES income_expenditure_managements (id) ON DELETE CASCADE + ); diff --git a/mysql/db/34_teachers_seed.sql b/mysql/seed/000001_initial_schema_seed.sql similarity index 71% rename from mysql/db/34_teachers_seed.sql rename to mysql/seed/000001_initial_schema_seed.sql index 2b19f1165..7f42cd58c 100644 --- a/mysql/db/34_teachers_seed.sql +++ b/mysql/seed/000001_initial_schema_seed.sql @@ -1,5 +1,196 @@ +-- TODO: シードを整理する use finansu_db; +INSERT INTO + years (year) +VALUES + (2025); + +-- ユーザーを一括で挿入 +INSERT INTO + users (name, bureau_id, role_id) +VALUES + -- 一般ユーザー + ('技大太郎1', 1, 1), + -- 管理者ユーザー + ('技大太郎2', 6, 2), + -- 財務局長 + ('技大太郎3', 3, 3), + -- 財務局員 + ('技大太郎4', 3, 4); + +INSERT INTO + financial_records (name, year_id) +VALUES + ('総務局', 1), + ('渉外局', 1); + +INSERT INTO + divisions (name, financial_record_id) +VALUES + ('衛生管理部門', 1), + ('国際部門', 1), + ('広報部門', 2), + ('ゲスト部門', 2); + +INSERT INTO + festival_items (name, memo, division_id) +VALUES + ('農ポリ', '', 1), + ('養生テープ', '', 1), + ('ラミ', '', 2), + ('広報物郵送費', '', 3), + ('折込チラシ用費', '', 3), + ('ゲストブッキング費', '', 4), + ('ゲスト用菓子折り費', '', 4); + +INSERT INTO + item_budgets (amount, festival_item_id) +VALUES + (10000, 1), + (10000, 2), + (10000, 3), + (20000, 4), + (50000, 5), + (1500000, 6), + (10000, 7); + +INSERT INTO + user_groups (user_id, group_id) +VALUES + (1, 1), + (1, 2), + (2, 3); + +INSERT INTO + buy_reports (festival_item_id, amount, memo, paid_by) +VALUES + (1, 5000, '', 'テスト太郎'), + (1, 4000, '', 'テスト太郎'), + (2, 5000, '', 'テスト太郎'), + (3, 2000, '', 'テスト2太郎'), + (3, 2000, '', 'テスト2太郎'), + (3, 2000, '', 'テスト2太郎'), + (4, 10000, '', 'テスト3太郎'); + +INSERT INTO + payment_receipts (buy_report_id, bucket_name, file_name, file_type, remark) +VALUES + (1, 'payment-receipts', 'receipt-1.jpg', 'image/jpeg', ''), + (2, 'payment-receipts', 'receipt-2.jpg', 'image/jpeg', ''), + (3, 'payment-receipts', 'receipt-3.jpg', 'image/jpeg', ''); + +INSERT INTO + buy_statuses (buy_report_id, is_packed, is_settled) +VALUES + (1, TRUE, TRUE), + (2, TRUE, FALSE), + (3, TRUE, FALSE), + (4, FALSE, FALSE), + (5, FALSE, FALSE), + (6, TRUE, FALSE), + (7, FALSE, FALSE); + +INSERT INTO + income_expenditure_managements (amount, log_category, year_id, receive_option, is_checked, created_at, updated_at) +VALUES + (50000, "income", 1, "hand", FALSE, NOW(), NOW()), + (100000, "sponsor's income", 1, "transfer", FALSE, NOW(), NOW()), + (5000, "expenditure", 1, NULL, FALSE, NOW(), NOW()), + (4000, "expenditure", 1, NULL, FALSE, NOW(), NOW()), + (5000, "expenditure", 1, NULL, FALSE, NOW(), NOW()), + (2000, "expenditure", 1, NULL, FALSE, NOW(), NOW()), + (2000, "expenditure", 1, NULL, FALSE, NOW(), NOW()), + (2000, "expenditure", 1, NULL, FALSE, NOW(), NOW()), + (10000, "expenditure", 1, NULL, FALSE, NOW(), NOW()); + +INSERT INTO + buy_report_income_expenditure_managements (buy_report_id, income_expenditure_management_id, created_at, updated_at) +VALUES + (1, 3, NOW(), NOW()), -- buy_reports.id: 1 と income_expenditure_managements.id: 3 の対応 + (2, 4, NOW(), NOW()), -- buy_reports.id: 2 と income_expenditure_managements.id: 4 の対応 + (3, 5, NOW(), NOW()), -- buy_reports.id: 3 と income_expenditure_managements.id: 5 の対応 + (4, 6, NOW(), NOW()), -- buy_reports.id: 4 と income_expenditure_managements.id: 6 の対応 + (5, 7, NOW(), NOW()), -- buy_reports.id: 5 と income_expenditure_managements.id: 7 の対応 + (6, 8, NOW(), NOW()), -- buy_reports.id: 6 と income_expenditure_managements.id: 8 の対応 + (7, 9, NOW(), NOW()); + +INSERT INTO + activities (user_id, is_done, sponsor_id, feature, expense, remark, design, url) +VALUES + (1, false, 1, "なし", 11, "", 1, ""), + (2, false, 2, "クーポン", 22, "味玉or大盛無料", 1, ""); + +INSERT INTO + activity_styles (activity_id, sponsor_style_id) +VALUES + (1, 1), + (2, 2), + (1, 2), + (2, 1); + +INSERT INTO + bureaus (name) +VALUES + ('総務局'), + ('渉外局'), + ('財務局'), + ('企画局'), + ('制作局'), + ('情報局'); + +INSERT INTO + departments (name) +VALUES + ('電気電子情報'), + ('物質生物'), + ('機械創造'), + ('環境社会基盤'), + ('情報・経営システム'), + ('基盤共通教育'), + ('原子力システム安全'), + ('技術科学イノベーション'), + ('システム安全'), + ('技術支援'), + ('その他'), + ('学長・事務'), + ('FL'); + +INSERT INTO + mail_auth (email, password, user_id) +VALUES + ("test1@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 1), + ("test2@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 2), + ("test3@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 3), + ("test4@example.com", "$2a$10$vtmStGYxc8/HdhBYJWyztOMrdpw1QaKxsuGdi72i8iqeyp.1997ke", 4); + +INSERT INTO + roles (name) +VALUES + ('user'), + ('admin'), + ('Finance Director'), + ('Finance Staff'); + +INSERT INTO + sponsor_styles (style, feature, price) +VALUES + ('8分の1', 'モノクロ', 3000), + ('8分の1', 'カラー', 5000), + ('4分の1', 'モノクロ', 8000), + ('4分の1', 'カラー', 10000), + ('2分の1', 'モノクロ', 12000), + ('2分の1', 'カラー', 15000), + ('1ページ', 'モノクロ', 20000), + ('2ページ', 'カラー', 30000), + ('企業ブース', 'なし', 30000); + +INSERT INTO + teachers (name, position, department_id, room, is_black, remark) +VALUES + ('test-name', 'test-position', 1, '605', false, 'test-remark'), + ('test-teacher', 'test-position2', 1, '605', false, 'test-remark'); + INSERT INTO teachers (name, position, department_id, room, is_black, remark) VALUES @@ -242,3 +433,62 @@ VALUES ('生物系', '系事務室', 12, '', false, ''), ('環境事務室', '系事務室', 12, '', false, ''), ('芳賀 仁', '助教', 12, '電気2号棟-364', false, '同窓会代表。局長が挨拶へ。学内募金は毎回断っている'); + +INSERT INTO + year_periods (year_id, started_at, ended_at) +VALUES + (1, '2024-11-15 00:00:00', '2025-11-15 00:00:00'); + +INSERT INTO + incomes (name, created_at, updated_at) +VALUES + ("教育振興会費", NOW(), NOW()), + ("学内募金", NOW(), NOW()), + ("同窓会費", NOW(), NOW()), + ("雑収入", NOW(), NOW()), + ("繰越金", NOW(), NOW()), + ("企業協賛金", NOW(), NOW()); + +INSERT INTO + buildings (name) +VALUES + ('機械・建設棟'), + ('電気棟'), + ('生物棟'), + ('環境・システム棟'), + ('物質・材料経営情報棟'), + ('総合研究棟'), + ('原子力・システム安全棟'), + ('事務局棟'), + ('極限エネルギ密度工学研究センター'), + ('工作センター'), + ('大型実験棟'), + ('分析計測センター'), + ('その他'); + +INSERT INTO + building_units (building_id, unit_number) +VALUES + (1, "1号棟"), + (1, "2号棟"), + (1, "3号棟"), + (2, "1号棟"), + (2, "2号棟"), + (3, "1号棟"), + (4, "1号棟"), + (5, "1号棟"), + (5, "2号棟"), + (6, "1号棟"), + (7, "1号棟"), + (8, "1号棟"), + (9, "1号棟"), + (10, "1号棟"), + (11, "1号棟"), + (12, "1号棟"), + (13, "1号棟"); + +INSERT INTO + campus_donations (user_id, teacher_id, year_id, price, remark, is_first_check, is_last_check, received_at) +VALUES + (1, 1, 1, 2000, "nothing", false, false, '2023-02-22'), + (2, 2, 1, 2000, "nothing", false, false, '2022-02-22'); diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 75799c67f..ae7a4be52 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1523,215 +1523,30 @@ paths: schema: type: string format: binary - /fund_informations: + /income_expenditure_management/csv/download: get: tags: - - fund_information - description: fund_informationの一覧を取得 - responses: - "200": - description: fund_informationの一覧の取得 - content: - application/json: - schema: - type: object - post: - tags: - - fund_information - description: fund_informationの作成 - parameters: - - name: user_id - in: query - description: user_id - required: true - schema: - type: integer - - name: teacher_id - in: query - description: teacher_id - required: true - schema: - type: integer - - name: price - in: query - description: price - required: true - schema: - type: integer - - name: remark - in: query - description: remark - schema: - type: string - - name: is_first_check - in: query - description: is_first_check - schema: - type: boolean - - name: is_last_check - in: query - description: is_last_check - schema: - type: boolean - - name: received_at - in: query - description: received_at - schema: - type: string - responses: - "200": - description: create されたfund_informationが返ってくる - content: - application/json: - schema: - type: object - - /fund_informations/details: - get: - tags: - - fund_information - description: fund_informationに紐づくteacherとuserの一覧を取得 - responses: - "200": - description: fund_informationに紐づくteacherとuserの一覧を取得 - content: - application/json: - schema: - type: object - - /fund_informations/{id}: - get: - tags: - - fund_information - description: IDで指定されたfund_informationの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: fund_informationの取得 - content: - application/json: - schema: - type: object - put: - tags: - - fund_information - description: fund_informationの更新 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - - name: user_id - in: query - description: user_id - required: true - schema: - type: integer - - name: teacher_id - in: query - description: teacher_id - required: true - schema: - type: integer - - name: price - in: query - description: price - required: true - schema: - type: integer - - name: remark - in: query - description: remark - schema: - type: string - - name: is_first_check - in: query - description: is_first_check - schema: - type: boolean - - name: is_last_check - in: query - description: is_last_check - schema: - type: boolean - - name: received_at - in: query - description: received_at - schema: - type: string - responses: - "200": - description: 更新されたfund_informationが返ってくる - content: - application/json: - schema: - type: object - delete: - tags: - - fund_information - description: IDを指定してfund_informationの削除 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: fund_informationの削除完了 - content: - application/json: - schema: - type: object - - /fund_informations/{id}/details: - get: - tags: - - fund_information - description: IDで指定されたfund_informatinに紐づくteacherとuserを取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: fund_informatinに紐づくteacherとuserを取得 - content: - application/json: - schema: - type: object - - /fund_informations/details/{year}: - get: - tags: - - fund_information - description: 年度で指定されたfund_informationsに紐づくデータを取得 + - income_expenditure_management + description: 収支管理一覧のCSVダウンロード、財務向けのページ parameters: - name: year - in: path + in: query description: year - required: true schema: type: integer responses: "200": - description: 年度で指定されたfund_informationsに紐づくデータを取得 + description: income_expenditure_managementのCSVダウンロード + headers: + Content-Disposition: + schema: + type: string + example: attachment; filename=income_expenditure_management.csv content: - application/json: + text/csv: schema: - type: object + type: string + format: binary /incomes: get: tags: diff --git a/scripts/create_migration.sh b/scripts/create_migration.sh new file mode 100755 index 000000000..de6f5f697 --- /dev/null +++ b/scripts/create_migration.sh @@ -0,0 +1,3 @@ +read -p "input migration name: " migration_name + +docker compose -f compose.migrate.yml run --rm migrate create -ext sql -dir /migrations -seq $migration_name diff --git a/scripts/seed.sh b/scripts/seed.sh new file mode 100644 index 000000000..eeb3c2fe1 --- /dev/null +++ b/scripts/seed.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# テーブルデータを初期化するためのSQLファイルを実行するよ〜!🐣 + +MYSQL_HOST="db" + +{ + echo "SET FOREIGN_KEY_CHECKS = 0;" + mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -D "$MYSQL_DATABASE" --batch --silent -N \ + -e "SELECT CONCAT('TRUNCATE TABLE \`', table_name, '\`;') \ + FROM information_schema.tables \ + WHERE table_schema = '${MYSQL_DATABASE}' AND table_name != 'schema_migrations';" + echo "SET FOREIGN_KEY_CHECKS = 1;" +} | mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" + +# ディレクトリのパスを指定 +SQL_DIR="../seed" + +# SQLファイルを順番に実行 +for sql_file in "$SQL_DIR"/*.sql; do + if [ -f "$sql_file" ]; then + echo "実行中: $sql_file 🚀" + mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < "$sql_file" + if [ $? -eq 0 ]; then + echo "成功: $sql_file 🎉" + else + echo "失敗: $sql_file 😭" + fi + else + echo "SQLファイルが見つからないよ〜!ぴえん🥺" + fi +done + +echo "全てのSQLファイルの実行が完了したよ!おけまる水産🐟✨" diff --git a/scripts/wait-for-mysql.sh b/scripts/wait-for-mysql.sh new file mode 100755 index 000000000..77c1a66ad --- /dev/null +++ b/scripts/wait-for-mysql.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# 環境変数から接続情報を取得 +host="${NUTMEG_DB_HOST:-nutfes-finansu-db}" +port="${NUTMEG_DB_PORT:-3306}" +user="${NUTMEG_DB_USER:-finansu}" +password="${NUTMEG_DB_PASSWORD:-password}" +database="${NUTMEG_DB_NAME:-finansu_db}" + +# 最大待機時間(秒) +max_wait=60 +waited=0 + +echo "Waiting for MySQL at ${host}:${port}..." + +until docker compose -f compose.db.yml exec -T db mysqladmin ping -h"localhost" -u"${user}" -p"${password}" --silent 2>/dev/null; do + if [ $waited -ge $max_wait ]; then + echo "Error: MySQL did not become ready within ${max_wait} seconds" + exit 1 + fi + + echo "MySQL is unavailable - waiting... (${waited}s/${max_wait}s)" + sleep 2 + waited=$((waited + 2)) +done + +echo "MySQL is ready!" diff --git a/view/next-project/src/components/fund_information/FundInformationHeader.tsx b/view/next-project/src/components/fund_information/FundInformationHeader.tsx index 8f5e16d40..0056c9aef 100644 --- a/view/next-project/src/components/fund_information/FundInformationHeader.tsx +++ b/view/next-project/src/components/fund_information/FundInformationHeader.tsx @@ -1,6 +1,6 @@ import { useRouter } from 'next/router'; import React from 'react'; -import { Title, AddButton } from '@components/common'; +import { Title, AddButton, OutlinePrimaryButton } from '@components/common'; interface FundInformationHeaderProps { totalBalance: number; @@ -19,7 +19,17 @@ const FundInformationHeader: React.FC = ({ totalBala 残高<span className='ml-1'>{totalBalance.toLocaleString()}</span> - 収入報告 +
+ + + CSVダウンロード + + + 収入報告 +
); }; diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index f9a27d841..901af7a75 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -29,7 +29,6 @@ import type { DeleteExpensesId200, DeleteFestivalItemsId200, DeleteFinancialRecordsId200, - DeleteFundInformationsId200, DeleteIncomesId200, DeleteReceiptsId200, DeleteSourcesId200, @@ -92,11 +91,7 @@ import type { GetFestivalItemsUsersParams, GetFinancialRecordsCsvDownloadParams, GetFinancialRecordsParams, - GetFundInformations200, - GetFundInformationsDetails200, - GetFundInformationsDetailsYear200, - GetFundInformationsId200, - GetFundInformationsIdDetails200, + GetIncomeExpenditureManagementCsvDownloadParams, GetIncomeExpenditureManagementsParams, GetReceipts200, GetReceiptsId200, @@ -123,8 +118,6 @@ import type { PostDepartmentsParams, PostExpenses200, PostExpensesParams, - PostFundInformations200, - PostFundInformationsParams, PostPasswordResetId200, PostPasswordResetIdValid200, PostPasswordResetIdValidParams, @@ -157,8 +150,6 @@ import type { PutDepartmentsIdParams, PutExpensesId200, PutExpensesIdParams, - PutFundInformationsId200, - PutFundInformationsIdParams, PutIncomeExpenditureManagementsCheckId200, PutIncomeExpenditureManagementsCheckIdBody, PutReceiptsId200, @@ -5079,272 +5070,24 @@ export const useGetFinancialRecordsCsvDownload = ( }; /** - * fund_informationの一覧を取得 + * 収支管理一覧のCSVダウンロード、財務向けのページ */ -export type getFundInformationsResponse200 = { - data: GetFundInformations200; - status: 200; -}; - -export type getFundInformationsResponseComposite = getFundInformationsResponse200; - -export type getFundInformationsResponse = getFundInformationsResponseComposite & { - headers: Headers; -}; - -export const getGetFundInformationsUrl = () => { - return `/fund_informations`; -}; - -export const getFundInformations = async ( - options?: RequestInit, -): Promise => { - return customFetch(getGetFundInformationsUrl(), { - ...options, - method: 'GET', - }); -}; - -export const getGetFundInformationsKey = () => [`/fund_informations`] as const; - -export type GetFundInformationsQueryResult = NonNullable< - Awaited> ->; -export type GetFundInformationsQueryError = unknown; - -export const useGetFundInformations = (options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; - request?: SecondParameter; -}) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const isEnabled = swrOptions?.enabled !== false; - const swrKey = swrOptions?.swrKey ?? (() => (isEnabled ? getGetFundInformationsKey() : null)); - const swrFn = () => getFundInformations(requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * fund_informationの作成 - */ -export type postFundInformationsResponse200 = { - data: PostFundInformations200; - status: 200; -}; - -export type postFundInformationsResponseComposite = postFundInformationsResponse200; - -export type postFundInformationsResponse = postFundInformationsResponseComposite & { - headers: Headers; -}; - -export const getPostFundInformationsUrl = (params: PostFundInformationsParams) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()); - } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 - ? `/fund_informations?${stringifiedParams}` - : `/fund_informations`; -}; - -export const postFundInformations = async ( - params: PostFundInformationsParams, - options?: RequestInit, -): Promise => { - return customFetch(getPostFundInformationsUrl(params), { - ...options, - method: 'POST', - }); -}; - -export const getPostFundInformationsMutationFetcher = ( - params: PostFundInformationsParams, - options?: SecondParameter, -) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postFundInformations(params, options); - }; -}; -export const getPostFundInformationsMutationKey = (params: PostFundInformationsParams) => - [`/fund_informations`, ...(params ? [params] : [])] as const; - -export type PostFundInformationsMutationResult = NonNullable< - Awaited> ->; -export type PostFundInformationsMutationError = unknown; - -export const usePostFundInformations = ( - params: PostFundInformationsParams, - options?: { - swr?: SWRMutationConfiguration< - Awaited>, - TError, - Key, - Arguments, - Awaited> - > & { swrKey?: string }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const swrKey = swrOptions?.swrKey ?? getPostFundInformationsMutationKey(params); - const swrFn = getPostFundInformationsMutationFetcher(params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * fund_informationに紐づくteacherとuserの一覧を取得 - */ -export type getFundInformationsDetailsResponse200 = { - data: GetFundInformationsDetails200; +export type getIncomeExpenditureManagementCsvDownloadResponse200 = { + data: Blob; status: 200; }; -export type getFundInformationsDetailsResponseComposite = getFundInformationsDetailsResponse200; - -export type getFundInformationsDetailsResponse = getFundInformationsDetailsResponseComposite & { - headers: Headers; -}; - -export const getGetFundInformationsDetailsUrl = () => { - return `/fund_informations/details`; -}; - -export const getFundInformationsDetails = async ( - options?: RequestInit, -): Promise => { - return customFetch(getGetFundInformationsDetailsUrl(), { - ...options, - method: 'GET', - }); -}; - -export const getGetFundInformationsDetailsKey = () => [`/fund_informations/details`] as const; - -export type GetFundInformationsDetailsQueryResult = NonNullable< - Awaited> ->; -export type GetFundInformationsDetailsQueryError = unknown; - -export const useGetFundInformationsDetails = (options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; - request?: SecondParameter; -}) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const isEnabled = swrOptions?.enabled !== false; - const swrKey = - swrOptions?.swrKey ?? (() => (isEnabled ? getGetFundInformationsDetailsKey() : null)); - const swrFn = () => getFundInformationsDetails(requestOptions); +export type getIncomeExpenditureManagementCsvDownloadResponseComposite = + getIncomeExpenditureManagementCsvDownloadResponse200; - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, +export type getIncomeExpenditureManagementCsvDownloadResponse = + getIncomeExpenditureManagementCsvDownloadResponseComposite & { + headers: Headers; }; -}; - -/** - * IDで指定されたfund_informationの取得 - */ -export type getFundInformationsIdResponse200 = { - data: GetFundInformationsId200; - status: 200; -}; - -export type getFundInformationsIdResponseComposite = getFundInformationsIdResponse200; -export type getFundInformationsIdResponse = getFundInformationsIdResponseComposite & { - headers: Headers; -}; - -export const getGetFundInformationsIdUrl = (id: number) => { - return `/fund_informations/${id}`; -}; - -export const getFundInformationsId = async ( - id: number, - options?: RequestInit, -): Promise => { - return customFetch(getGetFundInformationsIdUrl(id), { - ...options, - method: 'GET', - }); -}; - -export const getGetFundInformationsIdKey = (id: number) => [`/fund_informations/${id}`] as const; - -export type GetFundInformationsIdQueryResult = NonNullable< - Awaited> ->; -export type GetFundInformationsIdQueryError = unknown; - -export const useGetFundInformationsId = ( - id: number, - options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; - request?: SecondParameter; - }, +export const getGetIncomeExpenditureManagementCsvDownloadUrl = ( + params?: GetIncomeExpenditureManagementCsvDownloadParams, ) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const isEnabled = swrOptions?.enabled !== false && !!id; - const swrKey = swrOptions?.swrKey ?? (() => (isEnabled ? getGetFundInformationsIdKey(id) : null)); - const swrFn = () => getFundInformationsId(id, requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * fund_informationの更新 - */ -export type putFundInformationsIdResponse200 = { - data: PutFundInformationsId200; - status: 200; -}; - -export type putFundInformationsIdResponseComposite = putFundInformationsIdResponse200; - -export type putFundInformationsIdResponse = putFundInformationsIdResponseComposite & { - headers: Headers; -}; - -export const getPutFundInformationsIdUrl = (id: number, params: PutFundInformationsIdParams) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { @@ -5356,224 +5099,16 @@ export const getPutFundInformationsIdUrl = (id: number, params: PutFundInformati const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 - ? `/fund_informations/${id}?${stringifiedParams}` - : `/fund_informations/${id}`; -}; - -export const putFundInformationsId = async ( - id: number, - params: PutFundInformationsIdParams, - options?: RequestInit, -): Promise => { - return customFetch(getPutFundInformationsIdUrl(id, params), { - ...options, - method: 'PUT', - }); -}; - -export const getPutFundInformationsIdMutationFetcher = ( - id: number, - params: PutFundInformationsIdParams, - options?: SecondParameter, -) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putFundInformationsId(id, params, options); - }; -}; -export const getPutFundInformationsIdMutationKey = ( - id: number, - params: PutFundInformationsIdParams, -) => [`/fund_informations/${id}`, ...(params ? [params] : [])] as const; - -export type PutFundInformationsIdMutationResult = NonNullable< - Awaited> ->; -export type PutFundInformationsIdMutationError = unknown; - -export const usePutFundInformationsId = ( - id: number, - params: PutFundInformationsIdParams, - options?: { - swr?: SWRMutationConfiguration< - Awaited>, - TError, - Key, - Arguments, - Awaited> - > & { swrKey?: string }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const swrKey = swrOptions?.swrKey ?? getPutFundInformationsIdMutationKey(id, params); - const swrFn = getPutFundInformationsIdMutationFetcher(id, params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * IDを指定してfund_informationの削除 - */ -export type deleteFundInformationsIdResponse200 = { - data: DeleteFundInformationsId200; - status: 200; -}; - -export type deleteFundInformationsIdResponseComposite = deleteFundInformationsIdResponse200; - -export type deleteFundInformationsIdResponse = deleteFundInformationsIdResponseComposite & { - headers: Headers; + ? `/income_expenditure_management/csv/download?${stringifiedParams}` + : `/income_expenditure_management/csv/download`; }; -export const getDeleteFundInformationsIdUrl = (id: number) => { - return `/fund_informations/${id}`; -}; - -export const deleteFundInformationsId = async ( - id: number, +export const getIncomeExpenditureManagementCsvDownload = async ( + params?: GetIncomeExpenditureManagementCsvDownloadParams, options?: RequestInit, -): Promise => { - return customFetch(getDeleteFundInformationsIdUrl(id), { - ...options, - method: 'DELETE', - }); -}; - -export const getDeleteFundInformationsIdMutationFetcher = ( - id: number, - options?: SecondParameter, -) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteFundInformationsId(id, options); - }; -}; -export const getDeleteFundInformationsIdMutationKey = (id: number) => - [`/fund_informations/${id}`] as const; - -export type DeleteFundInformationsIdMutationResult = NonNullable< - Awaited> ->; -export type DeleteFundInformationsIdMutationError = unknown; - -export const useDeleteFundInformationsId = ( - id: number, - options?: { - swr?: SWRMutationConfiguration< - Awaited>, - TError, - Key, - Arguments, - Awaited> - > & { swrKey?: string }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const swrKey = swrOptions?.swrKey ?? getDeleteFundInformationsIdMutationKey(id); - const swrFn = getDeleteFundInformationsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * IDで指定されたfund_informatinに紐づくteacherとuserを取得 - */ -export type getFundInformationsIdDetailsResponse200 = { - data: GetFundInformationsIdDetails200; - status: 200; -}; - -export type getFundInformationsIdDetailsResponseComposite = getFundInformationsIdDetailsResponse200; - -export type getFundInformationsIdDetailsResponse = getFundInformationsIdDetailsResponseComposite & { - headers: Headers; -}; - -export const getGetFundInformationsIdDetailsUrl = (id: number) => { - return `/fund_informations/${id}/details`; -}; - -export const getFundInformationsIdDetails = async ( - id: number, - options?: RequestInit, -): Promise => { - return customFetch(getGetFundInformationsIdDetailsUrl(id), { - ...options, - method: 'GET', - }); -}; - -export const getGetFundInformationsIdDetailsKey = (id: number) => - [`/fund_informations/${id}/details`] as const; - -export type GetFundInformationsIdDetailsQueryResult = NonNullable< - Awaited> ->; -export type GetFundInformationsIdDetailsQueryError = unknown; - -export const useGetFundInformationsIdDetails = ( - id: number, - options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const isEnabled = swrOptions?.enabled !== false && !!id; - const swrKey = - swrOptions?.swrKey ?? (() => (isEnabled ? getGetFundInformationsIdDetailsKey(id) : null)); - const swrFn = () => getFundInformationsIdDetails(id, requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * 年度で指定されたfund_informationsに紐づくデータを取得 - */ -export type getFundInformationsDetailsYearResponse200 = { - data: GetFundInformationsDetailsYear200; - status: 200; -}; - -export type getFundInformationsDetailsYearResponseComposite = - getFundInformationsDetailsYearResponse200; - -export type getFundInformationsDetailsYearResponse = - getFundInformationsDetailsYearResponseComposite & { - headers: Headers; - }; - -export const getGetFundInformationsDetailsYearUrl = (year: number) => { - return `/fund_informations/details/${year}`; -}; - -export const getFundInformationsDetailsYear = async ( - year: number, - options?: RequestInit, -): Promise => { - return customFetch( - getGetFundInformationsDetailsYearUrl(year), +): Promise => { + return customFetch( + getGetIncomeExpenditureManagementCsvDownloadUrl(params), { ...options, method: 'GET', @@ -5581,30 +5116,32 @@ export const getFundInformationsDetailsYear = async ( ); }; -export const getGetFundInformationsDetailsYearKey = (year: number) => - [`/fund_informations/details/${year}`] as const; +export const getGetIncomeExpenditureManagementCsvDownloadKey = ( + params?: GetIncomeExpenditureManagementCsvDownloadParams, +) => [`/income_expenditure_management/csv/download`, ...(params ? [params] : [])] as const; -export type GetFundInformationsDetailsYearQueryResult = NonNullable< - Awaited> +export type GetIncomeExpenditureManagementCsvDownloadQueryResult = NonNullable< + Awaited> >; -export type GetFundInformationsDetailsYearQueryError = unknown; +export type GetIncomeExpenditureManagementCsvDownloadQueryError = unknown; -export const useGetFundInformationsDetailsYear = ( - year: number, +export const useGetIncomeExpenditureManagementCsvDownload = ( + params?: GetIncomeExpenditureManagementCsvDownloadParams, options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; request?: SecondParameter; }, ) => { const { swr: swrOptions, request: requestOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!year; + const isEnabled = swrOptions?.enabled !== false; const swrKey = - swrOptions?.swrKey ?? (() => (isEnabled ? getGetFundInformationsDetailsYearKey(year) : null)); - const swrFn = () => getFundInformationsDetailsYear(year, requestOptions); + swrOptions?.swrKey ?? + (() => (isEnabled ? getGetIncomeExpenditureManagementCsvDownloadKey(params) : null)); + const swrFn = () => getIncomeExpenditureManagementCsvDownload(params, requestOptions); const query = useSwr>, TError>(swrKey, swrFn, swrOptions); diff --git a/view/next-project/src/generated/model/getFoundInformationsCsvDownloadParams.ts b/view/next-project/src/generated/model/getFoundInformationsCsvDownloadParams.ts new file mode 100644 index 000000000..54dd77241 --- /dev/null +++ b/view/next-project/src/generated/model/getFoundInformationsCsvDownloadParams.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export type GetFoundInformationsCsvDownloadParams = { + /** + * year + */ + year?: number; +}; diff --git a/view/next-project/src/generated/model/getFundInformationsCsvDownloadParams.ts b/view/next-project/src/generated/model/getFundInformationsCsvDownloadParams.ts new file mode 100644 index 000000000..b1d4506a8 --- /dev/null +++ b/view/next-project/src/generated/model/getFundInformationsCsvDownloadParams.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export type GetFundInformationsCsvDownloadParams = { + /** + * year + */ + year?: number; +}; diff --git a/view/next-project/src/generated/model/getIncomeExpenditureManagementCsvDownloadParams.ts b/view/next-project/src/generated/model/getIncomeExpenditureManagementCsvDownloadParams.ts new file mode 100644 index 000000000..451198879 --- /dev/null +++ b/view/next-project/src/generated/model/getIncomeExpenditureManagementCsvDownloadParams.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export type GetIncomeExpenditureManagementCsvDownloadParams = { + /** + * year + */ + year?: number; +}; diff --git a/view/next-project/src/generated/model/index.ts b/view/next-project/src/generated/model/index.ts index 6bf3b52ea..868c4b0dd 100644 --- a/view/next-project/src/generated/model/index.ts +++ b/view/next-project/src/generated/model/index.ts @@ -93,11 +93,14 @@ export * from './getFestivalItemsParams'; export * from './getFestivalItemsUsersParams'; export * from './getFinancialRecordsCsvDownloadParams'; export * from './getFinancialRecordsParams'; +export * from './getFoundInformationsCsvDownloadParams'; export * from './getFundInformations200'; +export * from './getFundInformationsCsvDownloadParams'; export * from './getFundInformationsDetails200'; export * from './getFundInformationsDetailsYear200'; export * from './getFundInformationsId200'; export * from './getFundInformationsIdDetails200'; +export * from './getIncomeExpenditureManagementCsvDownloadParams'; export * from './getIncomeExpenditureManagements200'; export * from './getIncomeExpenditureManagementsParams'; export * from './getReceipts200';
campus_donations.year_idcampus_donations_ibfk_1C
financial_records.year_id financial_records_ibfk_1