From 48c5ed4ce218b00c73fc3b5f59511f7fca571ef1 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Mon, 3 Feb 2025 19:21:06 +0900 Subject: [PATCH 01/14] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AAapi=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/generated/openapi_gen.go | 655 ----- openapi/openapi.yaml | 567 ---- view/next-project/src/generated/hooks.ts | 3251 ++++++---------------- 3 files changed, 834 insertions(+), 3639 deletions(-) diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index a480cdc08..da4cc96fe 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -196,15 +196,6 @@ type PasswordResetData struct { Token *string `json:"token,omitempty"` } -// Receipt defines model for receipt. -type Receipt struct { - BucketName *string `json:"bucketName,omitempty"` - FileName *string `json:"fileName,omitempty"` - FileType *string `json:"fileType,omitempty"` - PurchaseReportID int `json:"purchaseReportID"` - Remark *string `json:"remark,omitempty"` -} - // Sponsor defines model for sponsor. type Sponsor struct { Address string `json:"address"` @@ -266,30 +257,6 @@ type GetActivitiesFilteredDetailsYearParams struct { // GetActivitiesFilteredDetailsYearParamsIsDone defines parameters for GetActivitiesFilteredDetailsYear. type GetActivitiesFilteredDetailsYearParamsIsDone string -// PostBudgetsParams defines parameters for PostBudgets. -type PostBudgetsParams struct { - // Price price - Price int `form:"price" json:"price"` - - // YearId year_id - YearId *int `form:"year_id,omitempty" json:"year_id,omitempty"` - - // SourceId source_id - SourceId *int `form:"source_id,omitempty" json:"source_id,omitempty"` -} - -// PutBudgetsIdParams defines parameters for PutBudgetsId. -type PutBudgetsIdParams struct { - // Price price - Price *int `form:"price,omitempty" json:"price,omitempty"` - - // YearId year_id - YearId *int `form:"year_id,omitempty" json:"year_id,omitempty"` - - // SourceId source_id - SourceId *int `form:"source_id,omitempty" json:"source_id,omitempty"` -} - // PostBureausParams defines parameters for PostBureaus. type PostBureausParams struct { // Name name @@ -354,24 +321,6 @@ type GetDivisionsParams struct { FinancialRecordId *int `form:"financial_record_id,omitempty" json:"financial_record_id,omitempty"` } -// PostExpensesParams defines parameters for PostExpenses. -type PostExpensesParams struct { - // Name name - Name *string `form:"name,omitempty" json:"name,omitempty"` - - // YearId year_id - YearId *string `form:"year_id,omitempty" json:"year_id,omitempty"` -} - -// PutExpensesIdParams defines parameters for PutExpensesId. -type PutExpensesIdParams struct { - // Name name - Name *string `form:"name,omitempty" json:"name,omitempty"` - - // YearId year_id - YearId *string `form:"year_id,omitempty" json:"year_id,omitempty"` -} - // GetFestivalItemsParams defines parameters for GetFestivalItems. type GetFestivalItemsParams struct { // Year year @@ -453,18 +402,6 @@ type PostPasswordResetIdValidParams struct { Token *string `form:"token,omitempty" json:"token,omitempty"` } -// PostSourcesParams defines parameters for PostSources. -type PostSourcesParams struct { - // Name name - Name string `form:"name" json:"name"` -} - -// PutSourcesIdParams defines parameters for PutSourcesId. -type PutSourcesIdParams struct { - // Name name - Name string `form:"name" json:"name"` -} - // PostTeachersParams defines parameters for PostTeachers. type PostTeachersParams struct { // Name 名前 @@ -596,12 +533,6 @@ type PutFinancialRecordsIdJSONRequestBody = FinancialRecord // PostPasswordResetIdJSONRequestBody defines body for PostPasswordResetId for application/json ContentType. type PostPasswordResetIdJSONRequestBody = PasswordResetData -// PostReceiptsJSONRequestBody defines body for PostReceipts for application/json ContentType. -type PostReceiptsJSONRequestBody = Receipt - -// PutReceiptsIdJSONRequestBody defines body for PutReceiptsId for application/json ContentType. -type PutReceiptsIdJSONRequestBody = Receipt - // PostSponsorsJSONRequestBody defines body for PostSponsors for application/json ContentType. type PostSponsorsJSONRequestBody = Sponsor @@ -686,30 +617,6 @@ type ServerInterface interface { // (PUT /activity_styles/{id}) PutActivityStylesId(ctx echo.Context, id int) error - // (GET /budgets) - GetBudgets(ctx echo.Context) error - - // (POST /budgets) - PostBudgets(ctx echo.Context, params PostBudgetsParams) error - - // (GET /budgets/details) - GetBudgetsDetails(ctx echo.Context) error - - // (GET /budgets/details/{year}) - GetBudgetsDetailsYear(ctx echo.Context, year int) error - - // (DELETE /budgets/{id}) - DeleteBudgetsId(ctx echo.Context, id int) error - - // (GET /budgets/{id}) - GetBudgetsId(ctx echo.Context, id int) error - - // (PUT /budgets/{id}) - PutBudgetsId(ctx echo.Context, id int, params PutBudgetsIdParams) error - - // (GET /budgets/{id}/details) - GetBudgetsIdDetails(ctx echo.Context, id int) error - // (GET /bureaus) GetBureaus(ctx echo.Context) error @@ -767,33 +674,6 @@ type ServerInterface interface { // (PUT /divisions/{id}) PutDivisionsId(ctx echo.Context, id int) error - // (GET /expenses) - GetExpenses(ctx echo.Context) error - - // (POST /expenses) - PostExpenses(ctx echo.Context, params PostExpensesParams) error - - // (GET /expenses/details) - GetExpensesDetails(ctx echo.Context) error - - // (GET /expenses/details/{year}) - GetExpensesDetailsYear(ctx echo.Context, year int) error - - // (GET /expenses/fiscalyear/{year}) - GetExpensesFiscalyearYear(ctx echo.Context, year int) error - - // (DELETE /expenses/{id}) - DeleteExpensesId(ctx echo.Context, id int) error - - // (GET /expenses/{id}) - GetExpensesId(ctx echo.Context, id int) error - - // (PUT /expenses/{id}) - PutExpensesId(ctx echo.Context, id int, params PutExpensesIdParams) error - - // (GET /expenses/{id}/details) - GetExpensesIdDetails(ctx echo.Context, id int) error - // (GET /festival_items) GetFestivalItems(ctx echo.Context, params GetFestivalItemsParams) error @@ -854,39 +734,6 @@ type ServerInterface interface { // (POST /password_reset/{id}/valid) PostPasswordResetIdValid(ctx echo.Context, id int, params PostPasswordResetIdValidParams) error - // (GET /receipts) - GetReceipts(ctx echo.Context) error - - // (POST /receipts) - PostReceipts(ctx echo.Context) error - - // (GET /receipts/reports/{id}) - GetReceiptsReportsId(ctx echo.Context, id int) error - - // (DELETE /receipts/{id}) - DeleteReceiptsId(ctx echo.Context, id int) error - - // (GET /receipts/{id}) - GetReceiptsId(ctx echo.Context, id int) error - - // (PUT /receipts/{id}) - PutReceiptsId(ctx echo.Context, id int) error - - // (GET /sources) - GetSources(ctx echo.Context) error - - // (POST /sources) - PostSources(ctx echo.Context, params PostSourcesParams) error - - // (DELETE /sources/{id}) - DeleteSourcesId(ctx echo.Context, id int) error - - // (GET /sources/{id}) - GetSourcesId(ctx echo.Context, id int) error - - // (PUT /sources/{id}) - PutSourcesId(ctx echo.Context, id int, params PutSourcesIdParams) error - // (GET /sponsors) GetSponsors(ctx echo.Context) error @@ -1289,159 +1136,6 @@ func (w *ServerInterfaceWrapper) PutActivityStylesId(ctx echo.Context) error { return err } -// GetBudgets converts echo context to params. -func (w *ServerInterfaceWrapper) GetBudgets(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetBudgets(ctx) - return err -} - -// PostBudgets converts echo context to params. -func (w *ServerInterfaceWrapper) PostBudgets(ctx echo.Context) error { - var err error - - // Parameter object where we will unmarshal all parameters from the context - var params PostBudgetsParams - // ------------- 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 "year_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "year_id", ctx.QueryParams(), ¶ms.YearId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year_id: %s", err)) - } - - // ------------- Optional query parameter "source_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "source_id", ctx.QueryParams(), ¶ms.SourceId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter source_id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostBudgets(ctx, params) - return err -} - -// GetBudgetsDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetBudgetsDetails(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetBudgetsDetails(ctx) - return err -} - -// GetBudgetsDetailsYear converts echo context to params. -func (w *ServerInterfaceWrapper) GetBudgetsDetailsYear(ctx echo.Context) error { - var err error - // ------------- Path parameter "year" ------------- - var year int - - err = runtime.BindStyledParameterWithOptions("simple", "year", ctx.Param("year"), &year, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - 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.GetBudgetsDetailsYear(ctx, year) - return err -} - -// DeleteBudgetsId converts echo context to params. -func (w *ServerInterfaceWrapper) DeleteBudgetsId(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.DeleteBudgetsId(ctx, id) - return err -} - -// GetBudgetsId converts echo context to params. -func (w *ServerInterfaceWrapper) GetBudgetsId(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.GetBudgetsId(ctx, id) - return err -} - -// PutBudgetsId converts echo context to params. -func (w *ServerInterfaceWrapper) PutBudgetsId(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 PutBudgetsIdParams - // ------------- Optional query parameter "price" ------------- - - err = runtime.BindQueryParameter("form", true, false, "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 "year_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "year_id", ctx.QueryParams(), ¶ms.YearId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year_id: %s", err)) - } - - // ------------- Optional query parameter "source_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "source_id", ctx.QueryParams(), ¶ms.SourceId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter source_id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PutBudgetsId(ctx, id, params) - return err -} - -// GetBudgetsIdDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetBudgetsIdDetails(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.GetBudgetsIdDetails(ctx, id) - return err -} - // GetBureaus converts echo context to params. func (w *ServerInterfaceWrapper) GetBureaus(ctx echo.Context) error { var err error @@ -1751,161 +1445,6 @@ func (w *ServerInterfaceWrapper) PutDivisionsId(ctx echo.Context) error { return err } -// GetExpenses converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpenses(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetExpenses(ctx) - return err -} - -// PostExpenses converts echo context to params. -func (w *ServerInterfaceWrapper) PostExpenses(ctx echo.Context) error { - var err error - - // Parameter object where we will unmarshal all parameters from the context - var params PostExpensesParams - // ------------- Optional query parameter "name" ------------- - - err = runtime.BindQueryParameter("form", true, false, "name", ctx.QueryParams(), ¶ms.Name) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) - } - - // ------------- Optional query parameter "year_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "year_id", ctx.QueryParams(), ¶ms.YearId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year_id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostExpenses(ctx, params) - return err -} - -// GetExpensesDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesDetails(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetExpensesDetails(ctx) - return err -} - -// GetExpensesDetailsYear converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesDetailsYear(ctx echo.Context) error { - var err error - // ------------- Path parameter "year" ------------- - var year int - - err = runtime.BindStyledParameterWithOptions("simple", "year", ctx.Param("year"), &year, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - 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.GetExpensesDetailsYear(ctx, year) - return err -} - -// GetExpensesFiscalyearYear converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesFiscalyearYear(ctx echo.Context) error { - var err error - // ------------- Path parameter "year" ------------- - var year int - - err = runtime.BindStyledParameterWithOptions("simple", "year", ctx.Param("year"), &year, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - 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.GetExpensesFiscalyearYear(ctx, year) - return err -} - -// DeleteExpensesId converts echo context to params. -func (w *ServerInterfaceWrapper) DeleteExpensesId(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.DeleteExpensesId(ctx, id) - return err -} - -// GetExpensesId converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesId(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.GetExpensesId(ctx, id) - return err -} - -// PutExpensesId converts echo context to params. -func (w *ServerInterfaceWrapper) PutExpensesId(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 PutExpensesIdParams - // ------------- Optional query parameter "name" ------------- - - err = runtime.BindQueryParameter("form", true, false, "name", ctx.QueryParams(), ¶ms.Name) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) - } - - // ------------- Optional query parameter "year_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "year_id", ctx.QueryParams(), ¶ms.YearId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year_id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PutExpensesId(ctx, id, params) - return err -} - -// GetExpensesIdDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesIdDetails(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.GetExpensesIdDetails(ctx, id) - return err -} - // GetFestivalItems converts echo context to params. func (w *ServerInterfaceWrapper) GetFestivalItems(ctx echo.Context) error { var err error @@ -2324,172 +1863,6 @@ func (w *ServerInterfaceWrapper) PostPasswordResetIdValid(ctx echo.Context) erro return err } -// GetReceipts converts echo context to params. -func (w *ServerInterfaceWrapper) GetReceipts(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetReceipts(ctx) - return err -} - -// PostReceipts converts echo context to params. -func (w *ServerInterfaceWrapper) PostReceipts(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostReceipts(ctx) - return err -} - -// GetReceiptsReportsId converts echo context to params. -func (w *ServerInterfaceWrapper) GetReceiptsReportsId(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.GetReceiptsReportsId(ctx, id) - return err -} - -// DeleteReceiptsId converts echo context to params. -func (w *ServerInterfaceWrapper) DeleteReceiptsId(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.DeleteReceiptsId(ctx, id) - return err -} - -// GetReceiptsId converts echo context to params. -func (w *ServerInterfaceWrapper) GetReceiptsId(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.GetReceiptsId(ctx, id) - return err -} - -// PutReceiptsId converts echo context to params. -func (w *ServerInterfaceWrapper) PutReceiptsId(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.PutReceiptsId(ctx, id) - return err -} - -// GetSources converts echo context to params. -func (w *ServerInterfaceWrapper) GetSources(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetSources(ctx) - return err -} - -// PostSources converts echo context to params. -func (w *ServerInterfaceWrapper) PostSources(ctx echo.Context) error { - var err error - - // Parameter object where we will unmarshal all parameters from the context - var params PostSourcesParams - // ------------- Required query parameter "name" ------------- - - err = runtime.BindQueryParameter("form", true, true, "name", ctx.QueryParams(), ¶ms.Name) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostSources(ctx, params) - return err -} - -// DeleteSourcesId converts echo context to params. -func (w *ServerInterfaceWrapper) DeleteSourcesId(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.DeleteSourcesId(ctx, id) - return err -} - -// GetSourcesId converts echo context to params. -func (w *ServerInterfaceWrapper) GetSourcesId(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.GetSourcesId(ctx, id) - return err -} - -// PutSourcesId converts echo context to params. -func (w *ServerInterfaceWrapper) PutSourcesId(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 PutSourcesIdParams - // ------------- Required query parameter "name" ------------- - - err = runtime.BindQueryParameter("form", true, true, "name", ctx.QueryParams(), ¶ms.Name) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PutSourcesId(ctx, id, params) - return err -} - // GetSponsors converts echo context to params. func (w *ServerInterfaceWrapper) GetSponsors(ctx echo.Context) error { var err error @@ -3128,14 +2501,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.DELETE(baseURL+"/activity_styles/:id", wrapper.DeleteActivityStylesId) router.GET(baseURL+"/activity_styles/:id", wrapper.GetActivityStylesId) router.PUT(baseURL+"/activity_styles/:id", wrapper.PutActivityStylesId) - router.GET(baseURL+"/budgets", wrapper.GetBudgets) - router.POST(baseURL+"/budgets", wrapper.PostBudgets) - router.GET(baseURL+"/budgets/details", wrapper.GetBudgetsDetails) - router.GET(baseURL+"/budgets/details/:year", wrapper.GetBudgetsDetailsYear) - router.DELETE(baseURL+"/budgets/:id", wrapper.DeleteBudgetsId) - router.GET(baseURL+"/budgets/:id", wrapper.GetBudgetsId) - router.PUT(baseURL+"/budgets/:id", wrapper.PutBudgetsId) - router.GET(baseURL+"/budgets/:id/details", wrapper.GetBudgetsIdDetails) router.GET(baseURL+"/bureaus", wrapper.GetBureaus) router.POST(baseURL+"/bureaus", wrapper.PostBureaus) router.DELETE(baseURL+"/bureaus/:id", wrapper.DeleteBureausId) @@ -3155,15 +2520,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.POST(baseURL+"/divisions", wrapper.PostDivisions) router.DELETE(baseURL+"/divisions/:id", wrapper.DeleteDivisionsId) router.PUT(baseURL+"/divisions/:id", wrapper.PutDivisionsId) - router.GET(baseURL+"/expenses", wrapper.GetExpenses) - router.POST(baseURL+"/expenses", wrapper.PostExpenses) - router.GET(baseURL+"/expenses/details", wrapper.GetExpensesDetails) - router.GET(baseURL+"/expenses/details/:year", wrapper.GetExpensesDetailsYear) - router.GET(baseURL+"/expenses/fiscalyear/:year", wrapper.GetExpensesFiscalyearYear) - router.DELETE(baseURL+"/expenses/:id", wrapper.DeleteExpensesId) - router.GET(baseURL+"/expenses/:id", wrapper.GetExpensesId) - router.PUT(baseURL+"/expenses/:id", wrapper.PutExpensesId) - router.GET(baseURL+"/expenses/:id/details", wrapper.GetExpensesIdDetails) router.GET(baseURL+"/festival_items", wrapper.GetFestivalItems) router.POST(baseURL+"/festival_items", wrapper.PostFestivalItems) router.GET(baseURL+"/festival_items/details/:user_id", wrapper.GetFestivalItemsDetailsUserId) @@ -3184,17 +2540,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.POST(baseURL+"/password_reset/request", wrapper.PostPasswordResetRequest) router.POST(baseURL+"/password_reset/:id", wrapper.PostPasswordResetId) router.POST(baseURL+"/password_reset/:id/valid", wrapper.PostPasswordResetIdValid) - router.GET(baseURL+"/receipts", wrapper.GetReceipts) - router.POST(baseURL+"/receipts", wrapper.PostReceipts) - router.GET(baseURL+"/receipts/reports/:id", wrapper.GetReceiptsReportsId) - router.DELETE(baseURL+"/receipts/:id", wrapper.DeleteReceiptsId) - router.GET(baseURL+"/receipts/:id", wrapper.GetReceiptsId) - router.PUT(baseURL+"/receipts/:id", wrapper.PutReceiptsId) - router.GET(baseURL+"/sources", wrapper.GetSources) - router.POST(baseURL+"/sources", wrapper.PostSources) - router.DELETE(baseURL+"/sources/:id", wrapper.DeleteSourcesId) - router.GET(baseURL+"/sources/:id", wrapper.GetSourcesId) - router.PUT(baseURL+"/sources/:id", wrapper.PutSourcesId) router.GET(baseURL+"/sponsors", wrapper.GetSponsors) router.POST(baseURL+"/sponsors", wrapper.PostSponsors) router.GET(baseURL+"/sponsors/periods/:year", wrapper.GetSponsorsPeriodsYear) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index a01939b1b..bb328fe82 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -408,172 +408,6 @@ paths: application/json: schema: type: object - - /budgets: - get: - tags: - - budget - description: budgetの一覧を取得 - responses: - "200": - description: budgetの一覧の取得 - content: - application/json: - schema: - type: object - post: - tags: - - budget - description: budgetの作成 - parameters: - - name: price - in: query - description: price - required: true - schema: - type: integer - - name: year_id - in: query - description: year_id - schema: - type: integer - - name: source_id - in: query - description: source_id - schema: - type: integer - responses: - "200": - description: create されたbudgetが返ってくる - content: - application/json: - schema: - type: object - - /budgets/details: - get: - tags: - - budget - description: budgetに紐づくyearとsourceの一覧を取得 - responses: - "200": - description: budgetに紐づくyearとsourceの一覧を取得 - content: - application/json: - schema: - type: object - - /budgets/details/{year}: - get: - tags: - - budget - description: 年度で指定されたbudgetsに紐づく年度とソースを取得 - parameters: - - name: year - in: path - description: year - required: true - schema: - type: integer - responses: - "200": - description: 年度で指定されたbudgetsに紐づく年度とソースを取得 - content: - application/json: - schema: - type: object - - /budgets/{id}: - get: - tags: - - budget - description: IDで指定されたbudgetの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: budgetの取得 - content: - application/json: - schema: - type: object - put: - tags: - - budget - description: budgetの更新 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - - name: price - in: query - description: price - schema: - type: integer - - name: year_id - in: query - description: year_id - schema: - type: integer - - name: source_id - in: query - description: source_id - schema: - type: integer - responses: - "200": - description: 更新されたbudgetが返ってくる - content: - application/json: - schema: - type: object - delete: - tags: - - budget - description: IDを指定してbudgetの削除 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: budgetの削除完了 - content: - application/json: - schema: - type: object - - /budgets/{id}/details: - get: - tags: - - budget - description: IDで指定されたbudgetに紐づくyearとsourceを取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: budgetに紐づくyearとsourceを取得 - content: - application/json: - schema: - type: object - /bureaus: get: tags: @@ -973,179 +807,6 @@ paths: application/json: schema: type: object - /expenses: - get: - tags: - - expense - description: expenseの一覧の取得 - responses: - "200": - description: expenseの一覧を取得 - content: - application/json: - schema: - type: object - post: - tags: - - expense - description: expenseの作成 - parameters: - - name: name - in: query - description: name - schema: - type: string - - name: year_id - in: query - description: year_id - schema: - type: string - responses: - "200": - description: 作成されたexpenseが返ってくる - content: - application/json: - schema: - type: object - - /expenses/details: - get: - tags: - - expense - description: expenseに紐づくpurchase_itemの一覧を取得 - responses: - "200": - description: expenseに紐づくpurchase_itemの一覧を取得 - content: - application/json: - schema: - type: object - - /expenses/{id}: - get: - tags: - - expense - description: IDで指定されたexpenseの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: expenseの取得 - content: - application/json: - schema: - type: object - put: - tags: - - expense - description: expenseの更新 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - - name: name - in: query - description: name - schema: - type: string - - name: year_id - in: query - description: year_id - schema: - type: string - responses: - "200": - description: 更新されたexpenseが返ってくる - content: - application/json: - schema: - type: object - delete: - tags: - - expense - description: IDを指定してexpenseの削除 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: expenseの削除完了 - content: - application/json: - schema: - type: object - - /expenses/{id}/details: - get: - tags: - - expense - description: IDで指定されたexpenseに紐づくpurchase_itemsを取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: IDで指定されたexpenseに紐づくpurchase_itemsを取得 - content: - application/json: - schema: - type: object - - /expenses/details/{year}: - get: - tags: - - expense - description: 年度で指定されたexpenseに紐づく購入申請と購入報告を取得 - parameters: - - name: year - in: path - description: year - required: true - schema: - type: integer - responses: - "200": - description: yearで指定されたexpenseに紐づく購入申請と購入報告を取得 - content: - application/json: - schema: - type: object - - /expenses/fiscalyear/{year}: - get: - tags: - - expense - description: 年度で指定されたexpensesを取得 - parameters: - - name: year - in: path - description: year - required: true - schema: - type: integer - responses: - "200": - description: yearで指定されたexpensesを取得 - content: - application/json: - schema: - type: object /festival_items: get: tags: @@ -1615,214 +1276,6 @@ paths: application/json: schema: type: object - - /receipts: - get: - tags: - - receipt - description: receiptの一覧を取得 - responses: - "200": - description: receiptの一覧の取得 - content: - application/json: - schema: - type: object - post: - tags: - - receipt - description: receiptの作成 - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/receipt" - required: false - responses: - "200": - description: create されたreceiptが返ってくる - content: - application/json: - schema: - type: object - x-codegen-request-body-name: receipt - - /receipts/{id}: - get: - tags: - - receipt - description: IDで指定されたreceiptの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: receiptの取得 - content: - application/json: - schema: - type: object - put: - tags: - - receipt - description: receiptの更新 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/receipt" - required: false - responses: - "200": - description: 更新されたreceiptが返ってくる - content: - application/json: - schema: - type: object - x-codegen-request-body-name: receipt - delete: - tags: - - receipt - description: IDを指定してreceiptの削除 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: receiptの削除完了 - content: - application/json: - schema: - type: object - - /receipts/reports/{id}: - get: - tags: - - receipt - description: 購入報告に紐づいたreceiptの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: reportsIDを指定してreceiptの取得 - content: - application/json: - schema: - type: object - - /sources: - get: - tags: - - source - description: sourceの一覧の取得 - responses: - "200": - description: sourceの一覧を取得 - content: - application/json: - schema: - type: object - post: - tags: - - source - description: sourceの作成 - parameters: - - name: name - in: query - description: name - required: true - schema: - type: string - responses: - "200": - description: 作成されたsourceが返ってくる - content: - application/json: - schema: - type: object - - /sources/{id}: - get: - tags: - - source - description: IDで指定されたsourceの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: sourceの取得 - content: - application/json: - schema: - type: object - put: - tags: - - source - description: sourceの更新 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - - name: name - in: query - description: name - required: true - schema: - type: string - responses: - "200": - description: 更新されたsourceが返ってくる - content: - application/json: - schema: - type: object - delete: - tags: - - source - description: IDを指定してsourceの削除 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: sourceの削除完了 - content: - application/json: - schema: - type: object - /sponsors: get: tags: @@ -2935,26 +2388,6 @@ components: example: [] items: type: number - receipt: - required: - - purchaseReportID - type: object - properties: - purchaseReportID: - type: integer - example: 1 - bucketName: - type: string - example: "" - fileName: - type: string - example: "" - fileType: - type: string - example: "" - remark: - type: string - example: "" total: type: object properties: diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index 01c4469cf..ebf63d243 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -24,17 +24,13 @@ import type { DeleteActivitiesId200, DeleteActivityInformationsId200, DeleteActivityStylesId200, - DeleteBudgetsId200, DeleteBureausId200, DeleteBuyReportsId200, DeleteDepartmentsId200, DeleteDivisionsId200, - DeleteExpensesId200, DeleteFestivalItemsId200, DeleteFinancialRecordsId200, DeleteFundInformationsId200, - DeleteReceiptsId200, - DeleteSourcesId200, DeleteSponsorsId200, DeleteSponsorstylesId200, DeleteTeachersDelete200, @@ -67,23 +63,12 @@ import type { GetActivityInformationsId200, GetActivityStyles200, GetActivityStylesId200, - GetBudgets200, - GetBudgetsDetails200, - GetBudgetsDetailsYear200, - GetBudgetsId200, - GetBudgetsIdDetails200, GetBureaus200, GetBureausId200, GetBuyReportsDetailsParams, GetDepartments200, GetDepartmentsId200, GetDivisionsParams, - GetExpenses200, - GetExpensesDetails200, - GetExpensesDetailsYear200, - GetExpensesFiscalyearYear200, - GetExpensesId200, - GetExpensesIdDetails200, GetFestivalItemsDetailsUserIdParams, GetFestivalItemsParams, GetFinancialRecordsParams, @@ -92,11 +77,6 @@ import type { GetFundInformationsDetailsYear200, GetFundInformationsId200, GetFundInformationsIdDetails200, - GetReceipts200, - GetReceiptsId200, - GetReceiptsReportsId200, - GetSources200, - GetSourcesId200, GetSponsorstyles200, GetSponsorstylesId200, GetTeachersFundRegisteredYear200, @@ -106,15 +86,11 @@ import type { PostActivities200, PostActivityInformations200, PostActivityStyles200, - PostBudgets200, - PostBudgetsParams, PostBureaus200, PostBureausParams, PostBuyReportsBody, PostDepartments200, PostDepartmentsParams, - PostExpenses200, - PostExpensesParams, PostFundInformations200, PostFundInformationsParams, PostPasswordResetId200, @@ -122,9 +98,6 @@ import type { PostPasswordResetIdValidParams, PostPasswordResetRequest200, PostPasswordResetRequestParams, - PostReceipts200, - PostSources200, - PostSourcesParams, PostSponsors200, PostSponsorstyles200, PostTeachers200, @@ -139,21 +112,14 @@ import type { PutActivitiesId200, PutActivityInformationsId200, PutActivityStylesId200, - PutBudgetsId200, - PutBudgetsIdParams, PutBureausId200, PutBureausIdParams, PutBuyReportStatusBuyReportIdBody, PutBuyReportsIdBody, PutDepartmentsId200, PutDepartmentsIdParams, - PutExpensesId200, - PutExpensesIdParams, PutFundInformationsId200, PutFundInformationsIdParams, - PutReceiptsId200, - PutSourcesId200, - PutSourcesIdParams, PutSponsorsId200, PutSponsorstylesId200, PutTeachersId200, @@ -163,7 +129,6 @@ import type { PutYearsId200, PutYearsIdParams, PutYearsPeriodsId200, - Receipt, Sponsor, SponsorStyle, YearPeriods @@ -1221,23 +1186,23 @@ export const useDeleteActivityStylesId = ( } /** - * budgetの一覧を取得 + * bureauの一覧を取得 */ -export type getBudgetsResponse = { - data: GetBudgets200; +export type getBureausResponse = { + data: GetBureaus200; status: number; headers: Headers; } -export const getGetBudgetsUrl = () => { +export const getGetBureausUrl = () => { - return `/budgets` + return `/bureaus` } -export const getBudgets = async ( options?: RequestInit): Promise => { +export const getBureaus = async ( options?: RequestInit): Promise => { - return customFetch>(getGetBudgetsUrl(), + return customFetch>(getGetBureausUrl(), { ...options, method: 'GET' @@ -1249,19 +1214,19 @@ export const getBudgets = async ( options?: RequestInit): Promise [`/budgets`] as const; +export const getGetBureausKey = () => [`/bureaus`] as const; -export type GetBudgetsQueryResult = NonNullable>> -export type GetBudgetsQueryError = unknown +export type GetBureausQueryResult = NonNullable>> +export type GetBureausQueryError = unknown -export const useGetBudgets = ( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetBureaus = ( + 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 ? getGetBudgetsKey() : null); - const swrFn = () => getBudgets(requestOptions) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBureausKey() : null); + const swrFn = () => getBureaus(requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -1272,15 +1237,15 @@ export const useGetBudgets = ( } /** - * budgetの作成 + * bureauの作成 */ -export type postBudgetsResponse = { - data: PostBudgets200; +export type postBureausResponse = { + data: PostBureaus200; status: number; headers: Headers; } -export const getPostBudgetsUrl = (params: PostBudgetsParams,) => { +export const getPostBureausUrl = (params: PostBureausParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { @@ -1290,12 +1255,12 @@ export const getPostBudgetsUrl = (params: PostBudgetsParams,) => { } }); - return normalizedParams.size ? `/budgets?${normalizedParams.toString()}` : `/budgets` + return normalizedParams.size ? `/bureaus?${normalizedParams.toString()}` : `/bureaus` } -export const postBudgets = async (params: PostBudgetsParams, options?: RequestInit): Promise => { +export const postBureaus = async (params: PostBureausParams, options?: RequestInit): Promise => { - return customFetch>(getPostBudgetsUrl(params), + return customFetch>(getPostBureausUrl(params), { ...options, method: 'POST' @@ -1307,24 +1272,24 @@ export const postBudgets = async (params: PostBudgetsParams, options?: RequestIn -export const getPostBudgetsMutationFetcher = (params: PostBudgetsParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postBudgets(params, options); +export const getPostBureausMutationFetcher = (params: PostBureausParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postBureaus(params, options); } } -export const getPostBudgetsMutationKey = (params: PostBudgetsParams,) => [`/budgets`, ...(params ? [params]: [])] as const; +export const getPostBureausMutationKey = (params: PostBureausParams,) => [`/bureaus`, ...(params ? [params]: [])] as const; -export type PostBudgetsMutationResult = NonNullable>> -export type PostBudgetsMutationError = unknown +export type PostBureausMutationResult = NonNullable>> +export type PostBureausMutationError = unknown -export const usePostBudgets = ( - params: PostBudgetsParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostBureaus = ( + params: PostBureausParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostBudgetsMutationKey(params); - const swrFn = getPostBudgetsMutationFetcher(params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostBureausMutationKey(params); + const swrFn = getPostBureausMutationFetcher(params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -1335,23 +1300,23 @@ export const usePostBudgets = ( } /** - * budgetに紐づくyearとsourceの一覧を取得 + * IDで指定されたbureauの取得 */ -export type getBudgetsDetailsResponse = { - data: GetBudgetsDetails200; +export type getBureausIdResponse = { + data: GetBureausId200; status: number; headers: Headers; } -export const getGetBudgetsDetailsUrl = () => { +export const getGetBureausIdUrl = (id: number,) => { - return `/budgets/details` + return `/bureaus/${id}` } -export const getBudgetsDetails = async ( options?: RequestInit): Promise => { +export const getBureausId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getGetBudgetsDetailsUrl(), + return customFetch>(getGetBureausIdUrl(id), { ...options, method: 'GET' @@ -1363,19 +1328,19 @@ export const getBudgetsDetails = async ( options?: RequestInit): Promise [`/budgets/details`] as const; +export const getGetBureausIdKey = (id: number,) => [`/bureaus/${id}`] as const; -export type GetBudgetsDetailsQueryResult = NonNullable>> -export type GetBudgetsDetailsQueryError = unknown +export type GetBureausIdQueryResult = NonNullable>> +export type GetBureausIdQueryError = unknown -export const useGetBudgetsDetails = ( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetBureausId = ( + id: number, 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 ? getGetBudgetsDetailsKey() : null); - const swrFn = () => getBudgetsDetails(requestOptions) + const isEnabled = swrOptions?.enabled !== false && !!(id) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBureausIdKey(id) : null); + const swrFn = () => getBureausId(id, requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -1386,26 +1351,35 @@ export const useGetBudgetsDetails = ( } /** - * 年度で指定されたbudgetsに紐づく年度とソースを取得 + * bureauの更新 */ -export type getBudgetsDetailsYearResponse = { - data: GetBudgetsDetailsYear200; +export type putBureausIdResponse = { + data: PutBureausId200; status: number; headers: Headers; } -export const getGetBudgetsDetailsYearUrl = (year: number,) => { +export const getPutBureausIdUrl = (id: number, + params?: PutBureausIdParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/budgets/details/${year}` + return normalizedParams.size ? `/bureaus/${id}?${normalizedParams.toString()}` : `/bureaus/${id}` } -export const getBudgetsDetailsYear = async (year: number, options?: RequestInit): Promise => { +export const putBureausId = async (id: number, + params?: PutBureausIdParams, options?: RequestInit): Promise => { - return customFetch>(getGetBudgetsDetailsYearUrl(year), + return customFetch>(getPutBureausIdUrl(id,params), { ...options, - method: 'GET' + method: 'PUT' } @@ -1414,21 +1388,29 @@ export const getBudgetsDetailsYear = async (year: number, options?: RequestInit) -export const getGetBudgetsDetailsYearKey = (year: number,) => [`/budgets/details/${year}`] as const; +export const getPutBureausIdMutationFetcher = (id: number, + params?: PutBureausIdParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return putBureausId(id, params, options); + } +} +export const getPutBureausIdMutationKey = (id: number, + params?: PutBureausIdParams,) => [`/bureaus/${id}`, ...(params ? [params]: [])] as const; -export type GetBudgetsDetailsYearQueryResult = NonNullable>> -export type GetBudgetsDetailsYearQueryError = unknown +export type PutBureausIdMutationResult = NonNullable>> +export type PutBureausIdMutationError = unknown -export const useGetBudgetsDetailsYear = ( - year: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const usePutBureausId = ( + id: number, + params?: PutBureausIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(year) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBudgetsDetailsYearKey(year) : null); - const swrFn = () => getBudgetsDetailsYear(year, requestOptions) + const swrKey = swrOptions?.swrKey ?? getPutBureausIdMutationKey(id,params); + const swrFn = getPutBureausIdMutationFetcher(id,params, requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -1437,26 +1419,26 @@ export const useGetBudgetsDetailsYear = ( } /** - * IDで指定されたbudgetの取得 + * IDを指定してbureauの削除 */ -export type getBudgetsIdResponse = { - data: GetBudgetsId200; +export type deleteBureausIdResponse = { + data: DeleteBureausId200; status: number; headers: Headers; } -export const getGetBudgetsIdUrl = (id: number,) => { +export const getDeleteBureausIdUrl = (id: number,) => { - return `/budgets/${id}` + return `/bureaus/${id}` } -export const getBudgetsId = async (id: number, options?: RequestInit): Promise => { +export const deleteBureausId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getGetBudgetsIdUrl(id), + return customFetch>(getDeleteBureausIdUrl(id), { ...options, - method: 'GET' + method: 'DELETE' } @@ -1465,21 +1447,26 @@ export const getBudgetsId = async (id: number, options?: RequestInit): Promise [`/budgets/${id}`] as const; +export const getDeleteBureausIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteBureausId(id, options); + } +} +export const getDeleteBureausIdMutationKey = (id: number,) => [`/bureaus/${id}`] as const; -export type GetBudgetsIdQueryResult = NonNullable>> -export type GetBudgetsIdQueryError = unknown +export type DeleteBureausIdMutationResult = NonNullable>> +export type DeleteBureausIdMutationError = unknown -export const useGetBudgetsId = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useDeleteBureausId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(id) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBudgetsIdKey(id) : null); - const swrFn = () => getBudgetsId(id, requestOptions) + const swrKey = swrOptions?.swrKey ?? getDeleteBureausIdMutationKey(id); + const swrFn = getDeleteBureausIdMutationFetcher(id, requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -1488,64 +1475,56 @@ export const useGetBudgetsId = ( } /** - * budgetの更新 + * 購入報告を行うAPI */ -export type putBudgetsIdResponse = { - data: PutBudgetsId200; +export type postBuyReportsResponse = { + data: BuyReport; status: number; headers: Headers; } -export const getPutBudgetsIdUrl = (id: number, - params?: PutBudgetsIdParams,) => { - const normalizedParams = new URLSearchParams(); +export const getPostBuyReportsUrl = () => { - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - return normalizedParams.size ? `/budgets/${id}?${normalizedParams.toString()}` : `/budgets/${id}` + return `/buy_reports` } -export const putBudgetsId = async (id: number, - params?: PutBudgetsIdParams, options?: RequestInit): Promise => { - - return customFetch>(getPutBudgetsIdUrl(id,params), +export const postBuyReports = async (postBuyReportsBody: PostBuyReportsBody, options?: RequestInit): Promise => { + const formData = new FormData(); +formData.append('file', postBuyReportsBody.file) +formData.append('buy_report', JSON.stringify(postBuyReportsBody.buy_report)); + + return customFetch>(getPostBuyReportsUrl(), { ...options, - method: 'PUT' - - + method: 'POST' + , + body: + formData, } );} -export const getPutBudgetsIdMutationFetcher = (id: number, - params?: PutBudgetsIdParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putBudgetsId(id, params, options); +export const getPostBuyReportsMutationFetcher = ( options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PostBuyReportsBody }): Promise => { + return postBuyReports(arg, options); } } -export const getPutBudgetsIdMutationKey = (id: number, - params?: PutBudgetsIdParams,) => [`/budgets/${id}`, ...(params ? [params]: [])] as const; +export const getPostBuyReportsMutationKey = () => [`/buy_reports`] as const; -export type PutBudgetsIdMutationResult = NonNullable>> -export type PutBudgetsIdMutationError = unknown +export type PostBuyReportsMutationResult = NonNullable>> +export type PostBuyReportsMutationError = unknown -export const usePutBudgetsId = ( - id: number, - params?: PutBudgetsIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostBuyReports = ( + options?: { swr?:SWRMutationConfiguration>, TError, Key, PostBuyReportsBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPutBudgetsIdMutationKey(id,params); - const swrFn = getPutBudgetsIdMutationFetcher(id,params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostBuyReportsMutationKey(); + const swrFn = getPostBuyReportsMutationFetcher(requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -1556,52 +1535,59 @@ export const usePutBudgetsId = ( } /** - * IDを指定してbudgetの削除 + * 購入報告を修正するAPI、画像がある場合は画像も更新 */ -export type deleteBudgetsIdResponse = { - data: DeleteBudgetsId200; +export type putBuyReportsIdResponse = { + data: BuyReport; status: number; headers: Headers; } -export const getDeleteBudgetsIdUrl = (id: number,) => { +export const getPutBuyReportsIdUrl = (id: number,) => { - return `/budgets/${id}` + return `/buy_reports/${id}` } -export const deleteBudgetsId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getDeleteBudgetsIdUrl(id), +export const putBuyReportsId = async (id: number, + putBuyReportsIdBody: PutBuyReportsIdBody, options?: RequestInit): Promise => { + const formData = new FormData(); +if(putBuyReportsIdBody.file !== undefined) { + formData.append('file', putBuyReportsIdBody.file) + } +formData.append('buy_report', JSON.stringify(putBuyReportsIdBody.buy_report)); + + return customFetch>(getPutBuyReportsIdUrl(id), { ...options, - method: 'DELETE' - - + method: 'PUT' + , + body: + formData, } );} -export const getDeleteBudgetsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteBudgetsId(id, options); +export const getPutBuyReportsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PutBuyReportsIdBody }): Promise => { + return putBuyReportsId(id, arg, options); } } -export const getDeleteBudgetsIdMutationKey = (id: number,) => [`/budgets/${id}`] as const; +export const getPutBuyReportsIdMutationKey = (id: number,) => [`/buy_reports/${id}`] as const; -export type DeleteBudgetsIdMutationResult = NonNullable>> -export type DeleteBudgetsIdMutationError = unknown +export type PutBuyReportsIdMutationResult = NonNullable>> +export type PutBuyReportsIdMutationError = unknown -export const useDeleteBudgetsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutBuyReportsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, PutBuyReportsIdBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getDeleteBudgetsIdMutationKey(id); - const swrFn = getDeleteBudgetsIdMutationFetcher(id, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutBuyReportsIdMutationKey(id); + const swrFn = getPutBuyReportsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -1612,26 +1598,26 @@ export const useDeleteBudgetsId = ( } /** - * IDで指定されたbudgetに紐づくyearとsourceを取得 + * IDを指定してbuy_reportの削除、紐づいた画像も削除、マイページから削除できる */ -export type getBudgetsIdDetailsResponse = { - data: GetBudgetsIdDetails200; +export type deleteBuyReportsIdResponse = { + data: DeleteBuyReportsId200; status: number; headers: Headers; } -export const getGetBudgetsIdDetailsUrl = (id: number,) => { +export const getDeleteBuyReportsIdUrl = (id: number,) => { - return `/budgets/${id}/details` + return `/buy_reports/${id}` } -export const getBudgetsIdDetails = async (id: number, options?: RequestInit): Promise => { +export const deleteBuyReportsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getGetBudgetsIdDetailsUrl(id), + return customFetch>(getDeleteBuyReportsIdUrl(id), { ...options, - method: 'GET' + method: 'DELETE' } @@ -1640,21 +1626,26 @@ export const getBudgetsIdDetails = async (id: number, options?: RequestInit): Pr -export const getGetBudgetsIdDetailsKey = (id: number,) => [`/budgets/${id}/details`] as const; +export const getDeleteBuyReportsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteBuyReportsId(id, options); + } +} +export const getDeleteBuyReportsIdMutationKey = (id: number,) => [`/buy_reports/${id}`] as const; -export type GetBudgetsIdDetailsQueryResult = NonNullable>> -export type GetBudgetsIdDetailsQueryError = unknown +export type DeleteBuyReportsIdMutationResult = NonNullable>> +export type DeleteBuyReportsIdMutationError = unknown -export const useGetBudgetsIdDetails = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useDeleteBuyReportsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(id) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBudgetsIdDetailsKey(id) : null); - const swrFn = () => getBudgetsIdDetails(id, requestOptions) + const swrKey = swrOptions?.swrKey ?? getDeleteBuyReportsIdMutationKey(id); + const swrFn = getDeleteBuyReportsIdMutationFetcher(id, requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -1663,23 +1654,30 @@ export const useGetBudgetsIdDetails = ( } /** - * bureauの一覧を取得 + * 購入報告で表示するbuy_report一覧の取得、主に財務向けのページ */ -export type getBureausResponse = { - data: GetBureaus200; +export type getBuyReportsDetailsResponse = { + data: BuyReportDetail[]; status: number; headers: Headers; } -export const getGetBureausUrl = () => { +export const getGetBuyReportsDetailsUrl = (params?: GetBuyReportsDetailsParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/bureaus` + return normalizedParams.size ? `/buy_reports/details?${normalizedParams.toString()}` : `/buy_reports/details` } -export const getBureaus = async ( options?: RequestInit): Promise => { +export const getBuyReportsDetails = async (params?: GetBuyReportsDetailsParams, options?: RequestInit): Promise => { - return customFetch>(getGetBureausUrl(), + return customFetch>(getGetBuyReportsDetailsUrl(params), { ...options, method: 'GET' @@ -1691,19 +1689,19 @@ export const getBureaus = async ( options?: RequestInit): Promise [`/bureaus`] as const; +export const getGetBuyReportsDetailsKey = (params?: GetBuyReportsDetailsParams,) => [`/buy_reports/details`, ...(params ? [params]: [])] as const; -export type GetBureausQueryResult = NonNullable>> -export type GetBureausQueryError = unknown +export type GetBuyReportsDetailsQueryResult = NonNullable>> +export type GetBuyReportsDetailsQueryError = unknown -export const useGetBureaus = ( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetBuyReportsDetails = ( + params?: GetBuyReportsDetailsParams, 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 ? getGetBureausKey() : null); - const swrFn = () => getBureaus(requestOptions) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBuyReportsDetailsKey(params) : null); + const swrFn = () => getBuyReportsDetails(params, requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -1714,59 +1712,54 @@ export const useGetBureaus = ( } /** - * bureauの作成 + * buy_reportのステータス更新、財務が封詰め、精算済みにするAPI */ -export type postBureausResponse = { - data: PostBureaus200; +export type putBuyReportStatusBuyReportIdResponse = { + data: BuyReportDetail; status: number; headers: Headers; } -export const getPostBureausUrl = (params: PostBureausParams,) => { - const normalizedParams = new URLSearchParams(); +export const getPutBuyReportStatusBuyReportIdUrl = (buyReportId: number,) => { - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - return normalizedParams.size ? `/bureaus?${normalizedParams.toString()}` : `/bureaus` + return `/buy_report/status/${buyReportId}` } -export const postBureaus = async (params: PostBureausParams, options?: RequestInit): Promise => { +export const putBuyReportStatusBuyReportId = async (buyReportId: number, + putBuyReportStatusBuyReportIdBody: PutBuyReportStatusBuyReportIdBody, options?: RequestInit): Promise => { - return customFetch>(getPostBureausUrl(params), + return customFetch>(getPutBuyReportStatusBuyReportIdUrl(buyReportId), { ...options, - method: 'POST' - - + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + putBuyReportStatusBuyReportIdBody,) } );} -export const getPostBureausMutationFetcher = (params: PostBureausParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postBureaus(params, options); +export const getPutBuyReportStatusBuyReportIdMutationFetcher = (buyReportId: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PutBuyReportStatusBuyReportIdBody }): Promise => { + return putBuyReportStatusBuyReportId(buyReportId, arg, options); } } -export const getPostBureausMutationKey = (params: PostBureausParams,) => [`/bureaus`, ...(params ? [params]: [])] as const; +export const getPutBuyReportStatusBuyReportIdMutationKey = (buyReportId: number,) => [`/buy_report/status/${buyReportId}`] as const; -export type PostBureausMutationResult = NonNullable>> -export type PostBureausMutationError = unknown +export type PutBuyReportStatusBuyReportIdMutationResult = NonNullable>> +export type PutBuyReportStatusBuyReportIdMutationError = unknown -export const usePostBureaus = ( - params: PostBureausParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutBuyReportStatusBuyReportId = ( + buyReportId: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, PutBuyReportStatusBuyReportIdBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostBureausMutationKey(params); - const swrFn = getPostBureausMutationFetcher(params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutBuyReportStatusBuyReportIdMutationKey(buyReportId); + const swrFn = getPutBuyReportStatusBuyReportIdMutationFetcher(buyReportId, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -1777,23 +1770,23 @@ export const usePostBureaus = ( } /** - * IDで指定されたbureauの取得 + * departmentの一覧の取得 */ -export type getBureausIdResponse = { - data: GetBureausId200; +export type getDepartmentsResponse = { + data: GetDepartments200; status: number; headers: Headers; } -export const getGetBureausIdUrl = (id: number,) => { +export const getGetDepartmentsUrl = () => { - return `/bureaus/${id}` + return `/departments` } -export const getBureausId = async (id: number, options?: RequestInit): Promise => { +export const getDepartments = async ( options?: RequestInit): Promise => { - return customFetch>(getGetBureausIdUrl(id), + return customFetch>(getGetDepartmentsUrl(), { ...options, method: 'GET' @@ -1805,19 +1798,19 @@ export const getBureausId = async (id: number, options?: RequestInit): Promise [`/bureaus/${id}`] as const; +export const getGetDepartmentsKey = () => [`/departments`] as const; -export type GetBureausIdQueryResult = NonNullable>> -export type GetBureausIdQueryError = unknown +export type GetDepartmentsQueryResult = NonNullable>> +export type GetDepartmentsQueryError = unknown -export const useGetBureausId = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetDepartments = ( + 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 ? getGetBureausIdKey(id) : null); - const swrFn = () => getBureausId(id, requestOptions) + const isEnabled = swrOptions?.enabled !== false + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDepartmentsKey() : null); + const swrFn = () => getDepartments(requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -1828,16 +1821,15 @@ export const useGetBureausId = ( } /** - * bureauの更新 + * departmentの作成 */ -export type putBureausIdResponse = { - data: PutBureausId200; +export type postDepartmentsResponse = { + data: PostDepartments200; status: number; headers: Headers; } -export const getPutBureausIdUrl = (id: number, - params?: PutBureausIdParams,) => { +export const getPostDepartmentsUrl = (params?: PostDepartmentsParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { @@ -1847,16 +1839,15 @@ export const getPutBureausIdUrl = (id: number, } }); - return normalizedParams.size ? `/bureaus/${id}?${normalizedParams.toString()}` : `/bureaus/${id}` + return normalizedParams.size ? `/departments?${normalizedParams.toString()}` : `/departments` } -export const putBureausId = async (id: number, - params?: PutBureausIdParams, options?: RequestInit): Promise => { +export const postDepartments = async (params?: PostDepartmentsParams, options?: RequestInit): Promise => { - return customFetch>(getPutBureausIdUrl(id,params), + return customFetch>(getPostDepartmentsUrl(params), { ...options, - method: 'PUT' + method: 'POST' } @@ -1865,27 +1856,24 @@ export const putBureausId = async (id: number, -export const getPutBureausIdMutationFetcher = (id: number, - params?: PutBureausIdParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putBureausId(id, params, options); +export const getPostDepartmentsMutationFetcher = (params?: PostDepartmentsParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postDepartments(params, options); } } -export const getPutBureausIdMutationKey = (id: number, - params?: PutBureausIdParams,) => [`/bureaus/${id}`, ...(params ? [params]: [])] as const; +export const getPostDepartmentsMutationKey = (params?: PostDepartmentsParams,) => [`/departments`, ...(params ? [params]: [])] as const; -export type PutBureausIdMutationResult = NonNullable>> -export type PutBureausIdMutationError = unknown +export type PostDepartmentsMutationResult = NonNullable>> +export type PostDepartmentsMutationError = unknown -export const usePutBureausId = ( - id: number, - params?: PutBureausIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostDepartments = ( + params?: PostDepartmentsParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPutBureausIdMutationKey(id,params); - const swrFn = getPutBureausIdMutationFetcher(id,params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostDepartmentsMutationKey(params); + const swrFn = getPostDepartmentsMutationFetcher(params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -1896,26 +1884,26 @@ export const usePutBureausId = ( } /** - * IDを指定してbureauの削除 + * IDで指定されたdepartmentの取得 */ -export type deleteBureausIdResponse = { - data: DeleteBureausId200; +export type getDepartmentsIdResponse = { + data: GetDepartmentsId200; status: number; headers: Headers; } -export const getDeleteBureausIdUrl = (id: number,) => { +export const getGetDepartmentsIdUrl = (id: number,) => { - return `/bureaus/${id}` + return `/departments/${id}` } -export const deleteBureausId = async (id: number, options?: RequestInit): Promise => { +export const getDepartmentsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getDeleteBureausIdUrl(id), + return customFetch>(getGetDepartmentsIdUrl(id), { ...options, - method: 'DELETE' + method: 'GET' } @@ -1924,26 +1912,21 @@ export const deleteBureausId = async (id: number, options?: RequestInit): Promis -export const getDeleteBureausIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteBureausId(id, options); - } -} -export const getDeleteBureausIdMutationKey = (id: number,) => [`/bureaus/${id}`] as const; +export const getGetDepartmentsIdKey = (id: number,) => [`/departments/${id}`] as const; -export type DeleteBureausIdMutationResult = NonNullable>> -export type DeleteBureausIdMutationError = unknown +export type GetDepartmentsIdQueryResult = NonNullable>> +export type GetDepartmentsIdQueryError = unknown -export const useDeleteBureausId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useGetDepartmentsId = ( + id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } ) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getDeleteBureausIdMutationKey(id); - const swrFn = getDeleteBureausIdMutationFetcher(id, requestOptions); + const isEnabled = swrOptions?.enabled !== false && !!(id) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDepartmentsIdKey(id) : null); + const swrFn = () => getDepartmentsId(id, requestOptions) - const query = useSWRMutation(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) return { swrKey, @@ -1952,56 +1935,64 @@ export const useDeleteBureausId = ( } /** - * 購入報告を行うAPI + * departmentの更新 */ -export type postBuyReportsResponse = { - data: BuyReport; +export type putDepartmentsIdResponse = { + data: PutDepartmentsId200; status: number; headers: Headers; } -export const getPostBuyReportsUrl = () => { +export const getPutDepartmentsIdUrl = (id: number, + params?: PutDepartmentsIdParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/buy_reports` + return normalizedParams.size ? `/departments/${id}?${normalizedParams.toString()}` : `/departments/${id}` } -export const postBuyReports = async (postBuyReportsBody: PostBuyReportsBody, options?: RequestInit): Promise => { - const formData = new FormData(); -formData.append('file', postBuyReportsBody.file) -formData.append('buy_report', JSON.stringify(postBuyReportsBody.buy_report)); - - return customFetch>(getPostBuyReportsUrl(), +export const putDepartmentsId = async (id: number, + params?: PutDepartmentsIdParams, options?: RequestInit): Promise => { + + return customFetch>(getPutDepartmentsIdUrl(id,params), { ...options, - method: 'POST' - , - body: - formData, + method: 'PUT' + + } );} -export const getPostBuyReportsMutationFetcher = ( options?: SecondParameter) => { - return (_: Key, { arg }: { arg: PostBuyReportsBody }): Promise => { - return postBuyReports(arg, options); +export const getPutDepartmentsIdMutationFetcher = (id: number, + params?: PutDepartmentsIdParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return putDepartmentsId(id, params, options); } } -export const getPostBuyReportsMutationKey = () => [`/buy_reports`] as const; +export const getPutDepartmentsIdMutationKey = (id: number, + params?: PutDepartmentsIdParams,) => [`/departments/${id}`, ...(params ? [params]: [])] as const; -export type PostBuyReportsMutationResult = NonNullable>> -export type PostBuyReportsMutationError = unknown +export type PutDepartmentsIdMutationResult = NonNullable>> +export type PutDepartmentsIdMutationError = unknown -export const usePostBuyReports = ( - options?: { swr?:SWRMutationConfiguration>, TError, Key, PostBuyReportsBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutDepartmentsId = ( + id: number, + params?: PutDepartmentsIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostBuyReportsMutationKey(); - const swrFn = getPostBuyReportsMutationFetcher(requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutDepartmentsIdMutationKey(id,params); + const swrFn = getPutDepartmentsIdMutationFetcher(id,params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -2012,59 +2003,52 @@ export const usePostBuyReports = ( } /** - * 購入報告を修正するAPI、画像がある場合は画像も更新 + * IDを指定してdepartmentの削除 */ -export type putBuyReportsIdResponse = { - data: BuyReport; +export type deleteDepartmentsIdResponse = { + data: DeleteDepartmentsId200; status: number; headers: Headers; } -export const getPutBuyReportsIdUrl = (id: number,) => { +export const getDeleteDepartmentsIdUrl = (id: number,) => { - return `/buy_reports/${id}` + return `/departments/${id}` } -export const putBuyReportsId = async (id: number, - putBuyReportsIdBody: PutBuyReportsIdBody, options?: RequestInit): Promise => { - const formData = new FormData(); -if(putBuyReportsIdBody.file !== undefined) { - formData.append('file', putBuyReportsIdBody.file) - } -formData.append('buy_report', JSON.stringify(putBuyReportsIdBody.buy_report)); - - return customFetch>(getPutBuyReportsIdUrl(id), +export const deleteDepartmentsId = async (id: number, options?: RequestInit): Promise => { + + return customFetch>(getDeleteDepartmentsIdUrl(id), { ...options, - method: 'PUT' - , - body: - formData, + method: 'DELETE' + + } );} -export const getPutBuyReportsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: PutBuyReportsIdBody }): Promise => { - return putBuyReportsId(id, arg, options); +export const getDeleteDepartmentsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteDepartmentsId(id, options); } } -export const getPutBuyReportsIdMutationKey = (id: number,) => [`/buy_reports/${id}`] as const; +export const getDeleteDepartmentsIdMutationKey = (id: number,) => [`/departments/${id}`] as const; -export type PutBuyReportsIdMutationResult = NonNullable>> -export type PutBuyReportsIdMutationError = unknown +export type DeleteDepartmentsIdMutationResult = NonNullable>> +export type DeleteDepartmentsIdMutationError = unknown -export const usePutBuyReportsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, PutBuyReportsIdBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useDeleteDepartmentsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPutBuyReportsIdMutationKey(id); - const swrFn = getPutBuyReportsIdMutationFetcher(id, requestOptions); + const swrKey = swrOptions?.swrKey ?? getDeleteDepartmentsIdMutationKey(id); + const swrFn = getDeleteDepartmentsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -2075,26 +2059,33 @@ export const usePutBuyReportsId = ( } /** - * IDを指定してbuy_reportの削除、紐づいた画像も削除、マイページから削除できる + * division一覧の取得 クエリでyearを指定することで年度ごとのdivisionを取得可能 */ -export type deleteBuyReportsIdResponse = { - data: DeleteBuyReportsId200; +export type getDivisionsResponse = { + data: DivisionDetails; status: number; headers: Headers; } -export const getDeleteBuyReportsIdUrl = (id: number,) => { - +export const getGetDivisionsUrl = (params?: GetDivisionsParams,) => { + const normalizedParams = new URLSearchParams(); - return `/buy_reports/${id}` + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + return normalizedParams.size ? `/divisions?${normalizedParams.toString()}` : `/divisions` } -export const deleteBuyReportsId = async (id: number, options?: RequestInit): Promise => { +export const getDivisions = async (params?: GetDivisionsParams, options?: RequestInit): Promise => { - return customFetch>(getDeleteBuyReportsIdUrl(id), + return customFetch>(getGetDivisionsUrl(params), { ...options, - method: 'DELETE' + method: 'GET' } @@ -2103,26 +2094,21 @@ export const deleteBuyReportsId = async (id: number, options?: RequestInit): Pro -export const getDeleteBuyReportsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteBuyReportsId(id, options); - } -} -export const getDeleteBuyReportsIdMutationKey = (id: number,) => [`/buy_reports/${id}`] as const; +export const getGetDivisionsKey = (params?: GetDivisionsParams,) => [`/divisions`, ...(params ? [params]: [])] as const; -export type DeleteBuyReportsIdMutationResult = NonNullable>> -export type DeleteBuyReportsIdMutationError = unknown +export type GetDivisionsQueryResult = NonNullable>> +export type GetDivisionsQueryError = unknown -export const useDeleteBuyReportsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useGetDivisions = ( + params?: GetDivisionsParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } ) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getDeleteBuyReportsIdMutationKey(id); - const swrFn = getDeleteBuyReportsIdMutationFetcher(id, requestOptions); + const isEnabled = swrOptions?.enabled !== false + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDivisionsKey(params) : null); + const swrFn = () => getDivisions(params, requestOptions) - const query = useSWRMutation(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) return { swrKey, @@ -2131,56 +2117,55 @@ export const useDeleteBuyReportsId = ( } /** - * 購入報告で表示するbuy_report一覧の取得、主に財務向けのページ + * divisionの作成 */ -export type getBuyReportsDetailsResponse = { - data: BuyReportDetail[]; +export type postDivisionsResponse = { + data: DivisionWithBalance; status: number; headers: Headers; } -export const getGetBuyReportsDetailsUrl = (params?: GetBuyReportsDetailsParams,) => { - const normalizedParams = new URLSearchParams(); +export const getPostDivisionsUrl = () => { - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - return normalizedParams.size ? `/buy_reports/details?${normalizedParams.toString()}` : `/buy_reports/details` + return `/divisions` } -export const getBuyReportsDetails = async (params?: GetBuyReportsDetailsParams, options?: RequestInit): Promise => { +export const postDivisions = async (division: Division, options?: RequestInit): Promise => { - return customFetch>(getGetBuyReportsDetailsUrl(params), + return customFetch>(getPostDivisionsUrl(), { ...options, - method: 'GET' - - + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + division,) } );} -export const getGetBuyReportsDetailsKey = (params?: GetBuyReportsDetailsParams,) => [`/buy_reports/details`, ...(params ? [params]: [])] as const; +export const getPostDivisionsMutationFetcher = ( options?: SecondParameter) => { + return (_: Key, { arg }: { arg: Division }): Promise => { + return postDivisions(arg, options); + } +} +export const getPostDivisionsMutationKey = () => [`/divisions`] as const; -export type GetBuyReportsDetailsQueryResult = NonNullable>> -export type GetBuyReportsDetailsQueryError = unknown +export type PostDivisionsMutationResult = NonNullable>> +export type PostDivisionsMutationError = unknown -export const useGetBuyReportsDetails = ( - params?: GetBuyReportsDetailsParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const usePostDivisions = ( + options?: { swr?:SWRMutationConfiguration>, TError, Key, Division, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetBuyReportsDetailsKey(params) : null); - const swrFn = () => getBuyReportsDetails(params, requestOptions) + const swrKey = swrOptions?.swrKey ?? getPostDivisionsMutationKey(); + const swrFn = getPostDivisionsMutationFetcher(requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -2189,54 +2174,54 @@ export const useGetBuyReportsDetails = ( } /** - * buy_reportのステータス更新、財務が封詰め、精算済みにするAPI + * divisionの更新 */ -export type putBuyReportStatusBuyReportIdResponse = { - data: BuyReportDetail; +export type putDivisionsIdResponse = { + data: DivisionWithBalance; status: number; headers: Headers; } -export const getPutBuyReportStatusBuyReportIdUrl = (buyReportId: number,) => { +export const getPutDivisionsIdUrl = (id: number,) => { - return `/buy_report/status/${buyReportId}` + return `/divisions/${id}` } -export const putBuyReportStatusBuyReportId = async (buyReportId: number, - putBuyReportStatusBuyReportIdBody: PutBuyReportStatusBuyReportIdBody, options?: RequestInit): Promise => { +export const putDivisionsId = async (id: number, + division: Division, options?: RequestInit): Promise => { - return customFetch>(getPutBuyReportStatusBuyReportIdUrl(buyReportId), + return customFetch>(getPutDivisionsIdUrl(id), { ...options, method: 'PUT', headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify( - putBuyReportStatusBuyReportIdBody,) + division,) } );} -export const getPutBuyReportStatusBuyReportIdMutationFetcher = (buyReportId: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: PutBuyReportStatusBuyReportIdBody }): Promise => { - return putBuyReportStatusBuyReportId(buyReportId, arg, options); +export const getPutDivisionsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: Division }): Promise => { + return putDivisionsId(id, arg, options); } } -export const getPutBuyReportStatusBuyReportIdMutationKey = (buyReportId: number,) => [`/buy_report/status/${buyReportId}`] as const; +export const getPutDivisionsIdMutationKey = (id: number,) => [`/divisions/${id}`] as const; -export type PutBuyReportStatusBuyReportIdMutationResult = NonNullable>> -export type PutBuyReportStatusBuyReportIdMutationError = unknown +export type PutDivisionsIdMutationResult = NonNullable>> +export type PutDivisionsIdMutationError = unknown -export const usePutBuyReportStatusBuyReportId = ( - buyReportId: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, PutBuyReportStatusBuyReportIdBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutDivisionsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Division, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPutBuyReportStatusBuyReportIdMutationKey(buyReportId); - const swrFn = getPutBuyReportStatusBuyReportIdMutationFetcher(buyReportId, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutDivisionsIdMutationKey(id); + const swrFn = getPutDivisionsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -2247,26 +2232,26 @@ export const usePutBuyReportStatusBuyReportId = ( } /** - * departmentの一覧の取得 + * IDを指定してdivisionの削除 */ -export type getDepartmentsResponse = { - data: GetDepartments200; +export type deleteDivisionsIdResponse = { + data: DeleteDivisionsId200; status: number; headers: Headers; } -export const getGetDepartmentsUrl = () => { +export const getDeleteDivisionsIdUrl = (id: number,) => { - return `/departments` + return `/divisions/${id}` } -export const getDepartments = async ( options?: RequestInit): Promise => { +export const deleteDivisionsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getGetDepartmentsUrl(), + return customFetch>(getDeleteDivisionsIdUrl(id), { ...options, - method: 'GET' + method: 'DELETE' } @@ -2275,21 +2260,26 @@ export const getDepartments = async ( options?: RequestInit): Promise [`/departments`] as const; +export const getDeleteDivisionsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteDivisionsId(id, options); + } +} +export const getDeleteDivisionsIdMutationKey = (id: number,) => [`/divisions/${id}`] as const; -export type GetDepartmentsQueryResult = NonNullable>> -export type GetDepartmentsQueryError = unknown +export type DeleteDivisionsIdMutationResult = NonNullable>> +export type DeleteDivisionsIdMutationError = unknown -export const useGetDepartments = ( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useDeleteDivisionsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDepartmentsKey() : null); - const swrFn = () => getDepartments(requestOptions) + const swrKey = swrOptions?.swrKey ?? getDeleteDivisionsIdMutationKey(id); + const swrFn = getDeleteDivisionsIdMutationFetcher(id, requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -2298,15 +2288,15 @@ export const useGetDepartments = ( } /** - * departmentの作成 + * festival_itemの一覧の取得 */ -export type postDepartmentsResponse = { - data: PostDepartments200; +export type getFestivalItemsResponse = { + data: FestivalItemDetails; status: number; headers: Headers; } -export const getPostDepartmentsUrl = (params?: PostDepartmentsParams,) => { +export const getGetFestivalItemsUrl = (params?: GetFestivalItemsParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { @@ -2316,15 +2306,15 @@ export const getPostDepartmentsUrl = (params?: PostDepartmentsParams,) => { } }); - return normalizedParams.size ? `/departments?${normalizedParams.toString()}` : `/departments` + return normalizedParams.size ? `/festival_items?${normalizedParams.toString()}` : `/festival_items` } -export const postDepartments = async (params?: PostDepartmentsParams, options?: RequestInit): Promise => { +export const getFestivalItems = async (params?: GetFestivalItemsParams, options?: RequestInit): Promise => { - return customFetch>(getPostDepartmentsUrl(params), + return customFetch>(getGetFestivalItemsUrl(params), { ...options, - method: 'POST' + method: 'GET' } @@ -2333,26 +2323,21 @@ export const postDepartments = async (params?: PostDepartmentsParams, options?: -export const getPostDepartmentsMutationFetcher = (params?: PostDepartmentsParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postDepartments(params, options); - } -} -export const getPostDepartmentsMutationKey = (params?: PostDepartmentsParams,) => [`/departments`, ...(params ? [params]: [])] as const; +export const getGetFestivalItemsKey = (params?: GetFestivalItemsParams,) => [`/festival_items`, ...(params ? [params]: [])] as const; -export type PostDepartmentsMutationResult = NonNullable>> -export type PostDepartmentsMutationError = unknown +export type GetFestivalItemsQueryResult = NonNullable>> +export type GetFestivalItemsQueryError = unknown -export const usePostDepartments = ( - params?: PostDepartmentsParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useGetFestivalItems = ( + params?: GetFestivalItemsParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } ) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostDepartmentsMutationKey(params); - const swrFn = getPostDepartmentsMutationFetcher(params, requestOptions); + const isEnabled = swrOptions?.enabled !== false + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFestivalItemsKey(params) : null); + const swrFn = () => getFestivalItems(params, requestOptions) - const query = useSWRMutation(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) return { swrKey, @@ -2361,49 +2346,55 @@ export const usePostDepartments = ( } /** - * IDで指定されたdepartmentの取得 + * festival_itemの作成 */ -export type getDepartmentsIdResponse = { - data: GetDepartmentsId200; +export type postFestivalItemsResponse = { + data: FestivalItemWithBalance; status: number; headers: Headers; } -export const getGetDepartmentsIdUrl = (id: number,) => { +export const getPostFestivalItemsUrl = () => { - return `/departments/${id}` + return `/festival_items` } -export const getDepartmentsId = async (id: number, options?: RequestInit): Promise => { +export const postFestivalItems = async (festivalItem: FestivalItem, options?: RequestInit): Promise => { - return customFetch>(getGetDepartmentsIdUrl(id), + return customFetch>(getPostFestivalItemsUrl(), { ...options, - method: 'GET' - - + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + festivalItem,) } );} -export const getGetDepartmentsIdKey = (id: number,) => [`/departments/${id}`] as const; +export const getPostFestivalItemsMutationFetcher = ( options?: SecondParameter) => { + return (_: Key, { arg }: { arg: FestivalItem }): Promise => { + return postFestivalItems(arg, options); + } +} +export const getPostFestivalItemsMutationKey = () => [`/festival_items`] as const; -export type GetDepartmentsIdQueryResult = NonNullable>> -export type GetDepartmentsIdQueryError = unknown +export type PostFestivalItemsMutationResult = NonNullable>> +export type PostFestivalItemsMutationError = unknown -export const useGetDepartmentsId = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const usePostFestivalItems = ( + options?: { swr?:SWRMutationConfiguration>, TError, Key, FestivalItem, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(id) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDepartmentsIdKey(id) : null); - const swrFn = () => getDepartmentsId(id, requestOptions) + const swrKey = swrOptions?.swrKey ?? getPostFestivalItemsMutationKey(); + const swrFn = getPostFestivalItemsMutationFetcher(requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -2412,235 +2403,54 @@ export const useGetDepartmentsId = ( } /** - * departmentの更新 + * festival_itemの更新 */ -export type putDepartmentsIdResponse = { - data: PutDepartmentsId200; - status: number; - headers: Headers; -} - -export const getPutDepartmentsIdUrl = (id: number, - params?: PutDepartmentsIdParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/departments/${id}?${normalizedParams.toString()}` : `/departments/${id}` -} - -export const putDepartmentsId = async (id: number, - params?: PutDepartmentsIdParams, options?: RequestInit): Promise => { - - return customFetch>(getPutDepartmentsIdUrl(id,params), - { - ...options, - method: 'PUT' - - - } -);} - - - - -export const getPutDepartmentsIdMutationFetcher = (id: number, - params?: PutDepartmentsIdParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putDepartmentsId(id, params, options); - } -} -export const getPutDepartmentsIdMutationKey = (id: number, - params?: PutDepartmentsIdParams,) => [`/departments/${id}`, ...(params ? [params]: [])] as const; - -export type PutDepartmentsIdMutationResult = NonNullable>> -export type PutDepartmentsIdMutationError = unknown - -export const usePutDepartmentsId = ( - id: number, - params?: PutDepartmentsIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPutDepartmentsIdMutationKey(id,params); - const swrFn = getPutDepartmentsIdMutationFetcher(id,params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDを指定してdepartmentの削除 - */ -export type deleteDepartmentsIdResponse = { - data: DeleteDepartmentsId200; - status: number; - headers: Headers; -} - -export const getDeleteDepartmentsIdUrl = (id: number,) => { - - - return `/departments/${id}` -} - -export const deleteDepartmentsId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getDeleteDepartmentsIdUrl(id), - { - ...options, - method: 'DELETE' - - - } -);} - - - - -export const getDeleteDepartmentsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteDepartmentsId(id, options); - } -} -export const getDeleteDepartmentsIdMutationKey = (id: number,) => [`/departments/${id}`] as const; - -export type DeleteDepartmentsIdMutationResult = NonNullable>> -export type DeleteDepartmentsIdMutationError = unknown - -export const useDeleteDepartmentsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getDeleteDepartmentsIdMutationKey(id); - const swrFn = getDeleteDepartmentsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * division一覧の取得 クエリでyearを指定することで年度ごとのdivisionを取得可能 - */ -export type getDivisionsResponse = { - data: DivisionDetails; - status: number; - headers: Headers; -} - -export const getGetDivisionsUrl = (params?: GetDivisionsParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/divisions?${normalizedParams.toString()}` : `/divisions` -} - -export const getDivisions = async (params?: GetDivisionsParams, options?: RequestInit): Promise => { - - return customFetch>(getGetDivisionsUrl(params), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetDivisionsKey = (params?: GetDivisionsParams,) => [`/divisions`, ...(params ? [params]: [])] as const; - -export type GetDivisionsQueryResult = NonNullable>> -export type GetDivisionsQueryError = unknown - -export const useGetDivisions = ( - params?: GetDivisionsParams, 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 ? getGetDivisionsKey(params) : null); - const swrFn = () => getDivisions(params, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * divisionの作成 - */ -export type postDivisionsResponse = { - data: DivisionWithBalance; +export type putFestivalItemsIdResponse = { + data: FestivalItemWithBalance; status: number; headers: Headers; } -export const getPostDivisionsUrl = () => { +export const getPutFestivalItemsIdUrl = (id: number,) => { - return `/divisions` + return `/festival_items/${id}` } -export const postDivisions = async (division: Division, options?: RequestInit): Promise => { +export const putFestivalItemsId = async (id: number, + festivalItem: FestivalItem, options?: RequestInit): Promise => { - return customFetch>(getPostDivisionsUrl(), + return customFetch>(getPutFestivalItemsIdUrl(id), { ...options, - method: 'POST', + method: 'PUT', headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify( - division,) + festivalItem,) } );} -export const getPostDivisionsMutationFetcher = ( options?: SecondParameter) => { - return (_: Key, { arg }: { arg: Division }): Promise => { - return postDivisions(arg, options); +export const getPutFestivalItemsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: FestivalItem }): Promise => { + return putFestivalItemsId(id, arg, options); } } -export const getPostDivisionsMutationKey = () => [`/divisions`] as const; +export const getPutFestivalItemsIdMutationKey = (id: number,) => [`/festival_items/${id}`] as const; -export type PostDivisionsMutationResult = NonNullable>> -export type PostDivisionsMutationError = unknown +export type PutFestivalItemsIdMutationResult = NonNullable>> +export type PutFestivalItemsIdMutationError = unknown -export const usePostDivisions = ( - options?: { swr?:SWRMutationConfiguration>, TError, Key, Division, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutFestivalItemsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, FestivalItem, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostDivisionsMutationKey(); - const swrFn = getPostDivisionsMutationFetcher(requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutFestivalItemsIdMutationKey(id); + const swrFn = getPutFestivalItemsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -2651,1434 +2461,23 @@ export const usePostDivisions = ( } /** - * divisionの更新 - */ -export type putDivisionsIdResponse = { - data: DivisionWithBalance; - status: number; - headers: Headers; -} - -export const getPutDivisionsIdUrl = (id: number,) => { - - - return `/divisions/${id}` -} - -export const putDivisionsId = async (id: number, - division: Division, options?: RequestInit): Promise => { - - return customFetch>(getPutDivisionsIdUrl(id), - { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - division,) - } -);} - - - - -export const getPutDivisionsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: Division }): Promise => { - return putDivisionsId(id, arg, options); - } -} -export const getPutDivisionsIdMutationKey = (id: number,) => [`/divisions/${id}`] as const; - -export type PutDivisionsIdMutationResult = NonNullable>> -export type PutDivisionsIdMutationError = unknown - -export const usePutDivisionsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Division, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPutDivisionsIdMutationKey(id); - const swrFn = getPutDivisionsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDを指定してdivisionの削除 - */ -export type deleteDivisionsIdResponse = { - data: DeleteDivisionsId200; - status: number; - headers: Headers; -} - -export const getDeleteDivisionsIdUrl = (id: number,) => { - - - return `/divisions/${id}` -} - -export const deleteDivisionsId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getDeleteDivisionsIdUrl(id), - { - ...options, - method: 'DELETE' - - - } -);} - - - - -export const getDeleteDivisionsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteDivisionsId(id, options); - } -} -export const getDeleteDivisionsIdMutationKey = (id: number,) => [`/divisions/${id}`] as const; - -export type DeleteDivisionsIdMutationResult = NonNullable>> -export type DeleteDivisionsIdMutationError = unknown - -export const useDeleteDivisionsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getDeleteDivisionsIdMutationKey(id); - const swrFn = getDeleteDivisionsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * expenseの一覧の取得 - */ -export type getExpensesResponse = { - data: GetExpenses200; - status: number; - headers: Headers; -} - -export const getGetExpensesUrl = () => { - - - return `/expenses` -} - -export const getExpenses = async ( options?: RequestInit): Promise => { - - return customFetch>(getGetExpensesUrl(), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetExpensesKey = () => [`/expenses`] as const; - -export type GetExpensesQueryResult = NonNullable>> -export type GetExpensesQueryError = unknown - -export const useGetExpenses = ( - 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 ? getGetExpensesKey() : null); - const swrFn = () => getExpenses(requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * expenseの作成 - */ -export type postExpensesResponse = { - data: PostExpenses200; - status: number; - headers: Headers; -} - -export const getPostExpensesUrl = (params?: PostExpensesParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/expenses?${normalizedParams.toString()}` : `/expenses` -} - -export const postExpenses = async (params?: PostExpensesParams, options?: RequestInit): Promise => { - - return customFetch>(getPostExpensesUrl(params), - { - ...options, - method: 'POST' - - - } -);} - - - - -export const getPostExpensesMutationFetcher = (params?: PostExpensesParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postExpenses(params, options); - } -} -export const getPostExpensesMutationKey = (params?: PostExpensesParams,) => [`/expenses`, ...(params ? [params]: [])] as const; - -export type PostExpensesMutationResult = NonNullable>> -export type PostExpensesMutationError = unknown - -export const usePostExpenses = ( - params?: PostExpensesParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPostExpensesMutationKey(params); - const swrFn = getPostExpensesMutationFetcher(params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * expenseに紐づくpurchase_itemの一覧を取得 - */ -export type getExpensesDetailsResponse = { - data: GetExpensesDetails200; - status: number; - headers: Headers; -} - -export const getGetExpensesDetailsUrl = () => { - - - return `/expenses/details` -} - -export const getExpensesDetails = async ( options?: RequestInit): Promise => { - - return customFetch>(getGetExpensesDetailsUrl(), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetExpensesDetailsKey = () => [`/expenses/details`] as const; - -export type GetExpensesDetailsQueryResult = NonNullable>> -export type GetExpensesDetailsQueryError = unknown - -export const useGetExpensesDetails = ( - 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 ? getGetExpensesDetailsKey() : null); - const swrFn = () => getExpensesDetails(requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDで指定されたexpenseの取得 - */ -export type getExpensesIdResponse = { - data: GetExpensesId200; - status: number; - headers: Headers; -} - -export const getGetExpensesIdUrl = (id: number,) => { - - - return `/expenses/${id}` -} - -export const getExpensesId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getGetExpensesIdUrl(id), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetExpensesIdKey = (id: number,) => [`/expenses/${id}`] as const; - -export type GetExpensesIdQueryResult = NonNullable>> -export type GetExpensesIdQueryError = unknown - -export const useGetExpensesId = ( - 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 ? getGetExpensesIdKey(id) : null); - const swrFn = () => getExpensesId(id, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * expenseの更新 - */ -export type putExpensesIdResponse = { - data: PutExpensesId200; - status: number; - headers: Headers; -} - -export const getPutExpensesIdUrl = (id: number, - params?: PutExpensesIdParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/expenses/${id}?${normalizedParams.toString()}` : `/expenses/${id}` -} - -export const putExpensesId = async (id: number, - params?: PutExpensesIdParams, options?: RequestInit): Promise => { - - return customFetch>(getPutExpensesIdUrl(id,params), - { - ...options, - method: 'PUT' - - - } -);} - - - - -export const getPutExpensesIdMutationFetcher = (id: number, - params?: PutExpensesIdParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putExpensesId(id, params, options); - } -} -export const getPutExpensesIdMutationKey = (id: number, - params?: PutExpensesIdParams,) => [`/expenses/${id}`, ...(params ? [params]: [])] as const; - -export type PutExpensesIdMutationResult = NonNullable>> -export type PutExpensesIdMutationError = unknown - -export const usePutExpensesId = ( - id: number, - params?: PutExpensesIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPutExpensesIdMutationKey(id,params); - const swrFn = getPutExpensesIdMutationFetcher(id,params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDを指定してexpenseの削除 - */ -export type deleteExpensesIdResponse = { - data: DeleteExpensesId200; - status: number; - headers: Headers; -} - -export const getDeleteExpensesIdUrl = (id: number,) => { - - - return `/expenses/${id}` -} - -export const deleteExpensesId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getDeleteExpensesIdUrl(id), - { - ...options, - method: 'DELETE' - - - } -);} - - - - -export const getDeleteExpensesIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteExpensesId(id, options); - } -} -export const getDeleteExpensesIdMutationKey = (id: number,) => [`/expenses/${id}`] as const; - -export type DeleteExpensesIdMutationResult = NonNullable>> -export type DeleteExpensesIdMutationError = unknown - -export const useDeleteExpensesId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getDeleteExpensesIdMutationKey(id); - const swrFn = getDeleteExpensesIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDで指定されたexpenseに紐づくpurchase_itemsを取得 - */ -export type getExpensesIdDetailsResponse = { - data: GetExpensesIdDetails200; - status: number; - headers: Headers; -} - -export const getGetExpensesIdDetailsUrl = (id: number,) => { - - - return `/expenses/${id}/details` -} - -export const getExpensesIdDetails = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getGetExpensesIdDetailsUrl(id), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetExpensesIdDetailsKey = (id: number,) => [`/expenses/${id}/details`] as const; - -export type GetExpensesIdDetailsQueryResult = NonNullable>> -export type GetExpensesIdDetailsQueryError = unknown - -export const useGetExpensesIdDetails = ( - 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 ? getGetExpensesIdDetailsKey(id) : null); - const swrFn = () => getExpensesIdDetails(id, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * 年度で指定されたexpenseに紐づく購入申請と購入報告を取得 - */ -export type getExpensesDetailsYearResponse = { - data: GetExpensesDetailsYear200; - status: number; - headers: Headers; -} - -export const getGetExpensesDetailsYearUrl = (year: number,) => { - - - return `/expenses/details/${year}` -} - -export const getExpensesDetailsYear = async (year: number, options?: RequestInit): Promise => { - - return customFetch>(getGetExpensesDetailsYearUrl(year), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetExpensesDetailsYearKey = (year: number,) => [`/expenses/details/${year}`] as const; - -export type GetExpensesDetailsYearQueryResult = NonNullable>> -export type GetExpensesDetailsYearQueryError = unknown - -export const useGetExpensesDetailsYear = ( - year: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } -) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false && !!(year) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetExpensesDetailsYearKey(year) : null); - const swrFn = () => getExpensesDetailsYear(year, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * 年度で指定されたexpensesを取得 - */ -export type getExpensesFiscalyearYearResponse = { - data: GetExpensesFiscalyearYear200; - status: number; - headers: Headers; -} - -export const getGetExpensesFiscalyearYearUrl = (year: number,) => { - - - return `/expenses/fiscalyear/${year}` -} - -export const getExpensesFiscalyearYear = async (year: number, options?: RequestInit): Promise => { - - return customFetch>(getGetExpensesFiscalyearYearUrl(year), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetExpensesFiscalyearYearKey = (year: number,) => [`/expenses/fiscalyear/${year}`] as const; - -export type GetExpensesFiscalyearYearQueryResult = NonNullable>> -export type GetExpensesFiscalyearYearQueryError = unknown - -export const useGetExpensesFiscalyearYear = ( - year: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } -) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false && !!(year) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetExpensesFiscalyearYearKey(year) : null); - const swrFn = () => getExpensesFiscalyearYear(year, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * festival_itemの一覧の取得 - */ -export type getFestivalItemsResponse = { - data: FestivalItemDetails; - status: number; - headers: Headers; -} - -export const getGetFestivalItemsUrl = (params?: GetFestivalItemsParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/festival_items?${normalizedParams.toString()}` : `/festival_items` -} - -export const getFestivalItems = async (params?: GetFestivalItemsParams, options?: RequestInit): Promise => { - - return customFetch>(getGetFestivalItemsUrl(params), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetFestivalItemsKey = (params?: GetFestivalItemsParams,) => [`/festival_items`, ...(params ? [params]: [])] as const; - -export type GetFestivalItemsQueryResult = NonNullable>> -export type GetFestivalItemsQueryError = unknown - -export const useGetFestivalItems = ( - params?: GetFestivalItemsParams, 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 ? getGetFestivalItemsKey(params) : null); - const swrFn = () => getFestivalItems(params, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * festival_itemの作成 - */ -export type postFestivalItemsResponse = { - data: FestivalItemWithBalance; - status: number; - headers: Headers; -} - -export const getPostFestivalItemsUrl = () => { - - - return `/festival_items` -} - -export const postFestivalItems = async (festivalItem: FestivalItem, options?: RequestInit): Promise => { - - return customFetch>(getPostFestivalItemsUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - festivalItem,) - } -);} - - - - -export const getPostFestivalItemsMutationFetcher = ( options?: SecondParameter) => { - return (_: Key, { arg }: { arg: FestivalItem }): Promise => { - return postFestivalItems(arg, options); - } -} -export const getPostFestivalItemsMutationKey = () => [`/festival_items`] as const; - -export type PostFestivalItemsMutationResult = NonNullable>> -export type PostFestivalItemsMutationError = unknown - -export const usePostFestivalItems = ( - options?: { swr?:SWRMutationConfiguration>, TError, Key, FestivalItem, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPostFestivalItemsMutationKey(); - const swrFn = getPostFestivalItemsMutationFetcher(requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * festival_itemの更新 - */ -export type putFestivalItemsIdResponse = { - data: FestivalItemWithBalance; - status: number; - headers: Headers; -} - -export const getPutFestivalItemsIdUrl = (id: number,) => { - - - return `/festival_items/${id}` -} - -export const putFestivalItemsId = async (id: number, - festivalItem: FestivalItem, options?: RequestInit): Promise => { - - return customFetch>(getPutFestivalItemsIdUrl(id), - { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - festivalItem,) - } -);} - - - - -export const getPutFestivalItemsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: FestivalItem }): Promise => { - return putFestivalItemsId(id, arg, options); - } -} -export const getPutFestivalItemsIdMutationKey = (id: number,) => [`/festival_items/${id}`] as const; - -export type PutFestivalItemsIdMutationResult = NonNullable>> -export type PutFestivalItemsIdMutationError = unknown - -export const usePutFestivalItemsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, FestivalItem, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPutFestivalItemsIdMutationKey(id); - const swrFn = getPutFestivalItemsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDを指定してfestival_itemの削除 - */ -export type deleteFestivalItemsIdResponse = { - data: DeleteFestivalItemsId200; - status: number; - headers: Headers; -} - -export const getDeleteFestivalItemsIdUrl = (id: number,) => { - - - return `/festival_items/${id}` -} - -export const deleteFestivalItemsId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getDeleteFestivalItemsIdUrl(id), - { - ...options, - method: 'DELETE' - - - } -);} - - - - -export const getDeleteFestivalItemsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteFestivalItemsId(id, options); - } -} -export const getDeleteFestivalItemsIdMutationKey = (id: number,) => [`/festival_items/${id}`] as const; - -export type DeleteFestivalItemsIdMutationResult = NonNullable>> -export type DeleteFestivalItemsIdMutationError = unknown - -export const useDeleteFestivalItemsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getDeleteFestivalItemsIdMutationKey(id); - const swrFn = getDeleteFestivalItemsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * ユーザーのマイページの予算一覧の取得 - */ -export type getFestivalItemsDetailsUserIdResponse = { - data: FestivalItemsForMyPage[]; - status: number; - headers: Headers; -} - -export const getGetFestivalItemsDetailsUserIdUrl = (userId: number, - params?: GetFestivalItemsDetailsUserIdParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/festival_items/details/${userId}?${normalizedParams.toString()}` : `/festival_items/details/${userId}` -} - -export const getFestivalItemsDetailsUserId = async (userId: number, - params?: GetFestivalItemsDetailsUserIdParams, options?: RequestInit): Promise => { - - return customFetch>(getGetFestivalItemsDetailsUserIdUrl(userId,params), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetFestivalItemsDetailsUserIdKey = (userId: number, - params?: GetFestivalItemsDetailsUserIdParams,) => [`/festival_items/details/${userId}`, ...(params ? [params]: [])] as const; - -export type GetFestivalItemsDetailsUserIdQueryResult = NonNullable>> -export type GetFestivalItemsDetailsUserIdQueryError = unknown - -export const useGetFestivalItemsDetailsUserId = ( - userId: number, - params?: GetFestivalItemsDetailsUserIdParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } -) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false && !!(userId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFestivalItemsDetailsUserIdKey(userId,params) : null); - const swrFn = () => getFestivalItemsDetailsUserId(userId,params, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * financial_recordの一覧を取得 - */ -export type getFinancialRecordsResponse = { - data: FinancialRecordDetails; - status: number; - headers: Headers; -} - -export const getGetFinancialRecordsUrl = (params?: GetFinancialRecordsParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/financial_records?${normalizedParams.toString()}` : `/financial_records` -} - -export const getFinancialRecords = async (params?: GetFinancialRecordsParams, options?: RequestInit): Promise => { - - return customFetch>(getGetFinancialRecordsUrl(params), - { - ...options, - method: 'GET' - - - } -);} - - - - -export const getGetFinancialRecordsKey = (params?: GetFinancialRecordsParams,) => [`/financial_records`, ...(params ? [params]: [])] as const; - -export type GetFinancialRecordsQueryResult = NonNullable>> -export type GetFinancialRecordsQueryError = unknown - -export const useGetFinancialRecords = ( - params?: GetFinancialRecordsParams, 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 ? getGetFinancialRecordsKey(params) : null); - const swrFn = () => getFinancialRecords(params, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * financial_recordの作成 - */ -export type postFinancialRecordsResponse = { - data: FinancialRecordWithBalance; - status: number; - headers: Headers; -} - -export const getPostFinancialRecordsUrl = () => { - - - return `/financial_records` -} - -export const postFinancialRecords = async (financialRecord: FinancialRecord, options?: RequestInit): Promise => { - - return customFetch>(getPostFinancialRecordsUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - financialRecord,) - } -);} - - - - -export const getPostFinancialRecordsMutationFetcher = ( options?: SecondParameter) => { - return (_: Key, { arg }: { arg: FinancialRecord }): Promise => { - return postFinancialRecords(arg, options); - } -} -export const getPostFinancialRecordsMutationKey = () => [`/financial_records`] as const; - -export type PostFinancialRecordsMutationResult = NonNullable>> -export type PostFinancialRecordsMutationError = unknown - -export const usePostFinancialRecords = ( - options?: { swr?:SWRMutationConfiguration>, TError, Key, FinancialRecord, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPostFinancialRecordsMutationKey(); - const swrFn = getPostFinancialRecordsMutationFetcher(requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * financial_recordの更新 - */ -export type putFinancialRecordsIdResponse = { - data: FinancialRecordWithBalance; - status: number; - headers: Headers; -} - -export const getPutFinancialRecordsIdUrl = (id: number,) => { - - - return `/financial_records/${id}` -} - -export const putFinancialRecordsId = async (id: number, - financialRecord: FinancialRecord, options?: RequestInit): Promise => { - - return customFetch>(getPutFinancialRecordsIdUrl(id), - { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - financialRecord,) - } -);} - - - - -export const getPutFinancialRecordsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: FinancialRecord }): Promise => { - return putFinancialRecordsId(id, arg, options); - } -} -export const getPutFinancialRecordsIdMutationKey = (id: number,) => [`/financial_records/${id}`] as const; - -export type PutFinancialRecordsIdMutationResult = NonNullable>> -export type PutFinancialRecordsIdMutationError = unknown - -export const usePutFinancialRecordsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, FinancialRecord, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getPutFinancialRecordsIdMutationKey(id); - const swrFn = getPutFinancialRecordsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDを指定してfinancial_recordの削除 - */ -export type deleteFinancialRecordsIdResponse = { - data: DeleteFinancialRecordsId200; - status: number; - headers: Headers; -} - -export const getDeleteFinancialRecordsIdUrl = (id: number,) => { - - - return `/financial_records/${id}` -} - -export const deleteFinancialRecordsId = async (id: number, options?: RequestInit): Promise => { - - return customFetch>(getDeleteFinancialRecordsIdUrl(id), - { - ...options, - method: 'DELETE' - - - } -);} - - - - -export const getDeleteFinancialRecordsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteFinancialRecordsId(id, options); - } -} -export const getDeleteFinancialRecordsIdMutationKey = (id: number,) => [`/financial_records/${id}`] as const; - -export type DeleteFinancialRecordsIdMutationResult = NonNullable>> -export type DeleteFinancialRecordsIdMutationError = unknown - -export const useDeleteFinancialRecordsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} -) => { - - const {swr: swrOptions, request: requestOptions} = options ?? {} - - const swrKey = swrOptions?.swrKey ?? getDeleteFinancialRecordsIdMutationKey(id); - const swrFn = getDeleteFinancialRecordsIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * fund_informationの一覧を取得 - */ -export type getFundInformationsResponse = { - data: GetFundInformations200; - status: number; - 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>> -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 postFundInformationsResponse = { - data: PostFundInformations200; - status: number; - 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()) - } - }); - - return normalizedParams.size ? `/fund_informations?${normalizedParams.toString()}` : `/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>> -export type PostFundInformationsMutationError = unknown - -export const usePostFundInformations = ( - params: PostFundInformationsParams, options?: { swr?:SWRMutationConfiguration>, 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 getFundInformationsDetailsResponse = { - data: GetFundInformationsDetails200; - status: number; - 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>> -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) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * IDで指定されたfund_informationの取得 - */ -export type getFundInformationsIdResponse = { - data: GetFundInformationsId200; - status: number; - 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>> -export type GetFundInformationsIdQueryError = unknown - -export const useGetFundInformationsId = ( - 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 ? getGetFundInformationsIdKey(id) : null); - const swrFn = () => getFundInformationsId(id, requestOptions) - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) - - return { - swrKey, - ...query - } -} - -/** - * fund_informationの更新 - */ -export type putFundInformationsIdResponse = { - data: PutFundInformationsId200; - status: number; - headers: Headers; -} - -export const getPutFundInformationsIdUrl = (id: number, - params: PutFundInformationsIdParams,) => { - const normalizedParams = new URLSearchParams(); - - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - - return normalizedParams.size ? `/fund_informations/${id}?${normalizedParams.toString()}` : `/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>> -export type PutFundInformationsIdMutationError = unknown - -export const usePutFundInformationsId = ( - id: number, - params: PutFundInformationsIdParams, options?: { swr?:SWRMutationConfiguration>, 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 deleteFundInformationsIdResponse = { - data: DeleteFundInformationsId200; + * IDを指定してfestival_itemの削除 + */ +export type deleteFestivalItemsIdResponse = { + data: DeleteFestivalItemsId200; status: number; headers: Headers; } -export const getDeleteFundInformationsIdUrl = (id: number,) => { +export const getDeleteFestivalItemsIdUrl = (id: number,) => { - return `/fund_informations/${id}` + return `/festival_items/${id}` } -export const deleteFundInformationsId = async (id: number, options?: RequestInit): Promise => { +export const deleteFestivalItemsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getDeleteFundInformationsIdUrl(id), + return customFetch>(getDeleteFestivalItemsIdUrl(id), { ...options, method: 'DELETE' @@ -4090,24 +2489,24 @@ export const deleteFundInformationsId = async (id: number, options?: RequestInit -export const getDeleteFundInformationsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteFundInformationsId(id, options); +export const getDeleteFestivalItemsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteFestivalItemsId(id, options); } } -export const getDeleteFundInformationsIdMutationKey = (id: number,) => [`/fund_informations/${id}`] as const; +export const getDeleteFestivalItemsIdMutationKey = (id: number,) => [`/festival_items/${id}`] as const; -export type DeleteFundInformationsIdMutationResult = NonNullable>> -export type DeleteFundInformationsIdMutationError = unknown +export type DeleteFestivalItemsIdMutationResult = NonNullable>> +export type DeleteFestivalItemsIdMutationError = unknown -export const useDeleteFundInformationsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useDeleteFestivalItemsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, 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 swrKey = swrOptions?.swrKey ?? getDeleteFestivalItemsIdMutationKey(id); + const swrFn = getDeleteFestivalItemsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4118,23 +2517,32 @@ export const useDeleteFundInformationsId = ( } /** - * IDで指定されたfund_informatinに紐づくteacherとuserを取得 + * ユーザーのマイページの予算一覧の取得 */ -export type getFundInformationsIdDetailsResponse = { - data: GetFundInformationsIdDetails200; +export type getFestivalItemsDetailsUserIdResponse = { + data: FestivalItemsForMyPage[]; status: number; headers: Headers; } -export const getGetFundInformationsIdDetailsUrl = (id: number,) => { +export const getGetFestivalItemsDetailsUserIdUrl = (userId: number, + params?: GetFestivalItemsDetailsUserIdParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/fund_informations/${id}/details` + return normalizedParams.size ? `/festival_items/details/${userId}?${normalizedParams.toString()}` : `/festival_items/details/${userId}` } -export const getFundInformationsIdDetails = async (id: number, options?: RequestInit): Promise => { +export const getFestivalItemsDetailsUserId = async (userId: number, + params?: GetFestivalItemsDetailsUserIdParams, options?: RequestInit): Promise => { - return customFetch>(getGetFundInformationsIdDetailsUrl(id), + return customFetch>(getGetFestivalItemsDetailsUserIdUrl(userId,params), { ...options, method: 'GET' @@ -4146,19 +2554,21 @@ export const getFundInformationsIdDetails = async (id: number, options?: Request -export const getGetFundInformationsIdDetailsKey = (id: number,) => [`/fund_informations/${id}/details`] as const; +export const getGetFestivalItemsDetailsUserIdKey = (userId: number, + params?: GetFestivalItemsDetailsUserIdParams,) => [`/festival_items/details/${userId}`, ...(params ? [params]: [])] as const; -export type GetFundInformationsIdDetailsQueryResult = NonNullable>> -export type GetFundInformationsIdDetailsQueryError = unknown +export type GetFestivalItemsDetailsUserIdQueryResult = NonNullable>> +export type GetFestivalItemsDetailsUserIdQueryError = unknown -export const useGetFundInformationsIdDetails = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetFestivalItemsDetailsUserId = ( + userId: number, + params?: GetFestivalItemsDetailsUserIdParams, 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 isEnabled = swrOptions?.enabled !== false && !!(userId) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFestivalItemsDetailsUserIdKey(userId,params) : null); + const swrFn = () => getFestivalItemsDetailsUserId(userId,params, requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -4169,23 +2579,30 @@ export const useGetFundInformationsIdDetails = ( } /** - * 年度で指定されたfund_informationsに紐づくデータを取得 + * financial_recordの一覧を取得 */ -export type getFundInformationsDetailsYearResponse = { - data: GetFundInformationsDetailsYear200; +export type getFinancialRecordsResponse = { + data: FinancialRecordDetails; status: number; headers: Headers; } -export const getGetFundInformationsDetailsYearUrl = (year: number,) => { +export const getGetFinancialRecordsUrl = (params?: GetFinancialRecordsParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/fund_informations/details/${year}` + return normalizedParams.size ? `/financial_records?${normalizedParams.toString()}` : `/financial_records` } -export const getFundInformationsDetailsYear = async (year: number, options?: RequestInit): Promise => { +export const getFinancialRecords = async (params?: GetFinancialRecordsParams, options?: RequestInit): Promise => { - return customFetch>(getGetFundInformationsDetailsYearUrl(year), + return customFetch>(getGetFinancialRecordsUrl(params), { ...options, method: 'GET' @@ -4197,19 +2614,19 @@ export const getFundInformationsDetailsYear = async (year: number, options?: Req -export const getGetFundInformationsDetailsYearKey = (year: number,) => [`/fund_informations/details/${year}`] as const; +export const getGetFinancialRecordsKey = (params?: GetFinancialRecordsParams,) => [`/financial_records`, ...(params ? [params]: [])] as const; -export type GetFundInformationsDetailsYearQueryResult = NonNullable>> -export type GetFundInformationsDetailsYearQueryError = unknown +export type GetFinancialRecordsQueryResult = NonNullable>> +export type GetFinancialRecordsQueryError = unknown -export const useGetFundInformationsDetailsYear = ( - year: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetFinancialRecords = ( + params?: GetFinancialRecordsParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(year) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFundInformationsDetailsYearKey(year) : null); - const swrFn = () => getFundInformationsDetailsYear(year, requestOptions) + const isEnabled = swrOptions?.enabled !== false + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFinancialRecordsKey(params) : null); + const swrFn = () => getFinancialRecords(params, requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -4220,54 +2637,53 @@ export const useGetFundInformationsDetailsYear = ( } /** - * password_変更 + * financial_recordの作成 */ -export type postPasswordResetIdResponse = { - data: PostPasswordResetId200; +export type postFinancialRecordsResponse = { + data: FinancialRecordWithBalance; status: number; headers: Headers; } -export const getPostPasswordResetIdUrl = (id: number,) => { +export const getPostFinancialRecordsUrl = () => { - return `/password_reset/${id}` + return `/financial_records` } -export const postPasswordResetId = async (id: number, - passwordResetData?: PasswordResetData, options?: RequestInit): Promise => { +export const postFinancialRecords = async (financialRecord: FinancialRecord, options?: RequestInit): Promise => { - return customFetch>(getPostPasswordResetIdUrl(id), + return customFetch>(getPostFinancialRecordsUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify( - passwordResetData,) + financialRecord,) } );} -export const getPostPasswordResetIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: PasswordResetData }): Promise => { - return postPasswordResetId(id, arg, options); +export const getPostFinancialRecordsMutationFetcher = ( options?: SecondParameter) => { + return (_: Key, { arg }: { arg: FinancialRecord }): Promise => { + return postFinancialRecords(arg, options); } } -export const getPostPasswordResetIdMutationKey = (id: number,) => [`/password_reset/${id}`] as const; +export const getPostFinancialRecordsMutationKey = () => [`/financial_records`] as const; -export type PostPasswordResetIdMutationResult = NonNullable>> -export type PostPasswordResetIdMutationError = unknown +export type PostFinancialRecordsMutationResult = NonNullable>> +export type PostFinancialRecordsMutationError = unknown -export const usePostPasswordResetId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, PasswordResetData, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostFinancialRecords = ( + options?: { swr?:SWRMutationConfiguration>, TError, Key, FinancialRecord, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostPasswordResetIdMutationKey(id); - const swrFn = getPostPasswordResetIdMutationFetcher(id, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostFinancialRecordsMutationKey(); + const swrFn = getPostFinancialRecordsMutationFetcher(requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4278,59 +2694,54 @@ export const usePostPasswordResetId = ( } /** - * password_reset_token発行リクエスト + * financial_recordの更新 */ -export type postPasswordResetRequestResponse = { - data: PostPasswordResetRequest200; +export type putFinancialRecordsIdResponse = { + data: FinancialRecordWithBalance; status: number; headers: Headers; } -export const getPostPasswordResetRequestUrl = (params?: PostPasswordResetRequestParams,) => { - const normalizedParams = new URLSearchParams(); +export const getPutFinancialRecordsIdUrl = (id: number,) => { - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - return normalizedParams.size ? `/password_reset/request?${normalizedParams.toString()}` : `/password_reset/request` + return `/financial_records/${id}` } -export const postPasswordResetRequest = async (params?: PostPasswordResetRequestParams, options?: RequestInit): Promise => { +export const putFinancialRecordsId = async (id: number, + financialRecord: FinancialRecord, options?: RequestInit): Promise => { - return customFetch>(getPostPasswordResetRequestUrl(params), + return customFetch>(getPutFinancialRecordsIdUrl(id), { ...options, - method: 'POST' - - + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + financialRecord,) } );} -export const getPostPasswordResetRequestMutationFetcher = (params?: PostPasswordResetRequestParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postPasswordResetRequest(params, options); +export const getPutFinancialRecordsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: FinancialRecord }): Promise => { + return putFinancialRecordsId(id, arg, options); } } -export const getPostPasswordResetRequestMutationKey = (params?: PostPasswordResetRequestParams,) => [`/password_reset/request`, ...(params ? [params]: [])] as const; +export const getPutFinancialRecordsIdMutationKey = (id: number,) => [`/financial_records/${id}`] as const; -export type PostPasswordResetRequestMutationResult = NonNullable>> -export type PostPasswordResetRequestMutationError = unknown +export type PutFinancialRecordsIdMutationResult = NonNullable>> +export type PutFinancialRecordsIdMutationError = unknown -export const usePostPasswordResetRequest = ( - params?: PostPasswordResetRequestParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutFinancialRecordsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, FinancialRecord, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostPasswordResetRequestMutationKey(params); - const swrFn = getPostPasswordResetRequestMutationFetcher(params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutFinancialRecordsIdMutationKey(id); + const swrFn = getPutFinancialRecordsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4341,35 +2752,26 @@ export const usePostPasswordResetRequest = ( } /** - * トークンの称号 + * IDを指定してfinancial_recordの削除 */ -export type postPasswordResetIdValidResponse = { - data: PostPasswordResetIdValid200; +export type deleteFinancialRecordsIdResponse = { + data: DeleteFinancialRecordsId200; status: number; headers: Headers; } -export const getPostPasswordResetIdValidUrl = (id: number, - params?: PostPasswordResetIdValidParams,) => { - const normalizedParams = new URLSearchParams(); +export const getDeleteFinancialRecordsIdUrl = (id: number,) => { - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - return normalizedParams.size ? `/password_reset/${id}/valid?${normalizedParams.toString()}` : `/password_reset/${id}/valid` + return `/financial_records/${id}` } -export const postPasswordResetIdValid = async (id: number, - params?: PostPasswordResetIdValidParams, options?: RequestInit): Promise => { +export const deleteFinancialRecordsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getPostPasswordResetIdValidUrl(id,params), + return customFetch>(getDeleteFinancialRecordsIdUrl(id), { ...options, - method: 'POST' + method: 'DELETE' } @@ -4378,27 +2780,24 @@ export const postPasswordResetIdValid = async (id: number, -export const getPostPasswordResetIdValidMutationFetcher = (id: number, - params?: PostPasswordResetIdValidParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postPasswordResetIdValid(id, params, options); +export const getDeleteFinancialRecordsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteFinancialRecordsId(id, options); } } -export const getPostPasswordResetIdValidMutationKey = (id: number, - params?: PostPasswordResetIdValidParams,) => [`/password_reset/${id}/valid`, ...(params ? [params]: [])] as const; +export const getDeleteFinancialRecordsIdMutationKey = (id: number,) => [`/financial_records/${id}`] as const; -export type PostPasswordResetIdValidMutationResult = NonNullable>> -export type PostPasswordResetIdValidMutationError = unknown +export type DeleteFinancialRecordsIdMutationResult = NonNullable>> +export type DeleteFinancialRecordsIdMutationError = unknown -export const usePostPasswordResetIdValid = ( - id: number, - params?: PostPasswordResetIdValidParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useDeleteFinancialRecordsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostPasswordResetIdValidMutationKey(id,params); - const swrFn = getPostPasswordResetIdValidMutationFetcher(id,params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getDeleteFinancialRecordsIdMutationKey(id); + const swrFn = getDeleteFinancialRecordsIdMutationFetcher(id, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4409,23 +2808,23 @@ export const usePostPasswordResetIdValid = ( } /** - * receiptの一覧を取得 + * fund_informationの一覧を取得 */ -export type getReceiptsResponse = { - data: GetReceipts200; +export type getFundInformationsResponse = { + data: GetFundInformations200; status: number; headers: Headers; } -export const getGetReceiptsUrl = () => { +export const getGetFundInformationsUrl = () => { - return `/receipts` + return `/fund_informations` } -export const getReceipts = async ( options?: RequestInit): Promise => { +export const getFundInformations = async ( options?: RequestInit): Promise => { - return customFetch>(getGetReceiptsUrl(), + return customFetch>(getGetFundInformationsUrl(), { ...options, method: 'GET' @@ -4437,19 +2836,19 @@ export const getReceipts = async ( options?: RequestInit): Promise [`/receipts`] as const; +export const getGetFundInformationsKey = () => [`/fund_informations`] as const; -export type GetReceiptsQueryResult = NonNullable>> -export type GetReceiptsQueryError = unknown +export type GetFundInformationsQueryResult = NonNullable>> +export type GetFundInformationsQueryError = unknown -export const useGetReceipts = ( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +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 ? getGetReceiptsKey() : null); - const swrFn = () => getReceipts(requestOptions) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFundInformationsKey() : null); + const swrFn = () => getFundInformations(requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -4460,53 +2859,59 @@ export const useGetReceipts = ( } /** - * receiptの作成 + * fund_informationの作成 */ -export type postReceiptsResponse = { - data: PostReceipts200; +export type postFundInformationsResponse = { + data: PostFundInformations200; status: number; headers: Headers; } -export const getPostReceiptsUrl = () => { +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()) + } + }); - return `/receipts` + return normalizedParams.size ? `/fund_informations?${normalizedParams.toString()}` : `/fund_informations` } -export const postReceipts = async (receipt?: Receipt, options?: RequestInit): Promise => { +export const postFundInformations = async (params: PostFundInformationsParams, options?: RequestInit): Promise => { - return customFetch>(getPostReceiptsUrl(), + return customFetch>(getPostFundInformationsUrl(params), { ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - receipt,) + method: 'POST' + + } );} -export const getPostReceiptsMutationFetcher = ( options?: SecondParameter) => { - return (_: Key, { arg }: { arg: Receipt }): Promise => { - return postReceipts(arg, options); +export const getPostFundInformationsMutationFetcher = (params: PostFundInformationsParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postFundInformations(params, options); } } -export const getPostReceiptsMutationKey = () => [`/receipts`] as const; +export const getPostFundInformationsMutationKey = (params: PostFundInformationsParams,) => [`/fund_informations`, ...(params ? [params]: [])] as const; -export type PostReceiptsMutationResult = NonNullable>> -export type PostReceiptsMutationError = unknown +export type PostFundInformationsMutationResult = NonNullable>> +export type PostFundInformationsMutationError = unknown -export const usePostReceipts = ( - options?: { swr?:SWRMutationConfiguration>, TError, Key, Receipt, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostFundInformations = ( + params: PostFundInformationsParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostReceiptsMutationKey(); - const swrFn = getPostReceiptsMutationFetcher(requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostFundInformationsMutationKey(params); + const swrFn = getPostFundInformationsMutationFetcher(params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4517,23 +2922,23 @@ export const usePostReceipts = ( } /** - * IDで指定されたreceiptの取得 + * fund_informationに紐づくteacherとuserの一覧を取得 */ -export type getReceiptsIdResponse = { - data: GetReceiptsId200; +export type getFundInformationsDetailsResponse = { + data: GetFundInformationsDetails200; status: number; headers: Headers; } -export const getGetReceiptsIdUrl = (id: number,) => { +export const getGetFundInformationsDetailsUrl = () => { - return `/receipts/${id}` + return `/fund_informations/details` } -export const getReceiptsId = async (id: number, options?: RequestInit): Promise => { +export const getFundInformationsDetails = async ( options?: RequestInit): Promise => { - return customFetch>(getGetReceiptsIdUrl(id), + return customFetch>(getGetFundInformationsDetailsUrl(), { ...options, method: 'GET' @@ -4545,19 +2950,19 @@ export const getReceiptsId = async (id: number, options?: RequestInit): Promise< -export const getGetReceiptsIdKey = (id: number,) => [`/receipts/${id}`] as const; +export const getGetFundInformationsDetailsKey = () => [`/fund_informations/details`] as const; -export type GetReceiptsIdQueryResult = NonNullable>> -export type GetReceiptsIdQueryError = unknown +export type GetFundInformationsDetailsQueryResult = NonNullable>> +export type GetFundInformationsDetailsQueryError = unknown -export const useGetReceiptsId = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useGetFundInformationsDetails = ( + 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 ? getGetReceiptsIdKey(id) : null); - const swrFn = () => getReceiptsId(id, requestOptions) + const isEnabled = swrOptions?.enabled !== false + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFundInformationsDetailsKey() : null); + const swrFn = () => getFundInformationsDetails(requestOptions) const query = useSwr>, TError>(swrKey, swrFn, swrOptions) @@ -4568,56 +2973,49 @@ export const useGetReceiptsId = ( } /** - * receiptの更新 + * IDで指定されたfund_informationの取得 */ -export type putReceiptsIdResponse = { - data: PutReceiptsId200; +export type getFundInformationsIdResponse = { + data: GetFundInformationsId200; status: number; headers: Headers; } -export const getPutReceiptsIdUrl = (id: number,) => { +export const getGetFundInformationsIdUrl = (id: number,) => { - return `/receipts/${id}` + return `/fund_informations/${id}` } -export const putReceiptsId = async (id: number, - receipt?: Receipt, options?: RequestInit): Promise => { +export const getFundInformationsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getPutReceiptsIdUrl(id), + return customFetch>(getGetFundInformationsIdUrl(id), { ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - receipt,) + method: 'GET' + + } );} -export const getPutReceiptsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, { arg }: { arg: Receipt }): Promise => { - return putReceiptsId(id, arg, options); - } -} -export const getPutReceiptsIdMutationKey = (id: number,) => [`/receipts/${id}`] as const; +export const getGetFundInformationsIdKey = (id: number,) => [`/fund_informations/${id}`] as const; -export type PutReceiptsIdMutationResult = NonNullable>> -export type PutReceiptsIdMutationError = unknown +export type GetFundInformationsIdQueryResult = NonNullable>> +export type GetFundInformationsIdQueryError = unknown -export const usePutReceiptsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Receipt, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useGetFundInformationsId = ( + id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } ) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPutReceiptsIdMutationKey(id); - const swrFn = getPutReceiptsIdMutationFetcher(id, requestOptions); + const isEnabled = swrOptions?.enabled !== false && !!(id) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFundInformationsIdKey(id) : null); + const swrFn = () => getFundInformationsId(id, requestOptions) - const query = useSWRMutation(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) return { swrKey, @@ -4626,26 +3024,35 @@ export const usePutReceiptsId = ( } /** - * IDを指定してreceiptの削除 + * fund_informationの更新 */ -export type deleteReceiptsIdResponse = { - data: DeleteReceiptsId200; +export type putFundInformationsIdResponse = { + data: PutFundInformationsId200; status: number; headers: Headers; } -export const getDeleteReceiptsIdUrl = (id: number,) => { +export const getPutFundInformationsIdUrl = (id: number, + params: PutFundInformationsIdParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/receipts/${id}` + return normalizedParams.size ? `/fund_informations/${id}?${normalizedParams.toString()}` : `/fund_informations/${id}` } -export const deleteReceiptsId = async (id: number, options?: RequestInit): Promise => { +export const putFundInformationsId = async (id: number, + params: PutFundInformationsIdParams, options?: RequestInit): Promise => { - return customFetch>(getDeleteReceiptsIdUrl(id), + return customFetch>(getPutFundInformationsIdUrl(id,params), { ...options, - method: 'DELETE' + method: 'PUT' } @@ -4654,24 +3061,27 @@ export const deleteReceiptsId = async (id: number, options?: RequestInit): Promi -export const getDeleteReceiptsIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteReceiptsId(id, options); +export const getPutFundInformationsIdMutationFetcher = (id: number, + params: PutFundInformationsIdParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return putFundInformationsId(id, params, options); } } -export const getDeleteReceiptsIdMutationKey = (id: number,) => [`/receipts/${id}`] as const; +export const getPutFundInformationsIdMutationKey = (id: number, + params: PutFundInformationsIdParams,) => [`/fund_informations/${id}`, ...(params ? [params]: [])] as const; -export type DeleteReceiptsIdMutationResult = NonNullable>> -export type DeleteReceiptsIdMutationError = unknown +export type PutFundInformationsIdMutationResult = NonNullable>> +export type PutFundInformationsIdMutationError = unknown -export const useDeleteReceiptsId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePutFundInformationsId = ( + id: number, + params: PutFundInformationsIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getDeleteReceiptsIdMutationKey(id); - const swrFn = getDeleteReceiptsIdMutationFetcher(id, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPutFundInformationsIdMutationKey(id,params); + const swrFn = getPutFundInformationsIdMutationFetcher(id,params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4682,26 +3092,26 @@ export const useDeleteReceiptsId = ( } /** - * 購入報告に紐づいたreceiptの取得 + * IDを指定してfund_informationの削除 */ -export type getReceiptsReportsIdResponse = { - data: GetReceiptsReportsId200; +export type deleteFundInformationsIdResponse = { + data: DeleteFundInformationsId200; status: number; headers: Headers; } -export const getGetReceiptsReportsIdUrl = (id: number,) => { +export const getDeleteFundInformationsIdUrl = (id: number,) => { - return `/receipts/reports/${id}` + return `/fund_informations/${id}` } -export const getReceiptsReportsId = async (id: number, options?: RequestInit): Promise => { +export const deleteFundInformationsId = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getGetReceiptsReportsIdUrl(id), + return customFetch>(getDeleteFundInformationsIdUrl(id), { ...options, - method: 'GET' + method: 'DELETE' } @@ -4710,21 +3120,26 @@ export const getReceiptsReportsId = async (id: number, options?: RequestInit): P -export const getGetReceiptsReportsIdKey = (id: number,) => [`/receipts/reports/${id}`] as const; +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 GetReceiptsReportsIdQueryResult = NonNullable>> -export type GetReceiptsReportsIdQueryError = unknown +export type DeleteFundInformationsIdMutationResult = NonNullable>> +export type DeleteFundInformationsIdMutationError = unknown -export const useGetReceiptsReportsId = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const useDeleteFundInformationsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(id) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetReceiptsReportsIdKey(id) : null); - const swrFn = () => getReceiptsReportsId(id, requestOptions) + const swrKey = swrOptions?.swrKey ?? getDeleteFundInformationsIdMutationKey(id); + const swrFn = getDeleteFundInformationsIdMutationFetcher(id, requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -4733,23 +3148,23 @@ export const useGetReceiptsReportsId = ( } /** - * sourceの一覧の取得 + * IDで指定されたfund_informatinに紐づくteacherとuserを取得 */ -export type getSourcesResponse = { - data: GetSources200; +export type getFundInformationsIdDetailsResponse = { + data: GetFundInformationsIdDetails200; status: number; headers: Headers; } -export const getGetSourcesUrl = () => { +export const getGetFundInformationsIdDetailsUrl = (id: number,) => { - return `/sources` + return `/fund_informations/${id}/details` } -export const getSources = async ( options?: RequestInit): Promise => { +export const getFundInformationsIdDetails = async (id: number, options?: RequestInit): Promise => { - return customFetch>(getGetSourcesUrl(), + return customFetch>(getGetFundInformationsIdDetailsUrl(id), { ...options, method: 'GET' @@ -4761,19 +3176,19 @@ export const getSources = async ( options?: RequestInit): Promise [`/sources`] as const; +export const getGetFundInformationsIdDetailsKey = (id: number,) => [`/fund_informations/${id}/details`] as const; -export type GetSourcesQueryResult = NonNullable>> -export type GetSourcesQueryError = unknown +export type GetFundInformationsIdDetailsQueryResult = NonNullable>> +export type GetFundInformationsIdDetailsQueryError = unknown -export const useGetSources = ( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +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 - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetSourcesKey() : null); - const swrFn = () => getSources(requestOptions) + 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) @@ -4784,33 +3199,26 @@ export const useGetSources = ( } /** - * sourceの作成 + * 年度で指定されたfund_informationsに紐づくデータを取得 */ -export type postSourcesResponse = { - data: PostSources200; +export type getFundInformationsDetailsYearResponse = { + data: GetFundInformationsDetailsYear200; status: number; headers: Headers; } -export const getPostSourcesUrl = (params: PostSourcesParams,) => { - const normalizedParams = new URLSearchParams(); +export const getGetFundInformationsDetailsYearUrl = (year: number,) => { - Object.entries(params || {}).forEach(([key, value]) => { - - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }); - return normalizedParams.size ? `/sources?${normalizedParams.toString()}` : `/sources` + return `/fund_informations/details/${year}` } -export const postSources = async (params: PostSourcesParams, options?: RequestInit): Promise => { +export const getFundInformationsDetailsYear = async (year: number, options?: RequestInit): Promise => { - return customFetch>(getPostSourcesUrl(params), + return customFetch>(getGetFundInformationsDetailsYearUrl(year), { ...options, - method: 'POST' + method: 'GET' } @@ -4819,26 +3227,21 @@ export const postSources = async (params: PostSourcesParams, options?: RequestIn -export const getPostSourcesMutationFetcher = (params: PostSourcesParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postSources(params, options); - } -} -export const getPostSourcesMutationKey = (params: PostSourcesParams,) => [`/sources`, ...(params ? [params]: [])] as const; +export const getGetFundInformationsDetailsYearKey = (year: number,) => [`/fund_informations/details/${year}`] as const; -export type PostSourcesMutationResult = NonNullable>> -export type PostSourcesMutationError = unknown +export type GetFundInformationsDetailsYearQueryResult = NonNullable>> +export type GetFundInformationsDetailsYearQueryError = unknown -export const usePostSources = ( - params: PostSourcesParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const useGetFundInformationsDetailsYear = ( + year: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } ) => { - const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPostSourcesMutationKey(params); - const swrFn = getPostSourcesMutationFetcher(params, requestOptions); + const isEnabled = swrOptions?.enabled !== false && !!(year) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFundInformationsDetailsYearKey(year) : null); + const swrFn = () => getFundInformationsDetailsYear(year, requestOptions) - const query = useSWRMutation(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) return { swrKey, @@ -4847,49 +3250,56 @@ export const usePostSources = ( } /** - * IDで指定されたsourceの取得 + * password_変更 */ -export type getSourcesIdResponse = { - data: GetSourcesId200; +export type postPasswordResetIdResponse = { + data: PostPasswordResetId200; status: number; headers: Headers; } -export const getGetSourcesIdUrl = (id: number,) => { +export const getPostPasswordResetIdUrl = (id: number,) => { - return `/sources/${id}` + return `/password_reset/${id}` } -export const getSourcesId = async (id: number, options?: RequestInit): Promise => { +export const postPasswordResetId = async (id: number, + passwordResetData?: PasswordResetData, options?: RequestInit): Promise => { - return customFetch>(getGetSourcesIdUrl(id), + return customFetch>(getPostPasswordResetIdUrl(id), { ...options, - method: 'GET' - - + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + passwordResetData,) } );} -export const getGetSourcesIdKey = (id: number,) => [`/sources/${id}`] as const; +export const getPostPasswordResetIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PasswordResetData }): Promise => { + return postPasswordResetId(id, arg, options); + } +} +export const getPostPasswordResetIdMutationKey = (id: number,) => [`/password_reset/${id}`] as const; -export type GetSourcesIdQueryResult = NonNullable>> -export type GetSourcesIdQueryError = unknown +export type PostPasswordResetIdMutationResult = NonNullable>> +export type PostPasswordResetIdMutationError = unknown -export const useGetSourcesId = ( - id: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +export const usePostPasswordResetId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, PasswordResetData, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} - const isEnabled = swrOptions?.enabled !== false && !!(id) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetSourcesIdKey(id) : null); - const swrFn = () => getSourcesId(id, requestOptions) + const swrKey = swrOptions?.swrKey ?? getPostPasswordResetIdMutationKey(id); + const swrFn = getPostPasswordResetIdMutationFetcher(id, requestOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSWRMutation(swrKey, swrFn, swrOptions) return { swrKey, @@ -4898,16 +3308,15 @@ export const useGetSourcesId = ( } /** - * sourceの更新 + * password_reset_token発行リクエスト */ -export type putSourcesIdResponse = { - data: PutSourcesId200; +export type postPasswordResetRequestResponse = { + data: PostPasswordResetRequest200; status: number; headers: Headers; } -export const getPutSourcesIdUrl = (id: number, - params: PutSourcesIdParams,) => { +export const getPostPasswordResetRequestUrl = (params?: PostPasswordResetRequestParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { @@ -4917,16 +3326,15 @@ export const getPutSourcesIdUrl = (id: number, } }); - return normalizedParams.size ? `/sources/${id}?${normalizedParams.toString()}` : `/sources/${id}` + return normalizedParams.size ? `/password_reset/request?${normalizedParams.toString()}` : `/password_reset/request` } -export const putSourcesId = async (id: number, - params: PutSourcesIdParams, options?: RequestInit): Promise => { +export const postPasswordResetRequest = async (params?: PostPasswordResetRequestParams, options?: RequestInit): Promise => { - return customFetch>(getPutSourcesIdUrl(id,params), + return customFetch>(getPostPasswordResetRequestUrl(params), { ...options, - method: 'PUT' + method: 'POST' } @@ -4935,27 +3343,24 @@ export const putSourcesId = async (id: number, -export const getPutSourcesIdMutationFetcher = (id: number, - params: PutSourcesIdParams, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putSourcesId(id, params, options); +export const getPostPasswordResetRequestMutationFetcher = (params?: PostPasswordResetRequestParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postPasswordResetRequest(params, options); } } -export const getPutSourcesIdMutationKey = (id: number, - params: PutSourcesIdParams,) => [`/sources/${id}`, ...(params ? [params]: [])] as const; +export const getPostPasswordResetRequestMutationKey = (params?: PostPasswordResetRequestParams,) => [`/password_reset/request`, ...(params ? [params]: [])] as const; -export type PutSourcesIdMutationResult = NonNullable>> -export type PutSourcesIdMutationError = unknown +export type PostPasswordResetRequestMutationResult = NonNullable>> +export type PostPasswordResetRequestMutationError = unknown -export const usePutSourcesId = ( - id: number, - params: PutSourcesIdParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostPasswordResetRequest = ( + params?: PostPasswordResetRequestParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getPutSourcesIdMutationKey(id,params); - const swrFn = getPutSourcesIdMutationFetcher(id,params, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostPasswordResetRequestMutationKey(params); + const swrFn = getPostPasswordResetRequestMutationFetcher(params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) @@ -4966,26 +3371,35 @@ export const usePutSourcesId = ( } /** - * IDを指定してsourceの削除 + * トークンの称号 */ -export type deleteSourcesIdResponse = { - data: DeleteSourcesId200; +export type postPasswordResetIdValidResponse = { + data: PostPasswordResetIdValid200; status: number; headers: Headers; } -export const getDeleteSourcesIdUrl = (id: number,) => { +export const getPostPasswordResetIdValidUrl = (id: number, + params?: PostPasswordResetIdValidParams,) => { + const normalizedParams = new URLSearchParams(); + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); - return `/sources/${id}` + return normalizedParams.size ? `/password_reset/${id}/valid?${normalizedParams.toString()}` : `/password_reset/${id}/valid` } -export const deleteSourcesId = async (id: number, options?: RequestInit): Promise => { +export const postPasswordResetIdValid = async (id: number, + params?: PostPasswordResetIdValidParams, options?: RequestInit): Promise => { - return customFetch>(getDeleteSourcesIdUrl(id), + return customFetch>(getPostPasswordResetIdValidUrl(id,params), { ...options, - method: 'DELETE' + method: 'POST' } @@ -4994,24 +3408,27 @@ export const deleteSourcesId = async (id: number, options?: RequestInit): Promis -export const getDeleteSourcesIdMutationFetcher = (id: number, options?: SecondParameter) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteSourcesId(id, options); +export const getPostPasswordResetIdValidMutationFetcher = (id: number, + params?: PostPasswordResetIdValidParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postPasswordResetIdValid(id, params, options); } } -export const getDeleteSourcesIdMutationKey = (id: number,) => [`/sources/${id}`] as const; +export const getPostPasswordResetIdValidMutationKey = (id: number, + params?: PostPasswordResetIdValidParams,) => [`/password_reset/${id}/valid`, ...(params ? [params]: [])] as const; -export type DeleteSourcesIdMutationResult = NonNullable>> -export type DeleteSourcesIdMutationError = unknown +export type PostPasswordResetIdValidMutationResult = NonNullable>> +export type PostPasswordResetIdValidMutationError = unknown -export const useDeleteSourcesId = ( - id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +export const usePostPasswordResetIdValid = ( + id: number, + params?: PostPasswordResetIdValidParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} ) => { const {swr: swrOptions, request: requestOptions} = options ?? {} - const swrKey = swrOptions?.swrKey ?? getDeleteSourcesIdMutationKey(id); - const swrFn = getDeleteSourcesIdMutationFetcher(id, requestOptions); + const swrKey = swrOptions?.swrKey ?? getPostPasswordResetIdValidMutationKey(id,params); + const swrFn = getPostPasswordResetIdValidMutationFetcher(id,params, requestOptions); const query = useSWRMutation(swrKey, swrFn, swrOptions) From 158e5f07bc48e3afdfa8432f12461f3940a8b2a5 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Mon, 3 Feb 2025 19:28:04 +0900 Subject: [PATCH 02/14] =?UTF-8?q?=E3=83=98=E3=83=AB=E3=82=B9=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/generated/openapi_gen.go | 13 ++++++ openapi/openapi.yaml | 13 ++++++ view/next-project/src/generated/hooks.ts | 51 ++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index da4cc96fe..bceb8c457 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -560,6 +560,9 @@ type PutYearsPeriodsIdJSONRequestBody = YearPeriods // ServerInterface represents all server handlers. type ServerInterface interface { + // (GET /) + Get(ctx echo.Context) error + // (GET /activities) GetActivities(ctx echo.Context) error @@ -842,6 +845,15 @@ type ServerInterfaceWrapper struct { Handler ServerInterface } +// Get converts echo context to params. +func (w *ServerInterfaceWrapper) Get(ctx echo.Context) error { + var err error + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.Get(ctx) + return err +} + // GetActivities converts echo context to params. func (w *ServerInterfaceWrapper) GetActivities(ctx echo.Context) error { var err error @@ -2482,6 +2494,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL Handler: si, } + router.GET(baseURL+"/", wrapper.Get) router.GET(baseURL+"/activities", wrapper.GetActivities) router.POST(baseURL+"/activities", wrapper.PostActivities) router.GET(baseURL+"/activities/details", wrapper.GetActivitiesDetails) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index bb328fe82..24633f335 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -9,6 +9,19 @@ servers: - url: http://localhost:1323/ paths: + /: + get: + tags: + - health + description: health check + responses: + "200": + description: OK + content: + application/json: + schema: + type: string + /activities: get: tags: diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index ebf63d243..7ff246b3d 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -144,6 +144,57 @@ import { customFetch } from '../mutator/custom-instance'; type SecondParameter any> = Parameters[1]; +/** + * health check + */ +export type getResponse = { + data: string; + status: number; + headers: Headers; +} + +export const getGetUrl = () => { + + + return `/` +} + +export const get = async ( options?: RequestInit): Promise => { + + return customFetch>(getGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + + +export const getGetKey = () => [`/`] as const; + +export type GetQueryResult = NonNullable>> +export type GetQueryError = unknown + +export const useGet = ( + 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 ? getGetKey() : null); + const swrFn = () => get(requestOptions) + + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + /** * activitiesの一覧を取得 */ From 9c7c389845ceebab5ff87368ecad4e42a436e119 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Mon, 3 Feb 2025 19:38:00 +0900 Subject: [PATCH 03/14] =?UTF-8?q?=E8=AA=8D=E8=A8=BC=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/generated/openapi_gen.go | 162 +++++++++++++++ openapi/openapi.yaml | 93 ++++++++- view/next-project/src/generated/hooks.ts | 239 +++++++++++++++++++++++ 3 files changed, 493 insertions(+), 1 deletion(-) diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index bceb8c457..5517b6e5a 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -390,6 +390,37 @@ type PutFundInformationsIdParams struct { ReceivedAt *string `form:"received_at,omitempty" json:"received_at,omitempty"` } +// GetMailAuthIsSigninParams defines parameters for GetMailAuthIsSignin. +type GetMailAuthIsSigninParams struct { + AccessToken *string `json:"Access-Token,omitempty"` +} + +// PostMailAuthSigninParams defines parameters for PostMailAuthSignin. +type PostMailAuthSigninParams struct { + // Email email + Email string `form:"email" json:"email"` + + // Password password + Password string `form:"password" json:"password"` +} + +// DeleteMailAuthSignoutParams defines parameters for DeleteMailAuthSignout. +type DeleteMailAuthSignoutParams struct { + AccessToken *string `json:"Access-Token,omitempty"` +} + +// PostMailAuthSignupParams defines parameters for PostMailAuthSignup. +type PostMailAuthSignupParams struct { + // Email email + Email string `form:"email" json:"email"` + + // Password password + Password string `form:"password" json:"password"` + + // UserId user_id + UserId int `form:"user_id" json:"user_id"` +} + // PostPasswordResetRequestParams defines parameters for PostPasswordResetRequest. type PostPasswordResetRequestParams struct { // Email email @@ -728,6 +759,18 @@ type ServerInterface interface { // (GET /fund_informations/{id}/details) GetFundInformationsIdDetails(ctx echo.Context, id int) error + // (GET /mail_auth/is_signin) + GetMailAuthIsSignin(ctx echo.Context, params GetMailAuthIsSigninParams) error + + // (POST /mail_auth/signin) + PostMailAuthSignin(ctx echo.Context, params PostMailAuthSigninParams) error + + // (DELETE /mail_auth/signout) + DeleteMailAuthSignout(ctx echo.Context, params DeleteMailAuthSignoutParams) error + + // (POST /mail_auth/signup) + PostMailAuthSignup(ctx echo.Context, params PostMailAuthSignupParams) error + // (POST /password_reset/request) PostPasswordResetRequest(ctx echo.Context, params PostPasswordResetRequestParams) error @@ -1816,6 +1859,121 @@ func (w *ServerInterfaceWrapper) GetFundInformationsIdDetails(ctx echo.Context) return err } +// GetMailAuthIsSignin converts echo context to params. +func (w *ServerInterfaceWrapper) GetMailAuthIsSignin(ctx echo.Context) error { + var err error + + // Parameter object where we will unmarshal all parameters from the context + var params GetMailAuthIsSigninParams + + headers := ctx.Request().Header + // ------------- Optional header parameter "Access-Token" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Access-Token")]; found { + var AccessToken string + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Access-Token, got %d", n)) + } + + err = runtime.BindStyledParameterWithOptions("simple", "Access-Token", valueList[0], &AccessToken, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Access-Token: %s", err)) + } + + params.AccessToken = &AccessToken + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetMailAuthIsSignin(ctx, params) + return err +} + +// PostMailAuthSignin converts echo context to params. +func (w *ServerInterfaceWrapper) PostMailAuthSignin(ctx echo.Context) error { + var err error + + // Parameter object where we will unmarshal all parameters from the context + var params PostMailAuthSigninParams + // ------------- Required query parameter "email" ------------- + + err = runtime.BindQueryParameter("form", true, true, "email", ctx.QueryParams(), ¶ms.Email) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter email: %s", err)) + } + + // ------------- Required query parameter "password" ------------- + + err = runtime.BindQueryParameter("form", true, true, "password", ctx.QueryParams(), ¶ms.Password) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter password: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.PostMailAuthSignin(ctx, params) + return err +} + +// DeleteMailAuthSignout converts echo context to params. +func (w *ServerInterfaceWrapper) DeleteMailAuthSignout(ctx echo.Context) error { + var err error + + // Parameter object where we will unmarshal all parameters from the context + var params DeleteMailAuthSignoutParams + + headers := ctx.Request().Header + // ------------- Optional header parameter "Access-Token" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Access-Token")]; found { + var AccessToken string + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Access-Token, got %d", n)) + } + + err = runtime.BindStyledParameterWithOptions("simple", "Access-Token", valueList[0], &AccessToken, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Access-Token: %s", err)) + } + + params.AccessToken = &AccessToken + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.DeleteMailAuthSignout(ctx, params) + return err +} + +// PostMailAuthSignup converts echo context to params. +func (w *ServerInterfaceWrapper) PostMailAuthSignup(ctx echo.Context) error { + var err error + + // Parameter object where we will unmarshal all parameters from the context + var params PostMailAuthSignupParams + // ------------- Required query parameter "email" ------------- + + err = runtime.BindQueryParameter("form", true, true, "email", ctx.QueryParams(), ¶ms.Email) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter email: %s", err)) + } + + // ------------- Required query parameter "password" ------------- + + err = runtime.BindQueryParameter("form", true, true, "password", ctx.QueryParams(), ¶ms.Password) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter password: %s", err)) + } + + // ------------- 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)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.PostMailAuthSignup(ctx, params) + return err +} + // PostPasswordResetRequest converts echo context to params. func (w *ServerInterfaceWrapper) PostPasswordResetRequest(ctx echo.Context) error { var err error @@ -2550,6 +2708,10 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL 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+"/mail_auth/is_signin", wrapper.GetMailAuthIsSignin) + router.POST(baseURL+"/mail_auth/signin", wrapper.PostMailAuthSignin) + router.DELETE(baseURL+"/mail_auth/signout", wrapper.DeleteMailAuthSignout) + router.POST(baseURL+"/mail_auth/signup", wrapper.PostMailAuthSignup) router.POST(baseURL+"/password_reset/request", wrapper.PostPasswordResetRequest) router.POST(baseURL+"/password_reset/:id", wrapper.PostPasswordResetId) router.POST(baseURL+"/password_reset/:id/valid", wrapper.PostPasswordResetIdValid) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 24633f335..e551ce823 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1218,7 +1218,98 @@ paths: application/json: schema: type: object - + /mail_auth/signup: + post: + tags: + - mail_auth + description: ユーザー登録 + parameters: + - name: email + in: query + description: email + required: true + schema: + type: string + - name: password + in: query + description: password + required: true + schema: + type: string + - name: user_id + in: query + description: user_id + required: true + schema: + type: integer + responses: + "200": + description: ユーザー登録完了 + content: + application/json: + schema: + type: object + x-codegen-request-body-name: mailAuthSignUp + /mail_auth/signin: + post: + tags: + - mail_auth + description: ログイン + parameters: + - name: email + in: query + description: email + required: true + schema: + type: string + - name: password + in: query + description: password + required: true + schema: + type: string + responses: + "200": + description: ログイン完了 + content: + application/json: + schema: + type: object + x-codegen-request-body-name: mailAuthSignIn + /mail_auth/signout: + delete: + tags: + - mail_auth + description: ログアウト + parameters: + - in: header + name: Access-Token + schema: + type: string + responses: + "200": + description: ログアウト完了 + content: + application/json: + schema: + type: object + /mail_auth/is_signin: + get: + tags: + - mail_auth + description: ログイン状態の確認 + parameters: + - in: header + name: Access-Token + schema: + type: string + responses: + "200": + description: ログイン状態の確認 + content: + application/json: + schema: + type: object /password_reset/{id}: post: tags: diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index 7ff246b3d..7d352d647 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -31,6 +31,7 @@ import type { DeleteFestivalItemsId200, DeleteFinancialRecordsId200, DeleteFundInformationsId200, + DeleteMailAuthSignout200, DeleteSponsorsId200, DeleteSponsorstylesId200, DeleteTeachersDelete200, @@ -77,6 +78,7 @@ import type { GetFundInformationsDetailsYear200, GetFundInformationsId200, GetFundInformationsIdDetails200, + GetMailAuthIsSignin200, GetSponsorstyles200, GetSponsorstylesId200, GetTeachersFundRegisteredYear200, @@ -93,6 +95,10 @@ import type { PostDepartmentsParams, PostFundInformations200, PostFundInformationsParams, + PostMailAuthSignin200, + PostMailAuthSigninParams, + PostMailAuthSignup200, + PostMailAuthSignupParams, PostPasswordResetId200, PostPasswordResetIdValid200, PostPasswordResetIdValidParams, @@ -3300,6 +3306,239 @@ export const useGetFundInformationsDetailsYear = ( } } +/** + * ユーザー登録 + */ +export type postMailAuthSignupResponse = { + data: PostMailAuthSignup200; + status: number; + headers: Headers; +} + +export const getPostMailAuthSignupUrl = (params: PostMailAuthSignupParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + return normalizedParams.size ? `/mail_auth/signup?${normalizedParams.toString()}` : `/mail_auth/signup` +} + +export const postMailAuthSignup = async (params: PostMailAuthSignupParams, options?: RequestInit): Promise => { + + return customFetch>(getPostMailAuthSignupUrl(params), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getPostMailAuthSignupMutationFetcher = (params: PostMailAuthSignupParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postMailAuthSignup(params, options); + } +} +export const getPostMailAuthSignupMutationKey = (params: PostMailAuthSignupParams,) => [`/mail_auth/signup`, ...(params ? [params]: [])] as const; + +export type PostMailAuthSignupMutationResult = NonNullable>> +export type PostMailAuthSignupMutationError = unknown + +export const usePostMailAuthSignup = ( + params: PostMailAuthSignupParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +) => { + + const {swr: swrOptions, request: requestOptions} = options ?? {} + + const swrKey = swrOptions?.swrKey ?? getPostMailAuthSignupMutationKey(params); + const swrFn = getPostMailAuthSignupMutationFetcher(params, requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * ログイン + */ +export type postMailAuthSigninResponse = { + data: PostMailAuthSignin200; + status: number; + headers: Headers; +} + +export const getPostMailAuthSigninUrl = (params: PostMailAuthSigninParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + return normalizedParams.size ? `/mail_auth/signin?${normalizedParams.toString()}` : `/mail_auth/signin` +} + +export const postMailAuthSignin = async (params: PostMailAuthSigninParams, options?: RequestInit): Promise => { + + return customFetch>(getPostMailAuthSigninUrl(params), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getPostMailAuthSigninMutationFetcher = (params: PostMailAuthSigninParams, options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return postMailAuthSignin(params, options); + } +} +export const getPostMailAuthSigninMutationKey = (params: PostMailAuthSigninParams,) => [`/mail_auth/signin`, ...(params ? [params]: [])] as const; + +export type PostMailAuthSigninMutationResult = NonNullable>> +export type PostMailAuthSigninMutationError = unknown + +export const usePostMailAuthSignin = ( + params: PostMailAuthSigninParams, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +) => { + + const {swr: swrOptions, request: requestOptions} = options ?? {} + + const swrKey = swrOptions?.swrKey ?? getPostMailAuthSigninMutationKey(params); + const swrFn = getPostMailAuthSigninMutationFetcher(params, requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * ログアウト + */ +export type deleteMailAuthSignoutResponse = { + data: DeleteMailAuthSignout200; + status: number; + headers: Headers; +} + +export const getDeleteMailAuthSignoutUrl = () => { + + + return `/mail_auth/signout` +} + +export const deleteMailAuthSignout = async ( options?: RequestInit): Promise => { + + return customFetch>(getDeleteMailAuthSignoutUrl(), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getDeleteMailAuthSignoutMutationFetcher = ( options?: SecondParameter) => { + return (_: Key, __: { arg: Arguments }): Promise => { + return deleteMailAuthSignout(options); + } +} +export const getDeleteMailAuthSignoutMutationKey = () => [`/mail_auth/signout`] as const; + +export type DeleteMailAuthSignoutMutationResult = NonNullable>> +export type DeleteMailAuthSignoutMutationError = unknown + +export const useDeleteMailAuthSignout = ( + options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +) => { + + const {swr: swrOptions, request: requestOptions} = options ?? {} + + const swrKey = swrOptions?.swrKey ?? getDeleteMailAuthSignoutMutationKey(); + const swrFn = getDeleteMailAuthSignoutMutationFetcher(requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * ログイン状態の確認 + */ +export type getMailAuthIsSigninResponse = { + data: GetMailAuthIsSignin200; + status: number; + headers: Headers; +} + +export const getGetMailAuthIsSigninUrl = () => { + + + return `/mail_auth/is_signin` +} + +export const getMailAuthIsSignin = async ( options?: RequestInit): Promise => { + + return customFetch>(getGetMailAuthIsSigninUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + + +export const getGetMailAuthIsSigninKey = () => [`/mail_auth/is_signin`] as const; + +export type GetMailAuthIsSigninQueryResult = NonNullable>> +export type GetMailAuthIsSigninQueryError = unknown + +export const useGetMailAuthIsSignin = ( + 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 ? getGetMailAuthIsSigninKey() : null); + const swrFn = () => getMailAuthIsSignin(requestOptions) + + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + /** * password_変更 */ From 1ba1cc49b1c8090fc35d82afde948ffa11440894 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Mon, 3 Feb 2025 23:36:19 +0900 Subject: [PATCH 04/14] =?UTF-8?q?handler=E3=81=A7=E7=94=9F=E6=88=90?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E9=96=A2=E6=95=B0=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/drivers/server/server.go | 31 +++++ api/externals/handler/activity_handler.go | 120 ++++++++++++++++ .../handler/activity_information_handler.go | 81 +++++++++++ .../handler/activity_style_handler.go | 131 ++++++++++++++++++ api/externals/handler/bureau_handler.go | 68 +++++++++ api/externals/handler/buy_report_handler.go | 88 ++++++++++++ api/externals/handler/department_handler.go | 62 +++++++++ api/externals/handler/division_handler.go | 69 +++++++++ .../handler/festival_item_handler.go | 85 ++++++++++++ .../handler/financial_record_handler.go | 62 +++++++++ .../handler/fund_information_handler.go | 100 +++++++++++++ api/externals/handler/handler.go | 68 +++++++++ api/externals/handler/health_check_handler.go | 12 ++ api/externals/handler/mail_auth_handler.go | 56 ++++++++ .../handler/object_upload_handler.go | 23 +++ .../handler/password_reset_token_handler.go | 62 +++++++++ api/externals/handler/sponsor_handler.go | 88 ++++++++++++ .../handler/sponsor_style_handler.go | 70 ++++++++++ api/externals/handler/teacher_handler.go | 92 ++++++++++++ api/externals/handler/user_handler.go | 75 ++++++++++ api/externals/handler/year_handler.go | 110 +++++++++++++++ api/internals/di/di.go | 26 +++- .../next-project/src/generated/model/index.ts | 6 + 23 files changed, 1583 insertions(+), 2 deletions(-) create mode 100644 api/externals/handler/activity_handler.go create mode 100644 api/externals/handler/activity_information_handler.go create mode 100644 api/externals/handler/activity_style_handler.go create mode 100644 api/externals/handler/bureau_handler.go create mode 100644 api/externals/handler/buy_report_handler.go create mode 100644 api/externals/handler/department_handler.go create mode 100644 api/externals/handler/division_handler.go create mode 100644 api/externals/handler/festival_item_handler.go create mode 100644 api/externals/handler/financial_record_handler.go create mode 100644 api/externals/handler/fund_information_handler.go create mode 100644 api/externals/handler/handler.go create mode 100644 api/externals/handler/health_check_handler.go create mode 100644 api/externals/handler/mail_auth_handler.go create mode 100644 api/externals/handler/object_upload_handler.go create mode 100644 api/externals/handler/password_reset_token_handler.go create mode 100644 api/externals/handler/sponsor_handler.go create mode 100644 api/externals/handler/sponsor_style_handler.go create mode 100644 api/externals/handler/teacher_handler.go create mode 100644 api/externals/handler/user_handler.go create mode 100644 api/externals/handler/year_handler.go diff --git a/api/drivers/server/server.go b/api/drivers/server/server.go index c2bd72df7..f1353360c 100644 --- a/api/drivers/server/server.go +++ b/api/drivers/server/server.go @@ -4,6 +4,8 @@ import ( "net/http" "os" + "github.com/NUTFes/FinanSu/api/externals/handler" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/router" echo "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" @@ -37,3 +39,32 @@ func RunServer(router router.Router) *echo.Echo { // サーバー起動 return e } + +func RunServer2(server *handler.Handler) *echo.Echo { + // echoのインスタンス + e := echo.New() + + // Middleware + e.Use(middleware.Recover()) + + // log + logger := middleware.LoggerWithConfig( + middleware.LoggerConfig{ + Format: logFormat(), + Output: os.Stdout, + }, + ) + e.Use(logger) + + // CORS対策 + e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ + AllowOrigins: []string{"http://localhost:3000", "127.0.0.1:3000", "http://localhost:3001", "127.0.0.1:3001", "http://localhost:8000", "127.0.0.1:8000", "https://finansu.nutfes.net"}, // ドメイン + AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete}, + })) + + // ルーティング + + generated.RegisterHandlers(e, server) + // サーバー起動 + return e +} diff --git a/api/externals/handler/activity_handler.go b/api/externals/handler/activity_handler.go new file mode 100644 index 000000000..f26a2fe0c --- /dev/null +++ b/api/externals/handler/activity_handler.go @@ -0,0 +1,120 @@ +package handler + +import ( + "fmt" + "net/http" + "strconv" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/activities", wrapper.GetActivities) +// router.POST(baseURL+"/activities", wrapper.PostActivities) +// router.GET(baseURL+"/activities/details", wrapper.GetActivitiesDetails) +// router.GET(baseURL+"/activities/details/:year", wrapper.GetActivitiesDetailsYear) +// router.GET(baseURL+"/activities/filtered_details", wrapper.GetActivitiesFilteredDetails) +// router.GET(baseURL+"/activities/filtered_details/:year", wrapper.GetActivitiesFilteredDetailsYear) +// router.DELETE(baseURL+"/activities/:id", wrapper.DeleteActivitiesId) +// router.GET(baseURL+"/activities/:id", wrapper.GetActivitiesId) +// router.PUT(baseURL+"/activities/:id", wrapper.PutActivitiesId) + +// Index +func (h *Handler) GetActivities(c echo.Context) error { + activities, err := h.activityUseCase.GetActivity(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activities) +} + +// Show +func (h *Handler) GetActivitiesId(c echo.Context) error { + id := c.Param("id") + activity, err := h.activityUseCase.GetActivityByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activity) +} + +// Create +func (h *Handler) PostActivities(c echo.Context) error { + activities := new(domain.Activity) + if err := c.Bind(activities); err != nil { + fmt.Println("err") + return err + } + latastActivity, err := h.activityUseCase.CreateActivity(c.Request().Context(), strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastActivity) +} + +// Update +func (h *Handler) PutActivitiesId(c echo.Context) error { + id := c.Param("id") + activities := new(domain.Activity) + if err := c.Bind(activities); err != nil { + fmt.Println("err") + return err + } + updatedActivity, err := h.activityUseCase.UpdateActivity(c.Request().Context(), id, strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedActivity) +} + +// Destroy +func (h *Handler) DeleteActivitiesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.activityUseCase.DestroyActivity(c.Request().Context(), idStr) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy Activity") +} + +// For admin view +func (h *Handler) GetActivitiesDetails(c echo.Context) error { + activities, err := h.activityUseCase.GetActivityDetail(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activities) +} + +// 年度で指定されたactivitiesとsponsor,sponsorStyle,userの一覧を取得 +func (h *Handler) GetActivitiesDetailsYear(c echo.Context) error { + year := c.Param("year") + activities, err := h.activityUseCase.GetActivityDetailsByPeriod(c.Request().Context(), year) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activities) +} + +func (h *Handler) GetActivitiesFilteredDetails(c echo.Context) error { + isDone := c.QueryParam("is_done") + sponsorStyleIDs := c.QueryParams()["sponsor_style_id"] + keyword := c.QueryParam("keyword") + activities, err := h.activityUseCase.GetFilteredActivityDetail(c.Request().Context(), isDone, sponsorStyleIDs, keyword) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activities) +} + +func (h *Handler) GetActivitiesFilteredDetailsYear(c echo.Context) error { + isDone := c.QueryParam("is_done") + sponsorStyleIDs := c.QueryParams()["sponsor_style_id"] + year := c.Param("year") + keyword := c.QueryParam("keyword") + activities, err := h.activityUseCase.GetFilteredActivityDetailByPeriod(c.Request().Context(), isDone, sponsorStyleIDs, year, keyword) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activities) +} diff --git a/api/externals/handler/activity_information_handler.go b/api/externals/handler/activity_information_handler.go new file mode 100644 index 000000000..3e2db6714 --- /dev/null +++ b/api/externals/handler/activity_information_handler.go @@ -0,0 +1,81 @@ +package handler + +import ( + "net/http" + "strconv" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/activity_informations", wrapper.GetActivityInformations) +func (h *Handler) GetActivityInformations(c echo.Context) error { + activityInformations, err := h.activityInformationUseCase.GetActivityInformation(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activityInformations) +} + +// router.POST(baseURL+"/activity_informations", wrapper.PostActivityInformations) +func (h *Handler) PostActivityInformations(c echo.Context) error { + activityInformation := new(domain.ActivityInformation) + if err := c.Bind(activityInformation); err != nil { + return err + } + + latastActivityInformation, err := h.activityInformationUseCase.CreateActivityInformation(c.Request().Context(), + strconv.Itoa(int(activityInformation.ActivityId)), + activityInformation.BucketName, + activityInformation.FileName, + activityInformation.FileType, + strconv.Itoa(int(activityInformation.DesignProgress)), + activityInformation.FileInformation, + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastActivityInformation) +} + +// router.DELETE(baseURL+"/activity_informations/:id", wrapper.DeleteActivityInformationsId) +func (h *Handler) DeleteActivityInformationsId(c echo.Context) error { + id := c.Param("id") + err := h.activityInformationUseCase.DestroyActivityInformation(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, "Destroy ActivityInformations") +} + +// router.GET(baseURL+"/activity_informations/:id", wrapper.GetActivityInformationsId) +func (h *Handler) GetActivityInformationsId(c echo.Context) error { + id := c.Param("id") + activityInformation, err := h.activityInformationUseCase.GetActivityInformationByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activityInformation) +} + +// router.PUT(baseURL+"/activity_informations/:id", wrapper.PutActivityInformationsId) +func (h *Handler) PutActivityInformationsId(c echo.Context) error { + id := c.Param("id") + activityInformation := new(domain.ActivityInformation) + if err := c.Bind(activityInformation); err != nil { + return err + } + updatedActivity, err := h.activityInformationUseCase.UpdateActivityInformation(c.Request().Context(), + id, + strconv.Itoa(int(activityInformation.ActivityId)), + activityInformation.BucketName, + activityInformation.FileName, + activityInformation.FileType, + strconv.Itoa(int(activityInformation.DesignProgress)), + activityInformation.FileInformation) + + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedActivity) +} diff --git a/api/externals/handler/activity_style_handler.go b/api/externals/handler/activity_style_handler.go new file mode 100644 index 000000000..302a1a598 --- /dev/null +++ b/api/externals/handler/activity_style_handler.go @@ -0,0 +1,131 @@ +package handler + +import ( + "net/http" + "strconv" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/activity_styles", wrapper.GetActivityStyles) +func (h *Handler) GetActivityStyles(c echo.Context) error { + activityStyles, err := h.activityStyleUseCase.GetActivityStyle(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activityStyles) +} + +// router.POST(baseURL+"/activity_styles", wrapper.PostActivityStyles) +func (h *Handler) PostActivityStyles(c echo.Context) error { + activityStyle := new(domain.ActivityStyle) + if err := c.Bind(activityStyle); err != nil { + return err + } + + latastActivityStyle, err := h.activityStyleUseCase.CreateActivityStyle(c.Request().Context(), + strconv.Itoa(int(activityStyle.ActivityID)), + strconv.Itoa(int(activityStyle.SponsoStyleID)), + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastActivityStyle) +} + +// router.DELETE(baseURL+"/activity_styles/:id", wrapper.DeleteActivityStylesId) +func (h *Handler) DeleteActivityStylesId(c echo.Context) error { + id := c.Param("id") + err := h.activityStyleUseCase.DestroyActivityStyle(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, "Destroy ActivityStyles") +} + +// router.GET(baseURL+"/activity_styles/:id", wrapper.GetActivityStylesId) +func (h *Handler) GetActivityStylesId(c echo.Context) error { + id := c.Param("id") + activityStyle, err := h.activityStyleUseCase.GetActivityStyleByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, activityStyle) +} + +// router.PUT(baseURL+"/activity_styles/:id", wrapper.PutActivityStylesId) +func (h *Handler) PutActivityStylesId(c echo.Context) error { + id := c.Param("id") + activityStyle := new(domain.ActivityStyle) + if err := c.Bind(activityStyle); err != nil { + return err + } + + updatedActivityStyle, err := h.activityStyleUseCase.UpdateActivityStyle(c.Request().Context(), id, + strconv.Itoa(int(activityStyle.ActivityID)), + strconv.Itoa(int(activityStyle.SponsoStyleID)), + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedActivityStyle) +} + +// // Index +// func (a *activityStyleController) IndexActivityStyle(c echo.Context) error { +// activityStyles, err := a.u.GetActivityStyle(c.Request().Context()) +// if err != nil { +// return err +// } +// return c.JSON(http.StatusOK, activityStyles) +// } + +// // Show +// func (a *activityStyleController) ShowActivityStyle(c echo.Context) error { +// id := c.Param("id") +// activityStyle, err := a.u.GetActivityStyleByID(c.Request().Context(), id) +// if err != nil { +// return err +// } +// return c.JSON(http.StatusOK, activityStyle) +// } + +// // Create +// func (a *activityStyleController) CreateActivityStyle(c echo.Context) error { +// activityStyle := new(domain.ActivityStyle) +// if err := c.Bind(activityStyle); err != nil { +// fmt.Println("err") +// return err +// } +// latastActivityStyle, err := a.u.CreateActivityStyle(c.Request().Context() , strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID))) +// if err != nil { +// return err +// } +// return c.JSON(http.StatusOK, latastActivityStyle) +// } + +// // Update +// func (a *activityStyleController) UpdateActivityStyle(c echo.Context) error { +// id := c.Param("id") +// activityStyle := new(domain.ActivityStyle) +// if err := c.Bind(activityStyle); err != nil { +// fmt.Println("err") +// return err +// } +// updatedActivityStyle, err := a.u.UpdateActivityStyle(c.Request().Context(), id , strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID))) +// if err != nil { +// return err +// } +// return c.JSON(http.StatusOK, updatedActivityStyle) +// } + +// // Destroy +// func (a *activityStyleController) DestroyActivityStyle(c echo.Context) error { +// id := c.Param("id") +// err := a.u.DestroyActivityStyle(c.Request().Context(), id) +// if err != nil { +// return err +// } +// return c.String(http.StatusOK, "Destroy ActivityStyle") +// } diff --git a/api/externals/handler/bureau_handler.go b/api/externals/handler/bureau_handler.go new file mode 100644 index 000000000..b6bec74cb --- /dev/null +++ b/api/externals/handler/bureau_handler.go @@ -0,0 +1,68 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/bureaus", wrapper.GetBureaus) +func (h *Handler) GetBureaus(c echo.Context) error { + bureaus, err := h.bureauUseCase.GetBureaus(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, bureaus) +} + +// router.POST(baseURL+"/bureaus", wrapper.PostBureaus) +func (h *Handler) PostBureaus(c echo.Context) error { + bureau := new(domain.Bureau) + if err := c.Bind(bureau); err != nil { + return err + } + + latastBureau, err := h.bureauUseCase.CreateBureau(c.Request().Context(), + bureau.Name, + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastBureau) +} + +// router.DELETE(baseURL+"/bureaus/:id", wrapper.DeleteBureausId) +func (h *Handler) DeleteBureausId(c echo.Context) error { + id := c.Param("id") + err := h.bureauUseCase.DestroyBureau(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, "Destroy Bureau") +} + +// router.GET(baseURL+"/bureaus/:id", wrapper.GetBureausId) +func (h *Handler) GetBureausId(c echo.Context) error { + id := c.Param("id") + bureau, err := h.bureauUseCase.GetBureauByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, bureau) +} + +// router.PUT(baseURL+"/bureaus/:id", wrapper.PutBureausId) +func (h *Handler) PutBureausId(c echo.Context) error { + id := c.Param("id") + bureau := new(domain.Bureau) + if err := c.Bind(bureau); err != nil { + return err + } + + updatedBureau, err := h.bureauUseCase.UpdateBureau(c.Request().Context(), id, bureau.Name) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedBureau) +} diff --git a/api/externals/handler/buy_report_handler.go b/api/externals/handler/buy_report_handler.go new file mode 100644 index 000000000..7da7fa765 --- /dev/null +++ b/api/externals/handler/buy_report_handler.go @@ -0,0 +1,88 @@ +package handler + +import ( + "encoding/json" + "net/http" + + "github.com/NUTFes/FinanSu/api/generated" + "github.com/labstack/echo/v4" +) + +// router.PUT(baseURL+"/buy_report/status/:buy_report_id", wrapper.PutBuyReportStatusBuyReportId) +func (h *Handler) PutBuyReportStatusBuyReportId(c echo.Context) error { + // 未実装 + return c.String(http.StatusNotImplemented, "PutBuyReportStatusBuyReportId is not implemented") +} + +// router.POST(baseURL+"/buy_reports", wrapper.PostBuyReports) +func (h *Handler) PostBuyReports(c echo.Context) error { + ctx := c.Request().Context() + // ファイル取得 + file, err := c.FormFile("file") + if err != nil { + return c.String(http.StatusBadRequest, "file not found") + } + // JSON データを取得 + buyReportStr := c.FormValue("buy_report") + if buyReportStr == "" { + return c.String(http.StatusBadRequest, "buy_report not found") + } + + // jsonのパース + var buyReportInfo BuyReport + err = json.Unmarshal([]byte(buyReportStr), &buyReportInfo) + if err != nil { + return c.String(http.StatusBadRequest, "buy_report is not valid") + } + + buyReport, err := h.buyReportUseCase.CreateBuyReport(ctx, buyReportInfo, file) + if err != nil { + return err + } + return c.JSON(http.StatusOK, buyReport) +} + +// router.GET(baseURL+"/buy_reports/details", wrapper.GetBuyReportsDetails) +func (h *Handler) GetBuyReportsDetails(c echo.Context) error { + //未実装 + return c.String(http.StatusNotImplemented, "GetBuyReportsDetails is not implemented") +} + +// router.DELETE(baseURL+"/buy_reports/:id", wrapper.DeleteBuyReportsId) +func (h *Handler) DeleteBuyReportsId(c echo.Context) error { + ctx := c.Request().Context() + id := c.Param("id") + err := h.buyReportUseCase.DeleteBuyReport(ctx, id) + if err != nil { + return c.String(http.StatusBadRequest, "buy_report delete failed") + } + return c.String(http.StatusOK, "buy_report delete success") +} + +// router.PUT(baseURL+"/buy_reports/:id", wrapper.PutBuyReportsId) +func (h *Handler) PutBuyReportsId(c echo.Context) error { + ctx := c.Request().Context() + id := c.Param("id") + // ファイル取得 + file, _ := c.FormFile("file") + // JSON データを取得 + buyReportStr := c.FormValue("buy_report") + if buyReportStr == "" { + return c.String(http.StatusBadRequest, "buy_report not found") + } + + // jsonのパース + var buyReportInfo BuyReport + err := json.Unmarshal([]byte(buyReportStr), &buyReportInfo) + if err != nil { + return c.String(http.StatusBadRequest, "buy_report is not valid") + } + + buyReportInfo, err = h.buyReportUseCase.UpdateBuyReport(ctx, id, buyReportInfo, file) + if err != nil { + return err + } + return c.JSON(http.StatusOK, buyReportInfo) +} + +type BuyReport = generated.BuyReport diff --git a/api/externals/handler/department_handler.go b/api/externals/handler/department_handler.go new file mode 100644 index 000000000..fafd25ad7 --- /dev/null +++ b/api/externals/handler/department_handler.go @@ -0,0 +1,62 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/departments", wrapper.GetDepartments) +func (h *Handler) GetDepartments(c echo.Context) error { + departments, err := h.departmentUseCase.GetDepartments(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, departments) +} + +// router.POST(baseURL+"/departments", wrapper.PostDepartments) +func (h *Handler) PostDepartments(c echo.Context) error { + department := new(domain.Department) + if err := c.Bind(department); err != nil { + return err + } + + latastDepartment, err := h.departmentUseCase.CreateDepartment(c.Request().Context(), department.Name) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastDepartment) +} + +// router.DELETE(baseURL+"/departments/:id", wrapper.DeleteDepartmentsId) +func (h *Handler) DeleteDepartmentsId(c echo.Context) error { + id := c.Param("id") + err := h.departmentUseCase.DestroyDepartment(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, "Destroy Department") +} + +// router.GET(baseURL+"/departments/:id", wrapper.GetDepartmentsId) +func (h *Handler) GetDepartmentsId(c echo.Context) error { + id := c.Param("id") + department, err := h.departmentUseCase.GetDepartmentByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, department) +} + +// router.PUT(baseURL+"/departments/:id", wrapper.PutDepartmentsId) +func (h *Handler) PutDepartmentsId(c echo.Context) error { + id := c.Param("id") + name := c.QueryParam("name") + updatedDepartment, err := h.departmentUseCase.UpdateDepartment(c.Request().Context(), id, name) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedDepartment) +} diff --git a/api/externals/handler/division_handler.go b/api/externals/handler/division_handler.go new file mode 100644 index 000000000..9401c9272 --- /dev/null +++ b/api/externals/handler/division_handler.go @@ -0,0 +1,69 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/generated" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/divisions", wrapper.GetDivisions) +func (h *Handler) GetDivisions(c echo.Context) error { + ctx := c.Request().Context() + year := c.QueryParam("year") + financialRecordId := c.QueryParam("financial_record_id") + + divisionDetails, err := h.divisionUseCase.GetDivisions(ctx, year, financialRecordId) + if err != nil { + return err + } + return c.JSON(http.StatusOK, divisionDetails) +} + +// router.POST(baseURL+"/divisions", wrapper.PostDivisions) +func (h *Handler) PostDivisions(c echo.Context) error { + ctx := c.Request().Context() + division := new(Division) + + if err := c.Bind(division); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + latestDivision, err := h.divisionUseCase.CreateDivision(ctx, *division) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latestDivision) +} + +// router.DELETE(baseURL+"/divisions/:id", wrapper.DeleteDivisionsId) +func (h *Handler) DeleteDivisionsId(c echo.Context) error { + ctx := c.Request().Context() + id := c.Param("id") + + err := h.divisionUseCase.DestroyDivision(ctx, id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy Division") +} + +// router.PUT(baseURL+"/divisions/:id", wrapper.PutDivisionsId) +func (h *Handler) PutDivisionsId(c echo.Context) error { + ctx := c.Request().Context() + id := c.Param("id") + division := new(Division) + + if err := c.Bind(division); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + updatedDivision, err := h.divisionUseCase.UpdateDivision(ctx, id, *division) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedDivision) +} + +type ( + Division = generated.Division + DivisionDetails = generated.DivisionDetails +) diff --git a/api/externals/handler/festival_item_handler.go b/api/externals/handler/festival_item_handler.go new file mode 100644 index 000000000..7dabf1fe8 --- /dev/null +++ b/api/externals/handler/festival_item_handler.go @@ -0,0 +1,85 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/generated" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/festival_items", wrapper.GetFestivalItems) +func (h *Handler) GetFestivalItems(c echo.Context) error { + ctx := c.Request().Context() + year := c.QueryParam("year") + divisionId := c.QueryParam("division_id") + var festivalItemDetails FestivalItemDetails + + festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItems(ctx, year, divisionId) + if err != nil { + return err + } + return c.JSON(http.StatusOK, festivalItemDetails) +} + +// router.POST(baseURL+"/festival_items", wrapper.PostFestivalItems) +func (h *Handler) PostFestivalItems(c echo.Context) error { + ctx := c.Request().Context() + festivalItem := new(FestivalItem) + + if err := c.Bind(festivalItem); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + + latestFestivalItem, err := h.festivalItemUseCase.CreateFestivalItem(ctx, *festivalItem) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latestFestivalItem) +} + +// router.GET(baseURL+"/festival_items/details/:user_id", wrapper.GetFestivalItemsDetailsUserId) +func (h *Handler) GetFestivalItemsDetailsUserId(c echo.Context) error { + ctx := c.Request().Context() + userId := c.Param("user_id") + year := c.QueryParam("year") + var festivalItemDetails []FestivalItemsForMyPage + + festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItemsForMypage(ctx, year, userId) + if err != nil { + return err + } + return c.JSON(http.StatusOK, festivalItemDetails) +} + +// router.DELETE(baseURL+"/festival_items/:id", wrapper.DeleteFestivalItemsId) +func (h *Handler) DeleteFestivalItemsId(c echo.Context) error { + ctx := c.Request().Context() + id := c.Param("id") + + err := h.festivalItemUseCase.DestroyFestivalItem(ctx, id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy Festival Item") +} + +// router.PUT(baseURL+"/festival_items/:id", wrapper.PutFestivalItemsId) +func (h *Handler) PutFestivalItemsId(c echo.Context) error { + ctx := c.Request().Context() + id := c.Param("id") + festivalItem := new(FestivalItem) + + if err := c.Bind(festivalItem); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + + updatedFestivalItem, err := h.festivalItemUseCase.UpdateFestivalItem(ctx, id, *festivalItem) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedFestivalItem) +} + +type FestivalItemDetails = generated.FestivalItemDetails +type FestivalItem = generated.FestivalItem +type FestivalItemsForMyPage = generated.FestivalItemsForMyPage diff --git a/api/externals/handler/financial_record_handler.go b/api/externals/handler/financial_record_handler.go new file mode 100644 index 000000000..f469b0acc --- /dev/null +++ b/api/externals/handler/financial_record_handler.go @@ -0,0 +1,62 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/generated" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/financial_records", wrapper.GetFinancialRecords) +func (h *Handler) GetFinancialRecords(c echo.Context) error { + financialRecordDetails, err := h.financialRecordUseCase.GetFinancialRecords(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, financialRecordDetails) +} + +// router.POST(baseURL+"/financial_records", wrapper.PostFinancialRecords) +func (h *Handler) PostFinancialRecords(c echo.Context) error { + financialRecord := new(FinancialRecord) + if err := c.Bind(financialRecord); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + + latestFinancialRecord, err := h.financialRecordUseCase.CreateFinancialRecord(c.Request().Context(), *financialRecord) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latestFinancialRecord) +} + +// router.DELETE(baseURL+"/financial_records/:id", wrapper.DeleteFinancialRecordsId) +func (h *Handler) DeleteFinancialRecordsId(c echo.Context) error { + id := c.Param("id") + err := h.financialRecordUseCase.DestroyFinancialRecord(c.Request().Context(), id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy FinancialRecord") +} + +// router.PUT(baseURL+"/financial_records/:id", wrapper.PutFinancialRecordsId) +func (h *Handler) PutFinancialRecordsId(c echo.Context) error { + id := c.Param("id") + financialRecord := new(FinancialRecord) + if err := c.Bind(financialRecord); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + updatedFinancialRecord, err := h.financialRecordUseCase.UpdateFinancialRecord( + c.Request().Context(), + id, + *financialRecord, + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedFinancialRecord) +} + +type FinancialRecordDetails = generated.FinancialRecordDetails +type FinancialRecord = generated.FinancialRecord diff --git a/api/externals/handler/fund_information_handler.go b/api/externals/handler/fund_information_handler.go new file mode 100644 index 000000000..06ee4966d --- /dev/null +++ b/api/externals/handler/fund_information_handler.go @@ -0,0 +1,100 @@ +package handler + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/fund_informations", wrapper.GetFundInformations) +func (h *Handler) GetFundInformations(c echo.Context) error { + fundInformations, err := h.fundInformationUseCase.GetFundInformations(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, fundInformations) +} + +// router.POST(baseURL+"/fund_informations", wrapper.PostFundInformations) +func (h *Handler) PostFundInformations(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") + + latestFundInformation, err := h.fundInformationUseCase.CreateFundInformation(c.Request().Context(), userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt) + if err != nil { + return err + } + return c.JSON(http.StatusCreated, latestFundInformation) +} + +// router.GET(baseURL+"/fund_informations/details", wrapper.GetFundInformationsDetails) +func (h *Handler) GetFundInformationsDetails(c echo.Context) error { + fundInformationDetails, err := h.fundInformationUseCase.GetFundInformationDetails(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, fundInformationDetails) +} + +// router.GET(baseURL+"/fund_informations/details/:year", wrapper.GetFundInformationsDetailsYear) +func (h *Handler) GetFundInformationsDetailsYear(c echo.Context) error { + year := c.Param("year") + fundInformationDetails, err := h.fundInformationUseCase.GetFundInformationDetailsByPeriod(c.Request().Context(), year) + if err != nil { + return err + } + return c.JSON(http.StatusOK, fundInformationDetails) +} + +// router.DELETE(baseURL+"/fund_informations/:id", wrapper.DeleteFundInformationsId) +func (h *Handler) DeleteFundInformationsId(c echo.Context) error { + id := c.Param("id") + err := h.fundInformationUseCase.DestroyFundInformation(c.Request().Context(), id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy FundInformation") +} + +// router.GET(baseURL+"/fund_informations/:id", wrapper.GetFundInformationsId) +func (h *Handler) GetFundInformationsId(c echo.Context) error { + id := c.Param("id") + fundInformation, err := h.fundInformationUseCase.GetFundInformationByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, fundInformation) +} + +// router.PUT(baseURL+"/fund_informations/:id", wrapper.PutFundInformationsId) +func (h *Handler) PutFundInformationsId(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 := h.fundInformationUseCase.UpdateFundInformation(c.Request().Context(), id, userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedFundInformation) +} + +// router.GET(baseURL+"/fund_informations/:id/details", wrapper.GetFundInformationsIdDetails) +func (h *Handler) GetFundInformationsIdDetails(c echo.Context) error { + id := c.Param("id") + fundInformationDetail, err := h.fundInformationUseCase.GetFundInformationDetailByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, fundInformationDetail) +} diff --git a/api/externals/handler/handler.go b/api/externals/handler/handler.go new file mode 100644 index 000000000..0aca48e5f --- /dev/null +++ b/api/externals/handler/handler.go @@ -0,0 +1,68 @@ +package handler + +import ( + "github.com/NUTFes/FinanSu/api/internals/usecase" +) + +type Handler struct { + activityUseCase usecase.ActivityUseCase + activityInformationUseCase usecase.ActivityInformationUseCase + activityStyleUseCase usecase.ActivityStyleUseCase + bureauUseCase usecase.BureauUseCase + buyReportUseCase usecase.BuyReportUseCase + departmentUseCase usecase.DepartmentUseCase + divisionUseCase usecase.DivisionUseCase + festivalItemUseCase usecase.FestivalItemUseCase + financialRecordUseCase usecase.FinancialRecordUseCase + fundInformationUseCase usecase.FundInformationUseCase + mailAuthUseCase usecase.MailAuthUseCase + objectUploadUseCase usecase.ObjectUploadUseCase + passwordResetTokenUseCase usecase.PasswordResetTokenUseCase + sponsorUseCase usecase.SponsorUseCase + sponsorStyleUseCase usecase.SponsorStyleUseCase + teacherUseCase usecase.TeacherUseCase + userUseCase usecase.UserUseCase + yearUseCase usecase.YearUseCase +} + +func NewHandler( + activityUseCase usecase.ActivityUseCase, + activityInformationUseCase usecase.ActivityInformationUseCase, + activityStyleUseCase usecase.ActivityStyleUseCase, + bureauUseCase usecase.BureauUseCase, + buyReportUseCase usecase.BuyReportUseCase, + departmentUseCase usecase.DepartmentUseCase, + divisionUseCase usecase.DivisionUseCase, + festivalItemUseCase usecase.FestivalItemUseCase, + financialRecordUseCase usecase.FinancialRecordUseCase, + fundInformationUseCase usecase.FundInformationUseCase, + mailAuthUseCase usecase.MailAuthUseCase, + objectUploadUseCase usecase.ObjectUploadUseCase, + passwordResetTokenUseCase usecase.PasswordResetTokenUseCase, + sponsorUseCase usecase.SponsorUseCase, + sponsorStyleUseCase usecase.SponsorStyleUseCase, + teacherUseCase usecase.TeacherUseCase, + userUseCase usecase.UserUseCase, + yearUseCase usecase.YearUseCase, +) *Handler { + return &Handler{ + activityUseCase: activityUseCase, + activityInformationUseCase: activityInformationUseCase, + activityStyleUseCase: activityStyleUseCase, + bureauUseCase: bureauUseCase, + buyReportUseCase: buyReportUseCase, + departmentUseCase: departmentUseCase, + divisionUseCase: divisionUseCase, + festivalItemUseCase: festivalItemUseCase, + financialRecordUseCase: financialRecordUseCase, + fundInformationUseCase: fundInformationUseCase, + mailAuthUseCase: mailAuthUseCase, + objectUploadUseCase: objectUploadUseCase, + passwordResetTokenUseCase: passwordResetTokenUseCase, + sponsorUseCase: sponsorUseCase, + sponsorStyleUseCase: sponsorStyleUseCase, + teacherUseCase: teacherUseCase, + userUseCase: userUseCase, + yearUseCase: yearUseCase, + } +} diff --git a/api/externals/handler/health_check_handler.go b/api/externals/handler/health_check_handler.go new file mode 100644 index 000000000..6987c8a7d --- /dev/null +++ b/api/externals/handler/health_check_handler.go @@ -0,0 +1,12 @@ +package handler + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/", wrapper.Get) +func (h *Handler) Get(c echo.Context) error { + return c.String(http.StatusOK, "healthcheck: ok") +} diff --git a/api/externals/handler/mail_auth_handler.go b/api/externals/handler/mail_auth_handler.go new file mode 100644 index 000000000..25ff577d9 --- /dev/null +++ b/api/externals/handler/mail_auth_handler.go @@ -0,0 +1,56 @@ +package handler + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/mail_auth/is_signin", wrapper.GetMailAuthIsSignin) +func (h *Handler) GetMailAuthIsSignin(c echo.Context) error { + // headerからトークンを取得する + accessToken := c.Request().Header["Access-Token"][0] + isSignIn, err := h.mailAuthUseCase.IsSignIn(c.Request().Context(), accessToken) + if err != nil { + return nil + } + c.JSON(http.StatusOK, isSignIn) + return nil +} + +// router.POST(baseURL+"/mail_auth/signin", wrapper.PostMailAuthSignin) +func (h *Handler) PostMailAuthSignin(c echo.Context) error { + email := c.QueryParam("email") + password := c.QueryParam("password") + token, err := h.mailAuthUseCase.SignIn(c.Request().Context(), email, password) + if err != nil { + return err + } + c.JSON(http.StatusOK, token) + return nil +} + +// router.DELETE(baseURL+"/mail_auth/signout", wrapper.DeleteMailAuthSignout) +func (h *Handler) DeleteMailAuthSignout(c echo.Context) error { + // headerからトークンを取得する + accessToken := c.Request().Header["Access-Token"][0] + err := h.mailAuthUseCase.SignOut(c.Request().Context(), accessToken) + if err != nil { + return err + } + c.String(http.StatusOK, "Success Sign Out") + return nil +} + +// router.POST(baseURL+"/mail_auth/signup", wrapper.PostMailAuthSignup) +func (h *Handler) PostMailAuthSignup(c echo.Context) error { + email := c.QueryParam("email") + password := c.QueryParam("password") + userID := c.QueryParam("user_id") + token, err := h.mailAuthUseCase.SignUp(c.Request().Context(), email, password, userID) + if err != nil { + return err + } + c.JSON(http.StatusOK, token) + return nil +} diff --git a/api/externals/handler/object_upload_handler.go b/api/externals/handler/object_upload_handler.go new file mode 100644 index 000000000..008b7ca98 --- /dev/null +++ b/api/externals/handler/object_upload_handler.go @@ -0,0 +1,23 @@ +package handler + +import ( + "log" + "net/http" + + "github.com/labstack/echo/v4" +) + +// router.POST(baseURL+"/upload_file", wrapper.PostUploadFile) +func (h *Handler) PostUploadFile(c echo.Context) error { + file, err := c.FormFile("file") + if err != nil { + return c.String(http.StatusBadRequest, "file not found") + } + + if err := h.objectUploadUseCase.UploadFile(c.Request().Context(), file); err != nil { + log.Println(err) + return c.String(http.StatusInternalServerError, "upload failed") + } + + return c.String(http.StatusOK, "upload success") +} diff --git a/api/externals/handler/password_reset_token_handler.go b/api/externals/handler/password_reset_token_handler.go new file mode 100644 index 000000000..4298a0476 --- /dev/null +++ b/api/externals/handler/password_reset_token_handler.go @@ -0,0 +1,62 @@ +package handler + +import ( + "errors" + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.POST(baseURL+"/password_reset/request", wrapper.PostPasswordResetRequest) +func (h *Handler) PostPasswordResetRequest(c echo.Context) error { + email := c.QueryParam("email") + err := h.passwordResetTokenUseCase.PasswordResetTokenRequest(c.Request().Context(), email) + if err != nil { + return c.String(http.StatusOK, err.Error()) + } + return c.String(http.StatusOK, "PasswordResetTokenを送信しました") +} + +// router.POST(baseURL+"/password_reset/:id", wrapper.PostPasswordResetId) +func (h *Handler) PostPasswordResetId(c echo.Context) error { + id := c.Param("id") + passwordResetData := new(domain.PasswordResetData) + + if err := c.Bind(passwordResetData); err != nil { + return err + } + + //トークンの有効チェック + err := h.passwordResetTokenUseCase.ValidPasswordResetToken(c.Request().Context(), id, passwordResetData.Token) + if err != nil { + return c.String(http.StatusBadRequest, err.Error()) + } + + //パスワードのバリデーション + isValidPassword := passwordResetData.Password != passwordResetData.ConfirmPassword || passwordResetData.Password == "" || len(passwordResetData.Password) < 6 + if isValidPassword { + err = errors.New("パスワードが不正です") + return c.String(http.StatusBadRequest, err.Error()) + } + + //パスワード変更 + err = h.passwordResetTokenUseCase.ChangePassword(c.Request().Context(), id, passwordResetData.Password) + if err != nil { + return c.String(http.StatusBadRequest, err.Error()) + } + + return c.String(http.StatusOK, "パスワードを変更しました") +} + +// router.POST(baseURL+"/password_reset/:id/valid", wrapper.PostPasswordResetIdValid) +func (h *Handler) PostPasswordResetIdValid(c echo.Context) error { + id := c.Param("id") + token := c.QueryParam("token") + err := h.passwordResetTokenUseCase.ValidPasswordResetToken(c.Request().Context(), id, token) + if err != nil { + return c.String(http.StatusBadRequest, err.Error()) + } + + return c.String(http.StatusOK, "Tokenは有効です") +} diff --git a/api/externals/handler/sponsor_handler.go b/api/externals/handler/sponsor_handler.go new file mode 100644 index 000000000..0f4d47441 --- /dev/null +++ b/api/externals/handler/sponsor_handler.go @@ -0,0 +1,88 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/sponsors", wrapper.GetSponsors) +func (h *Handler) GetSponsors(c echo.Context) error { + sponsors, err := h.sponsorUseCase.GetSponsor(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, sponsors) +} + +// router.POST(baseURL+"/sponsors", wrapper.PostSponsors) +func (h *Handler) PostSponsors(c echo.Context) error { + sponsor := new(domain.Sponsor) + if err := c.Bind(sponsor); err != nil { + return err + } + + latastSponsor, err := h.sponsorUseCase.CreateSponsor(c.Request().Context(), + sponsor.Name, + sponsor.Tel, + sponsor.Email, + sponsor.Address, + sponsor.Representative, + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastSponsor) +} + +// router.GET(baseURL+"/sponsors/periods/:year", wrapper.GetSponsorsPeriodsYear) +func (h *Handler) GetSponsorsPeriodsYear(c echo.Context) error { + year := c.Param("year") + sponsors, err := h.sponsorUseCase.GetSponsorByPeriod(c.Request().Context(), year) + if err != nil { + return err + } + return c.JSON(http.StatusOK, sponsors) +} + +// router.DELETE(baseURL+"/sponsors/:id", wrapper.DeleteSponsorsId) +func (h *Handler) DeleteSponsorsId(c echo.Context) error { + id := c.Param("id") + err := h.sponsorUseCase.DestroySponsor(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, "Destroy Sponsor") +} + +// router.GET(baseURL+"/sponsors/:id", wrapper.GetSponsorsId) +func (h *Handler) GetSponsorsId(c echo.Context) error { + id := c.Param("id") + sponsor, err := h.sponsorUseCase.GetSponsorByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, sponsor) +} + +// router.PUT(baseURL+"/sponsors/:id", wrapper.PutSponsorsId) +func (h *Handler) PutSponsorsId(c echo.Context) error { + id := c.Param("id") + sponsor := new(domain.Sponsor) + if err := c.Bind(sponsor); err != nil { + return err + } + + updatedSponsor, err := h.sponsorUseCase.UpdateSponsor(c.Request().Context(), id, + sponsor.Name, + sponsor.Tel, + sponsor.Email, + sponsor.Address, + sponsor.Representative, + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedSponsor) +} diff --git a/api/externals/handler/sponsor_style_handler.go b/api/externals/handler/sponsor_style_handler.go new file mode 100644 index 000000000..5cecd206f --- /dev/null +++ b/api/externals/handler/sponsor_style_handler.go @@ -0,0 +1,70 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/sponsorstyles", wrapper.GetSponsorstyles) +func (h *Handler) GetSponsorstyles(c echo.Context) error { + sponsorstyles, err := h.sponsorStyleUseCase.GetSponsorStyles(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, sponsorstyles) +} + +// router.POST(baseURL+"/sponsorstyles", wrapper.PostSponsorstyles) +func (h *Handler) PostSponsorstyles(c echo.Context) error { + sponsorstyle := new(domain.SponsorStyle) + if err := c.Bind(sponsorstyle); err != nil { + return err + } + + latastSponsorstyle, err := h.sponsorStyleUseCase.CreateSponsorStyle(c.Request().Context(), + sponsorstyle.Style, + sponsorstyle.Feature, + sponsorstyle.Price, + ) + if err != nil { + return err + } + return c.JSON(http.StatusOK, latastSponsorstyle) +} + +// router.DELETE(baseURL+"/sponsorstyles/:id", wrapper.DeleteSponsorstylesId) +func (h *Handler) DeleteSponsorstylesId(c echo.Context) error { + id := c.Param("id") + err := h.sponsorStyleUseCase.DestroySponsorStyle(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, "Destroy Sponsorstyles") +} + +// router.GET(baseURL+"/sponsorstyles/:id", wrapper.GetSponsorstylesId) +func (h *Handler) GetSponsorstylesId(c echo.Context) error { + id := c.Param("id") + sponsorstyle, err := h.sponsorStyleUseCase.GetSponsorStylesByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, sponsorstyle) +} + +// router.PUT(baseURL+"/sponsorstyles/:id", wrapper.PutSponsorstylesId) +func (h *Handler) PutSponsorstylesId(c echo.Context) error { + id := c.Param("id") + sponsorstyle := new(domain.SponsorStyle) + if err := c.Bind(sponsorstyle); err != nil { + return err + } + + updatedSponsorstyle, err := h.sponsorStyleUseCase.UpdateSponsorStyle(c.Request().Context(), id, sponsorstyle.Style, sponsorstyle.Feature, sponsorstyle.Price) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedSponsorstyle) +} diff --git a/api/externals/handler/teacher_handler.go b/api/externals/handler/teacher_handler.go new file mode 100644 index 000000000..a6a7f1ae5 --- /dev/null +++ b/api/externals/handler/teacher_handler.go @@ -0,0 +1,92 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/teachers", wrapper.GetTeachers) +func (h *Handler) GetTeachers(c echo.Context) error { + teachers, err := h.teacherUseCase.GetTeachers(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, teachers) +} + +// router.POST(baseURL+"/teachers", wrapper.PostTeachers) +func (h *Handler) PostTeachers(c echo.Context) error { + name := c.QueryParam("name") + position := c.QueryParam("position") + departmentID := c.QueryParam("department_id") + room := c.QueryParam("room") + isBlack := c.QueryParam("is_black") + remark := c.QueryParam("remark") + latestTeacher, err := h.teacherUseCase.CreateTeacher(c.Request().Context(), name, position, departmentID, room, isBlack, remark) + if err != nil { + return err + } + return c.JSON(http.StatusCreated, latestTeacher) +} + +// router.DELETE(baseURL+"/teachers/delete", wrapper.DeleteTeachersDelete) +func (h *Handler) DeleteTeachersDelete(c echo.Context) error { + destroyTeacherIDs := new(domain.DestroyTeacherIDs) + if err := c.Bind(&destroyTeacherIDs); err != nil { + return err + } + + err := h.teacherUseCase.DestroyMultiTeachers(c.Request().Context(), destroyTeacherIDs.DeleteIDs) + if err != nil { + return c.String(http.StatusBadRequest, err.Error()) + } + return c.String(http.StatusOK, "Destroy Teachers") +} + +// router.GET(baseURL+"/teachers/fundRegistered/:year", wrapper.GetTeachersFundRegisteredYear) +func (h *Handler) GetTeachersFundRegisteredYear(c echo.Context) error { + year := c.Param("year") + fundRegisteredTeachers, err := h.teacherUseCase.GetFundRegisteredByPeriods(c.Request().Context(), year) + if err != nil { + return err + } + return c.JSON(http.StatusOK, fundRegisteredTeachers) +} + +// router.DELETE(baseURL+"/teachers/:id", wrapper.DeleteTeachersId) +func (h *Handler) DeleteTeachersId(c echo.Context) error { + id := c.Param("id") + err := h.teacherUseCase.DestroyTeacher(c.Request().Context(), id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy Teacher") +} + +// router.GET(baseURL+"/teachers/:id", wrapper.GetTeachersId) +func (h *Handler) GetTeachersId(c echo.Context) error { + id := c.Param("id") + teacher, err := h.teacherUseCase.GetTeacherByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, teacher) +} + +// router.PUT(baseURL+"/teachers/:id", wrapper.PutTeachersId) +func (h *Handler) PutTeachersId(c echo.Context) error { + id := c.Param("id") + name := c.QueryParam("name") + position := c.QueryParam("position") + departmentID := c.QueryParam("department_id") + room := c.QueryParam("room") + isBlack := c.QueryParam("is_black") + remark := c.QueryParam("remark") + updateTeacher, err := h.teacherUseCase.UpdateTeacher(c.Request().Context(), id, name, position, departmentID, room, isBlack, remark) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updateTeacher) +} diff --git a/api/externals/handler/user_handler.go b/api/externals/handler/user_handler.go new file mode 100644 index 000000000..1b4883c10 --- /dev/null +++ b/api/externals/handler/user_handler.go @@ -0,0 +1,75 @@ +package handler + +import ( + "net/http" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +// router.GET(baseURL+"/users", wrapper.GetUsers) +func (h *Handler) GetUsers(c echo.Context) error { + users, err := h.userUseCase.GetUsers(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, users) +} + +// router.POST(baseURL+"/users", wrapper.PostUsers) +func (h *Handler) PostUsers(c echo.Context) error { + name := c.QueryParam("name") + bureauID := c.QueryParam("bureau_id") + roleID := c.QueryParam("role_id") + latastUser, err := h.userUseCase.CreateUser(c.Request().Context(), name, bureauID, roleID) + if err != nil { + return err + } + return c.JSON(http.StatusCreated, latastUser) +} + +// router.DELETE(baseURL+"/users/delete", wrapper.DeleteUsersDelete) +func (h *Handler) DeleteUsersDelete(c echo.Context) error { + destroyUser := new(domain.DestroyUserIDs) + if err := c.Bind(destroyUser); err != nil { + return err + } + err := h.userUseCase.DestroyMultiUsers(c.Request().Context(), destroyUser.DeleteIDs) + if err != nil { + return c.String(http.StatusBadRequest, err.Error()) + } + return c.String(http.StatusOK, "Destroy Users") +} + +// router.DELETE(baseURL+"/users/:id", wrapper.DeleteUsersId) +func (h *Handler) DeleteUsersId(c echo.Context) error { + id := c.Param("id") + err := h.userUseCase.DestroyUser(c.Request().Context(), id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy User") +} + +// router.GET(baseURL+"/users/:id", wrapper.GetUsersId) +func (h *Handler) GetUsersId(c echo.Context) error { + id := c.Param("id") + user, err := h.userUseCase.GetUserByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, user) +} + +// router.PUT(baseURL+"/users/:id", wrapper.PutUsersId) +func (h *Handler) PutUsersId(c echo.Context) error { + id := c.Param("id") + name := c.QueryParam("name") + bureauID := c.QueryParam("bureau_id") + roleID := c.QueryParam("role_id") + updatedUser, err := h.userUseCase.UpdateUser(c.Request().Context(), id, name, bureauID, roleID) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedUser) +} diff --git a/api/externals/handler/year_handler.go b/api/externals/handler/year_handler.go new file mode 100644 index 000000000..a6ba19c3f --- /dev/null +++ b/api/externals/handler/year_handler.go @@ -0,0 +1,110 @@ +package handler + +import ( + "fmt" + "net/http" + "strconv" + + "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/labstack/echo/v4" +) + +const Layout = "2006-01-02 15:04:05" + +// router.GET(baseURL+"/years", wrapper.GetYears) +func (h *Handler) GetYears(c echo.Context) error { + years, err := h.yearUseCase.GetYears(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, years) +} + +// router.POST(baseURL+"/years", wrapper.PostYears) +func (h *Handler) PostYears(c echo.Context) error { + year := c.QueryParam("year") + latestYear, err := h.yearUseCase.CreateYear(c.Request().Context(), year) + if err != nil { + return err + } + return c.JSON(http.StatusCreated, latestYear) +} + +// router.GET(baseURL+"/years/periods", wrapper.GetYearsPeriods) +func (h *Handler) GetYearsPeriods(c echo.Context) error { + years, err := h.yearUseCase.GetYearPeriods(c.Request().Context()) + if err != nil { + return err + } + return c.JSON(http.StatusOK, years) +} + +// router.POST(baseURL+"/years/periods", wrapper.PostYearsPeriods) +func (h *Handler) PostYearsPeriods(c echo.Context) error { + yearPeriod := new(domain.YearPeriod) + if err := c.Bind(yearPeriod); err != nil { + fmt.Println("err") + return err + } + latestYearPeriod, err := h.yearUseCase.CreateYearPeriod(c.Request().Context(), strconv.Itoa(yearPeriod.Year), yearPeriod.StartedAt.Format(Layout), yearPeriod.EndedAt.Format(Layout)) + if err != nil { + return err + } + return c.JSON(http.StatusCreated, latestYearPeriod) +} + +// router.DELETE(baseURL+"/years/periods/:id", wrapper.DeleteYearsPeriodsId) +func (h *Handler) DeleteYearsPeriodsId(c echo.Context) error { + id := c.Param("id") + err := h.yearUseCase.DestroyYearPeriod(c.Request().Context(), id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy Year Records") +} + +// router.PUT(baseURL+"/years/periods/:id", wrapper.PutYearsPeriodsId) +func (h *Handler) PutYearsPeriodsId(c echo.Context) error { + id := c.Param("id") + yearPeriod := new(domain.YearPeriod) + if err := c.Bind(yearPeriod); err != nil { + fmt.Println("err") + return err + } + updateYearPeriod, err := h.yearUseCase.UpdateYearPeriod(c.Request().Context(), id, strconv.Itoa(yearPeriod.Year), yearPeriod.StartedAt.Format(Layout), yearPeriod.EndedAt.Format(Layout)) + if err != nil { + return err + } + return c.JSON(http.StatusCreated, updateYearPeriod) +} + +// router.DELETE(baseURL+"/years/:id", wrapper.DeleteYearsId) +func (h *Handler) DeleteYearsId(c echo.Context) error { + id := c.Param("id") + err := h.yearUseCase.DestroyYear(c.Request().Context(), id) + if err != nil { + return err + } + return c.String(http.StatusOK, "Destroy Year") +} + +// router.GET(baseURL+"/years/:id", wrapper.GetYearsId) +func (h *Handler) GetYearsId(c echo.Context) error { + id := c.Param("id") + year, err := h.yearUseCase.GetYearByID(c.Request().Context(), id) + if err != nil { + return err + } + return c.JSON(http.StatusOK, year) +} + +// router.PUT(baseURL+"/years/:id", wrapper.PutYearsId) +func (h *Handler) PutYearsId(c echo.Context) error { + id := c.Param("id") + year := c.QueryParam("year") + updatedYear, err := h.yearUseCase.UpdateYear(c.Request().Context(), id, year) + if err != nil { + return err + } + return c.JSON(http.StatusOK, updatedYear) +} diff --git a/api/internals/di/di.go b/api/internals/di/di.go index 346904e8c..32ac56acb 100644 --- a/api/internals/di/di.go +++ b/api/internals/di/di.go @@ -8,6 +8,7 @@ import ( "github.com/NUTFes/FinanSu/api/drivers/mc" "github.com/NUTFes/FinanSu/api/drivers/server" "github.com/NUTFes/FinanSu/api/externals/controller" + "github.com/NUTFes/FinanSu/api/externals/handler" "github.com/NUTFes/FinanSu/api/externals/repository" "github.com/NUTFes/FinanSu/api/externals/repository/abstract" "github.com/NUTFes/FinanSu/api/internals/usecase" @@ -162,10 +163,31 @@ func InitializeServer() (db.Client, *echo.Echo) { yearController, ) - // ↓ + fmt.Println("router", router) + + handler := handler.NewHandler( + activityUseCase, + activityInformationUseCase, + activityStyleUseCase, + bureauUseCase, + buyReportUseCase, + departmentUseCase, + divisionUseCase, + festivalUseCase, + financialRecordUseCase, + fundInformationUseCase, + mailAuthUseCase, + objectHandleUseCase, + passwordResetTokenUseCase, + sponsorUseCase, + sponsorStyleUseCase, + teacherUseCase, + userUseCase, + yearUseCase, + ) // Server - e := server.RunServer(router) + e := server.RunServer2(handler) return client, e } diff --git a/view/next-project/src/generated/model/index.ts b/view/next-project/src/generated/model/index.ts index 992020119..db66bd7c4 100644 --- a/view/next-project/src/generated/model/index.ts +++ b/view/next-project/src/generated/model/index.ts @@ -26,6 +26,7 @@ export * from './deleteFestivalItemsId200'; export * from './deleteFinancailRecordsId200'; export * from './deleteFinancialRecordsId200'; export * from './deleteFundInformationsId200'; +export * from './deleteMailAuthSignout200'; export * from './deleteReceiptsId200'; export * from './deleteSourcesId200'; export * from './deleteSponsorsId200'; @@ -89,6 +90,7 @@ export * from './getFundInformationsDetails200'; export * from './getFundInformationsDetailsYear200'; export * from './getFundInformationsId200'; export * from './getFundInformationsIdDetails200'; +export * from './getMailAuthIsSignin200'; export * from './getReceipts200'; export * from './getReceiptsId200'; export * from './getReceiptsReportsId200'; @@ -114,6 +116,10 @@ export * from './postExpenses200'; export * from './postExpensesParams'; export * from './postFundInformations200'; export * from './postFundInformationsParams'; +export * from './postMailAuthSignin200'; +export * from './postMailAuthSigninParams'; +export * from './postMailAuthSignup200'; +export * from './postMailAuthSignupParams'; export * from './postPasswordResetId200'; export * from './postPasswordResetIdValid200'; export * from './postPasswordResetIdValidParams'; From 18935672d13bb412fe034bb040ea905b125ca949 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Mon, 3 Feb 2025 23:44:04 +0900 Subject: [PATCH 05/14] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=81=AE=E5=BC=95=E6=95=B0=E3=82=92=E5=90=88=E3=82=8F=E3=81=9B?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/externals/handler/activity_handler.go | 28 ++++++------------- .../handler/activity_information_handler.go | 6 ++-- .../handler/activity_style_handler.go | 6 ++-- api/externals/handler/bureau_handler.go | 7 +++-- api/externals/handler/buy_report_handler.go | 7 +++-- api/externals/handler/department_handler.go | 7 +++-- api/externals/handler/division_handler.go | 8 +++--- api/internals/usecase/activity_usecase.go | 18 ++++++------ 8 files changed, 40 insertions(+), 47 deletions(-) diff --git a/api/externals/handler/activity_handler.go b/api/externals/handler/activity_handler.go index f26a2fe0c..85166a59a 100644 --- a/api/externals/handler/activity_handler.go +++ b/api/externals/handler/activity_handler.go @@ -9,16 +9,6 @@ import ( "github.com/labstack/echo/v4" ) -// router.GET(baseURL+"/activities", wrapper.GetActivities) -// router.POST(baseURL+"/activities", wrapper.PostActivities) -// router.GET(baseURL+"/activities/details", wrapper.GetActivitiesDetails) -// router.GET(baseURL+"/activities/details/:year", wrapper.GetActivitiesDetailsYear) -// router.GET(baseURL+"/activities/filtered_details", wrapper.GetActivitiesFilteredDetails) -// router.GET(baseURL+"/activities/filtered_details/:year", wrapper.GetActivitiesFilteredDetailsYear) -// router.DELETE(baseURL+"/activities/:id", wrapper.DeleteActivitiesId) -// router.GET(baseURL+"/activities/:id", wrapper.GetActivitiesId) -// router.PUT(baseURL+"/activities/:id", wrapper.PutActivitiesId) - // Index func (h *Handler) GetActivities(c echo.Context) error { activities, err := h.activityUseCase.GetActivity(c.Request().Context()) @@ -29,9 +19,9 @@ func (h *Handler) GetActivities(c echo.Context) error { } // Show -func (h *Handler) GetActivitiesId(c echo.Context) error { - id := c.Param("id") - activity, err := h.activityUseCase.GetActivityByID(c.Request().Context(), id) +func (h *Handler) GetActivitiesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + activity, err := h.activityUseCase.GetActivityByID(c.Request().Context(), idStr) if err != nil { return err } @@ -53,14 +43,14 @@ func (h *Handler) PostActivities(c echo.Context) error { } // Update -func (h *Handler) PutActivitiesId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutActivitiesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) activities := new(domain.Activity) if err := c.Bind(activities); err != nil { fmt.Println("err") return err } - updatedActivity, err := h.activityUseCase.UpdateActivity(c.Request().Context(), id, strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) + updatedActivity, err := h.activityUseCase.UpdateActivity(c.Request().Context(), idStr, strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) if err != nil { return err } @@ -87,9 +77,9 @@ func (h *Handler) GetActivitiesDetails(c echo.Context) error { } // 年度で指定されたactivitiesとsponsor,sponsorStyle,userの一覧を取得 -func (h *Handler) GetActivitiesDetailsYear(c echo.Context) error { - year := c.Param("year") - activities, err := h.activityUseCase.GetActivityDetailsByPeriod(c.Request().Context(), year) +func (h *Handler) GetActivitiesDetailsYear(c echo.Context, year int) error { + yearStr := strconv.Itoa(year) + activities, err := h.activityUseCase.GetActivityDetailsByPeriod(c.Request().Context(), yearStr) if err != nil { return err } diff --git a/api/externals/handler/activity_information_handler.go b/api/externals/handler/activity_information_handler.go index 3e2db6714..e2319085e 100644 --- a/api/externals/handler/activity_information_handler.go +++ b/api/externals/handler/activity_information_handler.go @@ -39,9 +39,9 @@ func (h *Handler) PostActivityInformations(c echo.Context) error { } // router.DELETE(baseURL+"/activity_informations/:id", wrapper.DeleteActivityInformationsId) -func (h *Handler) DeleteActivityInformationsId(c echo.Context) error { - id := c.Param("id") - err := h.activityInformationUseCase.DestroyActivityInformation(c.Request().Context(), id) +func (h *Handler) DeleteActivityInformationsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.activityInformationUseCase.DestroyActivityInformation(c.Request().Context(), idStr) if err != nil { return err } diff --git a/api/externals/handler/activity_style_handler.go b/api/externals/handler/activity_style_handler.go index 302a1a598..71c3fb144 100644 --- a/api/externals/handler/activity_style_handler.go +++ b/api/externals/handler/activity_style_handler.go @@ -35,9 +35,9 @@ func (h *Handler) PostActivityStyles(c echo.Context) error { } // router.DELETE(baseURL+"/activity_styles/:id", wrapper.DeleteActivityStylesId) -func (h *Handler) DeleteActivityStylesId(c echo.Context) error { - id := c.Param("id") - err := h.activityStyleUseCase.DestroyActivityStyle(c.Request().Context(), id) +func (h *Handler) DeleteActivityStylesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.activityStyleUseCase.DestroyActivityStyle(c.Request().Context(), idStr) if err != nil { return err } diff --git a/api/externals/handler/bureau_handler.go b/api/externals/handler/bureau_handler.go index b6bec74cb..fc44e0ca2 100644 --- a/api/externals/handler/bureau_handler.go +++ b/api/externals/handler/bureau_handler.go @@ -2,6 +2,7 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" @@ -33,9 +34,9 @@ func (h *Handler) PostBureaus(c echo.Context) error { } // router.DELETE(baseURL+"/bureaus/:id", wrapper.DeleteBureausId) -func (h *Handler) DeleteBureausId(c echo.Context) error { - id := c.Param("id") - err := h.bureauUseCase.DestroyBureau(c.Request().Context(), id) +func (h *Handler) DeleteBureausId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.bureauUseCase.DestroyBureau(c.Request().Context(), idStr) if err != nil { return err } diff --git a/api/externals/handler/buy_report_handler.go b/api/externals/handler/buy_report_handler.go index 7da7fa765..c7c3fb5aa 100644 --- a/api/externals/handler/buy_report_handler.go +++ b/api/externals/handler/buy_report_handler.go @@ -3,6 +3,7 @@ package handler import ( "encoding/json" "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" @@ -49,10 +50,10 @@ func (h *Handler) GetBuyReportsDetails(c echo.Context) error { } // router.DELETE(baseURL+"/buy_reports/:id", wrapper.DeleteBuyReportsId) -func (h *Handler) DeleteBuyReportsId(c echo.Context) error { +func (h *Handler) DeleteBuyReportsId(c echo.Context, id int) error { ctx := c.Request().Context() - id := c.Param("id") - err := h.buyReportUseCase.DeleteBuyReport(ctx, id) + idStr := strconv.Itoa(id) + err := h.buyReportUseCase.DeleteBuyReport(ctx, idStr) if err != nil { return c.String(http.StatusBadRequest, "buy_report delete failed") } diff --git a/api/externals/handler/department_handler.go b/api/externals/handler/department_handler.go index fafd25ad7..eb54cac50 100644 --- a/api/externals/handler/department_handler.go +++ b/api/externals/handler/department_handler.go @@ -2,6 +2,7 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" @@ -31,9 +32,9 @@ func (h *Handler) PostDepartments(c echo.Context) error { } // router.DELETE(baseURL+"/departments/:id", wrapper.DeleteDepartmentsId) -func (h *Handler) DeleteDepartmentsId(c echo.Context) error { - id := c.Param("id") - err := h.departmentUseCase.DestroyDepartment(c.Request().Context(), id) +func (h *Handler) DeleteDepartmentsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.departmentUseCase.DestroyDepartment(c.Request().Context(), idStr) if err != nil { return err } diff --git a/api/externals/handler/division_handler.go b/api/externals/handler/division_handler.go index 9401c9272..11ff67d75 100644 --- a/api/externals/handler/division_handler.go +++ b/api/externals/handler/division_handler.go @@ -2,6 +2,7 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" @@ -36,11 +37,10 @@ func (h *Handler) PostDivisions(c echo.Context) error { } // router.DELETE(baseURL+"/divisions/:id", wrapper.DeleteDivisionsId) -func (h *Handler) DeleteDivisionsId(c echo.Context) error { +func (h *Handler) DeleteDivisionsId(c echo.Context, id int) error { ctx := c.Request().Context() - id := c.Param("id") - - err := h.divisionUseCase.DestroyDivision(ctx, id) + idStr := strconv.Itoa(id) + err := h.divisionUseCase.DestroyDivision(ctx, idStr) if err != nil { return err } diff --git a/api/internals/usecase/activity_usecase.go b/api/internals/usecase/activity_usecase.go index 757af3397..2d9c2cdfb 100644 --- a/api/internals/usecase/activity_usecase.go +++ b/api/internals/usecase/activity_usecase.go @@ -212,7 +212,7 @@ func (a *activityUseCase) GetActivityDetail(c context.Context) ([]domain.Activit } rows, err := a.rep.FindActivityInformation(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &activityInformation.ID, &activityInformation.ActivityId, @@ -233,7 +233,7 @@ func (a *activityUseCase) GetActivityDetail(c context.Context) ([]domain.Activit activityInformations = nil rows, err = a.rep.FindSponsorStyle(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &styleDetail.ActivityStyle.ID, &styleDetail.ActivityStyle.ActivityID, @@ -310,7 +310,7 @@ func (a *activityUseCase) GetActivityDetailsByPeriod(c context.Context, year str } rows, err := a.rep.FindActivityInformation(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &activityInformation.ID, &activityInformation.ActivityId, @@ -330,8 +330,8 @@ func (a *activityUseCase) GetActivityDetailsByPeriod(c context.Context, year str activity.ActivityInformation = activityInformations activityInformations = nil - rows, err = a.rep.FindSponsorStyle(c,strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + rows, err = a.rep.FindSponsorStyle(c, strconv.Itoa(int(activity.Activity.ID))) + for rows.Next() { err := rows.Scan( &styleDetail.ActivityStyle.ID, &styleDetail.ActivityStyle.ActivityID, @@ -408,7 +408,7 @@ func (a *activityUseCase) GetFilteredActivityDetail(c context.Context, isDone st } rows, err := a.rep.FindActivityInformation(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &activityInformation.ID, &activityInformation.ActivityId, @@ -429,7 +429,7 @@ func (a *activityUseCase) GetFilteredActivityDetail(c context.Context, isDone st activityInformations = nil rows, err = a.rep.FindSponsorStyle(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &styleDetail.ActivityStyle.ID, &styleDetail.ActivityStyle.ActivityID, @@ -506,7 +506,7 @@ func (a *activityUseCase) GetFilteredActivityDetailByPeriod(c context.Context, i } rows, err := a.rep.FindActivityInformation(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &activityInformation.ID, &activityInformation.ActivityId, @@ -527,7 +527,7 @@ func (a *activityUseCase) GetFilteredActivityDetailByPeriod(c context.Context, i activityInformations = nil rows, err = a.rep.FindSponsorStyle(c, strconv.Itoa(int(activity.Activity.ID))) - for rows.Next(){ + for rows.Next() { err := rows.Scan( &styleDetail.ActivityStyle.ID, &styleDetail.ActivityStyle.ActivityID, From 90801f90afb19ee9f1f409b03494729b02c293fd Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Tue, 4 Feb 2025 00:01:53 +0900 Subject: [PATCH 06/14] wip --- .../handler/activity_information_handler.go | 12 ++-- .../handler/activity_style_handler.go | 70 ++----------------- api/externals/handler/bureau_handler.go | 12 ++-- api/externals/handler/buy_report_handler.go | 6 +- api/externals/handler/department_handler.go | 15 ++-- api/externals/handler/division_handler.go | 6 +- .../handler/festival_item_handler.go | 27 +++---- .../handler/financial_record_handler.go | 13 ++-- .../handler/fund_information_handler.go | 64 +++++++++-------- 9 files changed, 86 insertions(+), 139 deletions(-) diff --git a/api/externals/handler/activity_information_handler.go b/api/externals/handler/activity_information_handler.go index e2319085e..c8c82599f 100644 --- a/api/externals/handler/activity_information_handler.go +++ b/api/externals/handler/activity_information_handler.go @@ -49,9 +49,9 @@ func (h *Handler) DeleteActivityInformationsId(c echo.Context, id int) error { } // router.GET(baseURL+"/activity_informations/:id", wrapper.GetActivityInformationsId) -func (h *Handler) GetActivityInformationsId(c echo.Context) error { - id := c.Param("id") - activityInformation, err := h.activityInformationUseCase.GetActivityInformationByID(c.Request().Context(), id) +func (h *Handler) GetActivityInformationsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + activityInformation, err := h.activityInformationUseCase.GetActivityInformationByID(c.Request().Context(), idStr) if err != nil { return err } @@ -59,14 +59,14 @@ func (h *Handler) GetActivityInformationsId(c echo.Context) error { } // router.PUT(baseURL+"/activity_informations/:id", wrapper.PutActivityInformationsId) -func (h *Handler) PutActivityInformationsId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutActivityInformationsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) activityInformation := new(domain.ActivityInformation) if err := c.Bind(activityInformation); err != nil { return err } updatedActivity, err := h.activityInformationUseCase.UpdateActivityInformation(c.Request().Context(), - id, + idStr, strconv.Itoa(int(activityInformation.ActivityId)), activityInformation.BucketName, activityInformation.FileName, diff --git a/api/externals/handler/activity_style_handler.go b/api/externals/handler/activity_style_handler.go index 71c3fb144..6698caa41 100644 --- a/api/externals/handler/activity_style_handler.go +++ b/api/externals/handler/activity_style_handler.go @@ -45,9 +45,9 @@ func (h *Handler) DeleteActivityStylesId(c echo.Context, id int) error { } // router.GET(baseURL+"/activity_styles/:id", wrapper.GetActivityStylesId) -func (h *Handler) GetActivityStylesId(c echo.Context) error { - id := c.Param("id") - activityStyle, err := h.activityStyleUseCase.GetActivityStyleByID(c.Request().Context(), id) +func (h *Handler) GetActivityStylesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + activityStyle, err := h.activityStyleUseCase.GetActivityStyleByID(c.Request().Context(), idStr) if err != nil { return err } @@ -55,14 +55,14 @@ func (h *Handler) GetActivityStylesId(c echo.Context) error { } // router.PUT(baseURL+"/activity_styles/:id", wrapper.PutActivityStylesId) -func (h *Handler) PutActivityStylesId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutActivityStylesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) activityStyle := new(domain.ActivityStyle) if err := c.Bind(activityStyle); err != nil { return err } - updatedActivityStyle, err := h.activityStyleUseCase.UpdateActivityStyle(c.Request().Context(), id, + updatedActivityStyle, err := h.activityStyleUseCase.UpdateActivityStyle(c.Request().Context(), idStr, strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID)), ) @@ -71,61 +71,3 @@ func (h *Handler) PutActivityStylesId(c echo.Context) error { } return c.JSON(http.StatusOK, updatedActivityStyle) } - -// // Index -// func (a *activityStyleController) IndexActivityStyle(c echo.Context) error { -// activityStyles, err := a.u.GetActivityStyle(c.Request().Context()) -// if err != nil { -// return err -// } -// return c.JSON(http.StatusOK, activityStyles) -// } - -// // Show -// func (a *activityStyleController) ShowActivityStyle(c echo.Context) error { -// id := c.Param("id") -// activityStyle, err := a.u.GetActivityStyleByID(c.Request().Context(), id) -// if err != nil { -// return err -// } -// return c.JSON(http.StatusOK, activityStyle) -// } - -// // Create -// func (a *activityStyleController) CreateActivityStyle(c echo.Context) error { -// activityStyle := new(domain.ActivityStyle) -// if err := c.Bind(activityStyle); err != nil { -// fmt.Println("err") -// return err -// } -// latastActivityStyle, err := a.u.CreateActivityStyle(c.Request().Context() , strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID))) -// if err != nil { -// return err -// } -// return c.JSON(http.StatusOK, latastActivityStyle) -// } - -// // Update -// func (a *activityStyleController) UpdateActivityStyle(c echo.Context) error { -// id := c.Param("id") -// activityStyle := new(domain.ActivityStyle) -// if err := c.Bind(activityStyle); err != nil { -// fmt.Println("err") -// return err -// } -// updatedActivityStyle, err := a.u.UpdateActivityStyle(c.Request().Context(), id , strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID))) -// if err != nil { -// return err -// } -// return c.JSON(http.StatusOK, updatedActivityStyle) -// } - -// // Destroy -// func (a *activityStyleController) DestroyActivityStyle(c echo.Context) error { -// id := c.Param("id") -// err := a.u.DestroyActivityStyle(c.Request().Context(), id) -// if err != nil { -// return err -// } -// return c.String(http.StatusOK, "Destroy ActivityStyle") -// } diff --git a/api/externals/handler/bureau_handler.go b/api/externals/handler/bureau_handler.go index fc44e0ca2..2e0efad6f 100644 --- a/api/externals/handler/bureau_handler.go +++ b/api/externals/handler/bureau_handler.go @@ -44,9 +44,9 @@ func (h *Handler) DeleteBureausId(c echo.Context, id int) error { } // router.GET(baseURL+"/bureaus/:id", wrapper.GetBureausId) -func (h *Handler) GetBureausId(c echo.Context) error { - id := c.Param("id") - bureau, err := h.bureauUseCase.GetBureauByID(c.Request().Context(), id) +func (h *Handler) GetBureausId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + bureau, err := h.bureauUseCase.GetBureauByID(c.Request().Context(), idStr) if err != nil { return err } @@ -54,14 +54,14 @@ func (h *Handler) GetBureausId(c echo.Context) error { } // router.PUT(baseURL+"/bureaus/:id", wrapper.PutBureausId) -func (h *Handler) PutBureausId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutBureausId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) bureau := new(domain.Bureau) if err := c.Bind(bureau); err != nil { return err } - updatedBureau, err := h.bureauUseCase.UpdateBureau(c.Request().Context(), id, bureau.Name) + updatedBureau, err := h.bureauUseCase.UpdateBureau(c.Request().Context(), idStr, bureau.Name) if err != nil { return err } diff --git a/api/externals/handler/buy_report_handler.go b/api/externals/handler/buy_report_handler.go index c7c3fb5aa..8da68e7bd 100644 --- a/api/externals/handler/buy_report_handler.go +++ b/api/externals/handler/buy_report_handler.go @@ -61,9 +61,9 @@ func (h *Handler) DeleteBuyReportsId(c echo.Context, id int) error { } // router.PUT(baseURL+"/buy_reports/:id", wrapper.PutBuyReportsId) -func (h *Handler) PutBuyReportsId(c echo.Context) error { +func (h *Handler) PutBuyReportsId(c echo.Context, id int) error { ctx := c.Request().Context() - id := c.Param("id") + idStr := strconv.Itoa(id) // ファイル取得 file, _ := c.FormFile("file") // JSON データを取得 @@ -79,7 +79,7 @@ func (h *Handler) PutBuyReportsId(c echo.Context) error { return c.String(http.StatusBadRequest, "buy_report is not valid") } - buyReportInfo, err = h.buyReportUseCase.UpdateBuyReport(ctx, id, buyReportInfo, file) + buyReportInfo, err = h.buyReportUseCase.UpdateBuyReport(ctx, idStr, buyReportInfo, file) if err != nil { return err } diff --git a/api/externals/handler/department_handler.go b/api/externals/handler/department_handler.go index eb54cac50..ab1d3fc99 100644 --- a/api/externals/handler/department_handler.go +++ b/api/externals/handler/department_handler.go @@ -4,6 +4,7 @@ import ( "net/http" "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) @@ -42,9 +43,9 @@ func (h *Handler) DeleteDepartmentsId(c echo.Context, id int) error { } // router.GET(baseURL+"/departments/:id", wrapper.GetDepartmentsId) -func (h *Handler) GetDepartmentsId(c echo.Context) error { - id := c.Param("id") - department, err := h.departmentUseCase.GetDepartmentByID(c.Request().Context(), id) +func (h *Handler) GetDepartmentsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + department, err := h.departmentUseCase.GetDepartmentByID(c.Request().Context(), idStr) if err != nil { return err } @@ -52,10 +53,10 @@ func (h *Handler) GetDepartmentsId(c echo.Context) error { } // router.PUT(baseURL+"/departments/:id", wrapper.PutDepartmentsId) -func (h *Handler) PutDepartmentsId(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - updatedDepartment, err := h.departmentUseCase.UpdateDepartment(c.Request().Context(), id, name) +func (h *Handler) PutDepartmentsId(c echo.Context, id int, params generated.PutDepartmentsIdParams) error { + idStr := strconv.Itoa(id) + name := params.Name + updatedDepartment, err := h.departmentUseCase.UpdateDepartment(c.Request().Context(), idStr, *name) if err != nil { return err } diff --git a/api/externals/handler/division_handler.go b/api/externals/handler/division_handler.go index 11ff67d75..029029c36 100644 --- a/api/externals/handler/division_handler.go +++ b/api/externals/handler/division_handler.go @@ -48,15 +48,15 @@ func (h *Handler) DeleteDivisionsId(c echo.Context, id int) error { } // router.PUT(baseURL+"/divisions/:id", wrapper.PutDivisionsId) -func (h *Handler) PutDivisionsId(c echo.Context) error { +func (h *Handler) PutDivisionsId(c echo.Context, id int) error { ctx := c.Request().Context() - id := c.Param("id") + idStr := strconv.Itoa(id) division := new(Division) if err := c.Bind(division); err != nil { return c.String(http.StatusBadRequest, "Bad Request") } - updatedDivision, err := h.divisionUseCase.UpdateDivision(ctx, id, *division) + updatedDivision, err := h.divisionUseCase.UpdateDivision(ctx, idStr, *division) if err != nil { return err } diff --git a/api/externals/handler/festival_item_handler.go b/api/externals/handler/festival_item_handler.go index 7dabf1fe8..bb877ce4c 100644 --- a/api/externals/handler/festival_item_handler.go +++ b/api/externals/handler/festival_item_handler.go @@ -2,16 +2,17 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" ) // router.GET(baseURL+"/festival_items", wrapper.GetFestivalItems) -func (h *Handler) GetFestivalItems(c echo.Context) error { +func (h *Handler) GetFestivalItems(c echo.Context, params generated.GetFestivalItemsParams) error { ctx := c.Request().Context() - year := c.QueryParam("year") - divisionId := c.QueryParam("division_id") + year := strconv.Itoa(*params.Year) + divisionId := strconv.Itoa(*params.DivisionId) var festivalItemDetails FestivalItemDetails festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItems(ctx, year, divisionId) @@ -38,13 +39,13 @@ func (h *Handler) PostFestivalItems(c echo.Context) error { } // router.GET(baseURL+"/festival_items/details/:user_id", wrapper.GetFestivalItemsDetailsUserId) -func (h *Handler) GetFestivalItemsDetailsUserId(c echo.Context) error { +func (h *Handler) GetFestivalItemsDetailsUserId(c echo.Context, userId int, params generated.GetFestivalItemsDetailsUserIdParams) error { ctx := c.Request().Context() - userId := c.Param("user_id") - year := c.QueryParam("year") + userIdStr := strconv.Itoa(userId) + year := strconv.Itoa(*params.Year) var festivalItemDetails []FestivalItemsForMyPage - festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItemsForMypage(ctx, year, userId) + festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItemsForMypage(ctx, year, userIdStr) if err != nil { return err } @@ -52,11 +53,11 @@ func (h *Handler) GetFestivalItemsDetailsUserId(c echo.Context) error { } // router.DELETE(baseURL+"/festival_items/:id", wrapper.DeleteFestivalItemsId) -func (h *Handler) DeleteFestivalItemsId(c echo.Context) error { +func (h *Handler) DeleteFestivalItemsId(c echo.Context, id int) error { ctx := c.Request().Context() - id := c.Param("id") + idStr := strconv.Itoa(id) - err := h.festivalItemUseCase.DestroyFestivalItem(ctx, id) + err := h.festivalItemUseCase.DestroyFestivalItem(ctx, idStr) if err != nil { return err } @@ -64,16 +65,16 @@ func (h *Handler) DeleteFestivalItemsId(c echo.Context) error { } // router.PUT(baseURL+"/festival_items/:id", wrapper.PutFestivalItemsId) -func (h *Handler) PutFestivalItemsId(c echo.Context) error { +func (h *Handler) PutFestivalItemsId(c echo.Context, id int) error { ctx := c.Request().Context() - id := c.Param("id") festivalItem := new(FestivalItem) + idStr := strconv.Itoa(id) if err := c.Bind(festivalItem); err != nil { return c.String(http.StatusBadRequest, "Bad Request") } - updatedFestivalItem, err := h.festivalItemUseCase.UpdateFestivalItem(ctx, id, *festivalItem) + updatedFestivalItem, err := h.festivalItemUseCase.UpdateFestivalItem(ctx, idStr, *festivalItem) if err != nil { return err } diff --git a/api/externals/handler/financial_record_handler.go b/api/externals/handler/financial_record_handler.go index f469b0acc..43d5a1eb3 100644 --- a/api/externals/handler/financial_record_handler.go +++ b/api/externals/handler/financial_record_handler.go @@ -2,6 +2,7 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" @@ -31,9 +32,9 @@ func (h *Handler) PostFinancialRecords(c echo.Context) error { } // router.DELETE(baseURL+"/financial_records/:id", wrapper.DeleteFinancialRecordsId) -func (h *Handler) DeleteFinancialRecordsId(c echo.Context) error { - id := c.Param("id") - err := h.financialRecordUseCase.DestroyFinancialRecord(c.Request().Context(), id) +func (h *Handler) DeleteFinancialRecordsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.financialRecordUseCase.DestroyFinancialRecord(c.Request().Context(), idStr) if err != nil { return err } @@ -41,15 +42,15 @@ func (h *Handler) DeleteFinancialRecordsId(c echo.Context) error { } // router.PUT(baseURL+"/financial_records/:id", wrapper.PutFinancialRecordsId) -func (h *Handler) PutFinancialRecordsId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutFinancialRecordsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) financialRecord := new(FinancialRecord) if err := c.Bind(financialRecord); err != nil { return c.String(http.StatusBadRequest, "Bad Request") } updatedFinancialRecord, err := h.financialRecordUseCase.UpdateFinancialRecord( c.Request().Context(), - id, + idStr, *financialRecord, ) if err != nil { diff --git a/api/externals/handler/fund_information_handler.go b/api/externals/handler/fund_information_handler.go index 06ee4966d..f83df6f4a 100644 --- a/api/externals/handler/fund_information_handler.go +++ b/api/externals/handler/fund_information_handler.go @@ -2,7 +2,9 @@ package handler import ( "net/http" + "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" ) @@ -16,16 +18,16 @@ func (h *Handler) GetFundInformations(c echo.Context) error { } // router.POST(baseURL+"/fund_informations", wrapper.PostFundInformations) -func (h *Handler) PostFundInformations(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") +func (h *Handler) PostFundInformations(c echo.Context, params generated.PostFundInformationsParams) error { + userID := strconv.Itoa(params.UserId) + teacherID := strconv.Itoa(params.TeacherId) + price := strconv.Itoa(params.Price) + remark := params.Remark + isFirstCheck := strconv.FormatBool(*params.IsFirstCheck) + isLastCheck := strconv.FormatBool(*params.IsLastCheck) + receivedAt := params.ReceivedAt - latestFundInformation, err := h.fundInformationUseCase.CreateFundInformation(c.Request().Context(), userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt) + latestFundInformation, err := h.fundInformationUseCase.CreateFundInformation(c.Request().Context(), userID, teacherID, price, *remark, isFirstCheck, isLastCheck, *receivedAt) if err != nil { return err } @@ -42,9 +44,9 @@ func (h *Handler) GetFundInformationsDetails(c echo.Context) error { } // router.GET(baseURL+"/fund_informations/details/:year", wrapper.GetFundInformationsDetailsYear) -func (h *Handler) GetFundInformationsDetailsYear(c echo.Context) error { - year := c.Param("year") - fundInformationDetails, err := h.fundInformationUseCase.GetFundInformationDetailsByPeriod(c.Request().Context(), year) +func (h *Handler) GetFundInformationsDetailsYear(c echo.Context, year int) error { + yearStr := strconv.Itoa(year) + fundInformationDetails, err := h.fundInformationUseCase.GetFundInformationDetailsByPeriod(c.Request().Context(), yearStr) if err != nil { return err } @@ -52,9 +54,9 @@ func (h *Handler) GetFundInformationsDetailsYear(c echo.Context) error { } // router.DELETE(baseURL+"/fund_informations/:id", wrapper.DeleteFundInformationsId) -func (h *Handler) DeleteFundInformationsId(c echo.Context) error { - id := c.Param("id") - err := h.fundInformationUseCase.DestroyFundInformation(c.Request().Context(), id) +func (h *Handler) DeleteFundInformationsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.fundInformationUseCase.DestroyFundInformation(c.Request().Context(), idStr) if err != nil { return err } @@ -62,9 +64,9 @@ func (h *Handler) DeleteFundInformationsId(c echo.Context) error { } // router.GET(baseURL+"/fund_informations/:id", wrapper.GetFundInformationsId) -func (h *Handler) GetFundInformationsId(c echo.Context) error { - id := c.Param("id") - fundInformation, err := h.fundInformationUseCase.GetFundInformationByID(c.Request().Context(), id) +func (h *Handler) GetFundInformationsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + fundInformation, err := h.fundInformationUseCase.GetFundInformationByID(c.Request().Context(), idStr) if err != nil { return err } @@ -72,17 +74,17 @@ func (h *Handler) GetFundInformationsId(c echo.Context) error { } // router.PUT(baseURL+"/fund_informations/:id", wrapper.PutFundInformationsId) -func (h *Handler) PutFundInformationsId(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") +func (h *Handler) PutFundInformationsId(c echo.Context, id int, params generated.PostFundInformationsParams) error { + idStr := strconv.Itoa(id) + userId := strconv.Itoa(params.UserId) + teacherId := strconv.Itoa(params.TeacherId) + price := strconv.Itoa(params.Price) + remark := params.Remark + isFirstCheck := strconv.FormatBool(*params.IsFirstCheck) + isLastCheck := strconv.FormatBool(*params.IsLastCheck) + receivedAt := params.ReceivedAt - updatedFundInformation, err := h.fundInformationUseCase.UpdateFundInformation(c.Request().Context(), id, userID, teacherID, price, remark, isFirstCheck, isLastCheck, receivedAt) + updatedFundInformation, err := h.fundInformationUseCase.UpdateFundInformation(c.Request().Context(), idStr, userId, teacherId, price, *remark, isFirstCheck, isLastCheck, *receivedAt) if err != nil { return err } @@ -90,9 +92,9 @@ func (h *Handler) PutFundInformationsId(c echo.Context) error { } // router.GET(baseURL+"/fund_informations/:id/details", wrapper.GetFundInformationsIdDetails) -func (h *Handler) GetFundInformationsIdDetails(c echo.Context) error { - id := c.Param("id") - fundInformationDetail, err := h.fundInformationUseCase.GetFundInformationDetailByID(c.Request().Context(), id) +func (h *Handler) GetFundInformationsIdDetails(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + fundInformationDetail, err := h.fundInformationUseCase.GetFundInformationDetailByID(c.Request().Context(), idStr) if err != nil { return err } From c017e73b3c7a570eba3f0efba06ca896b8376839 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Tue, 4 Feb 2025 23:28:11 +0900 Subject: [PATCH 07/14] =?UTF-8?q?handler=E3=81=AE=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/externals/handler/activity_handler.go | 24 +++++---- api/externals/handler/bureau_handler.go | 22 +++----- api/externals/handler/buy_report_handler.go | 4 +- api/externals/handler/department_handler.go | 10 +--- api/externals/handler/division_handler.go | 6 +-- .../handler/financial_record_handler.go | 5 +- .../handler/fund_information_handler.go | 2 +- api/externals/handler/mail_auth_handler.go | 31 ++++++----- .../handler/password_reset_token_handler.go | 24 +++++---- api/externals/handler/sponsor_handler.go | 25 ++++----- .../handler/sponsor_style_handler.go | 19 +++---- api/externals/handler/teacher_handler.go | 54 ++++++++++--------- api/externals/handler/user_handler.go | 34 ++++++------ api/externals/handler/year_handler.go | 37 ++++++------- 14 files changed, 152 insertions(+), 145 deletions(-) diff --git a/api/externals/handler/activity_handler.go b/api/externals/handler/activity_handler.go index 85166a59a..1b209ea55 100644 --- a/api/externals/handler/activity_handler.go +++ b/api/externals/handler/activity_handler.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) @@ -86,10 +87,13 @@ func (h *Handler) GetActivitiesDetailsYear(c echo.Context, year int) error { return c.JSON(http.StatusOK, activities) } -func (h *Handler) GetActivitiesFilteredDetails(c echo.Context) error { - isDone := c.QueryParam("is_done") - sponsorStyleIDs := c.QueryParams()["sponsor_style_id"] - keyword := c.QueryParam("keyword") +func (h *Handler) GetActivitiesFilteredDetails(c echo.Context, params generated.GetActivitiesFilteredDetailsParams) error { + isDone := string(*params.IsDone) + sponsorStyleIDs := []string{} + for _, id := range *params.SponsorStyleId { + sponsorStyleIDs = append(sponsorStyleIDs, strconv.Itoa(int(id))) + } + keyword := *params.Keyword activities, err := h.activityUseCase.GetFilteredActivityDetail(c.Request().Context(), isDone, sponsorStyleIDs, keyword) if err != nil { return err @@ -97,11 +101,13 @@ func (h *Handler) GetActivitiesFilteredDetails(c echo.Context) error { return c.JSON(http.StatusOK, activities) } -func (h *Handler) GetActivitiesFilteredDetailsYear(c echo.Context) error { - isDone := c.QueryParam("is_done") - sponsorStyleIDs := c.QueryParams()["sponsor_style_id"] - year := c.Param("year") - keyword := c.QueryParam("keyword") +func (h *Handler) GetActivitiesFilteredDetailsYear(c echo.Context, year string, params generated.GetActivitiesFilteredDetailsYearParams) error { + isDone := string(*params.IsDone) + sponsorStyleIDs := []string{} + for _, id := range *params.SponsorStyleId { + sponsorStyleIDs = append(sponsorStyleIDs, strconv.Itoa(int(id))) + } + keyword := *params.Keyword activities, err := h.activityUseCase.GetFilteredActivityDetailByPeriod(c.Request().Context(), isDone, sponsorStyleIDs, year, keyword) if err != nil { return err diff --git a/api/externals/handler/bureau_handler.go b/api/externals/handler/bureau_handler.go index 2e0efad6f..9514547d5 100644 --- a/api/externals/handler/bureau_handler.go +++ b/api/externals/handler/bureau_handler.go @@ -4,7 +4,7 @@ import ( "net/http" "strconv" - "github.com/NUTFes/FinanSu/api/internals/domain" + "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" ) @@ -18,14 +18,10 @@ func (h *Handler) GetBureaus(c echo.Context) error { } // router.POST(baseURL+"/bureaus", wrapper.PostBureaus) -func (h *Handler) PostBureaus(c echo.Context) error { - bureau := new(domain.Bureau) - if err := c.Bind(bureau); err != nil { - return err - } - +func (h *Handler) PostBureaus(c echo.Context, params generated.PostBureausParams) error { + name := params.Name latastBureau, err := h.bureauUseCase.CreateBureau(c.Request().Context(), - bureau.Name, + name, ) if err != nil { return err @@ -54,14 +50,10 @@ func (h *Handler) GetBureausId(c echo.Context, id int) error { } // router.PUT(baseURL+"/bureaus/:id", wrapper.PutBureausId) -func (h *Handler) PutBureausId(c echo.Context, id int) error { +func (h *Handler) PutBureausId(c echo.Context, id int, params generated.PutBureausIdParams) error { idStr := strconv.Itoa(id) - bureau := new(domain.Bureau) - if err := c.Bind(bureau); err != nil { - return err - } - - updatedBureau, err := h.bureauUseCase.UpdateBureau(c.Request().Context(), idStr, bureau.Name) + name := *params.Name + updatedBureau, err := h.bureauUseCase.UpdateBureau(c.Request().Context(), idStr, name) if err != nil { return err } diff --git a/api/externals/handler/buy_report_handler.go b/api/externals/handler/buy_report_handler.go index 8da68e7bd..cd52a64cc 100644 --- a/api/externals/handler/buy_report_handler.go +++ b/api/externals/handler/buy_report_handler.go @@ -10,7 +10,7 @@ import ( ) // router.PUT(baseURL+"/buy_report/status/:buy_report_id", wrapper.PutBuyReportStatusBuyReportId) -func (h *Handler) PutBuyReportStatusBuyReportId(c echo.Context) error { +func (h *Handler) PutBuyReportStatusBuyReportId(c echo.Context, id int) error { // 未実装 return c.String(http.StatusNotImplemented, "PutBuyReportStatusBuyReportId is not implemented") } @@ -44,7 +44,7 @@ func (h *Handler) PostBuyReports(c echo.Context) error { } // router.GET(baseURL+"/buy_reports/details", wrapper.GetBuyReportsDetails) -func (h *Handler) GetBuyReportsDetails(c echo.Context) error { +func (h *Handler) GetBuyReportsDetails(c echo.Context, params generated.GetBuyReportsDetailsParams) error { //未実装 return c.String(http.StatusNotImplemented, "GetBuyReportsDetails is not implemented") } diff --git a/api/externals/handler/department_handler.go b/api/externals/handler/department_handler.go index ab1d3fc99..5424986c2 100644 --- a/api/externals/handler/department_handler.go +++ b/api/externals/handler/department_handler.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/NUTFes/FinanSu/api/generated" - "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) @@ -19,13 +18,8 @@ func (h *Handler) GetDepartments(c echo.Context) error { } // router.POST(baseURL+"/departments", wrapper.PostDepartments) -func (h *Handler) PostDepartments(c echo.Context) error { - department := new(domain.Department) - if err := c.Bind(department); err != nil { - return err - } - - latastDepartment, err := h.departmentUseCase.CreateDepartment(c.Request().Context(), department.Name) +func (h *Handler) PostDepartments(c echo.Context, params generated.PostDepartmentsParams) error { + latastDepartment, err := h.departmentUseCase.CreateDepartment(c.Request().Context(), *params.Name) if err != nil { return err } diff --git a/api/externals/handler/division_handler.go b/api/externals/handler/division_handler.go index 029029c36..74b8ba390 100644 --- a/api/externals/handler/division_handler.go +++ b/api/externals/handler/division_handler.go @@ -9,10 +9,10 @@ import ( ) // router.GET(baseURL+"/divisions", wrapper.GetDivisions) -func (h *Handler) GetDivisions(c echo.Context) error { +func (h *Handler) GetDivisions(c echo.Context, params generated.GetDivisionsParams) error { ctx := c.Request().Context() - year := c.QueryParam("year") - financialRecordId := c.QueryParam("financial_record_id") + year := strconv.Itoa(*params.Year) + financialRecordId := strconv.Itoa(*params.FinancialRecordId) divisionDetails, err := h.divisionUseCase.GetDivisions(ctx, year, financialRecordId) if err != nil { diff --git a/api/externals/handler/financial_record_handler.go b/api/externals/handler/financial_record_handler.go index 43d5a1eb3..42a8ba120 100644 --- a/api/externals/handler/financial_record_handler.go +++ b/api/externals/handler/financial_record_handler.go @@ -9,8 +9,9 @@ import ( ) // router.GET(baseURL+"/financial_records", wrapper.GetFinancialRecords) -func (h *Handler) GetFinancialRecords(c echo.Context) error { - financialRecordDetails, err := h.financialRecordUseCase.GetFinancialRecords(c.Request().Context()) +func (h *Handler) GetFinancialRecords(c echo.Context, params generated.GetFinancialRecordsParams) error { + yearStr := strconv.Itoa(*params.Year) + financialRecordDetails, err := h.financialRecordUseCase.GetFinancialRecordsByYears(c.Request().Context(), yearStr) if err != nil { return err } diff --git a/api/externals/handler/fund_information_handler.go b/api/externals/handler/fund_information_handler.go index f83df6f4a..543726da0 100644 --- a/api/externals/handler/fund_information_handler.go +++ b/api/externals/handler/fund_information_handler.go @@ -74,7 +74,7 @@ func (h *Handler) GetFundInformationsId(c echo.Context, id int) error { } // router.PUT(baseURL+"/fund_informations/:id", wrapper.PutFundInformationsId) -func (h *Handler) PutFundInformationsId(c echo.Context, id int, params generated.PostFundInformationsParams) error { +func (h *Handler) PutFundInformationsId(c echo.Context, id int, params generated.PutFundInformationsIdParams) error { idStr := strconv.Itoa(id) userId := strconv.Itoa(params.UserId) teacherId := strconv.Itoa(params.TeacherId) diff --git a/api/externals/handler/mail_auth_handler.go b/api/externals/handler/mail_auth_handler.go index 25ff577d9..a91a05080 100644 --- a/api/externals/handler/mail_auth_handler.go +++ b/api/externals/handler/mail_auth_handler.go @@ -1,16 +1,20 @@ package handler import ( + "fmt" "net/http" + "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" ) // router.GET(baseURL+"/mail_auth/is_signin", wrapper.GetMailAuthIsSignin) -func (h *Handler) GetMailAuthIsSignin(c echo.Context) error { +func (h *Handler) GetMailAuthIsSignin(c echo.Context, params generated.GetMailAuthIsSigninParams) error { // headerからトークンを取得する - accessToken := c.Request().Header["Access-Token"][0] - isSignIn, err := h.mailAuthUseCase.IsSignIn(c.Request().Context(), accessToken) + accessToken := params.AccessToken + fmt.Println(accessToken) + isSignIn, err := h.mailAuthUseCase.IsSignIn(c.Request().Context(), *accessToken) if err != nil { return nil } @@ -19,9 +23,10 @@ func (h *Handler) GetMailAuthIsSignin(c echo.Context) error { } // router.POST(baseURL+"/mail_auth/signin", wrapper.PostMailAuthSignin) -func (h *Handler) PostMailAuthSignin(c echo.Context) error { - email := c.QueryParam("email") - password := c.QueryParam("password") +func (h *Handler) PostMailAuthSignin(c echo.Context, params generated.PostMailAuthSigninParams) error { + email := params.Email + password := params.Password + fmt.Println(email, password) token, err := h.mailAuthUseCase.SignIn(c.Request().Context(), email, password) if err != nil { return err @@ -31,10 +36,10 @@ func (h *Handler) PostMailAuthSignin(c echo.Context) error { } // router.DELETE(baseURL+"/mail_auth/signout", wrapper.DeleteMailAuthSignout) -func (h *Handler) DeleteMailAuthSignout(c echo.Context) error { +func (h *Handler) DeleteMailAuthSignout(c echo.Context, params generated.DeleteMailAuthSignoutParams) error { // headerからトークンを取得する - accessToken := c.Request().Header["Access-Token"][0] - err := h.mailAuthUseCase.SignOut(c.Request().Context(), accessToken) + accessToken := params.AccessToken + err := h.mailAuthUseCase.SignOut(c.Request().Context(), *accessToken) if err != nil { return err } @@ -43,10 +48,10 @@ func (h *Handler) DeleteMailAuthSignout(c echo.Context) error { } // router.POST(baseURL+"/mail_auth/signup", wrapper.PostMailAuthSignup) -func (h *Handler) PostMailAuthSignup(c echo.Context) error { - email := c.QueryParam("email") - password := c.QueryParam("password") - userID := c.QueryParam("user_id") +func (h *Handler) PostMailAuthSignup(c echo.Context, params generated.PostMailAuthSignupParams) error { + email := params.Email + password := params.Password + userID := strconv.Itoa(params.UserId) token, err := h.mailAuthUseCase.SignUp(c.Request().Context(), email, password, userID) if err != nil { return err diff --git a/api/externals/handler/password_reset_token_handler.go b/api/externals/handler/password_reset_token_handler.go index 4298a0476..549760272 100644 --- a/api/externals/handler/password_reset_token_handler.go +++ b/api/externals/handler/password_reset_token_handler.go @@ -3,15 +3,17 @@ package handler import ( "errors" "net/http" + "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) // router.POST(baseURL+"/password_reset/request", wrapper.PostPasswordResetRequest) -func (h *Handler) PostPasswordResetRequest(c echo.Context) error { - email := c.QueryParam("email") - err := h.passwordResetTokenUseCase.PasswordResetTokenRequest(c.Request().Context(), email) +func (h *Handler) PostPasswordResetRequest(c echo.Context, params generated.PostPasswordResetRequestParams) error { + email := params.Email + err := h.passwordResetTokenUseCase.PasswordResetTokenRequest(c.Request().Context(), *email) if err != nil { return c.String(http.StatusOK, err.Error()) } @@ -19,8 +21,8 @@ func (h *Handler) PostPasswordResetRequest(c echo.Context) error { } // router.POST(baseURL+"/password_reset/:id", wrapper.PostPasswordResetId) -func (h *Handler) PostPasswordResetId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PostPasswordResetId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) passwordResetData := new(domain.PasswordResetData) if err := c.Bind(passwordResetData); err != nil { @@ -28,7 +30,7 @@ func (h *Handler) PostPasswordResetId(c echo.Context) error { } //トークンの有効チェック - err := h.passwordResetTokenUseCase.ValidPasswordResetToken(c.Request().Context(), id, passwordResetData.Token) + err := h.passwordResetTokenUseCase.ValidPasswordResetToken(c.Request().Context(), idStr, passwordResetData.Token) if err != nil { return c.String(http.StatusBadRequest, err.Error()) } @@ -41,7 +43,7 @@ func (h *Handler) PostPasswordResetId(c echo.Context) error { } //パスワード変更 - err = h.passwordResetTokenUseCase.ChangePassword(c.Request().Context(), id, passwordResetData.Password) + err = h.passwordResetTokenUseCase.ChangePassword(c.Request().Context(), idStr, passwordResetData.Password) if err != nil { return c.String(http.StatusBadRequest, err.Error()) } @@ -50,10 +52,10 @@ func (h *Handler) PostPasswordResetId(c echo.Context) error { } // router.POST(baseURL+"/password_reset/:id/valid", wrapper.PostPasswordResetIdValid) -func (h *Handler) PostPasswordResetIdValid(c echo.Context) error { - id := c.Param("id") - token := c.QueryParam("token") - err := h.passwordResetTokenUseCase.ValidPasswordResetToken(c.Request().Context(), id, token) +func (h *Handler) PostPasswordResetIdValid(c echo.Context, id int, params generated.PostPasswordResetIdValidParams) error { + idStr := strconv.Itoa(id) + token := params.Token + err := h.passwordResetTokenUseCase.ValidPasswordResetToken(c.Request().Context(), idStr, *token) if err != nil { return c.String(http.StatusBadRequest, err.Error()) } diff --git a/api/externals/handler/sponsor_handler.go b/api/externals/handler/sponsor_handler.go index 0f4d47441..f16829f8a 100644 --- a/api/externals/handler/sponsor_handler.go +++ b/api/externals/handler/sponsor_handler.go @@ -2,6 +2,7 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" @@ -37,9 +38,9 @@ func (h *Handler) PostSponsors(c echo.Context) error { } // router.GET(baseURL+"/sponsors/periods/:year", wrapper.GetSponsorsPeriodsYear) -func (h *Handler) GetSponsorsPeriodsYear(c echo.Context) error { - year := c.Param("year") - sponsors, err := h.sponsorUseCase.GetSponsorByPeriod(c.Request().Context(), year) +func (h *Handler) GetSponsorsPeriodsYear(c echo.Context, year int) error { + yearStr := strconv.Itoa(year) + sponsors, err := h.sponsorUseCase.GetSponsorByPeriod(c.Request().Context(), yearStr) if err != nil { return err } @@ -47,9 +48,9 @@ func (h *Handler) GetSponsorsPeriodsYear(c echo.Context) error { } // router.DELETE(baseURL+"/sponsors/:id", wrapper.DeleteSponsorsId) -func (h *Handler) DeleteSponsorsId(c echo.Context) error { - id := c.Param("id") - err := h.sponsorUseCase.DestroySponsor(c.Request().Context(), id) +func (h *Handler) DeleteSponsorsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.sponsorUseCase.DestroySponsor(c.Request().Context(), idStr) if err != nil { return err } @@ -57,9 +58,9 @@ func (h *Handler) DeleteSponsorsId(c echo.Context) error { } // router.GET(baseURL+"/sponsors/:id", wrapper.GetSponsorsId) -func (h *Handler) GetSponsorsId(c echo.Context) error { - id := c.Param("id") - sponsor, err := h.sponsorUseCase.GetSponsorByID(c.Request().Context(), id) +func (h *Handler) GetSponsorsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + sponsor, err := h.sponsorUseCase.GetSponsorByID(c.Request().Context(), idStr) if err != nil { return err } @@ -67,14 +68,14 @@ func (h *Handler) GetSponsorsId(c echo.Context) error { } // router.PUT(baseURL+"/sponsors/:id", wrapper.PutSponsorsId) -func (h *Handler) PutSponsorsId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutSponsorsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) sponsor := new(domain.Sponsor) if err := c.Bind(sponsor); err != nil { return err } - updatedSponsor, err := h.sponsorUseCase.UpdateSponsor(c.Request().Context(), id, + updatedSponsor, err := h.sponsorUseCase.UpdateSponsor(c.Request().Context(), idStr, sponsor.Name, sponsor.Tel, sponsor.Email, diff --git a/api/externals/handler/sponsor_style_handler.go b/api/externals/handler/sponsor_style_handler.go index 5cecd206f..a6e704b8c 100644 --- a/api/externals/handler/sponsor_style_handler.go +++ b/api/externals/handler/sponsor_style_handler.go @@ -2,6 +2,7 @@ package handler import ( "net/http" + "strconv" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" @@ -35,9 +36,9 @@ func (h *Handler) PostSponsorstyles(c echo.Context) error { } // router.DELETE(baseURL+"/sponsorstyles/:id", wrapper.DeleteSponsorstylesId) -func (h *Handler) DeleteSponsorstylesId(c echo.Context) error { - id := c.Param("id") - err := h.sponsorStyleUseCase.DestroySponsorStyle(c.Request().Context(), id) +func (h *Handler) DeleteSponsorstylesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.sponsorStyleUseCase.DestroySponsorStyle(c.Request().Context(), idStr) if err != nil { return err } @@ -45,9 +46,9 @@ func (h *Handler) DeleteSponsorstylesId(c echo.Context) error { } // router.GET(baseURL+"/sponsorstyles/:id", wrapper.GetSponsorstylesId) -func (h *Handler) GetSponsorstylesId(c echo.Context) error { - id := c.Param("id") - sponsorstyle, err := h.sponsorStyleUseCase.GetSponsorStylesByID(c.Request().Context(), id) +func (h *Handler) GetSponsorstylesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + sponsorstyle, err := h.sponsorStyleUseCase.GetSponsorStylesByID(c.Request().Context(), idStr) if err != nil { return err } @@ -55,14 +56,14 @@ func (h *Handler) GetSponsorstylesId(c echo.Context) error { } // router.PUT(baseURL+"/sponsorstyles/:id", wrapper.PutSponsorstylesId) -func (h *Handler) PutSponsorstylesId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutSponsorstylesId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) sponsorstyle := new(domain.SponsorStyle) if err := c.Bind(sponsorstyle); err != nil { return err } - updatedSponsorstyle, err := h.sponsorStyleUseCase.UpdateSponsorStyle(c.Request().Context(), id, sponsorstyle.Style, sponsorstyle.Feature, sponsorstyle.Price) + updatedSponsorstyle, err := h.sponsorStyleUseCase.UpdateSponsorStyle(c.Request().Context(), idStr, sponsorstyle.Style, sponsorstyle.Feature, sponsorstyle.Price) if err != nil { return err } diff --git a/api/externals/handler/teacher_handler.go b/api/externals/handler/teacher_handler.go index a6a7f1ae5..a747b0364 100644 --- a/api/externals/handler/teacher_handler.go +++ b/api/externals/handler/teacher_handler.go @@ -2,7 +2,9 @@ package handler import ( "net/http" + "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) @@ -17,14 +19,14 @@ func (h *Handler) GetTeachers(c echo.Context) error { } // router.POST(baseURL+"/teachers", wrapper.PostTeachers) -func (h *Handler) PostTeachers(c echo.Context) error { - name := c.QueryParam("name") - position := c.QueryParam("position") - departmentID := c.QueryParam("department_id") - room := c.QueryParam("room") - isBlack := c.QueryParam("is_black") - remark := c.QueryParam("remark") - latestTeacher, err := h.teacherUseCase.CreateTeacher(c.Request().Context(), name, position, departmentID, room, isBlack, remark) +func (h *Handler) PostTeachers(c echo.Context, params generated.PostTeachersParams) error { + name := params.Name + position := params.Position + departmentID := strconv.Itoa(*params.DepartmentId) + room := params.Room + isBlack := strconv.FormatBool(*params.IsBlack) + remark := params.Remark + latestTeacher, err := h.teacherUseCase.CreateTeacher(c.Request().Context(), name, position, departmentID, *room, isBlack, *remark) if err != nil { return err } @@ -46,9 +48,9 @@ func (h *Handler) DeleteTeachersDelete(c echo.Context) error { } // router.GET(baseURL+"/teachers/fundRegistered/:year", wrapper.GetTeachersFundRegisteredYear) -func (h *Handler) GetTeachersFundRegisteredYear(c echo.Context) error { - year := c.Param("year") - fundRegisteredTeachers, err := h.teacherUseCase.GetFundRegisteredByPeriods(c.Request().Context(), year) +func (h *Handler) GetTeachersFundRegisteredYear(c echo.Context, year int) error { + yearStr := strconv.Itoa(year) + fundRegisteredTeachers, err := h.teacherUseCase.GetFundRegisteredByPeriods(c.Request().Context(), yearStr) if err != nil { return err } @@ -56,9 +58,9 @@ func (h *Handler) GetTeachersFundRegisteredYear(c echo.Context) error { } // router.DELETE(baseURL+"/teachers/:id", wrapper.DeleteTeachersId) -func (h *Handler) DeleteTeachersId(c echo.Context) error { - id := c.Param("id") - err := h.teacherUseCase.DestroyTeacher(c.Request().Context(), id) +func (h *Handler) DeleteTeachersId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.teacherUseCase.DestroyTeacher(c.Request().Context(), idStr) if err != nil { return err } @@ -66,9 +68,9 @@ func (h *Handler) DeleteTeachersId(c echo.Context) error { } // router.GET(baseURL+"/teachers/:id", wrapper.GetTeachersId) -func (h *Handler) GetTeachersId(c echo.Context) error { - id := c.Param("id") - teacher, err := h.teacherUseCase.GetTeacherByID(c.Request().Context(), id) +func (h *Handler) GetTeachersId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + teacher, err := h.teacherUseCase.GetTeacherByID(c.Request().Context(), idStr) if err != nil { return err } @@ -76,15 +78,15 @@ func (h *Handler) GetTeachersId(c echo.Context) error { } // router.PUT(baseURL+"/teachers/:id", wrapper.PutTeachersId) -func (h *Handler) PutTeachersId(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - position := c.QueryParam("position") - departmentID := c.QueryParam("department_id") - room := c.QueryParam("room") - isBlack := c.QueryParam("is_black") - remark := c.QueryParam("remark") - updateTeacher, err := h.teacherUseCase.UpdateTeacher(c.Request().Context(), id, name, position, departmentID, room, isBlack, remark) +func (h *Handler) PutTeachersId(c echo.Context, id int, params generated.PutTeachersIdParams) error { + idStr := strconv.Itoa(id) + name := params.Name + position := params.Position + departmentID := strconv.Itoa(*params.DepartmentId) + room := params.Room + isBlack := strconv.FormatBool(*params.IsBlack) + remark := params.Remark + updateTeacher, err := h.teacherUseCase.UpdateTeacher(c.Request().Context(), idStr, name, position, departmentID, *room, isBlack, *remark) if err != nil { return err } diff --git a/api/externals/handler/user_handler.go b/api/externals/handler/user_handler.go index 1b4883c10..84419153d 100644 --- a/api/externals/handler/user_handler.go +++ b/api/externals/handler/user_handler.go @@ -2,7 +2,9 @@ package handler import ( "net/http" + "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) @@ -17,10 +19,10 @@ func (h *Handler) GetUsers(c echo.Context) error { } // router.POST(baseURL+"/users", wrapper.PostUsers) -func (h *Handler) PostUsers(c echo.Context) error { - name := c.QueryParam("name") - bureauID := c.QueryParam("bureau_id") - roleID := c.QueryParam("role_id") +func (h *Handler) PostUsers(c echo.Context, params generated.PostUsersParams) error { + name := params.Name + bureauID := strconv.Itoa(params.BureauId) + roleID := strconv.Itoa(params.RoleId) latastUser, err := h.userUseCase.CreateUser(c.Request().Context(), name, bureauID, roleID) if err != nil { return err @@ -42,9 +44,9 @@ func (h *Handler) DeleteUsersDelete(c echo.Context) error { } // router.DELETE(baseURL+"/users/:id", wrapper.DeleteUsersId) -func (h *Handler) DeleteUsersId(c echo.Context) error { - id := c.Param("id") - err := h.userUseCase.DestroyUser(c.Request().Context(), id) +func (h *Handler) DeleteUsersId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.userUseCase.DestroyUser(c.Request().Context(), idStr) if err != nil { return err } @@ -52,9 +54,9 @@ func (h *Handler) DeleteUsersId(c echo.Context) error { } // router.GET(baseURL+"/users/:id", wrapper.GetUsersId) -func (h *Handler) GetUsersId(c echo.Context) error { - id := c.Param("id") - user, err := h.userUseCase.GetUserByID(c.Request().Context(), id) +func (h *Handler) GetUsersId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + user, err := h.userUseCase.GetUserByID(c.Request().Context(), idStr) if err != nil { return err } @@ -62,12 +64,12 @@ func (h *Handler) GetUsersId(c echo.Context) error { } // router.PUT(baseURL+"/users/:id", wrapper.PutUsersId) -func (h *Handler) PutUsersId(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - bureauID := c.QueryParam("bureau_id") - roleID := c.QueryParam("role_id") - updatedUser, err := h.userUseCase.UpdateUser(c.Request().Context(), id, name, bureauID, roleID) +func (h *Handler) PutUsersId(c echo.Context, id int, params generated.PutUsersIdParams) error { + idStr := strconv.Itoa(id) + name := params.Name + bureauID := strconv.Itoa(params.BureauId) + roleID := strconv.Itoa(params.RoleId) + updatedUser, err := h.userUseCase.UpdateUser(c.Request().Context(), idStr, name, bureauID, roleID) if err != nil { return err } diff --git a/api/externals/handler/year_handler.go b/api/externals/handler/year_handler.go index a6ba19c3f..fd4de5f7e 100644 --- a/api/externals/handler/year_handler.go +++ b/api/externals/handler/year_handler.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" + "github.com/NUTFes/FinanSu/api/generated" "github.com/NUTFes/FinanSu/api/internals/domain" "github.com/labstack/echo/v4" ) @@ -21,8 +22,8 @@ func (h *Handler) GetYears(c echo.Context) error { } // router.POST(baseURL+"/years", wrapper.PostYears) -func (h *Handler) PostYears(c echo.Context) error { - year := c.QueryParam("year") +func (h *Handler) PostYears(c echo.Context, params generated.PostYearsParams) error { + year := strconv.Itoa(params.Year) latestYear, err := h.yearUseCase.CreateYear(c.Request().Context(), year) if err != nil { return err @@ -54,9 +55,9 @@ func (h *Handler) PostYearsPeriods(c echo.Context) error { } // router.DELETE(baseURL+"/years/periods/:id", wrapper.DeleteYearsPeriodsId) -func (h *Handler) DeleteYearsPeriodsId(c echo.Context) error { - id := c.Param("id") - err := h.yearUseCase.DestroyYearPeriod(c.Request().Context(), id) +func (h *Handler) DeleteYearsPeriodsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.yearUseCase.DestroyYearPeriod(c.Request().Context(), idStr) if err != nil { return err } @@ -64,14 +65,14 @@ func (h *Handler) DeleteYearsPeriodsId(c echo.Context) error { } // router.PUT(baseURL+"/years/periods/:id", wrapper.PutYearsPeriodsId) -func (h *Handler) PutYearsPeriodsId(c echo.Context) error { - id := c.Param("id") +func (h *Handler) PutYearsPeriodsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) yearPeriod := new(domain.YearPeriod) if err := c.Bind(yearPeriod); err != nil { fmt.Println("err") return err } - updateYearPeriod, err := h.yearUseCase.UpdateYearPeriod(c.Request().Context(), id, strconv.Itoa(yearPeriod.Year), yearPeriod.StartedAt.Format(Layout), yearPeriod.EndedAt.Format(Layout)) + updateYearPeriod, err := h.yearUseCase.UpdateYearPeriod(c.Request().Context(), idStr, strconv.Itoa(yearPeriod.Year), yearPeriod.StartedAt.Format(Layout), yearPeriod.EndedAt.Format(Layout)) if err != nil { return err } @@ -79,9 +80,9 @@ func (h *Handler) PutYearsPeriodsId(c echo.Context) error { } // router.DELETE(baseURL+"/years/:id", wrapper.DeleteYearsId) -func (h *Handler) DeleteYearsId(c echo.Context) error { - id := c.Param("id") - err := h.yearUseCase.DestroyYear(c.Request().Context(), id) +func (h *Handler) DeleteYearsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + err := h.yearUseCase.DestroyYear(c.Request().Context(), idStr) if err != nil { return err } @@ -89,9 +90,9 @@ func (h *Handler) DeleteYearsId(c echo.Context) error { } // router.GET(baseURL+"/years/:id", wrapper.GetYearsId) -func (h *Handler) GetYearsId(c echo.Context) error { - id := c.Param("id") - year, err := h.yearUseCase.GetYearByID(c.Request().Context(), id) +func (h *Handler) GetYearsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + year, err := h.yearUseCase.GetYearByID(c.Request().Context(), idStr) if err != nil { return err } @@ -99,10 +100,10 @@ func (h *Handler) GetYearsId(c echo.Context) error { } // router.PUT(baseURL+"/years/:id", wrapper.PutYearsId) -func (h *Handler) PutYearsId(c echo.Context) error { - id := c.Param("id") - year := c.QueryParam("year") - updatedYear, err := h.yearUseCase.UpdateYear(c.Request().Context(), id, year) +func (h *Handler) PutYearsId(c echo.Context, id int, params generated.PutYearsIdParams) error { + idStr := strconv.Itoa(id) + year := strconv.Itoa(params.Year) + updatedYear, err := h.yearUseCase.UpdateYear(c.Request().Context(), idStr, year) if err != nil { return err } From c8e0611848f4836c09decd527a2130f120089376 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Tue, 4 Feb 2025 23:28:33 +0900 Subject: [PATCH 08/14] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/externals/handler/mail_auth_handler.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/api/externals/handler/mail_auth_handler.go b/api/externals/handler/mail_auth_handler.go index a91a05080..682b50c99 100644 --- a/api/externals/handler/mail_auth_handler.go +++ b/api/externals/handler/mail_auth_handler.go @@ -1,7 +1,6 @@ package handler import ( - "fmt" "net/http" "strconv" @@ -13,7 +12,6 @@ import ( func (h *Handler) GetMailAuthIsSignin(c echo.Context, params generated.GetMailAuthIsSigninParams) error { // headerからトークンを取得する accessToken := params.AccessToken - fmt.Println(accessToken) isSignIn, err := h.mailAuthUseCase.IsSignIn(c.Request().Context(), *accessToken) if err != nil { return nil @@ -26,7 +24,6 @@ func (h *Handler) GetMailAuthIsSignin(c echo.Context, params generated.GetMailAu func (h *Handler) PostMailAuthSignin(c echo.Context, params generated.PostMailAuthSigninParams) error { email := params.Email password := params.Password - fmt.Println(email, password) token, err := h.mailAuthUseCase.SignIn(c.Request().Context(), email, password) if err != nil { return err From c8dfb6bd6ea0da5c7021060748569d7b7eed1c84 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Wed, 5 Feb 2025 21:55:10 +0900 Subject: [PATCH 09/14] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/drivers/server/server.go | 32 +------------ api/internals/di/di.go | 87 +----------------------------------- 2 files changed, 2 insertions(+), 117 deletions(-) diff --git a/api/drivers/server/server.go b/api/drivers/server/server.go index f1353360c..c4519fbba 100644 --- a/api/drivers/server/server.go +++ b/api/drivers/server/server.go @@ -6,41 +6,11 @@ import ( "github.com/NUTFes/FinanSu/api/externals/handler" "github.com/NUTFes/FinanSu/api/generated" - "github.com/NUTFes/FinanSu/api/router" echo "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" ) -func RunServer(router router.Router) *echo.Echo { - // echoのインスタンス - e := echo.New() - - // Middleware - e.Use(middleware.Recover()) - - // log - logger := middleware.LoggerWithConfig( - middleware.LoggerConfig{ - Format: logFormat(), - Output: os.Stdout, - }, - ) - e.Use(logger) - - // CORS対策 - e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ - AllowOrigins: []string{"http://localhost:3000", "127.0.0.1:3000", "http://localhost:3001", "127.0.0.1:3001", "http://localhost:8000", "127.0.0.1:8000", "https://finansu.nutfes.net"}, // ドメイン - AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete}, - })) - - // ルーティング - router.ProvideRouter(e) - - // サーバー起動 - return e -} - -func RunServer2(server *handler.Handler) *echo.Echo { +func RunServer(server *handler.Handler) *echo.Echo { // echoのインスタンス e := echo.New() diff --git a/api/internals/di/di.go b/api/internals/di/di.go index 32ac56acb..502c64882 100644 --- a/api/internals/di/di.go +++ b/api/internals/di/di.go @@ -7,12 +7,10 @@ import ( "github.com/NUTFes/FinanSu/api/drivers/db" "github.com/NUTFes/FinanSu/api/drivers/mc" "github.com/NUTFes/FinanSu/api/drivers/server" - "github.com/NUTFes/FinanSu/api/externals/controller" "github.com/NUTFes/FinanSu/api/externals/handler" "github.com/NUTFes/FinanSu/api/externals/repository" "github.com/NUTFes/FinanSu/api/externals/repository/abstract" "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/NUTFes/FinanSu/api/router" "github.com/labstack/echo/v4" ) @@ -36,24 +34,17 @@ func InitializeServer() (db.Client, *echo.Echo) { activityRepository := repository.NewActivityRepository(client, crud) activityInformationRepository := repository.NewActivityInformationsRepository(client, crud) activityStyleRepository := repository.NewActivityStyleRepository(client, crud) - budgetRepository := repository.NewBudgetRepository(client, crud) bureauRepository := repository.NewBureauRepository(client, crud) buyReportRepository := repository.NewBuyReportRepository(client, crud) departmentRepository := repository.NewDepartmentRepository(client, crud) divisionRepository := repository.NewDivisionRepository(client, crud) - expenseRepository := repository.NewExpenseRepository(client, crud) festivalItemRepository := repository.NewFestivalItemRepository(client, crud) financialRecordRepository := repository.NewFinancialRecordRepository(client, crud) fundInformationRepository := repository.NewFundInformationRepository(client, crud) mailAuthRepository := repository.NewMailAuthRepository(client, crud) objectHandleRepository := repository.NewObjectHandleRepository(minioClient) passwordResetTokenRepository := repository.NewPasswordResetTokenRepository(client, crud) - purchaseItemRepository := repository.NewPurchaseItemRepository(client, crud) - purchaseOrderRepository := repository.NewPurchaseOrderRepository(client, crud) - purchaseReportRepository := repository.NewPurchaseReportRepository(client, crud) - receiptRepository := repository.NewReceiptRepository(client, crud) sessionRepository := repository.NewSessionRepository(client) - sourceRepository := repository.NewSourceRepository(client, crud) sponsorRepository := repository.NewSponsorRepository(client, crud) sponsorStyleRepository := repository.NewSponsorStyleRepository(client, crud) teacherRepository := repository.NewTeacherRepository(client, crud) @@ -68,12 +59,10 @@ func InitializeServer() (db.Client, *echo.Echo) { activityInformationRepository, ) activityStyleUseCase := usecase.NewActivityStyleUseCase(activityStyleRepository) - budgetUseCase := usecase.NewBudgetUseCase(budgetRepository) bureauUseCase := usecase.NewBureauUseCase(bureauRepository) buyReportUseCase := usecase.NewBuyReportUseCase(buyReportRepository, transactionRepository, objectHandleRepository) departmentUseCase := usecase.NewDepartmentUseCase(departmentRepository) divisionUseCase := usecase.NewDivisionUseCase(divisionRepository) - expenseUseCase := usecase.NewExpenseUseCase(expenseRepository) festivalUseCase := usecase.NewFestivalItemUseCase(festivalItemRepository, transactionRepository) financialRecordUseCase := usecase.NewFinancialRecordUseCase(financialRecordRepository) fundInformationUseCase := usecase.NewFundInformationUseCase(fundInformationRepository) @@ -84,15 +73,6 @@ func InitializeServer() (db.Client, *echo.Echo) { userRepository, mailAuthRepository, ) - purchaseItemUseCase := usecase.NewPurchaseItemUseCase(purchaseItemRepository) - purchaseOrderUseCase := usecase.NewPurchaseOrderUseCase( - purchaseOrderRepository, - bureauRepository, - expenseRepository, - ) - purchaseReportUseCase := usecase.NewPurchaseReportUseCase(purchaseReportRepository) - receiptUseCase := usecase.NewReceiptUseCase(receiptRepository) - sourceUseCase := usecase.NewSourceUseCase(sourceRepository) sponsorUseCase := usecase.NewSponsorUseCase(sponsorRepository) sponsorStyleUseCase := usecase.NewSponsorStyleUseCase(sponsorStyleRepository) teacherUseCase := usecase.NewTeacherUseCase(teacherRepository) @@ -100,71 +80,6 @@ func InitializeServer() (db.Client, *echo.Echo) { yearUseCase := usecase.NewYearUseCase(yearRepository) // ↓ - // Controller - activityController := controller.NewActivityController(activityUseCase) - activityInformationController := controller.NewActivityInformationController( - activityInformationUseCase, - ) - activityStyleController := controller.NewActivityStyleController(activityStyleUseCase) - budgetController := controller.NewBudgetController(budgetUseCase) - bureauController := controller.NewBureauController(bureauUseCase) - buyReportContoroller := controller.NewBuyReportController(buyReportUseCase) - departmentController := controller.NewDepartmentController(departmentUseCase) - divisionController := controller.NewDivisionController(divisionUseCase) - expenseController := controller.NewExpenseController(expenseUseCase) - festivalItemController := controller.NewFestivalItemController(festivalUseCase) - financialRecordController := controller.NewFinancialRecordController(financialRecordUseCase) - fundInformationController := controller.NewFundInformationController(fundInformationUseCase) - healthcheckController := controller.NewHealthCheckController() - mailAuthController := controller.NewMailAuthController(mailAuthUseCase) - objectUploadController := controller.NewObjectUploadController(objectHandleUseCase) - passwordResetTokenController := controller.NewPasswordResetTokenController( - passwordResetTokenUseCase, - ) - purchaseItemController := controller.NewPurchaseItemController(purchaseItemUseCase) - purchaseOrderController := controller.NewPurchaseOrderController(purchaseOrderUseCase) - purchaseReportController := controller.NewPurchaseReportController(purchaseReportUseCase) - receiptController := controller.NewReceiptController(receiptUseCase) - sourceController := controller.NewSourceController(sourceUseCase) - sponsorController := controller.NewSponsorController(sponsorUseCase) - sponsorStyleController := controller.NewSponsorStyleController(sponsorStyleUseCase) - teacherController := controller.NewTeacherController(teacherUseCase) - userController := controller.NewUserController(userUseCase) - yearController := controller.NewYearController(yearUseCase) - // ↓ - - // router - router := router.NewRouter( - activityController, - activityInformationController, - activityStyleController, - budgetController, - bureauController, - buyReportContoroller, - departmentController, - divisionController, - expenseController, - festivalItemController, - financialRecordController, - fundInformationController, - healthcheckController, - mailAuthController, - objectUploadController, - passwordResetTokenController, - purchaseItemController, - purchaseOrderController, - purchaseReportController, - receiptController, - sourceController, - sponsorController, - sponsorStyleController, - teacherController, - userController, - yearController, - ) - - fmt.Println("router", router) - handler := handler.NewHandler( activityUseCase, activityInformationUseCase, @@ -187,7 +102,7 @@ func InitializeServer() (db.Client, *echo.Echo) { ) // Server - e := server.RunServer2(handler) + e := server.RunServer(handler) return client, e } From 30cac64d7b15c2c0a855383f3c46ced3ffad9bf8 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Fri, 26 Sep 2025 22:21:19 +0900 Subject: [PATCH 10/14] gen --- api/externals/handler/handler.go | 77 ++++++++++--------- .../model/deleteMailAuthSignout200.ts | 2 +- .../generated/model/getMailAuthIsSignin200.ts | 2 +- .../generated/model/postMailAuthSignin200.ts | 2 +- .../model/postMailAuthSigninParams.ts | 2 +- .../generated/model/postMailAuthSignup200.ts | 2 +- .../model/postMailAuthSignupParams.ts | 2 +- 7 files changed, 46 insertions(+), 43 deletions(-) diff --git a/api/externals/handler/handler.go b/api/externals/handler/handler.go index 0aca48e5f..56a88a936 100644 --- a/api/externals/handler/handler.go +++ b/api/externals/handler/handler.go @@ -5,24 +5,25 @@ import ( ) type Handler struct { - activityUseCase usecase.ActivityUseCase - activityInformationUseCase usecase.ActivityInformationUseCase - activityStyleUseCase usecase.ActivityStyleUseCase - bureauUseCase usecase.BureauUseCase - buyReportUseCase usecase.BuyReportUseCase - departmentUseCase usecase.DepartmentUseCase - divisionUseCase usecase.DivisionUseCase - festivalItemUseCase usecase.FestivalItemUseCase - financialRecordUseCase usecase.FinancialRecordUseCase - fundInformationUseCase usecase.FundInformationUseCase - mailAuthUseCase usecase.MailAuthUseCase - objectUploadUseCase usecase.ObjectUploadUseCase - passwordResetTokenUseCase usecase.PasswordResetTokenUseCase - sponsorUseCase usecase.SponsorUseCase - sponsorStyleUseCase usecase.SponsorStyleUseCase - teacherUseCase usecase.TeacherUseCase - userUseCase usecase.UserUseCase - yearUseCase usecase.YearUseCase + activityUseCase usecase.ActivityUseCase + activityInformationUseCase usecase.ActivityInformationUseCase + activityStyleUseCase usecase.ActivityStyleUseCase + bureauUseCase usecase.BureauUseCase + buyReportUseCase usecase.BuyReportUseCase + departmentUseCase usecase.DepartmentUseCase + divisionUseCase usecase.DivisionUseCase + festivalItemUseCase usecase.FestivalItemUseCase + financialRecordUseCase usecase.FinancialRecordUseCase + incomeUseCase usecase.IncomeUseCase + incomeExpenditureManagementUseCase usecase.IncomeExpenditureManagementUseCase + mailAuthUseCase usecase.MailAuthUseCase + objectUploadUseCase usecase.ObjectUploadUseCase + passwordResetTokenUseCase usecase.PasswordResetTokenUseCase + sponsorUseCase usecase.SponsorUseCase + sponsorStyleUseCase usecase.SponsorStyleUseCase + teacherUseCase usecase.TeacherUseCase + userUseCase usecase.UserUseCase + yearUseCase usecase.YearUseCase } func NewHandler( @@ -35,7 +36,8 @@ func NewHandler( divisionUseCase usecase.DivisionUseCase, festivalItemUseCase usecase.FestivalItemUseCase, financialRecordUseCase usecase.FinancialRecordUseCase, - fundInformationUseCase usecase.FundInformationUseCase, + incomeUseCase usecase.IncomeUseCase, + incomeExpenditureManagementUseCase usecase.IncomeExpenditureManagementUseCase, mailAuthUseCase usecase.MailAuthUseCase, objectUploadUseCase usecase.ObjectUploadUseCase, passwordResetTokenUseCase usecase.PasswordResetTokenUseCase, @@ -46,23 +48,24 @@ func NewHandler( yearUseCase usecase.YearUseCase, ) *Handler { return &Handler{ - activityUseCase: activityUseCase, - activityInformationUseCase: activityInformationUseCase, - activityStyleUseCase: activityStyleUseCase, - bureauUseCase: bureauUseCase, - buyReportUseCase: buyReportUseCase, - departmentUseCase: departmentUseCase, - divisionUseCase: divisionUseCase, - festivalItemUseCase: festivalItemUseCase, - financialRecordUseCase: financialRecordUseCase, - fundInformationUseCase: fundInformationUseCase, - mailAuthUseCase: mailAuthUseCase, - objectUploadUseCase: objectUploadUseCase, - passwordResetTokenUseCase: passwordResetTokenUseCase, - sponsorUseCase: sponsorUseCase, - sponsorStyleUseCase: sponsorStyleUseCase, - teacherUseCase: teacherUseCase, - userUseCase: userUseCase, - yearUseCase: yearUseCase, + activityUseCase: activityUseCase, + activityInformationUseCase: activityInformationUseCase, + activityStyleUseCase: activityStyleUseCase, + bureauUseCase: bureauUseCase, + buyReportUseCase: buyReportUseCase, + departmentUseCase: departmentUseCase, + divisionUseCase: divisionUseCase, + festivalItemUseCase: festivalItemUseCase, + financialRecordUseCase: financialRecordUseCase, + incomeUseCase: incomeUseCase, + incomeExpenditureManagementUseCase: incomeExpenditureManagementUseCase, + mailAuthUseCase: mailAuthUseCase, + objectUploadUseCase: objectUploadUseCase, + passwordResetTokenUseCase: passwordResetTokenUseCase, + sponsorUseCase: sponsorUseCase, + sponsorStyleUseCase: sponsorStyleUseCase, + teacherUseCase: teacherUseCase, + userUseCase: userUseCase, + yearUseCase: yearUseCase, } } diff --git a/view/next-project/src/generated/model/deleteMailAuthSignout200.ts b/view/next-project/src/generated/model/deleteMailAuthSignout200.ts index 7b3e295c5..8d57600de 100644 --- a/view/next-project/src/generated/model/deleteMailAuthSignout200.ts +++ b/view/next-project/src/generated/model/deleteMailAuthSignout200.ts @@ -1,5 +1,5 @@ /** - * Generated by orval v7.3.0 🍺 + * Generated by orval v7.6.0 🍺 * Do not edit manually. * NUTFes FinanSu API * FinanSu APIドキュメント diff --git a/view/next-project/src/generated/model/getMailAuthIsSignin200.ts b/view/next-project/src/generated/model/getMailAuthIsSignin200.ts index 2d50082b2..5359a4144 100644 --- a/view/next-project/src/generated/model/getMailAuthIsSignin200.ts +++ b/view/next-project/src/generated/model/getMailAuthIsSignin200.ts @@ -1,5 +1,5 @@ /** - * Generated by orval v7.3.0 🍺 + * Generated by orval v7.6.0 🍺 * Do not edit manually. * NUTFes FinanSu API * FinanSu APIドキュメント diff --git a/view/next-project/src/generated/model/postMailAuthSignin200.ts b/view/next-project/src/generated/model/postMailAuthSignin200.ts index b760f08b9..9730d95b4 100644 --- a/view/next-project/src/generated/model/postMailAuthSignin200.ts +++ b/view/next-project/src/generated/model/postMailAuthSignin200.ts @@ -1,5 +1,5 @@ /** - * Generated by orval v7.3.0 🍺 + * Generated by orval v7.6.0 🍺 * Do not edit manually. * NUTFes FinanSu API * FinanSu APIドキュメント diff --git a/view/next-project/src/generated/model/postMailAuthSigninParams.ts b/view/next-project/src/generated/model/postMailAuthSigninParams.ts index fbedccc3c..f043353ce 100644 --- a/view/next-project/src/generated/model/postMailAuthSigninParams.ts +++ b/view/next-project/src/generated/model/postMailAuthSigninParams.ts @@ -1,5 +1,5 @@ /** - * Generated by orval v7.3.0 🍺 + * Generated by orval v7.6.0 🍺 * Do not edit manually. * NUTFes FinanSu API * FinanSu APIドキュメント diff --git a/view/next-project/src/generated/model/postMailAuthSignup200.ts b/view/next-project/src/generated/model/postMailAuthSignup200.ts index 91bf9b3c1..5fe10ffb7 100644 --- a/view/next-project/src/generated/model/postMailAuthSignup200.ts +++ b/view/next-project/src/generated/model/postMailAuthSignup200.ts @@ -1,5 +1,5 @@ /** - * Generated by orval v7.3.0 🍺 + * Generated by orval v7.6.0 🍺 * Do not edit manually. * NUTFes FinanSu API * FinanSu APIドキュメント diff --git a/view/next-project/src/generated/model/postMailAuthSignupParams.ts b/view/next-project/src/generated/model/postMailAuthSignupParams.ts index a0f7c19f0..067553730 100644 --- a/view/next-project/src/generated/model/postMailAuthSignupParams.ts +++ b/view/next-project/src/generated/model/postMailAuthSignupParams.ts @@ -1,5 +1,5 @@ /** - * Generated by orval v7.3.0 🍺 + * Generated by orval v7.6.0 🍺 * Do not edit manually. * NUTFes FinanSu API * FinanSu APIドキュメント From dad9492acbec52532f9c3d2e0879943c61f32324 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Fri, 26 Sep 2025 23:02:18 +0900 Subject: [PATCH 11/14] =?UTF-8?q?handler=E3=81=8A=E5=BC=95=E8=B6=8A?= =?UTF-8?q?=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/externals/handler/buy_report_handler.go | 109 ++++ api/externals/handler/division_handler.go | 33 + .../handler/festival_item_handler.go | 24 + .../handler/financial_record_handler.go | 61 ++ .../handler/fund_information_handler.go | 102 --- .../income_expenditure_management_handler.go | 41 ++ api/externals/handler/income_handler.go | 79 +++ api/generated/openapi_gen.go | 209 ------- openapi/openapi.yaml | 173 ------ view/next-project/src/generated/hooks.ts | 583 ------------------ 10 files changed, 347 insertions(+), 1067 deletions(-) delete mode 100644 api/externals/handler/fund_information_handler.go create mode 100644 api/externals/handler/income_expenditure_management_handler.go create mode 100644 api/externals/handler/income_handler.go diff --git a/api/externals/handler/buy_report_handler.go b/api/externals/handler/buy_report_handler.go index cd52a64cc..1c0835b99 100644 --- a/api/externals/handler/buy_report_handler.go +++ b/api/externals/handler/buy_report_handler.go @@ -1,12 +1,17 @@ package handler import ( + "encoding/csv" "encoding/json" + "fmt" "net/http" "strconv" + "time" "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" + "golang.org/x/text/encoding/japanese" + "golang.org/x/text/transform" ) // router.PUT(baseURL+"/buy_report/status/:buy_report_id", wrapper.PutBuyReportStatusBuyReportId) @@ -86,4 +91,108 @@ func (h *Handler) PutBuyReportsId(c echo.Context, id int) error { return c.JSON(http.StatusOK, buyReportInfo) } +// router.GET(baseURL+"/buy_reports/:id", wrapper.GetBuyReportsId) +func (h *Handler) GetBuyReportsId(c echo.Context, id int) error { + ctx := c.Request().Context() + + buyReportDetail, err := h.buyReportUseCase.GetBuyReportById(ctx, strconv.Itoa(id)) + if err != nil { + return c.String(http.StatusBadRequest, "failed to buy_report") + } + + return c.JSON(http.StatusOK, buyReportDetail) +} + +// router.GET(baseURL+"/buy_reports/csv", wrapper.GetBuyReportsCsvDownload) +func (h *Handler) GetBuyReportsCsvDownload(c echo.Context, params generated.GetBuyReportsCsvDownloadParams) error { + ctx := c.Request().Context() + year := strconv.Itoa(*params.Year) + + buyReportDetails, err := h.buyReportUseCase.GetBuyReports(ctx, year) + if err != nil { + return err + } + + // CSVデータの準備 + records := make([][]string, 0, len(buyReportDetails)+1) + + // ヘッダー + header := []string{"年度", "日付", "局名", "部門", "物品", "立替者", "金額", "封詰め", "清算完了"} + records = append(records, header) + + // データ行を追加 + for _, detail := range buyReportDetails { + yearStr := "" + if detail.Year != nil { + yearStr = strconv.Itoa(*detail.Year) + } + + // 封詰めと清算完了のステータスを「未」「済」で表示 + packedStatus := "未" + if detail.IsPacked { + packedStatus = "済" + } + settledStatus := "未" + if detail.IsSettled { + settledStatus = "済" + } + + reportDateStr := detail.ReportDate + t, err := time.Parse(time.RFC3339, reportDateStr) + if err == nil { + reportDateStr = t.Format("2006年1月2日") + } + + record := []string{ + yearStr, + reportDateStr, + detail.FinancialRecordName, + detail.DivisionName, + detail.FestivalItemName, + detail.PaidBy, + strconv.Itoa(detail.Amount), + packedStatus, + settledStatus, + } + records = append(records, record) + } + + // ヘッダーの設定 + w := c.Response().Writer + fileName := fmt.Sprintf("purchase_reports_%s.csv", year) + attachment := fmt.Sprintf(`attachment; filename="%s"`, fileName) + w.Header().Set("Content-Type", "text/csv") + w.Header().Set("Content-Disposition", attachment) + + if err := makeBuyReportCSV(w, records); err != nil { + return err + } + + return nil +} + +func makeBuyReportCSV(writer http.ResponseWriter, records [][]string) error { + // Shift_JISエンコーディング用の変換を設定 + encoder := japanese.ShiftJIS.NewEncoder() + + // writerに対してエンコーダを設定して変換する + shiftJISWriter := transform.NewWriter(writer, encoder) + + // CSVライターを作成 + 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 +} + type BuyReport = generated.BuyReport diff --git a/api/externals/handler/division_handler.go b/api/externals/handler/division_handler.go index 74b8ba390..480defb67 100644 --- a/api/externals/handler/division_handler.go +++ b/api/externals/handler/division_handler.go @@ -36,6 +36,16 @@ func (h *Handler) PostDivisions(c echo.Context) error { return c.JSON(http.StatusOK, latestDivision) } +// router.GET(baseURL+"/divisions/:id", wrapper.GetDivisionsId) +func (h *Handler) GetDivisionsId(c echo.Context, id int) error { + ctx := c.Request().Context() + division, err := h.divisionUseCase.GetDivision(ctx, strconv.Itoa(id)) + if err != nil { + return err + } + return c.JSON(http.StatusOK, division) +} + // router.DELETE(baseURL+"/divisions/:id", wrapper.DeleteDivisionsId) func (h *Handler) DeleteDivisionsId(c echo.Context, id int) error { ctx := c.Request().Context() @@ -63,6 +73,29 @@ func (h *Handler) PutDivisionsId(c echo.Context, id int) error { return c.JSON(http.StatusOK, updatedDivision) } +// GetDivisionsUsers +func (h *Handler) GetDivisionsUsers(c echo.Context, params generated.GetDivisionsUsersParams) error { + ctx := c.Request().Context() + + divisionOptions, err := h.divisionUseCase.GetDivisionOptions(ctx, strconv.Itoa(*params.Year), strconv.Itoa(params.UserId)) + if err != nil { + return err + } + return c.JSON(http.StatusOK, divisionOptions) +} + +// GetDivisionsYears +func (h *Handler) GetDivisionsYears(c echo.Context, params generated.GetDivisionsYearsParams) error { + ctx := c.Request().Context() + + // Retrieve division options for each year from the usecase layer. + divisions, err := h.divisionUseCase.GetDivisionsYears(ctx, strconv.Itoa(*params.Year)) + if err != nil { + return err + } + return c.JSON(http.StatusOK, divisions) +} + type ( Division = generated.Division DivisionDetails = generated.DivisionDetails diff --git a/api/externals/handler/festival_item_handler.go b/api/externals/handler/festival_item_handler.go index bb877ce4c..ffd832455 100644 --- a/api/externals/handler/festival_item_handler.go +++ b/api/externals/handler/festival_item_handler.go @@ -81,6 +81,30 @@ func (h *Handler) PutFestivalItemsId(c echo.Context, id int) error { return c.JSON(http.StatusOK, updatedFestivalItem) } +// GetFestivalItemsId +func (h *Handler) GetFestivalItemsId(c echo.Context, id int) error { + ctx := c.Request().Context() + idStr := strconv.Itoa(id) + festivalItem, err := h.festivalItemUseCase.GetFestivalItem(ctx, idStr) + if err != nil { + return err + } + return c.JSON(http.StatusOK, festivalItem) +} + +// GetFestivalItemsUsers +func (h *Handler) GetFestivalItemsUsers(c echo.Context, params generated.GetFestivalItemsUsersParams) error { + ctx := c.Request().Context() + year := strconv.Itoa(*params.Year) + divisionId := strconv.Itoa(params.DivisionId) + + festivalItemOptions, err := h.festivalItemUseCase.GetFestivalItemOptions(ctx, year, divisionId) + if err != nil { + return err + } + return c.JSON(http.StatusOK, festivalItemOptions) +} + type FestivalItemDetails = generated.FestivalItemDetails type FestivalItem = generated.FestivalItem type FestivalItemsForMyPage = generated.FestivalItemsForMyPage diff --git a/api/externals/handler/financial_record_handler.go b/api/externals/handler/financial_record_handler.go index 42a8ba120..c8aea2124 100644 --- a/api/externals/handler/financial_record_handler.go +++ b/api/externals/handler/financial_record_handler.go @@ -1,11 +1,15 @@ package handler import ( + "encoding/csv" + "fmt" "net/http" "strconv" "github.com/NUTFes/FinanSu/api/generated" "github.com/labstack/echo/v4" + "golang.org/x/text/encoding/japanese" + "golang.org/x/text/transform" ) // router.GET(baseURL+"/financial_records", wrapper.GetFinancialRecords) @@ -60,5 +64,62 @@ func (h *Handler) PutFinancialRecordsId(c echo.Context, id int) error { return c.JSON(http.StatusOK, updatedFinancialRecord) } +// GetFinancialRecordsId +func (h *Handler) GetFinancialRecordsId(c echo.Context, id int) error { + idStr := strconv.Itoa(id) + financialRecord, err := h.financialRecordUseCase.GetFinancialRecord(c.Request().Context(), idStr) + if err != nil { + return err + } + return c.JSON(http.StatusOK, financialRecord) +} + +// GetFinancialRecordsCsvDownload(ctx echo.Context, params GetFinancialRecordsCsvDownloadParams) error +func (h *Handler) GetFinancialRecordsCsvDownload(c echo.Context, params generated.GetFinancialRecordsCsvDownloadParams) error { + var err error + year := strconv.Itoa(params.Year) + records, err := h.financialRecordUseCase.GetFinancialRecordDetailForCSV(c.Request().Context(), year) + if err != nil { + return err + } + + // ヘッダーの設定 + w := c.Response().Writer + fileName := fmt.Sprintf("予算_%s.csv", year) + attachment := fmt.Sprintf(`attachment; filename="%s"`, fileName) + w.Header().Set("Content-Type", "text/csv") + w.Header().Set("Content-Disposition", attachment) + + if err := makeCSV(w, records); err != nil { + return err + } + + return nil +} + +func makeCSV(writer http.ResponseWriter, records [][]string) error { + // Shift_JISエンコーディング用の変換を設定 + encoder := japanese.ShiftJIS.NewEncoder() + + // writerに対してエンコーダを設定して変換する + shiftJISWriter := transform.NewWriter(writer, encoder) + + // CSVライターを作成 + 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 +} + type FinancialRecordDetails = generated.FinancialRecordDetails type FinancialRecord = generated.FinancialRecord diff --git a/api/externals/handler/fund_information_handler.go b/api/externals/handler/fund_information_handler.go deleted file mode 100644 index 543726da0..000000000 --- a/api/externals/handler/fund_information_handler.go +++ /dev/null @@ -1,102 +0,0 @@ -package handler - -import ( - "net/http" - "strconv" - - "github.com/NUTFes/FinanSu/api/generated" - "github.com/labstack/echo/v4" -) - -// router.GET(baseURL+"/fund_informations", wrapper.GetFundInformations) -func (h *Handler) GetFundInformations(c echo.Context) error { - fundInformations, err := h.fundInformationUseCase.GetFundInformations(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, fundInformations) -} - -// router.POST(baseURL+"/fund_informations", wrapper.PostFundInformations) -func (h *Handler) PostFundInformations(c echo.Context, params generated.PostFundInformationsParams) error { - userID := strconv.Itoa(params.UserId) - teacherID := strconv.Itoa(params.TeacherId) - price := strconv.Itoa(params.Price) - remark := params.Remark - isFirstCheck := strconv.FormatBool(*params.IsFirstCheck) - isLastCheck := strconv.FormatBool(*params.IsLastCheck) - receivedAt := params.ReceivedAt - - latestFundInformation, err := h.fundInformationUseCase.CreateFundInformation(c.Request().Context(), userID, teacherID, price, *remark, isFirstCheck, isLastCheck, *receivedAt) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latestFundInformation) -} - -// router.GET(baseURL+"/fund_informations/details", wrapper.GetFundInformationsDetails) -func (h *Handler) GetFundInformationsDetails(c echo.Context) error { - fundInformationDetails, err := h.fundInformationUseCase.GetFundInformationDetails(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, fundInformationDetails) -} - -// router.GET(baseURL+"/fund_informations/details/:year", wrapper.GetFundInformationsDetailsYear) -func (h *Handler) GetFundInformationsDetailsYear(c echo.Context, year int) error { - yearStr := strconv.Itoa(year) - fundInformationDetails, err := h.fundInformationUseCase.GetFundInformationDetailsByPeriod(c.Request().Context(), yearStr) - if err != nil { - return err - } - return c.JSON(http.StatusOK, fundInformationDetails) -} - -// router.DELETE(baseURL+"/fund_informations/:id", wrapper.DeleteFundInformationsId) -func (h *Handler) DeleteFundInformationsId(c echo.Context, id int) error { - idStr := strconv.Itoa(id) - err := h.fundInformationUseCase.DestroyFundInformation(c.Request().Context(), idStr) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy FundInformation") -} - -// router.GET(baseURL+"/fund_informations/:id", wrapper.GetFundInformationsId) -func (h *Handler) GetFundInformationsId(c echo.Context, id int) error { - idStr := strconv.Itoa(id) - fundInformation, err := h.fundInformationUseCase.GetFundInformationByID(c.Request().Context(), idStr) - if err != nil { - return err - } - return c.JSON(http.StatusOK, fundInformation) -} - -// router.PUT(baseURL+"/fund_informations/:id", wrapper.PutFundInformationsId) -func (h *Handler) PutFundInformationsId(c echo.Context, id int, params generated.PutFundInformationsIdParams) error { - idStr := strconv.Itoa(id) - userId := strconv.Itoa(params.UserId) - teacherId := strconv.Itoa(params.TeacherId) - price := strconv.Itoa(params.Price) - remark := params.Remark - isFirstCheck := strconv.FormatBool(*params.IsFirstCheck) - isLastCheck := strconv.FormatBool(*params.IsLastCheck) - receivedAt := params.ReceivedAt - - updatedFundInformation, err := h.fundInformationUseCase.UpdateFundInformation(c.Request().Context(), idStr, userId, teacherId, price, *remark, isFirstCheck, isLastCheck, *receivedAt) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedFundInformation) -} - -// router.GET(baseURL+"/fund_informations/:id/details", wrapper.GetFundInformationsIdDetails) -func (h *Handler) GetFundInformationsIdDetails(c echo.Context, id int) error { - idStr := strconv.Itoa(id) - fundInformationDetail, err := h.fundInformationUseCase.GetFundInformationDetailByID(c.Request().Context(), idStr) - if err != nil { - return err - } - return c.JSON(http.StatusOK, fundInformationDetail) -} diff --git a/api/externals/handler/income_expenditure_management_handler.go b/api/externals/handler/income_expenditure_management_handler.go new file mode 100644 index 000000000..b3d7807f1 --- /dev/null +++ b/api/externals/handler/income_expenditure_management_handler.go @@ -0,0 +1,41 @@ +package handler + +import ( + "net/http" + "strconv" + + "github.com/NUTFes/FinanSu/api/generated" + "github.com/labstack/echo/v4" +) + +// Index +func (h *Handler) GetIncomeExpenditureManagements(c echo.Context, params generated.GetIncomeExpenditureManagementsParams) error { + ctx := c.Request().Context() + year := strconv.Itoa(*params.Year) + incomeExpenditureManagements, err := h.incomeExpenditureManagementUseCase.IndexIncomeExpenditureManagements(ctx, year) + if err != nil { + return err + } + return c.JSON(http.StatusOK, incomeExpenditureManagements) +} + +// PutIncomeExpenditureManagementsCheckId +func (h *Handler) PutIncomeExpenditureManagementsCheckId(c echo.Context, id int) error { + ctx := c.Request().Context() + + var body generated.PutIncomeExpenditureManagementsCheckIdJSONBody + if err := c.Bind(&body); err != nil { + return err + } + idStr := strconv.Itoa(id) + + if err := h.incomeExpenditureManagementUseCase.PutIncomeExpenditureManagementCheck(ctx, idStr, body.IsChecked); err != nil { + return err + } + + return c.JSON(http.StatusOK, "ok") +} + +type ( + PutIncomeExpenditureManagementsCheckIdJSONBody = generated.PutIncomeExpenditureManagementsCheckIdJSONBody +) diff --git a/api/externals/handler/income_handler.go b/api/externals/handler/income_handler.go new file mode 100644 index 000000000..bfceb0977 --- /dev/null +++ b/api/externals/handler/income_handler.go @@ -0,0 +1,79 @@ +package handler + +import ( + "net/http" + "strconv" + + "github.com/NUTFes/FinanSu/api/generated" + "github.com/labstack/echo/v4" +) + +// Get all income categories +func (h *Handler) GetIncomes(c echo.Context) error { + ctx := c.Request().Context() + incomeCategories, err := h.incomeUseCase.GetAllIncome(ctx) + if err != nil { + return c.JSON(http.StatusInternalServerError, "failed to get all income items") + } + return c.JSON(http.StatusOK, incomeCategories) +} + +// PostIncome creates a new income category +func (h *Handler) PostIncomes(c echo.Context) error { + ctx := c.Request().Context() + var income Income + if err := c.Bind(&income); err != nil { + return c.JSON(http.StatusBadRequest, "failed to bind") + } + createdIncome, err := h.incomeUseCase.CreateIncome(ctx, income) + if err != nil { + return c.JSON(http.StatusInternalServerError, err.Error()) + } + return c.JSON(http.StatusOK, createdIncome) +} + +// GET /incomes/:id +func (h *Handler) GetIncomesId(c echo.Context, id int) error { + ctx := c.Request().Context() + idStr := strconv.Itoa(id) + + income, err := h.incomeUseCase.GetIncome(ctx, idStr) + if err != nil { + return c.JSON(http.StatusInternalServerError, "failed to get income") + } + if income == nil { + return c.JSON(http.StatusNotFound, "income not found") + } + return c.JSON(http.StatusOK, income) +} + +// PUT /incomes/:id +func (h *Handler) PutIncomesId(c echo.Context, id int) error { + ctx := c.Request().Context() + idStr := strconv.Itoa(id) + + var income Income + if err := c.Bind(&income); err != nil { + return c.JSON(http.StatusBadRequest, "failed to bind") + } + updatedIncome, err := h.incomeUseCase.UpdateIncome(ctx, idStr, income) + if err != nil { + return c.JSON(http.StatusInternalServerError, err.Error()) + } + // Return the updated income + return c.JSON(http.StatusOK, updatedIncome) +} + +// DELETE /incomes/:id +func (h *Handler) DeleteIncomesId(c echo.Context, id int) error { + ctx := c.Request().Context() + + if err := h.incomeUseCase.DeleteIncome(ctx, strconv.Itoa(id)); err != nil { + return c.JSON(http.StatusInternalServerError, "failed to delete income") + } + return c.JSON(http.StatusOK, "ok") +} + +type ( + Income = generated.Income +) diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index c04cf62a1..59052f732 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -424,24 +424,6 @@ type GetDivisionsYearsParams struct { Year *int `form:"year,omitempty" json:"year,omitempty"` } -// PostExpensesParams defines parameters for PostExpenses. -type PostExpensesParams struct { - // Name name - Name *string `form:"name,omitempty" json:"name,omitempty"` - - // YearId year_id - YearId *string `form:"year_id,omitempty" json:"year_id,omitempty"` -} - -// PutExpensesIdParams defines parameters for PutExpensesId. -type PutExpensesIdParams struct { - // Name name - Name *string `form:"name,omitempty" json:"name,omitempty"` - - // YearId year_id - YearId *string `form:"year_id,omitempty" json:"year_id,omitempty"` -} - // GetFestivalItemsParams defines parameters for GetFestivalItems. type GetFestivalItemsParams struct { // Year year @@ -838,33 +820,6 @@ type ServerInterface interface { // (PUT /divisions/{id}) PutDivisionsId(ctx echo.Context, id int) error - // (GET /expenses) - GetExpenses(ctx echo.Context) error - - // (POST /expenses) - PostExpenses(ctx echo.Context, params PostExpensesParams) error - - // (GET /expenses/details) - GetExpensesDetails(ctx echo.Context) error - - // (GET /expenses/details/{year}) - GetExpensesDetailsYear(ctx echo.Context, year int) error - - // (GET /expenses/fiscalyear/{year}) - GetExpensesFiscalyearYear(ctx echo.Context, year int) error - - // (DELETE /expenses/{id}) - DeleteExpensesId(ctx echo.Context, id int) error - - // (GET /expenses/{id}) - GetExpensesId(ctx echo.Context, id int) error - - // (PUT /expenses/{id}) - PutExpensesId(ctx echo.Context, id int, params PutExpensesIdParams) error - - // (GET /expenses/{id}/details) - GetExpensesIdDetails(ctx echo.Context, id int) error - // (GET /festival_items) GetFestivalItems(ctx echo.Context, params GetFestivalItemsParams) error @@ -1759,161 +1714,6 @@ func (w *ServerInterfaceWrapper) PutDivisionsId(ctx echo.Context) error { return err } -// GetExpenses converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpenses(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetExpenses(ctx) - return err -} - -// PostExpenses converts echo context to params. -func (w *ServerInterfaceWrapper) PostExpenses(ctx echo.Context) error { - var err error - - // Parameter object where we will unmarshal all parameters from the context - var params PostExpensesParams - // ------------- Optional query parameter "name" ------------- - - err = runtime.BindQueryParameter("form", true, false, "name", ctx.QueryParams(), ¶ms.Name) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) - } - - // ------------- Optional query parameter "year_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "year_id", ctx.QueryParams(), ¶ms.YearId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year_id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PostExpenses(ctx, params) - return err -} - -// GetExpensesDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesDetails(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetExpensesDetails(ctx) - return err -} - -// GetExpensesDetailsYear converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesDetailsYear(ctx echo.Context) error { - var err error - // ------------- Path parameter "year" ------------- - var year int - - err = runtime.BindStyledParameterWithOptions("simple", "year", ctx.Param("year"), &year, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - 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.GetExpensesDetailsYear(ctx, year) - return err -} - -// GetExpensesFiscalyearYear converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesFiscalyearYear(ctx echo.Context) error { - var err error - // ------------- Path parameter "year" ------------- - var year int - - err = runtime.BindStyledParameterWithOptions("simple", "year", ctx.Param("year"), &year, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - 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.GetExpensesFiscalyearYear(ctx, year) - return err -} - -// DeleteExpensesId converts echo context to params. -func (w *ServerInterfaceWrapper) DeleteExpensesId(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.DeleteExpensesId(ctx, id) - return err -} - -// GetExpensesId converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesId(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.GetExpensesId(ctx, id) - return err -} - -// PutExpensesId converts echo context to params. -func (w *ServerInterfaceWrapper) PutExpensesId(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 PutExpensesIdParams - // ------------- Optional query parameter "name" ------------- - - err = runtime.BindQueryParameter("form", true, false, "name", ctx.QueryParams(), ¶ms.Name) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) - } - - // ------------- Optional query parameter "year_id" ------------- - - err = runtime.BindQueryParameter("form", true, false, "year_id", ctx.QueryParams(), ¶ms.YearId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year_id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.PutExpensesId(ctx, id, params) - return err -} - -// GetExpensesIdDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetExpensesIdDetails(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.GetExpensesIdDetails(ctx, id) - return err -} - // GetFestivalItems converts echo context to params. func (w *ServerInterfaceWrapper) GetFestivalItems(ctx echo.Context) error { var err error @@ -3090,15 +2890,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.DELETE(baseURL+"/divisions/:id", wrapper.DeleteDivisionsId) router.GET(baseURL+"/divisions/:id", wrapper.GetDivisionsId) router.PUT(baseURL+"/divisions/:id", wrapper.PutDivisionsId) - router.GET(baseURL+"/expenses", wrapper.GetExpenses) - router.POST(baseURL+"/expenses", wrapper.PostExpenses) - router.GET(baseURL+"/expenses/details", wrapper.GetExpensesDetails) - router.GET(baseURL+"/expenses/details/:year", wrapper.GetExpensesDetailsYear) - router.GET(baseURL+"/expenses/fiscalyear/:year", wrapper.GetExpensesFiscalyearYear) - router.DELETE(baseURL+"/expenses/:id", wrapper.DeleteExpensesId) - router.GET(baseURL+"/expenses/:id", wrapper.GetExpensesId) - router.PUT(baseURL+"/expenses/:id", wrapper.PutExpensesId) - router.GET(baseURL+"/expenses/:id/details", wrapper.GetExpensesIdDetails) router.GET(baseURL+"/festival_items", wrapper.GetFestivalItems) router.POST(baseURL+"/festival_items", wrapper.PostFestivalItems) router.GET(baseURL+"/festival_items/details/:user_id", wrapper.GetFestivalItemsDetailsUserId) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 65c0435e8..2dd2f1266 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -921,179 +921,6 @@ paths: type: array items: $ref: "#/components/schemas/divisionOption" - /expenses: - get: - tags: - - expense - description: expenseの一覧の取得 - responses: - "200": - description: expenseの一覧を取得 - content: - application/json: - schema: - type: object - post: - tags: - - expense - description: expenseの作成 - parameters: - - name: name - in: query - description: name - schema: - type: string - - name: year_id - in: query - description: year_id - schema: - type: string - responses: - "200": - description: 作成されたexpenseが返ってくる - content: - application/json: - schema: - type: object - - /expenses/details: - get: - tags: - - expense - description: expenseに紐づくpurchase_itemの一覧を取得 - responses: - "200": - description: expenseに紐づくpurchase_itemの一覧を取得 - content: - application/json: - schema: - type: object - - /expenses/{id}: - get: - tags: - - expense - description: IDで指定されたexpenseの取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: expenseの取得 - content: - application/json: - schema: - type: object - put: - tags: - - expense - description: expenseの更新 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - - name: name - in: query - description: name - schema: - type: string - - name: year_id - in: query - description: year_id - schema: - type: string - responses: - "200": - description: 更新されたexpenseが返ってくる - content: - application/json: - schema: - type: object - delete: - tags: - - expense - description: IDを指定してexpenseの削除 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: expenseの削除完了 - content: - application/json: - schema: - type: object - - /expenses/{id}/details: - get: - tags: - - expense - description: IDで指定されたexpenseに紐づくpurchase_itemsを取得 - parameters: - - name: id - in: path - description: id - required: true - schema: - type: integer - responses: - "200": - description: IDで指定されたexpenseに紐づくpurchase_itemsを取得 - content: - application/json: - schema: - type: object - - /expenses/details/{year}: - get: - tags: - - expense - description: 年度で指定されたexpenseに紐づく購入申請と購入報告を取得 - parameters: - - name: year - in: path - description: year - required: true - schema: - type: integer - responses: - "200": - description: yearで指定されたexpenseに紐づく購入申請と購入報告を取得 - content: - application/json: - schema: - type: object - - /expenses/fiscalyear/{year}: - get: - tags: - - expense - description: 年度で指定されたexpensesを取得 - parameters: - - name: year - in: path - description: year - required: true - schema: - type: integer - responses: - "200": - description: yearで指定されたexpensesを取得 - content: - application/json: - schema: - type: object /festival_items: get: tags: diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index 33adc58c0..2761a72db 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -25,7 +25,6 @@ import type { DeleteBuyReportsId200, DeleteDepartmentsId200, DeleteDivisionsId200, - DeleteExpensesId200, DeleteFestivalItemsId200, DeleteFinancialRecordsId200, DeleteIncomesId200, @@ -73,12 +72,6 @@ import type { GetDivisionsParams, GetDivisionsUsersParams, GetDivisionsYearsParams, - GetExpenses200, - GetExpensesDetails200, - GetExpensesDetailsYear200, - GetExpensesFiscalyearYear200, - GetExpensesId200, - GetExpensesIdDetails200, GetFestivalItemsDetailsUserIdParams, GetFestivalItemsParams, GetFestivalItemsUsersParams, @@ -102,8 +95,6 @@ import type { PostBuyReportsBody, PostDepartments200, PostDepartmentsParams, - PostExpenses200, - PostExpensesParams, PostMailAuthSignin200, PostMailAuthSigninParams, PostMailAuthSignup200, @@ -133,8 +124,6 @@ import type { PutBuyReportsIdBody, PutDepartmentsId200, PutDepartmentsIdParams, - PutExpensesId200, - PutExpensesIdParams, PutIncomeExpenditureManagementsCheckId200, PutIncomeExpenditureManagementsCheckIdBody, PutSponsorsId200, @@ -3101,578 +3090,6 @@ export const useGetDivisionsYears = ( }; }; -/** - * expenseの一覧の取得 - */ -export type getExpensesResponse200 = { - data: GetExpenses200; - status: 200; -}; - -export type getExpensesResponseComposite = getExpensesResponse200; - -export type getExpensesResponse = getExpensesResponseComposite & { - headers: Headers; -}; - -export const getGetExpensesUrl = () => { - return `/expenses`; -}; - -export const getExpenses = async (options?: RequestInit): Promise => { - return customFetch(getGetExpensesUrl(), { - ...options, - method: 'GET', - }); -}; - -export const getGetExpensesKey = () => [`/expenses`] as const; - -export type GetExpensesQueryResult = NonNullable>>; -export type GetExpensesQueryError = unknown; - -export const useGetExpenses = (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 ? getGetExpensesKey() : null)); - const swrFn = () => getExpenses(requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * expenseの作成 - */ -export type postExpensesResponse200 = { - data: PostExpenses200; - status: 200; -}; - -export type postExpensesResponseComposite = postExpensesResponse200; - -export type postExpensesResponse = postExpensesResponseComposite & { - headers: Headers; -}; - -export const getPostExpensesUrl = (params?: PostExpensesParams) => { - 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 ? `/expenses?${stringifiedParams}` : `/expenses`; -}; - -export const postExpenses = async ( - params?: PostExpensesParams, - options?: RequestInit, -): Promise => { - return customFetch(getPostExpensesUrl(params), { - ...options, - method: 'POST', - }); -}; - -export const getPostExpensesMutationFetcher = ( - params?: PostExpensesParams, - options?: SecondParameter, -) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return postExpenses(params, options); - }; -}; -export const getPostExpensesMutationKey = (params?: PostExpensesParams) => - [`/expenses`, ...(params ? [params] : [])] as const; - -export type PostExpensesMutationResult = NonNullable>>; -export type PostExpensesMutationError = unknown; - -export const usePostExpenses = ( - params?: PostExpensesParams, - options?: { - swr?: SWRMutationConfiguration< - Awaited>, - TError, - Key, - Arguments, - Awaited> - > & { swrKey?: string }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const swrKey = swrOptions?.swrKey ?? getPostExpensesMutationKey(params); - const swrFn = getPostExpensesMutationFetcher(params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * expenseに紐づくpurchase_itemの一覧を取得 - */ -export type getExpensesDetailsResponse200 = { - data: GetExpensesDetails200; - status: 200; -}; - -export type getExpensesDetailsResponseComposite = getExpensesDetailsResponse200; - -export type getExpensesDetailsResponse = getExpensesDetailsResponseComposite & { - headers: Headers; -}; - -export const getGetExpensesDetailsUrl = () => { - return `/expenses/details`; -}; - -export const getExpensesDetails = async ( - options?: RequestInit, -): Promise => { - return customFetch(getGetExpensesDetailsUrl(), { - ...options, - method: 'GET', - }); -}; - -export const getGetExpensesDetailsKey = () => [`/expenses/details`] as const; - -export type GetExpensesDetailsQueryResult = NonNullable< - Awaited> ->; -export type GetExpensesDetailsQueryError = unknown; - -export const useGetExpensesDetails = (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 ? getGetExpensesDetailsKey() : null)); - const swrFn = () => getExpensesDetails(requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * IDで指定されたexpenseの取得 - */ -export type getExpensesIdResponse200 = { - data: GetExpensesId200; - status: 200; -}; - -export type getExpensesIdResponseComposite = getExpensesIdResponse200; - -export type getExpensesIdResponse = getExpensesIdResponseComposite & { - headers: Headers; -}; - -export const getGetExpensesIdUrl = (id: number) => { - return `/expenses/${id}`; -}; - -export const getExpensesId = async ( - id: number, - options?: RequestInit, -): Promise => { - return customFetch(getGetExpensesIdUrl(id), { - ...options, - method: 'GET', - }); -}; - -export const getGetExpensesIdKey = (id: number) => [`/expenses/${id}`] as const; - -export type GetExpensesIdQueryResult = NonNullable>>; -export type GetExpensesIdQueryError = unknown; - -export const useGetExpensesId = ( - 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 ? getGetExpensesIdKey(id) : null)); - const swrFn = () => getExpensesId(id, requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * expenseの更新 - */ -export type putExpensesIdResponse200 = { - data: PutExpensesId200; - status: 200; -}; - -export type putExpensesIdResponseComposite = putExpensesIdResponse200; - -export type putExpensesIdResponse = putExpensesIdResponseComposite & { - headers: Headers; -}; - -export const getPutExpensesIdUrl = (id: number, params?: PutExpensesIdParams) => { - 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 ? `/expenses/${id}?${stringifiedParams}` : `/expenses/${id}`; -}; - -export const putExpensesId = async ( - id: number, - params?: PutExpensesIdParams, - options?: RequestInit, -): Promise => { - return customFetch(getPutExpensesIdUrl(id, params), { - ...options, - method: 'PUT', - }); -}; - -export const getPutExpensesIdMutationFetcher = ( - id: number, - params?: PutExpensesIdParams, - options?: SecondParameter, -) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return putExpensesId(id, params, options); - }; -}; -export const getPutExpensesIdMutationKey = (id: number, params?: PutExpensesIdParams) => - [`/expenses/${id}`, ...(params ? [params] : [])] as const; - -export type PutExpensesIdMutationResult = NonNullable>>; -export type PutExpensesIdMutationError = unknown; - -export const usePutExpensesId = ( - id: number, - params?: PutExpensesIdParams, - options?: { - swr?: SWRMutationConfiguration< - Awaited>, - TError, - Key, - Arguments, - Awaited> - > & { swrKey?: string }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const swrKey = swrOptions?.swrKey ?? getPutExpensesIdMutationKey(id, params); - const swrFn = getPutExpensesIdMutationFetcher(id, params, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * IDを指定してexpenseの削除 - */ -export type deleteExpensesIdResponse200 = { - data: DeleteExpensesId200; - status: 200; -}; - -export type deleteExpensesIdResponseComposite = deleteExpensesIdResponse200; - -export type deleteExpensesIdResponse = deleteExpensesIdResponseComposite & { - headers: Headers; -}; - -export const getDeleteExpensesIdUrl = (id: number) => { - return `/expenses/${id}`; -}; - -export const deleteExpensesId = async ( - id: number, - options?: RequestInit, -): Promise => { - return customFetch(getDeleteExpensesIdUrl(id), { - ...options, - method: 'DELETE', - }); -}; - -export const getDeleteExpensesIdMutationFetcher = ( - id: number, - options?: SecondParameter, -) => { - return (_: Key, __: { arg: Arguments }): Promise => { - return deleteExpensesId(id, options); - }; -}; -export const getDeleteExpensesIdMutationKey = (id: number) => [`/expenses/${id}`] as const; - -export type DeleteExpensesIdMutationResult = NonNullable< - Awaited> ->; -export type DeleteExpensesIdMutationError = unknown; - -export const useDeleteExpensesId = ( - id: number, - options?: { - swr?: SWRMutationConfiguration< - Awaited>, - TError, - Key, - Arguments, - Awaited> - > & { swrKey?: string }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const swrKey = swrOptions?.swrKey ?? getDeleteExpensesIdMutationKey(id); - const swrFn = getDeleteExpensesIdMutationFetcher(id, requestOptions); - - const query = useSWRMutation(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * IDで指定されたexpenseに紐づくpurchase_itemsを取得 - */ -export type getExpensesIdDetailsResponse200 = { - data: GetExpensesIdDetails200; - status: 200; -}; - -export type getExpensesIdDetailsResponseComposite = getExpensesIdDetailsResponse200; - -export type getExpensesIdDetailsResponse = getExpensesIdDetailsResponseComposite & { - headers: Headers; -}; - -export const getGetExpensesIdDetailsUrl = (id: number) => { - return `/expenses/${id}/details`; -}; - -export const getExpensesIdDetails = async ( - id: number, - options?: RequestInit, -): Promise => { - return customFetch(getGetExpensesIdDetailsUrl(id), { - ...options, - method: 'GET', - }); -}; - -export const getGetExpensesIdDetailsKey = (id: number) => [`/expenses/${id}/details`] as const; - -export type GetExpensesIdDetailsQueryResult = NonNullable< - Awaited> ->; -export type GetExpensesIdDetailsQueryError = unknown; - -export const useGetExpensesIdDetails = ( - 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 ? getGetExpensesIdDetailsKey(id) : null)); - const swrFn = () => getExpensesIdDetails(id, requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * 年度で指定されたexpenseに紐づく購入申請と購入報告を取得 - */ -export type getExpensesDetailsYearResponse200 = { - data: GetExpensesDetailsYear200; - status: 200; -}; - -export type getExpensesDetailsYearResponseComposite = getExpensesDetailsYearResponse200; - -export type getExpensesDetailsYearResponse = getExpensesDetailsYearResponseComposite & { - headers: Headers; -}; - -export const getGetExpensesDetailsYearUrl = (year: number) => { - return `/expenses/details/${year}`; -}; - -export const getExpensesDetailsYear = async ( - year: number, - options?: RequestInit, -): Promise => { - return customFetch(getGetExpensesDetailsYearUrl(year), { - ...options, - method: 'GET', - }); -}; - -export const getGetExpensesDetailsYearKey = (year: number) => - [`/expenses/details/${year}`] as const; - -export type GetExpensesDetailsYearQueryResult = NonNullable< - Awaited> ->; -export type GetExpensesDetailsYearQueryError = unknown; - -export const useGetExpensesDetailsYear = ( - year: number, - options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const isEnabled = swrOptions?.enabled !== false && !!year; - const swrKey = - swrOptions?.swrKey ?? (() => (isEnabled ? getGetExpensesDetailsYearKey(year) : null)); - const swrFn = () => getExpensesDetailsYear(year, requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - -/** - * 年度で指定されたexpensesを取得 - */ -export type getExpensesFiscalyearYearResponse200 = { - data: GetExpensesFiscalyearYear200; - status: 200; -}; - -export type getExpensesFiscalyearYearResponseComposite = getExpensesFiscalyearYearResponse200; - -export type getExpensesFiscalyearYearResponse = getExpensesFiscalyearYearResponseComposite & { - headers: Headers; -}; - -export const getGetExpensesFiscalyearYearUrl = (year: number) => { - return `/expenses/fiscalyear/${year}`; -}; - -export const getExpensesFiscalyearYear = async ( - year: number, - options?: RequestInit, -): Promise => { - return customFetch(getGetExpensesFiscalyearYearUrl(year), { - ...options, - method: 'GET', - }); -}; - -export const getGetExpensesFiscalyearYearKey = (year: number) => - [`/expenses/fiscalyear/${year}`] as const; - -export type GetExpensesFiscalyearYearQueryResult = NonNullable< - Awaited> ->; -export type GetExpensesFiscalyearYearQueryError = unknown; - -export const useGetExpensesFiscalyearYear = ( - year: number, - options?: { - swr?: SWRConfiguration>, TError> & { - swrKey?: Key; - enabled?: boolean; - }; - request?: SecondParameter; - }, -) => { - const { swr: swrOptions, request: requestOptions } = options ?? {}; - - const isEnabled = swrOptions?.enabled !== false && !!year; - const swrKey = - swrOptions?.swrKey ?? (() => (isEnabled ? getGetExpensesFiscalyearYearKey(year) : null)); - const swrFn = () => getExpensesFiscalyearYear(year, requestOptions); - - const query = useSwr>, TError>(swrKey, swrFn, swrOptions); - - return { - swrKey, - ...query, - }; -}; - /** * festival_itemの一覧の取得 */ From 74ec35a1f70a6a370c6f2505885fad96ea902617 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Fri, 26 Sep 2025 23:41:54 +0900 Subject: [PATCH 12/14] =?UTF-8?q?=E8=AB=B8=E3=80=85=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/activity_controller.go | 131 ------- .../activity_information_controller.go | 102 ------ .../controller/activity_style_controller.go | 85 ----- api/externals/controller/budget_controller.go | 110 ------ api/externals/controller/bureau_controller.go | 72 ---- .../controller/buy_report_controller.go | 238 ------------- .../controller/department_controller.go | 73 ---- .../controller/division_controller.go | 118 ------- .../controller/expense_controller.go | 131 ------- .../controller/festival_item_controller.go | 119 ------- .../controller/financial_record_controller.go | 148 -------- .../controller/health_check_controller.go | 21 -- api/externals/controller/income_controller.go | 108 ------ ...ncome_expenditure_management_controller.go | 54 --- .../controller/mail_auth_controller.go | 68 ---- .../controller/object_upload_controller.go | 35 -- .../password_reset_token_controller.go | 78 ---- .../controller/purchase_item_controller.go | 106 ------ .../controller/purchase_report_controller.go | 111 ------ .../controller/purhcase_order_controller.go | 140 -------- .../controller/receipt_controller.go | 91 ----- api/externals/controller/source_controller.go | 73 ---- .../controller/sponsor_controller.go | 138 -------- .../controller/sponsor_style_controller.go | 81 ----- .../controller/teacher_controller.go | 111 ------ api/externals/controller/user_controller.go | 106 ------ api/externals/controller/year_controller.go | 128 ------- api/externals/handler/activity_handler.go | 12 +- api/externals/handler/buy_report_handler.go | 30 +- api/externals/handler/division_handler.go | 12 +- .../handler/festival_item_handler.go | 12 +- .../handler/financial_record_handler.go | 19 +- .../income_expenditure_management_handler.go | 7 +- api/externals/handler/user_handler.go | 11 + api/generated/openapi_gen.go | 49 +++ api/router/router.go | 334 ------------------ openapi/openapi.yaml | 50 ++- view/next-project/src/generated/hooks.ts | 52 +++ .../next-project/src/generated/model/index.ts | 1 + view/next-project/src/generated/model/user.ts | 17 + 40 files changed, 255 insertions(+), 3127 deletions(-) delete mode 100644 api/externals/controller/activity_controller.go delete mode 100644 api/externals/controller/activity_information_controller.go delete mode 100644 api/externals/controller/activity_style_controller.go delete mode 100644 api/externals/controller/budget_controller.go delete mode 100644 api/externals/controller/bureau_controller.go delete mode 100644 api/externals/controller/buy_report_controller.go delete mode 100644 api/externals/controller/department_controller.go delete mode 100644 api/externals/controller/division_controller.go delete mode 100644 api/externals/controller/expense_controller.go delete mode 100644 api/externals/controller/festival_item_controller.go delete mode 100644 api/externals/controller/financial_record_controller.go delete mode 100644 api/externals/controller/health_check_controller.go delete mode 100644 api/externals/controller/income_controller.go delete mode 100644 api/externals/controller/income_expenditure_management_controller.go delete mode 100644 api/externals/controller/mail_auth_controller.go delete mode 100644 api/externals/controller/object_upload_controller.go delete mode 100644 api/externals/controller/password_reset_token_controller.go delete mode 100644 api/externals/controller/purchase_item_controller.go delete mode 100644 api/externals/controller/purchase_report_controller.go delete mode 100644 api/externals/controller/purhcase_order_controller.go delete mode 100644 api/externals/controller/receipt_controller.go delete mode 100644 api/externals/controller/source_controller.go delete mode 100644 api/externals/controller/sponsor_controller.go delete mode 100644 api/externals/controller/sponsor_style_controller.go delete mode 100644 api/externals/controller/teacher_controller.go delete mode 100644 api/externals/controller/user_controller.go delete mode 100644 api/externals/controller/year_controller.go delete mode 100644 api/router/router.go create mode 100644 view/next-project/src/generated/model/user.ts diff --git a/api/externals/controller/activity_controller.go b/api/externals/controller/activity_controller.go deleted file mode 100644 index 6a4ab7e98..000000000 --- a/api/externals/controller/activity_controller.go +++ /dev/null @@ -1,131 +0,0 @@ -package controller - -import ( - "fmt" - "net/http" - "strconv" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type activityController struct { - u usecase.ActivityUseCase -} - -type ActivityController interface { - IndexActivity(echo.Context) error - ShowActivity(echo.Context) error - CreateActivity(echo.Context) error - UpdateActivity(echo.Context) error - DestroyActivity(echo.Context) error - IndexActivityDetail(echo.Context) error - IndexActivityDetailsByPeriod(echo.Context) error - IndexFilteredActivityDetail(echo.Context) error - IndexFilteredActivityDetailByPeriod(echo.Context) error -} - -func NewActivityController(u usecase.ActivityUseCase) ActivityController { - return &activityController{u} -} - -// Index -func (a *activityController) IndexActivity(c echo.Context) error { - activities, err := a.u.GetActivity(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activities) -} - -// Show -func (a *activityController) ShowActivity(c echo.Context) error { - id := c.Param("id") - activity, err := a.u.GetActivityByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activity) -} - -// Create -func (a *activityController) CreateActivity(c echo.Context) error { - activities := new(domain.Activity) - if err := c.Bind(activities); err != nil { - fmt.Println("err") - return err - } - latastActivity, err := a.u.CreateActivity(c.Request().Context(), strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastActivity) -} - -// Update -func (a *activityController) UpdateActivity(c echo.Context) error { - id := c.Param("id") - activities := new(domain.Activity) - if err := c.Bind(activities); err != nil { - fmt.Println("err") - return err - } - updatedActivity, err := a.u.UpdateActivity(c.Request().Context(), id, strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedActivity) -} - -// Destroy -func (a *activityController) DestroyActivity(c echo.Context) error { - id := c.Param("id") - err := a.u.DestroyActivity(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Activity") -} - -// For admin view -func (a *activityController) IndexActivityDetail(c echo.Context) error { - activities, err := a.u.GetActivityDetail(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activities) -} - -// 年度で指定されたactivitiesとsponsor,sponsorStyle,userの一覧を取得 -func (a *activityController) IndexActivityDetailsByPeriod(c echo.Context) error { - year := c.Param("year") - activities, err := a.u.GetActivityDetailsByPeriod(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activities) -} - -func (a *activityController) IndexFilteredActivityDetail(c echo.Context) error { - isDone := c.QueryParam("is_done") - sponsorStyleIDs := c.QueryParams()["sponsor_style_id"] - keyword := c.QueryParam("keyword") - activities, err := a.u.GetFilteredActivityDetail(c.Request().Context(), isDone, sponsorStyleIDs, keyword) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activities) -} - -func (a *activityController) IndexFilteredActivityDetailByPeriod(c echo.Context) error { - isDone := c.QueryParam("is_done") - sponsorStyleIDs := c.QueryParams()["sponsor_style_id"] - year := c.Param("year") - keyword := c.QueryParam("keyword") - activities, err := a.u.GetFilteredActivityDetailByPeriod(c.Request().Context(), isDone, sponsorStyleIDs, year, keyword) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activities) -} diff --git a/api/externals/controller/activity_information_controller.go b/api/externals/controller/activity_information_controller.go deleted file mode 100644 index c91a1d990..000000000 --- a/api/externals/controller/activity_information_controller.go +++ /dev/null @@ -1,102 +0,0 @@ -package controller - -import ( - "fmt" - "net/http" - "strconv" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - - "github.com/labstack/echo/v4" -) - -type activityInformationController struct { - u usecase.ActivityInformationUseCase -} - -type ActivityInformationController interface { - IndexActivityInformation(echo.Context) error - ShowActivityInformation(echo.Context) error - CreateActivityInformation(echo.Context) error - UpdateActivityInformation(echo.Context) error - DestroyActivityInformation(echo.Context) error -} - -func NewActivityInformationController(u usecase.ActivityInformationUseCase) ActivityInformationController { - return &activityInformationController{u} -} - -// Index -func (a *activityInformationController) IndexActivityInformation(c echo.Context) error { - activityInformations, err := a.u.GetActivityInformation(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activityInformations) -} - -// Show -func (a *activityInformationController) ShowActivityInformation(c echo.Context) error { - id := c.Param("id") - activityInformation, err := a.u.GetActivityInformationByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activityInformation) -} - -// Create -func (a *activityInformationController) CreateActivityInformation(c echo.Context) error { - activityInformation := new(domain.ActivityInformation) - if err := c.Bind(activityInformation); err != nil { - fmt.Println("err") - return err - } - - latastActivityInformation, err := a.u.CreateActivityInformation(c.Request().Context() , - strconv.Itoa(int(activityInformation.ActivityId)), - activityInformation.BucketName, - activityInformation.FileName, - activityInformation.FileType, - strconv.Itoa(int(activityInformation.DesignProgress)), - activityInformation.FileInformation, - ) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastActivityInformation) -} - -// Update -func (a *activityInformationController) UpdateActivityInformation(c echo.Context) error { - id := c.Param("id") - activityInformation := new(domain.ActivityInformation) - if err := c.Bind(activityInformation); err != nil { - fmt.Println("err") - return err - } - updatedActivity, err := a.u.UpdateActivityInformation(c.Request().Context(), - id, - strconv.Itoa(int(activityInformation.ActivityId)), - activityInformation.BucketName, - activityInformation.FileName, - activityInformation.FileType, - strconv.Itoa(int(activityInformation.DesignProgress)), - activityInformation.FileInformation) - - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedActivity) -} - -// Destroy -func (a *activityInformationController) DestroyActivityInformation(c echo.Context) error { - id := c.Param("id") - err := a.u.DestroyActivityInformation(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, "Destroy ActivityInformations") -} diff --git a/api/externals/controller/activity_style_controller.go b/api/externals/controller/activity_style_controller.go deleted file mode 100644 index 2f41d0483..000000000 --- a/api/externals/controller/activity_style_controller.go +++ /dev/null @@ -1,85 +0,0 @@ -package controller - -import ( - "fmt" - "net/http" - "strconv" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type activityStyleController struct { - u usecase.ActivityStyleUseCase -} - -type ActivityStyleController interface { - IndexActivityStyle(echo.Context) error - ShowActivityStyle(echo.Context) error - CreateActivityStyle(echo.Context) error - UpdateActivityStyle(echo.Context) error - DestroyActivityStyle(echo.Context) error -} - -func NewActivityStyleController(u usecase.ActivityStyleUseCase) ActivityStyleController { - return &activityStyleController{u} -} - -// Index -func (a *activityStyleController) IndexActivityStyle(c echo.Context) error { - activityStyles, err := a.u.GetActivityStyle(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activityStyles) -} - -// Show -func (a *activityStyleController) ShowActivityStyle(c echo.Context) error { - id := c.Param("id") - activityStyle, err := a.u.GetActivityStyleByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, activityStyle) -} - -// Create -func (a *activityStyleController) CreateActivityStyle(c echo.Context) error { - activityStyle := new(domain.ActivityStyle) - if err := c.Bind(activityStyle); err != nil { - fmt.Println("err") - return err - } - latastActivityStyle, err := a.u.CreateActivityStyle(c.Request().Context() , strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID))) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastActivityStyle) -} - -// Update -func (a *activityStyleController) UpdateActivityStyle(c echo.Context) error { - id := c.Param("id") - activityStyle := new(domain.ActivityStyle) - if err := c.Bind(activityStyle); err != nil { - fmt.Println("err") - return err - } - updatedActivityStyle, err := a.u.UpdateActivityStyle(c.Request().Context(), id , strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID))) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedActivityStyle) -} - -// Destroy -func (a *activityStyleController) DestroyActivityStyle(c echo.Context) error { - id := c.Param("id") - err := a.u.DestroyActivityStyle(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy ActivityStyle") -} diff --git a/api/externals/controller/budget_controller.go b/api/externals/controller/budget_controller.go deleted file mode 100644 index 6a5f0a3b8..000000000 --- a/api/externals/controller/budget_controller.go +++ /dev/null @@ -1,110 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type budgetController struct { - u usecase.BudgetUseCase -} - -type BudgetController interface { - IndexBudget(echo.Context) error - ShowBudget(echo.Context) error - CreateBudget(echo.Context) error - UpdateBudget(echo.Context) error - DestroyBudget(echo.Context) error - ShowBudgetDetailById(echo.Context) error - ShowBudgetDetails(echo.Context) error - ShowBudgetDetailsByPeriods(echo.Context) error -} - -func NewBudgetController(u usecase.BudgetUseCase) BudgetController { - return &budgetController{u} -} - -func (b *budgetController) IndexBudget(c echo.Context) error { - budgets, err := b.u.GetBudgets(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, budgets) -} - -func (b *budgetController) ShowBudget(c echo.Context) error { - id := c.Param("id") - - budget, err := b.u.GetBudgetByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, budget) -} - -func (b *budgetController) CreateBudget(c echo.Context) error { - price := c.QueryParam("price") - yearID := c.QueryParam("year_id") - sourceID := c.QueryParam("source_id") - - latastBudget, err := b.u.CreateBudget(c.Request().Context(), price, yearID, sourceID) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastBudget) -} - -func (b *budgetController) UpdateBudget(c echo.Context) error { - id := c.Param("id") - price := c.QueryParam("price") - yearID := c.QueryParam("year_id") - sourceID := c.QueryParam("source_id") - - updatedBudget, err := b.u.UpdateBudget(c.Request().Context(), id, price, yearID, sourceID) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedBudget) -} - -func (b *budgetController) DestroyBudget(c echo.Context) error { - id := c.Param("id") - - err := b.u.DestroyBudget(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Budget") -} - -// IDを指定してBudgetに紐づくyearとsourceの取得 -func (b *budgetController) ShowBudgetDetailById(c echo.Context) error { - id := c.Param("id") - - budgetDetail, err := b.u.GetBudgetDetailByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, budgetDetail) -} - -// Budgetに紐づくyearとsourceの全件取得 -func (b *budgetController) ShowBudgetDetails(c echo.Context) error { - budgetDetails, err := b.u.GetBudgetDetails(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, budgetDetails) -} - -// 年度ごとにBudgetと紐づくデータ全件取得 -func (b *budgetController) ShowBudgetDetailsByPeriods(c echo.Context) error { - year := c.Param("year") - budgetDetails, err := b.u.GetBudgetDetailsByPeriod(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, budgetDetails) -} diff --git a/api/externals/controller/bureau_controller.go b/api/externals/controller/bureau_controller.go deleted file mode 100644 index 711436f84..000000000 --- a/api/externals/controller/bureau_controller.go +++ /dev/null @@ -1,72 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type bureauController struct { - u usecase.BureauUseCase -} - -type BureauController interface { - IndexBureau(echo.Context) error - ShowBureau(echo.Context) error - CreateBureau(echo.Context) error - UpdateBureau(echo.Context) error - DestroyBureau(echo.Context) error -} - -func NewBureauController(u usecase.BureauUseCase) BureauController { - return &bureauController{u} -} - -func (b *bureauController) IndexBureau(c echo.Context) error { - bureaus, err := b.u.GetBureaus(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, bureaus) -} - -func (b *bureauController) ShowBureau(c echo.Context) error { - id := c.Param("id") - bureau, err := b.u.GetBureauByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, bureau) -} - -func (b *bureauController) CreateBureau(c echo.Context) error { - name := c.QueryParam("name") - - latastBureau, err := b.u.CreateBureau(c.Request().Context(), name) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastBureau) -} - -func (b *bureauController) UpdateBureau(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - - updatedBureau, err := b.u.UpdateBureau(c.Request().Context(), id, name) - - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedBureau) -} - -func (b *bureauController) DestroyBureau(c echo.Context) error { - id := c.Param("id") - err := b.u.DestroyBureau(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Bureau") -} diff --git a/api/externals/controller/buy_report_controller.go b/api/externals/controller/buy_report_controller.go deleted file mode 100644 index 81527d7a7..000000000 --- a/api/externals/controller/buy_report_controller.go +++ /dev/null @@ -1,238 +0,0 @@ -package controller - -import ( - "encoding/csv" - "encoding/json" - "fmt" - "net/http" - "strconv" - "time" - - "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 buyReportController struct { - u usecase.BuyReportUseCase -} - -type BuyReportController interface { - CreateBuyReport(echo.Context) error - UpdateBuyReport(echo.Context) error - DeleteBuyReport(echo.Context) error - IndexBuyReport(echo.Context) error - GetBuyReportById(echo.Context) error - UpdateBuyReportStatus(echo.Context) error - GetBuyReportsCsvDownload(echo.Context) error -} - -func NewBuyReportController(u usecase.BuyReportUseCase) BuyReportController { - return &buyReportController{u} -} - -// Create -func (s *buyReportController) CreateBuyReport(c echo.Context) error { - ctx := c.Request().Context() - // ファイル取得 - file, err := c.FormFile("file") - if err != nil { - return c.String(http.StatusBadRequest, "file not found") - } - // JSON データを取得 - buyReportStr := c.FormValue("buy_report") - if buyReportStr == "" { - return c.String(http.StatusBadRequest, "buy_report not found") - } - - // jsonのパース - var buyReportInfo BuyReport - err = json.Unmarshal([]byte(buyReportStr), &buyReportInfo) - if err != nil { - return c.String(http.StatusBadRequest, "buy_report is not valid") - } - - buyReport, err := s.u.CreateBuyReport(ctx, buyReportInfo, file) - if err != nil { - return err - } - return c.JSON(http.StatusOK, buyReport) -} - -// Update -func (s *buyReportController) UpdateBuyReport(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - // ファイル取得 - file, _ := c.FormFile("file") - // JSON データを取得 - buyReportStr := c.FormValue("buy_report") - if buyReportStr == "" { - return c.String(http.StatusBadRequest, "buy_report not found") - } - - // jsonのパース - var buyReportInfo BuyReport - err := json.Unmarshal([]byte(buyReportStr), &buyReportInfo) - if err != nil { - return c.String(http.StatusBadRequest, "buy_report is not valid") - } - - buyReportInfo, err = s.u.UpdateBuyReport(ctx, id, buyReportInfo, file) - if err != nil { - return err - } - return c.JSON(http.StatusOK, buyReportInfo) -} - -// Delete -func (s *buyReportController) DeleteBuyReport(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - err := s.u.DeleteBuyReport(ctx, id) - if err != nil { - return c.String(http.StatusBadRequest, "buy_report delete failed") - } - return c.String(http.StatusOK, "buy_report delete success") -} - -// Index -func (s *buyReportController) IndexBuyReport(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - - buyReportDetails, err := s.u.GetBuyReports(ctx, year) - if err != nil { - return c.String(http.StatusBadRequest, "failed to buy_reports") - } - - return c.JSON(http.StatusOK, buyReportDetails) -} - -// Get -func (s *buyReportController) GetBuyReportById(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - - buyReportDetail, err := s.u.GetBuyReportById(ctx, id) - if err != nil { - return c.String(http.StatusBadRequest, "failed to buy_report") - } - - return c.JSON(http.StatusOK, buyReportDetail) -} - -// UpdateStatus -func (s *buyReportController) UpdateBuyReportStatus(c echo.Context) error { - ctx := c.Request().Context() - buyReportId := c.Param("buy_report_id") - var requestBody BuyReportStatusRequestBody - if err := c.Bind(&requestBody); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - - buyReportDetail, err := s.u.UpdateBuyReportStatus(ctx, buyReportId, requestBody) - if err != nil { - return c.String(http.StatusBadRequest, "failed update buy_reports") - } - - return c.JSON(http.StatusOK, buyReportDetail) -} - -// GetBuyReportsCsvDownload -func (s *buyReportController) GetBuyReportsCsvDownload(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - - buyReportDetails, err := s.u.GetBuyReports(ctx, year) - if err != nil { - return err - } - - // CSVデータの準備 - records := make([][]string, 0, len(buyReportDetails)+1) - - // ヘッダー - header := []string{"年度", "日付", "局名", "部門", "物品", "立替者", "金額", "封詰め", "清算完了"} - records = append(records, header) - - // データ行を追加 - for _, detail := range buyReportDetails { - yearStr := "" - if detail.Year != nil { - yearStr = strconv.Itoa(*detail.Year) - } - - // 封詰めと清算完了のステータスを「未」「済」で表示 - packedStatus := "未" - if detail.IsPacked { - packedStatus = "済" - } - settledStatus := "未" - if detail.IsSettled { - settledStatus = "済" - } - - reportDateStr := detail.ReportDate - t, err := time.Parse(time.RFC3339, reportDateStr) - if err == nil { - reportDateStr = t.Format("2006年1月2日") - } - - record := []string{ - yearStr, - reportDateStr, - detail.FinancialRecordName, - detail.DivisionName, - detail.FestivalItemName, - detail.PaidBy, - strconv.Itoa(detail.Amount), - packedStatus, - settledStatus, - } - records = append(records, record) - } - - // ヘッダーの設定 - w := c.Response().Writer - fileName := fmt.Sprintf("purchase_reports_%s.csv", year) - attachment := fmt.Sprintf(`attachment; filename="%s"`, fileName) - w.Header().Set("Content-Type", "text/csv") - w.Header().Set("Content-Disposition", attachment) - - if err := makeBuyReportCSV(w, records); err != nil { - return err - } - - return nil -} - -func makeBuyReportCSV(writer http.ResponseWriter, records [][]string) error { - // Shift_JISエンコーディング用の変換を設定 - encoder := japanese.ShiftJIS.NewEncoder() - - // writerに対してエンコーダを設定して変換する - shiftJISWriter := transform.NewWriter(writer, encoder) - - // CSVライターを作成 - 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 -} - -type BuyReport = generated.BuyReport -type BuyReportDetails = []generated.BuyReportDetail -type BuyReportStatusRequestBody = generated.PutBuyReportStatusBuyReportIdJSONRequestBody diff --git a/api/externals/controller/department_controller.go b/api/externals/controller/department_controller.go deleted file mode 100644 index 588d79646..000000000 --- a/api/externals/controller/department_controller.go +++ /dev/null @@ -1,73 +0,0 @@ -package controller - -import ( - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" - "net/http" -) - -type departmentController struct { - u usecase.DepartmentUseCase -} - -type DepartmentController interface { - IndexDepartment(echo.Context) error - ShowDepartment(echo.Context) error - CreateDepartment(echo.Context) error - UpdateDepartment(echo.Context) error - DestroyDepartment(echo.Context) error -} - -func NewDepartmentController(u usecase.DepartmentUseCase) DepartmentController { - return &departmentController{u} -} - -// Index -func (d *departmentController) IndexDepartment(c echo.Context) error { - departments, err := d.u.GetDepartments(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, departments) -} - -// Show -func (d *departmentController) ShowDepartment(c echo.Context) error { - id := c.Param("id") - department, err := d.u.GetDepartmentByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, department) -} - -// Create -func (d *departmentController) CreateDepartment(c echo.Context) error { - name := c.QueryParam("name") - latastDepartment, err := d.u.CreateDepartment(c.Request().Context(), name) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latastDepartment) -} - -// Update -func (d *departmentController) UpdateDepartment(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - updatedDepartment, err := d.u.UpdateDepartment(c.Request().Context(), id, name) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedDepartment) -} - -// Destroy -func (d *departmentController) DestroyDepartment(c echo.Context) error { - id := c.Param("id") - err := d.u.DestroyDepartment(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Department") -} diff --git a/api/externals/controller/division_controller.go b/api/externals/controller/division_controller.go deleted file mode 100644 index 8273a7e7f..000000000 --- a/api/externals/controller/division_controller.go +++ /dev/null @@ -1,118 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/generated" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type divisionController struct { - u usecase.DivisionUseCase -} - -type DivisionController interface { - IndexDivisions(echo.Context) error - GetDivisionOptions(echo.Context) error - GetDivision(echo.Context) error - CreateDivision(echo.Context) error - UpdateDivision(echo.Context) error - DestroyDivision(echo.Context) error - GetDivisionsYears(echo.Context) error -} - -func NewDivisionController(u usecase.DivisionUseCase) DivisionController { - return &divisionController{u} -} - -func (d *divisionController) IndexDivisions(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - financialRecordId := c.QueryParam("financial_record_id") - - divisionDetails, err := d.u.GetDivisions(ctx, year, financialRecordId) - if err != nil { - return err - } - return c.JSON(http.StatusOK, divisionDetails) -} - -func (d *divisionController) GetDivisionOptions(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - userId := c.QueryParam("user_id") - - divisionOptions, err := d.u.GetDivisionOptions(ctx, year, userId) - if err != nil { - return err - } - return c.JSON(http.StatusOK, divisionOptions) -} - -func (d *divisionController) GetDivision(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - - division, err := d.u.GetDivision(ctx, id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, division) -} - -func (d *divisionController) CreateDivision(c echo.Context) error { - ctx := c.Request().Context() - division := new(Division) - - if err := c.Bind(division); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - latestDivision, err := d.u.CreateDivision(ctx, *division) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latestDivision) -} - -func (d *divisionController) UpdateDivision(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - division := new(Division) - - if err := c.Bind(division); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - updatedDivision, err := d.u.UpdateDivision(ctx, id, *division) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedDivision) -} - -func (d *divisionController) DestroyDivision(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - - err := d.u.DestroyDivision(ctx, id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Division") -} - -func (d *divisionController) GetDivisionsYears(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - // Retrieve division options for each year from the usecase layer. - divisions, err := d.u.GetDivisionsYears(ctx, year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, divisions) -} - -type ( - Division = generated.Division - DivisionDetails = generated.DivisionDetails -) diff --git a/api/externals/controller/expense_controller.go b/api/externals/controller/expense_controller.go deleted file mode 100644 index 611ba1543..000000000 --- a/api/externals/controller/expense_controller.go +++ /dev/null @@ -1,131 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type expenseController struct { - u usecase.ExpenseUseCase -} - -type ExpenseController interface { - IndexExpense(echo.Context) error - ShowExpense(echo.Context) error - CreateExpense(echo.Context) error - UpdateExpense(echo.Context) error - DestroyExpense(echo.Context) error - UpdateExpenseTP(echo.Context) error - IndexExpenseDetails(echo.Context) error - ShowExpenseDetail(echo.Context) error - IndexExpenseDetailsByPeriod(echo.Context) error - IndexExpenseByPeriod(echo.Context) error -} - -func NewExpenseController(u usecase.ExpenseUseCase) ExpenseController { - return &expenseController{u} -} - -func (e *expenseController) IndexExpense(c echo.Context) error { - err := e.u.UpdateExpenseTP(c.Request().Context()) - if err != nil { - return err - } - expenses, err := e.u.GetExpenses(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, expenses) -} - -func (e *expenseController) ShowExpense(c echo.Context) error { - id := c.Param("id") - expense, err := e.u.GetExpenseByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, expense) -} - -func (e *expenseController) CreateExpense(c echo.Context) error { - name := c.QueryParam("name") - yearID := c.QueryParam("year_id") - latastExpense, err := e.u.CreateExpense(c.Request().Context(), name, yearID) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latastExpense) -} - -func (e *expenseController) UpdateExpense(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - yearID := c.QueryParam("year_id") - updatedExpense, err := e.u.UpdateExpense(c.Request().Context(), id, name, yearID) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedExpense) -} - -func (e *expenseController) DestroyExpense(c echo.Context) error { - id := c.Param("id") - err := e.u.DestroyExpense(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Expense") -} - -func (e *expenseController) UpdateExpenseTP(c echo.Context) error { - err := e.u.UpdateExpenseTP(c.Request().Context()) - if err != nil { - return err - } - return c.String(http.StatusOK, "Updated Expense's totalPrice") -} - -func (e *expenseController) IndexExpenseDetails(c echo.Context) error { - err := e.u.UpdateExpenseTP(c.Request().Context()) - if err != nil { - return err - } - expenseDetails, err := e.u.GetExpenseDetails(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, expenseDetails) -} - -func (e *expenseController) ShowExpenseDetail(c echo.Context) error { - id := c.Param("id") - expenseDetail, err := e.u.GetExpenseDetailByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, expenseDetail) -} - -func (e *expenseController) IndexExpenseDetailsByPeriod(c echo.Context) error { - year := c.Param("year") - err := e.u.UpdateExpenseTP(c.Request().Context()) - if err != nil { - return err - } - expenseDetails, err := e.u.GetExpenseDetailsByPeriod(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, expenseDetails) -} - -func (e *expenseController) IndexExpenseByPeriod(c echo.Context) error { - year := c.Param("year") - expense, err := e.u.GetExpensesByPeriod(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, expense) -} diff --git a/api/externals/controller/festival_item_controller.go b/api/externals/controller/festival_item_controller.go deleted file mode 100644 index d5b29ed19..000000000 --- a/api/externals/controller/festival_item_controller.go +++ /dev/null @@ -1,119 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/generated" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type festivalItemController struct { - u usecase.FestivalItemUseCase -} - -type FestivalItemController interface { - IndexFestivalItems(echo.Context) error - IndexFestivalItemsForMypage(echo.Context) error - IndexFestivalItemOption(echo.Context) error - GetFestivalItem(echo.Context) error - CreateFestivalItem(echo.Context) error - UpdateFestivalItem(echo.Context) error - DestroyFestivalItem(echo.Context) error -} - -func NewFestivalItemController(u usecase.FestivalItemUseCase) FestivalItemController { - return &festivalItemController{u} -} - -func (f *festivalItemController) IndexFestivalItems(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - divisionId := c.QueryParam("division_id") - var festivalItemDetails FestivalItemDetails - - festivalItemDetails, err := f.u.GetFestivalItems(ctx, year, divisionId) - if err != nil { - return err - } - return c.JSON(http.StatusOK, festivalItemDetails) -} - -func (f *festivalItemController) IndexFestivalItemsForMypage(c echo.Context) error { - ctx := c.Request().Context() - userId := c.Param("user_id") - year := c.QueryParam("year") - var festivalItemDetails []FestivalItemsForMyPage - - festivalItemDetails, err := f.u.GetFestivalItemsForMypage(ctx, year, userId) - if err != nil { - return err - } - return c.JSON(http.StatusOK, festivalItemDetails) -} - -func (f *festivalItemController) IndexFestivalItemOption(c echo.Context) error { - ctx := c.Request().Context() - divisionId := c.QueryParam("division_id") - year := c.QueryParam("year") - var festivalItemOptions []FestivalItemOption - - festivalItemOptions, err := f.u.GetFestivalItemOptions(ctx, year, divisionId) - if err != nil { - return err - } - return c.JSON(http.StatusOK, festivalItemOptions) -} - -func (f *festivalItemController) GetFestivalItem(c echo.Context) error { - id := c.Param("id") - ctx := c.Request().Context() - festivalItem, err := f.u.GetFestivalItem(ctx, id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, festivalItem) -} - -func (f *festivalItemController) CreateFestivalItem(c echo.Context) error { - festivalItem := new(FestivalItem) - if err := c.Bind(festivalItem); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - latestFestivalItem, err := f.u.CreateFestivalItem(c.Request().Context(), *festivalItem) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latestFestivalItem) -} - -func (f *festivalItemController) UpdateFestivalItem(c echo.Context) error { - id := c.Param("id") - festivalItem := new(FestivalItem) - if err := c.Bind(festivalItem); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - updatedFestivalItem, err := f.u.UpdateFestivalItem( - c.Request().Context(), - id, - *festivalItem, - ) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedFestivalItem) -} - -func (f *festivalItemController) DestroyFestivalItem(c echo.Context) error { - id := c.Param("id") - err := f.u.DestroyFestivalItem(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Festival Item") -} - -type FestivalItemDetails = generated.FestivalItemDetails -type FestivalItem = generated.FestivalItem -type FestivalItemsForMyPage = generated.FestivalItemsForMyPage -type FestivalItemOption = generated.FestivalItemOption diff --git a/api/externals/controller/financial_record_controller.go b/api/externals/controller/financial_record_controller.go deleted file mode 100644 index 1e50fadf0..000000000 --- a/api/externals/controller/financial_record_controller.go +++ /dev/null @@ -1,148 +0,0 @@ -package controller - -import ( - "encoding/csv" - "fmt" - "net/http" - - "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 financialRecordController struct { - u usecase.FinancialRecordUseCase -} - -type FinancialRecordController interface { - IndexFinancialRecords(echo.Context) error - GetFinancialRecord(echo.Context) error - CreateFinancialRecord(echo.Context) error - UpdateFinancialRecord(echo.Context) error - DestroyFinancialRecord(echo.Context) error - DownloadFinancialRecordsCSV(echo.Context) error -} - -func NewFinancialRecordController(u usecase.FinancialRecordUseCase) FinancialRecordController { - return &financialRecordController{u} -} - -func (f *financialRecordController) IndexFinancialRecords(c echo.Context) error { - year := c.QueryParam("year") - var financialRecordDetails FinancialRecordDetails - var err error - ctx := c.Request().Context() - - if year != "" { - financialRecordDetails, err = f.u.GetFinancialRecordsByYears(ctx, year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, financialRecordDetails) - } - - financialRecordDetails, err = f.u.GetFinancialRecords(ctx) - if err != nil { - return err - } - return c.JSON(http.StatusOK, financialRecordDetails) -} - -func (f *financialRecordController) GetFinancialRecord(c echo.Context) error { - id := c.Param("id") - financialRecord, err := f.u.GetFinancialRecord(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, financialRecord) -} - -func (f *financialRecordController) CreateFinancialRecord(c echo.Context) error { - financialRecord := new(FinancialRecord) - if err := c.Bind(financialRecord); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - latestFinancialRecord, err := f.u.CreateFinancialRecord(c.Request().Context(), *financialRecord) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latestFinancialRecord) -} - -func (f *financialRecordController) UpdateFinancialRecord(c echo.Context) error { - id := c.Param("id") - financialRecord := new(FinancialRecord) - if err := c.Bind(financialRecord); err != nil { - return c.String(http.StatusBadRequest, "Bad Request") - } - updatedFinancialRecord, err := f.u.UpdateFinancialRecord( - c.Request().Context(), - id, - *financialRecord, - ) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedFinancialRecord) -} - -func (f *financialRecordController) DestroyFinancialRecord(c echo.Context) error { - id := c.Param("id") - err := f.u.DestroyFinancialRecord(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy FinancialRecord") -} - -func (f *financialRecordController) DownloadFinancialRecordsCSV(c echo.Context) error { - year := c.QueryParam("year") - var err error - - records, err := f.u.GetFinancialRecordDetailForCSV(c.Request().Context(), year) - if err != nil { - return err - } - - // ヘッダーの設定 - w := c.Response().Writer - fileName := fmt.Sprintf("予算_%s.csv", year) - attachment := fmt.Sprintf(`attachment; filename="%s"`, fileName) - w.Header().Set("Content-Type", "text/csv") - w.Header().Set("Content-Disposition", attachment) - - if err := makeCSV(w, records); err != nil { - return err - } - - return nil -} - -func makeCSV(writer http.ResponseWriter, records [][]string) error { - // Shift_JISエンコーディング用の変換を設定 - encoder := japanese.ShiftJIS.NewEncoder() - - // writerに対してエンコーダを設定して変換する - shiftJISWriter := transform.NewWriter(writer, encoder) - - // CSVライターを作成 - 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 -} - -type FinancialRecordDetails = generated.FinancialRecordDetails -type FinancialRecord = generated.FinancialRecord diff --git a/api/externals/controller/health_check_controller.go b/api/externals/controller/health_check_controller.go deleted file mode 100644 index 8f438ded0..000000000 --- a/api/externals/controller/health_check_controller.go +++ /dev/null @@ -1,21 +0,0 @@ -package controller - -import ( - "github.com/labstack/echo/v4" - "net/http" -) - -type healthcheckController struct { -} - -type HealthcheckController interface { - IndexHealthcheck(echo.Context) error -} - -func NewHealthCheckController() HealthcheckController { - return &healthcheckController{} -} - -func (hc healthcheckController) IndexHealthcheck(c echo.Context) error { - return c.String(http.StatusOK, "healthcheck: ok") -} diff --git a/api/externals/controller/income_controller.go b/api/externals/controller/income_controller.go deleted file mode 100644 index 11f3961c2..000000000 --- a/api/externals/controller/income_controller.go +++ /dev/null @@ -1,108 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/generated" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type incomeController struct { - u usecase.IncomeUseCase -} - -type IncomeController interface { - IndexIncome(c echo.Context) error - PostIncome(c echo.Context) error - GetIncome(c echo.Context) error - PutIncome(c echo.Context) error - DeleteIncome(c echo.Context) error -} - -func NewIncomeController( - u usecase.IncomeUseCase, -) IncomeController { - return &incomeController{u} -} - -// Get all incomeCategories -func (i *incomeController) IndexIncome(c echo.Context) error { - ctx := c.Request().Context() - incomeCategories, err := i.u.GetAllIncome(ctx) - if err != nil { - return c.JSON(http.StatusInternalServerError, "failed to get all income items") - } - return c.JSON(http.StatusOK, incomeCategories) -} - -// Post -func (i *incomeController) PostIncome(c echo.Context) error { - ctx := c.Request().Context() - var income Income - if err := c.Bind(&income); err != nil { - return c.JSON(http.StatusBadRequest, "failed to bind") - } - - createdIncome, err := i.u.CreateIncome(ctx, income) - if err != nil { - return c.JSON(http.StatusInternalServerError, err.Error()) - } - return c.JSON(http.StatusOK, createdIncome) -} - -// GET -func (i *incomeController) GetIncome(c echo.Context) error { - ctx := c.Request().Context() - incomeID := c.Param("id") - if incomeID == "" { - return c.JSON(http.StatusBadRequest, "income ID is required") - } - - income, err := i.u.GetIncome(ctx, incomeID) - if err != nil { - return c.JSON(http.StatusInternalServerError, "failed to get income") - } - if income == nil { - return c.JSON(http.StatusNotFound, "income not found") - } - return c.JSON(http.StatusOK, income) -} - -// PUT -func (i *incomeController) PutIncome(c echo.Context) error { - ctx := c.Request().Context() - incomeID := c.Param("id") - if incomeID == "" { - return c.JSON(http.StatusBadRequest, "income ID is required") - } - - var income Income - if err := c.Bind(&income); err != nil { - return c.JSON(http.StatusBadRequest, "failed to bind") - } - updatedIncome, err := i.u.UpdateIncome(ctx, incomeID, income) - if err != nil { - return c.JSON(http.StatusInternalServerError, err.Error()) - } - // Return the updated income - return c.JSON(http.StatusOK, updatedIncome) -} - -// DELETE -func (i *incomeController) DeleteIncome(c echo.Context) error { - ctx := c.Request().Context() - incomeID := c.Param("id") - if incomeID == "" { - return c.JSON(http.StatusBadRequest, "income ID is required") - } - - if err := i.u.DeleteIncome(ctx, incomeID); err != nil { - return c.JSON(http.StatusInternalServerError, "failed to delete income") - } - return c.JSON(http.StatusOK, "ok") -} - -type ( - Income = generated.Income -) diff --git a/api/externals/controller/income_expenditure_management_controller.go b/api/externals/controller/income_expenditure_management_controller.go deleted file mode 100644 index 8614be46d..000000000 --- a/api/externals/controller/income_expenditure_management_controller.go +++ /dev/null @@ -1,54 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/generated" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type incomeExpenditureManagementController struct { - u usecase.IncomeExpenditureManagementUseCase -} - -type IncomeExpenditureManagementController interface { - IndexIncomeExpenditureManagements(echo.Context) error - PutIncomeExpenditureManagementCheck(echo.Context) error -} - -func NewIncomeExpenditureManagementController(u usecase.IncomeExpenditureManagementUseCase) IncomeExpenditureManagementController { - return &incomeExpenditureManagementController{u} -} - -// Index -func (i *incomeExpenditureManagementController) IndexIncomeExpenditureManagements(c echo.Context) error { - ctx := c.Request().Context() - year := c.QueryParam("year") - - incomeExpenditureManagements, err := i.u.IndexIncomeExpenditureManagements(ctx, year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, incomeExpenditureManagements) -} - -// Put -func (i *incomeExpenditureManagementController) PutIncomeExpenditureManagementCheck(c echo.Context) error { - ctx := c.Request().Context() - id := c.Param("id") - var body generated.PutIncomeExpenditureManagementsCheckIdJSONBody - if err := c.Bind(&body); err != nil { - return err - } - - if err := i.u.PutIncomeExpenditureManagementCheck(ctx, id, body.IsChecked); err != nil { - return err - } - - return c.JSON(http.StatusOK, "ok") -} - -type ( - PutIncomeExpenditureManagementsCheckIdJSONBody = generated.PutIncomeExpenditureManagementsCheckIdJSONBody -) diff --git a/api/externals/controller/mail_auth_controller.go b/api/externals/controller/mail_auth_controller.go deleted file mode 100644 index 742c8dc09..000000000 --- a/api/externals/controller/mail_auth_controller.go +++ /dev/null @@ -1,68 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type mailAuthController struct { - u usecase.MailAuthUseCase -} - -type MailAuthController interface { - SignUp(echo.Context) error - SignIn(echo.Context) error - SignOut(echo.Context) error - IsSignIn(echo.Context) error -} - -func NewMailAuthController(u usecase.MailAuthUseCase) MailAuthController { - return &mailAuthController{u} -} - -// sign up -func (auth *mailAuthController) SignUp(c echo.Context) error { - email := c.QueryParam("email") - password := c.QueryParam("password") - userID := c.QueryParam("user_id") - token, err := auth.u.SignUp(c.Request().Context(), email, password, userID) - if err != nil { - return err - } - return c.JSON(http.StatusOK, token) -} - -// sign in -func (auth *mailAuthController) SignIn(c echo.Context) error { - email := c.QueryParam("email") - password := c.QueryParam("password") - token, err := auth.u.SignIn(c.Request().Context(), email, password) - if err != nil { - return err - } - return c.JSON(http.StatusOK, token) -} - -// sign out -func (auth *mailAuthController) SignOut(c echo.Context) error { - // headerからトークンを取得する - accessToken := c.Request().Header["Access-Token"][0] - err := auth.u.SignOut(c.Request().Context(), accessToken) - if err != nil { - return err - } - return c.String(http.StatusOK, "Success Sign Out") -} - -// ログインしてるかを確認 -func (auth *mailAuthController) IsSignIn(c echo.Context) error { - // headerからトークンを取得する - accessToken := c.Request().Header["Access-Token"][0] - isSignIn, err := auth.u.IsSignIn(c.Request().Context(), accessToken) - if err != nil { - return nil - } - return c.JSON(http.StatusOK, isSignIn) -} diff --git a/api/externals/controller/object_upload_controller.go b/api/externals/controller/object_upload_controller.go deleted file mode 100644 index 0ee774315..000000000 --- a/api/externals/controller/object_upload_controller.go +++ /dev/null @@ -1,35 +0,0 @@ -package controller - -import ( - "log" - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type objectUploadController struct { - u usecase.ObjectUploadUseCase -} - -type ObjectUploadController interface { - UploadObject(echo.Context) error -} - -func NewObjectUploadController(u usecase.ObjectUploadUseCase) ObjectUploadController { - return &objectUploadController{u} -} - -func (oc objectUploadController) UploadObject(c echo.Context) error { - file, err := c.FormFile("file") - if err != nil { - return c.String(http.StatusBadRequest, "file not found") - } - - if err := oc.u.UploadFile(c.Request().Context(), file); err != nil { - log.Println(err) - return c.String(http.StatusInternalServerError, "upload failed") - } - - return c.String(http.StatusOK, "upload success") -} diff --git a/api/externals/controller/password_reset_token_controller.go b/api/externals/controller/password_reset_token_controller.go deleted file mode 100644 index ca097849f..000000000 --- a/api/externals/controller/password_reset_token_controller.go +++ /dev/null @@ -1,78 +0,0 @@ -package controller - -import ( - "errors" - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type passwordResetTokenController struct { - u usecase.PasswordResetTokenUseCase -} - -type PasswordResetTokenController interface { - SendPasswordResetRequest(echo.Context) error - ValidPasswordResetToken(echo.Context) error - ChangePassword(echo.Context) error -} - -func NewPasswordResetTokenController(u usecase.PasswordResetTokenUseCase) PasswordResetTokenController { - return &passwordResetTokenController{u} -} - -// パスワード変更リクエスト -func (p *passwordResetTokenController) SendPasswordResetRequest(c echo.Context) error { - email := c.QueryParam("email") - err := p.u.PasswordResetTokenRequest(c.Request().Context(), email) - if err != nil { - return c.String(http.StatusOK, err.Error()) - } - return c.String(http.StatusOK, "PasswordResetTokenを送信しました") -} - -// トークンが有効チェック -func (p *passwordResetTokenController) ValidPasswordResetToken(c echo.Context) error { - id := c.Param("id") - token := c.QueryParam("token") - err := p.u.ValidPasswordResetToken(c.Request().Context(), id, token) - if err != nil { - return c.String(http.StatusBadRequest, err.Error()) - } - - return c.String(http.StatusOK, "Tokenは有効です") -} - - -// パスワード変更 -func (p *passwordResetTokenController) ChangePassword(c echo.Context) error { - id := c.Param("id") - passwordResetData := new(domain.PasswordResetData) - - if err := c.Bind(passwordResetData); err != nil { - return err - } - - //トークンの有効チェック - err := p.u.ValidPasswordResetToken(c.Request().Context(), id, passwordResetData.Token) - if err != nil { - return c.String(http.StatusBadRequest, err.Error()) - } - - //パスワードのバリデーション - isValidPassword := passwordResetData.Password != passwordResetData.ConfirmPassword || passwordResetData.Password == "" || len(passwordResetData.Password)<6 - if isValidPassword { - err = errors.New("パスワードが不正です") - return c.String(http.StatusBadRequest, err.Error()) - } - - //パスワード変更 - err = p.u.ChangePassword(c.Request().Context(), id, passwordResetData.Password) - if err != nil { - return c.String(http.StatusBadRequest, err.Error()) - } - - return c.String(http.StatusOK, "パスワードを変更しました") -} diff --git a/api/externals/controller/purchase_item_controller.go b/api/externals/controller/purchase_item_controller.go deleted file mode 100644 index 5838a1994..000000000 --- a/api/externals/controller/purchase_item_controller.go +++ /dev/null @@ -1,106 +0,0 @@ -package controller - -import( - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" - "net/http" -) - -type purchaseItemController struct { - u usecase.PurchaseItemUseCase -} - -type PurchaseItemController interface { - IndexPurchaseItem(echo.Context) error - ShowPurchaseItem(echo.Context) error - CreatePurchaseItem(echo.Context) error - UpdatePurchaseItem(echo.Context) error - DestroyPurchaseItem(echo.Context) error - IndexPurchaseItemDetails(echo.Context) error - ShowPurchaseItemDetails(echo.Context) error -} - -func NewPurchaseItemController(u usecase.PurchaseItemUseCase) PurchaseItemController{ - return &purchaseItemController{u} -} - -//Index -func (p *purchaseItemController) IndexPurchaseItem(c echo.Context)error{ - purchaseItems , err := p.u.GetPurchaseItem(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseItems) -} - -//show -func(p *purchaseItemController) ShowPurchaseItem(c echo.Context)error{ - id := c.Param("id") - purchaseItem ,err := p.u.GetPurchaseItemByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK,purchaseItem) -} - -//Create -func (p *purchaseItemController) CreatePurchaseItem(c echo.Context)error{ - item := c.QueryParam("item") - price := c.QueryParam("price") - quantity := c.QueryParam("quantity") - detail := c.QueryParam("detail") - url := c.QueryParam("url") - purchaseOrderID := c.QueryParam("purchase_order_id") - financeCheck := c.QueryParam("finance_check") - latastPurchaseItem, err := p.u.CreatePurchaseItem(c.Request().Context(),item, price, quantity, detail, url, purchaseOrderID, financeCheck) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastPurchaseItem) -} - -//Update -func(p *purchaseItemController) UpdatePurchaseItem(c echo.Context)error{ - id := c.Param("id") - item := c.QueryParam("item") - price := c.QueryParam("price") - quantity := c.QueryParam("quantity") - detail := c.QueryParam("detail") - url := c.QueryParam("url") - purchaseOrderID := c.QueryParam("purchase_order_id") - financeCheck := c.QueryParam("finance_check") - updatedPurchaseItem, err := p.u.UpdatePurchaseItem(c.Request().Context(), id, item, price, quantity, detail, url, purchaseOrderID,financeCheck) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedPurchaseItem) -} - -//Destory -func (p *purchaseItemController) DestroyPurchaseItem(c echo.Context) error{ - id := c.Param("id") - err := p.u.DestroyPurchaseItem(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destory PurchaseItem") -} - -//IndexPurchaseItemWithPurchaseOrder -func (p *purchaseItemController) IndexPurchaseItemDetails(c echo.Context) error { - purchaseItemWithPurchaseOrders, err := p.u.GetPurchaseItemDetails(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseItemWithPurchaseOrders) -} - -//ShowPurchaseItemWithPurchaseorder -func (p *purchaseItemController) ShowPurchaseItemDetails(c echo.Context) error { - id :=c.Param("id") - purchaseItemwithpurchaseorder, err :=p.u.GetPurchaseItemDetailsByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK,purchaseItemwithpurchaseorder ) -} diff --git a/api/externals/controller/purchase_report_controller.go b/api/externals/controller/purchase_report_controller.go deleted file mode 100644 index 7fe8ec52d..000000000 --- a/api/externals/controller/purchase_report_controller.go +++ /dev/null @@ -1,111 +0,0 @@ -package controller - -import ( - "net/http" - "strconv" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type purchaseReportController struct { - u usecase.PurchaseReportUseCase -} - -type PurchaseReportController interface { - IndexPurchaseReport(echo.Context) error - ShowPurchaseReport(echo.Context) error - CreatePurchaseReport(echo.Context) error - UpdatePurchaseReport(echo.Context) error - DestroyPurchaseReport(echo.Context) error - IndexPurchaseReportDetails(echo.Context) error - ShowPurchaseReportDetail(echo.Context) error - IndexPurchaseReportDetailsByYear(echo.Context) error -} - -func NewPurchaseReportController(u usecase.PurchaseReportUseCase) PurchaseReportController { - return &purchaseReportController{u} -} - -// Index -func (p *purchaseReportController) IndexPurchaseReport(c echo.Context) error { - purchaseReports, err := p.u.GetPurchaseReports(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseReports) -} - -// show -func (p *purchaseReportController) ShowPurchaseReport(c echo.Context) error { - id := c.Param("id") - purchaseReport, err := p.u.GetPurchaseReportByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseReport) -} - -// Create -func (p *purchaseReportController) CreatePurchaseReport(c echo.Context) error { - report := new(domain.PurchaseReport) - if err := c.Bind(report); err != nil { - return err - } - latastPurchaseReport, err := p.u.CreatePurchaseReport(c.Request().Context(), strconv.Itoa(report.UserID), strconv.Itoa(report.Discount), strconv.Itoa(report.Addition), strconv.FormatBool(report.FinanceCheck), strconv.Itoa(report.PurchaseOrderID), report.Remark, report.Buyer) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastPurchaseReport) -} - -// Update -func (p *purchaseReportController) UpdatePurchaseReport(c echo.Context) error { - id := c.Param("id") - report := new(domain.PurchaseReport) - if err := c.Bind(report); err != nil { - return err - } - updatedPurchaseReport, err := p.u.UpdatePurchaseReport(c.Request().Context(), id, strconv.Itoa(report.UserID), strconv.Itoa(report.Discount), strconv.Itoa(report.Addition), strconv.FormatBool(report.FinanceCheck), strconv.Itoa(report.PurchaseOrderID), report.Remark, report.Buyer) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedPurchaseReport) -} - -// Destory -func (p *purchaseReportController) DestroyPurchaseReport(c echo.Context) error { - id := c.Param("id") - err := p.u.DestroyPurchaseReport(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destory PurchaseReport") -} - -func (p *purchaseReportController) IndexPurchaseReportDetails(c echo.Context) error { - purchaseReportDetails, err := p.u.GetPurchaseReportDetails(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseReportDetails) -} - -func (p *purchaseReportController) ShowPurchaseReportDetail(c echo.Context) error { - id := c.Param("id") - purchaseReportDetail, err := p.u.GetPurchaseReportDetailByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseReportDetail) -} - -func (p *purchaseReportController) IndexPurchaseReportDetailsByYear(c echo.Context) error { - year := c.Param("year") - purchaseReportDetails, err := p.u.GetPurchaseReportDetailsByYear(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseReportDetails) -} diff --git a/api/externals/controller/purhcase_order_controller.go b/api/externals/controller/purhcase_order_controller.go deleted file mode 100644 index 4c9eaf771..000000000 --- a/api/externals/controller/purhcase_order_controller.go +++ /dev/null @@ -1,140 +0,0 @@ -package controller - -import ( - "fmt" - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type purchaseOrderController struct { - u usecase.PurchaseOrderUseCase -} - -type PurchaseOrderController interface { - IndexPurchaseOrder(echo.Context) error - ShowPurchaseOrder(echo.Context) error - CreatePurchaseOrder(echo.Context) error - UpdatePurchaseOrder(echo.Context) error - DestroyPurchaseOrder(echo.Context) error - IndexOrderDetail(echo.Context) error - ShowOrderDetail(echo.Context) error - IndexOrderDetailByYear(echo.Context) error - NotifySlack(echo.Context) error - IndexUnregisteredOrderDetailByYear(echo.Context) error -} - -func NewPurchaseOrderController(u usecase.PurchaseOrderUseCase) PurchaseOrderController { - return &purchaseOrderController{u} -} - -// Index -func (p *purchaseOrderController) IndexPurchaseOrder(c echo.Context) error { - purchaseOrders, err := p.u.GetPurchaseOrders(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseOrders) -} - -// show -func (p *purchaseOrderController) ShowPurchaseOrder(c echo.Context) error { - id := c.Param("id") - purchaseOrder, err := p.u.GetPurchaseOrderByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseOrder) -} - -// Create -func (p *purchaseOrderController) CreatePurchaseOrder(c echo.Context) error { - deadLine := c.QueryParam("deadline") - userID := c.QueryParam("user_id") - expenseID := c.QueryParam("expense_id") - financeCheck := c.QueryParam("finance_check") - purchaseOrder, err := p.u.CreatePurchaseOrder(c.Request().Context(), deadLine, userID, expenseID, financeCheck) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseOrder) -} - -// Update -func (p *purchaseOrderController) UpdatePurchaseOrder(c echo.Context) error { - id := c.Param("id") - deadLine := c.QueryParam("deadline") - userID := c.QueryParam("user_id") - expenseID := c.QueryParam("expense_id") - financeCheck := c.QueryParam("finance_check") - - purchaseOrder, err := p.u.UpdatePurchaseOrder(c.Request().Context(), id, deadLine, userID, expenseID, financeCheck) - if err != nil { - return err - } - return c.JSON(http.StatusOK, purchaseOrder) -} - -// Destory -func (p *purchaseOrderController) DestroyPurchaseOrder(c echo.Context) error { - id := c.Param("id") - err := p.u.DestroyPurchaseOrder(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy PurchaseOrder") -} - -// IndexOrderWithUserItem -func (p *purchaseOrderController) IndexOrderDetail(c echo.Context) error { - orderDetails, err := p.u.GetPurchaseOrderDetails(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, orderDetails) -} - -func (p *purchaseOrderController) ShowOrderDetail(c echo.Context) error { - id := c.Param("id") - orderDetail, err := p.u.GetPurchaseOrderDetailByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, orderDetail) -} - -func (p *purchaseOrderController) IndexOrderDetailByYear(c echo.Context) error { - year := c.Param("year") - orderDetails, err := p.u.GetPurchaseOrderDetailsByYear(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, orderDetails) -} - -//通知用API -// TODO いずれは購入申請と物品を一括送信してSlack通知をするようにフロント・バックのリファクタリングを行う -func (p *purchaseOrderController) NotifySlack(c echo.Context) error { - id := c.Param("id") - purchaseItems := new([]domain.PurchaseItem) - if err := c.Bind(purchaseItems); err != nil { - fmt.Println("err") - return err - } - err := p.u.NotifySlack(c.Request().Context(), id, *purchaseItems) - if err != nil { - return err - } - return c.JSON(http.StatusOK, err) -} - -func (p *purchaseOrderController) IndexUnregisteredOrderDetailByYear(c echo.Context) error { - year := c.Param("year") - orderDetails, err := p.u.GetUnregisteredPurchaseOrderDetailsByYear(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, orderDetails) -} diff --git a/api/externals/controller/receipt_controller.go b/api/externals/controller/receipt_controller.go deleted file mode 100644 index d787e4d22..000000000 --- a/api/externals/controller/receipt_controller.go +++ /dev/null @@ -1,91 +0,0 @@ -package controller - -import ( - "fmt" - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type receiptController struct { - u usecase.ReceiptUseCase -} - -type ReceiptController interface { - IndexReceipt(echo.Context) error - ShowReceipt(echo.Context) error - FindReceiptsByReportID(echo.Context) error - CreateReceipt(echo.Context) error - UpdateReceipt(echo.Context) error - DestroyReceipt(echo.Context) error -} - -func NewReceiptController(u usecase.ReceiptUseCase) ReceiptController { - return &receiptController{u} -} - -func (r *receiptController) IndexReceipt(c echo.Context) error { - receipts, err := r.u.GetAllReceipts(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, receipts) -} - -func (r *receiptController) ShowReceipt(c echo.Context) error { - id := c.Param("id") - receipt, err := r.u.GetReceiptByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, receipt) -} - -func (r *receiptController) FindReceiptsByReportID(c echo.Context) error { - id := c.Param("id") - receipts, err := r.u.GetReceiptByPurchaseReportID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, receipts) -} - - -func (r *receiptController) CreateReceipt(c echo.Context) error { - var receipt domain.Receipt - if err := c.Bind(&receipt); err != nil { - fmt.Println("err") - return err - } - latestReceipt, err := r.u.CreateReceipt(c.Request().Context(), receipt) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latestReceipt) -} - -func (r *receiptController) UpdateReceipt(c echo.Context) error { - id := c.Param("id") - var receipt domain.Receipt - if err := c.Bind(&receipt); err != nil { - fmt.Println("err") - return err - } - updatedReceipt, err := r.u.UpdateReceipt(c.Request().Context(), id, receipt) - - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedReceipt) -} - -func (r *receiptController) DestroyReceipt(c echo.Context) error { - id := c.Param("id") - err := r.u.DestroyReceipt(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, "Destroy Receipt") -} diff --git a/api/externals/controller/source_controller.go b/api/externals/controller/source_controller.go deleted file mode 100644 index e96dc354b..000000000 --- a/api/externals/controller/source_controller.go +++ /dev/null @@ -1,73 +0,0 @@ -package controller - -import ( - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" - "net/http" -) - -type sourceController struct { - u usecase.SourceUseCase -} - -type SourceController interface { - IndexSource(echo.Context) error - ShowSource(echo.Context) error - CreateSource(echo.Context) error - UpdateSource(echo.Context) error - DestroySource(echo.Context) error -} - -func NewSourceController(u usecase.SourceUseCase) SourceController { - return &sourceController{u} -} - -// Index -func (s *sourceController) IndexSource(c echo.Context) error { - sources, err := s.u.GetSources(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sources) -} - -// Show -func (s *sourceController) ShowSource(c echo.Context) error { - id := c.Param("id") - source, err := s.u.GetSourceByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, source) -} - -// Create -func (s *sourceController) CreateSource(c echo.Context) error { - name := c.QueryParam("name") - latastSource,err := s.u.CreateSource(c.Request().Context(), name) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latastSource) -} - -// Update -func (s *sourceController) UpdateSource(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - updatedSource,err := s.u.UpdateSource(c.Request().Context(), id, name) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedSource) -} - -// Destroy -func (s *sourceController) DestroySource(c echo.Context) error { - id := c.Param("id") - err := s.u.DestroySource(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Source") -} diff --git a/api/externals/controller/sponsor_controller.go b/api/externals/controller/sponsor_controller.go deleted file mode 100644 index 5e23743d5..000000000 --- a/api/externals/controller/sponsor_controller.go +++ /dev/null @@ -1,138 +0,0 @@ -package controller - -import ( - "log" - "net/http" - "strings" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type sponsorController struct { - u usecase.SponsorUseCase -} - -type SponsorController interface { - IndexSponsor(echo.Context) error - ShowSponsor(echo.Context) error - CreateSponsor(echo.Context) error - UpdateSponsor(echo.Context) error - DestroySponsor(echo.Context) error - IndexSponsorByPeriod(echo.Context) error - CreateSponsorsByCsv(echo.Context) error - IndexSponsorsByRowAffected(echo.Context) error -} - -func NewSponsorController(u usecase.SponsorUseCase) SponsorController { - return &sponsorController{u} -} - -func (s *sponsorController) IndexSponsor(c echo.Context) error { - sponsors, err := s.u.GetSponsor(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sponsors) -} - -func (s *sponsorController) ShowSponsor(c echo.Context) error { - id := c.Param("id") - sponsor, err := s.u.GetSponsorByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sponsor) -} - -func (s *sponsorController) CreateSponsor(c echo.Context) error { - sponsor := new(domain.Sponsor) - if err := c.Bind(sponsor); err != nil { - return err - } - //エスケープ処理 - Name := strings.ReplaceAll(sponsor.Name, `"`, `\"`) - Tel := strings.ReplaceAll(sponsor.Tel, `"`, `\"`) - Email := strings.ReplaceAll(sponsor.Email, `"`, `\"`) - Address := strings.ReplaceAll(sponsor.Address, `"`, `\"`) - Representative := strings.ReplaceAll(sponsor.Representative, `"`, `\"`) - - latastSponsor, err := s.u.CreateSponsor(c.Request().Context(), Name, Tel, Email, Address, Representative) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastSponsor) -} - -func (s *sponsorController) UpdateSponsor(c echo.Context) error { - id := c.Param("id") - sponsor := new(domain.Sponsor) - if err := c.Bind(sponsor); err != nil { - return err - } - //エスケープ処理 - Name := strings.ReplaceAll(sponsor.Name, `"`, `\"`) - Tel := strings.ReplaceAll(sponsor.Tel, `"`, `\"`) - Email := strings.ReplaceAll(sponsor.Email, `"`, `\"`) - Address := strings.ReplaceAll(sponsor.Address, `"`, `\"`) - Representative := strings.ReplaceAll(sponsor.Representative, `"`, `\"`) - - updatedSponsor, err := s.u.UpdateSponsor(c.Request().Context(), id, Name, Tel, Email, Address, Representative) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedSponsor) -} - -func (s *sponsorController) DestroySponsor(c echo.Context) error { - id := c.Param("id") - - err := s.u.DestroySponsor(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Sponsor") -} - -// 年度別に取得 -func (s *sponsorController) IndexSponsorByPeriod(c echo.Context) error { - year := c.Param("year") - sponsors, err := s.u.GetSponsorByPeriod(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sponsors) -} - -// cavで一括登録 -func (s *sponsorController) CreateSponsorsByCsv(c echo.Context) error { - file, err := c.FormFile("file") - if err != nil { - return err - } - csv, err := file.Open() - if err != nil { - return err - } - defer func() { - if err := csv.Close(); err != nil { - log.Println(err) - } - }() - - csvSponsor, err := s.u.CreateSponsorsByCsv(c.Request().Context(), csv) - if err != nil { - return c.JSON(http.StatusInternalServerError, map[string]string{"message": err.Error()}) - } - return c.JSON(http.StatusOK, csvSponsor) -} - -func (s *sponsorController) IndexSponsorsByRowAffected(c echo.Context) error { - row := c.Param("row") - sponsors, err := s.u.GetSponsorByRowAffected(c.Request().Context(), row) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sponsors) -} diff --git a/api/externals/controller/sponsor_style_controller.go b/api/externals/controller/sponsor_style_controller.go deleted file mode 100644 index 21d05d6aa..000000000 --- a/api/externals/controller/sponsor_style_controller.go +++ /dev/null @@ -1,81 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type sponsorStyleController struct { - u usecase.SponsorStyleUseCase -} - -type SponsorStyleController interface { - IndexSponsorStyle(echo.Context) error - ShowSponsorStyle(echo.Context) error - CreateSponsorStyle(echo.Context) error - UpdateSponsorStyle(echo.Context) error - DestroySponsorStyle(echo.Context) error -} - -func NewSponsorStyleController(u usecase.SponsorStyleUseCase) SponsorStyleController { - return &sponsorStyleController{u} -} - -// Index -func (s *sponsorStyleController) IndexSponsorStyle(c echo.Context) error { - sponsorStyles, err := s.u.GetSponsorStyles(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sponsorStyles) -} - -// show -func (s *sponsorStyleController) ShowSponsorStyle(c echo.Context) error { - id := c.Param("id") - sponsorStyle, err := s.u.GetSponsorStylesByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, sponsorStyle) -} - -// Create -func (s *sponsorStyleController) CreateSponsorStyle(c echo.Context) error { - sponsorStyle := new(domain.SponsorStyle) - if err := c.Bind(sponsorStyle); err != nil { - return err - } - latastSponsorStyle, err := s.u.CreateSponsorStyle(c.Request().Context(), sponsorStyle.Style, sponsorStyle.Feature, sponsorStyle.Price) - if err != nil { - return err - } - return c.JSON(http.StatusOK, latastSponsorStyle) -} - -// Update -func (s *sponsorStyleController) UpdateSponsorStyle(c echo.Context) error { - id := c.Param("id") - sponsorStyle := new(domain.SponsorStyle) - if err := c.Bind(sponsorStyle); err != nil { - return err - } - updatedSponsorStyle, err := s.u.UpdateSponsorStyle(c.Request().Context(), id, sponsorStyle.Style, sponsorStyle.Feature, sponsorStyle.Price) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedSponsorStyle) -} - -// Destory -func (s *sponsorStyleController) DestroySponsorStyle(c echo.Context) error { - id := c.Param("id") - err := s.u.DestroySponsorStyle(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy SponsorStyle") -} diff --git a/api/externals/controller/teacher_controller.go b/api/externals/controller/teacher_controller.go deleted file mode 100644 index 010375976..000000000 --- a/api/externals/controller/teacher_controller.go +++ /dev/null @@ -1,111 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type teacherController struct { - u usecase.TeacherUseCase -} - -type TeacherController interface { - IndexTeacher(echo.Context) error - IndexFundRegisteredTeacher(echo.Context) error - ShowTeacher(echo.Context) error - CreateTeacher(echo.Context) error - UpdateTeacher(echo.Context) error - DestroyTeacher(echo.Context) error - DestroyMultiTeachers(echo.Context) error -} - -func NewTeacherController(u usecase.TeacherUseCase) TeacherController { - return &teacherController{u} -} - -// Index -func (t *teacherController) IndexTeacher(c echo.Context) error { - teachers, err := t.u.GetTeachers(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, teachers) -} - -// IndexFundRegistered -func (t *teacherController) IndexFundRegisteredTeacher(c echo.Context) error { - year := c.Param("year") - fundRegisteredTeachers, err := t.u.GetFundRegisteredByPeriods(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, fundRegisteredTeachers) -} - -// Show -func (t *teacherController) ShowTeacher(c echo.Context) error { - id := c.Param("id") - teacher, err := t.u.GetTeacherByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, teacher) -} - -// Create -func (t *teacherController) CreateTeacher(c echo.Context) error { - name := c.QueryParam("name") - position := c.QueryParam("position") - departmentID := c.QueryParam("department_id") - room := c.QueryParam("room") - isBlack := c.QueryParam("is_black") - remark := c.QueryParam("remark") - latestTeacher, err := t.u.CreateTeacher(c.Request().Context(), name, position, departmentID, room, isBlack, remark) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latestTeacher) -} - -// Update -func (t *teacherController) UpdateTeacher(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - position := c.QueryParam("position") - departmentID := c.QueryParam("department_id") - room := c.QueryParam("room") - isBlack := c.QueryParam("is_black") - remark := c.QueryParam("remark") - updateTeacher, err := t.u.UpdateTeacher(c.Request().Context(), id, name, position, departmentID, room, isBlack, remark) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updateTeacher) -} - -// Destroy -func (t *teacherController) DestroyTeacher(c echo.Context) error { - id := c.Param("id") - err := t.u.DestroyTeacher(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Teacher") -} - -// DestroyMultiTeachers -func (t *teacherController) DestroyMultiTeachers(c echo.Context) error { - destroyTeacherIDs := new(domain.DestroyTeacherIDs) - if err := c.Bind(&destroyTeacherIDs);err != nil { - return err - } - - err := t.u.DestroyMultiTeachers(c.Request().Context(), destroyTeacherIDs.DeleteIDs) - if err != nil { - return c.String(http.StatusBadRequest,err.Error()) - } - return c.String(http.StatusOK, "Destroy Teachers") -} diff --git a/api/externals/controller/user_controller.go b/api/externals/controller/user_controller.go deleted file mode 100644 index 9aeb27ccb..000000000 --- a/api/externals/controller/user_controller.go +++ /dev/null @@ -1,106 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type userController struct { - u usecase.UserUseCase -} - -type UserController interface { - IndexUser(echo.Context) error - ShowUser(echo.Context) error - CreateUser(echo.Context) error - UpdateUser(echo.Context) error - DestroyUser(echo.Context) error - DestroyMultiUsers(echo.Context) error - GetCurrentUser(echo.Context) error -} - -func NewUserController(u usecase.UserUseCase) UserController { - return &userController{u} -} - -// Index -func (u *userController) IndexUser(c echo.Context) error { - users, err := u.u.GetUsers(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, users) -} - -// Show -func (u *userController) ShowUser(c echo.Context) error { - id := c.Param("id") - user, err := u.u.GetUserByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, user) -} - -// Create -func (u *userController) CreateUser(c echo.Context) error { - name := c.QueryParam("name") - bureauID := c.QueryParam("bureau_id") - roleID := c.QueryParam("role_id") - latastUser, err := u.u.CreateUser(c.Request().Context(), name, bureauID, roleID) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latastUser) -} - -// Update -func (u *userController) UpdateUser(c echo.Context) error { - id := c.Param("id") - name := c.QueryParam("name") - bureauID := c.QueryParam("bureau_id") - roleID := c.QueryParam("role_id") - updatedUser, err := u.u.UpdateUser(c.Request().Context(), id, name, bureauID, roleID) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedUser) -} - -// Destroy -func (u *userController) DestroyUser(c echo.Context) error { - id := c.Param("id") - err := u.u.DestroyUser(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy User") -} - -// Destroy -func (u *userController) DestroyMultiUsers(c echo.Context) error { - destroyUser := new(domain.DestroyUserIDs) - if err := c.Bind(destroyUser); err != nil { - return err - } - err := u.u.DestroyMultiUsers(c.Request().Context(), destroyUser.DeleteIDs) - if err != nil { - return c.String(http.StatusBadRequest, err.Error()) - } - return c.String(http.StatusOK, "Destroy Users") -} - -// ログインユーザーの取得 -func (auth *userController) GetCurrentUser(c echo.Context) error { - // headerからトークンを取得する - accessToken := c.Request().Header["Access-Token"][0] - user, err := auth.u.GetCurrentUser(c.Request().Context(), accessToken) - if err != nil { - return c.JSON(http.StatusNotFound, user) - } else { - return c.JSON(http.StatusOK, user) - } -} diff --git a/api/externals/controller/year_controller.go b/api/externals/controller/year_controller.go deleted file mode 100644 index a6bd268fe..000000000 --- a/api/externals/controller/year_controller.go +++ /dev/null @@ -1,128 +0,0 @@ -package controller - -import ( - "fmt" - "net/http" - "strconv" - - "github.com/NUTFes/FinanSu/api/internals/domain" - "github.com/NUTFes/FinanSu/api/internals/usecase" - "github.com/labstack/echo/v4" -) - -type yearController struct { - u usecase.YearUseCase -} - -const Layout = "2006-01-02 15:04:05" - -type YearController interface { - IndexYear(echo.Context) error - ShowYear(echo.Context) error - CreateYear(echo.Context) error - UpdateYear(echo.Context) error - DestroyYear(echo.Context) error - IndexYearPeriods(echo.Context) error - CreateYearPeriod(echo.Context) error - UpdateYearPeriod(echo.Context) error - DestroyYearPeriod(echo.Context) error -} - -func NewYearController(u usecase.YearUseCase) YearController { - return &yearController{u} -} - -// Index -func (y *yearController) IndexYear(c echo.Context) error { - years, err := y.u.GetYears(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, years) -} - -// Show -func (y *yearController) ShowYear(c echo.Context) error { - id := c.Param("id") - year, err := y.u.GetYearByID(c.Request().Context(), id) - if err != nil { - return err - } - return c.JSON(http.StatusOK, year) -} - -// Create -func (y *yearController) CreateYear(c echo.Context) error { - year := c.QueryParam("year") - latestYear, err := y.u.CreateYear(c.Request().Context(), year) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latestYear) -} - -// Update -func (y *yearController) UpdateYear(c echo.Context) error { - id := c.Param("id") - year := c.QueryParam("year") - updatedYear, err := y.u.UpdateYear(c.Request().Context(), id, year) - if err != nil { - return err - } - return c.JSON(http.StatusOK, updatedYear) -} - -// Destroy -func (y *yearController) DestroyYear(c echo.Context) error { - id := c.Param("id") - err := y.u.DestroyYear(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Year") -} - -func (y *yearController) IndexYearPeriods(c echo.Context) error { - years, err := y.u.GetYearPeriods(c.Request().Context()) - if err != nil { - return err - } - return c.JSON(http.StatusOK, years) -} - -func (y *yearController) CreateYearPeriod(c echo.Context) error { - yearPeriod := new(domain.YearPeriod) - if err := c.Bind(yearPeriod); err != nil { - fmt.Println("err") - return err - } - latestYearPeriod, err := y.u.CreateYearPeriod(c.Request().Context(), strconv.Itoa(yearPeriod.Year), yearPeriod.StartedAt.Format(Layout), yearPeriod.EndedAt.Format(Layout)) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, latestYearPeriod) -} - -func (y *yearController) UpdateYearPeriod(c echo.Context) error { - id := c.Param("id") - print(id) - yearPeriod := new(domain.YearPeriod) - if err := c.Bind(yearPeriod); err != nil { - fmt.Println("err") - return err - } - updateYearPeriod, err := y.u.UpdateYearPeriod(c.Request().Context(), id , strconv.Itoa(yearPeriod.Year), yearPeriod.StartedAt.Format(Layout), yearPeriod.EndedAt.Format(Layout)) - if err != nil { - return err - } - return c.JSON(http.StatusCreated, updateYearPeriod) -} - -func (y *yearController) DestroyYearPeriod(c echo.Context) error { - id := c.Param("id") - err := y.u.DestroyYearPeriod(c.Request().Context(), id) - if err != nil { - return err - } - return c.String(http.StatusOK, "Destroy Year Records") -} diff --git a/api/externals/handler/activity_handler.go b/api/externals/handler/activity_handler.go index 1b209ea55..ec90076f3 100644 --- a/api/externals/handler/activity_handler.go +++ b/api/externals/handler/activity_handler.go @@ -102,12 +102,20 @@ func (h *Handler) GetActivitiesFilteredDetails(c echo.Context, params generated. } func (h *Handler) GetActivitiesFilteredDetailsYear(c echo.Context, year string, params generated.GetActivitiesFilteredDetailsYearParams) error { - isDone := string(*params.IsDone) + var isDone string + if params.IsDone != nil { + isDone = string(*params.IsDone) + } + sponsorStyleIDs := []string{} for _, id := range *params.SponsorStyleId { sponsorStyleIDs = append(sponsorStyleIDs, strconv.Itoa(int(id))) } - keyword := *params.Keyword + var keyword string + if params.Keyword != nil { + keyword = *params.Keyword + } + activities, err := h.activityUseCase.GetFilteredActivityDetailByPeriod(c.Request().Context(), isDone, sponsorStyleIDs, year, keyword) if err != nil { return err diff --git a/api/externals/handler/buy_report_handler.go b/api/externals/handler/buy_report_handler.go index 1c0835b99..dcdb32683 100644 --- a/api/externals/handler/buy_report_handler.go +++ b/api/externals/handler/buy_report_handler.go @@ -16,8 +16,20 @@ import ( // router.PUT(baseURL+"/buy_report/status/:buy_report_id", wrapper.PutBuyReportStatusBuyReportId) func (h *Handler) PutBuyReportStatusBuyReportId(c echo.Context, id int) error { - // 未実装 - return c.String(http.StatusNotImplemented, "PutBuyReportStatusBuyReportId is not implemented") + ctx := c.Request().Context() + buyReportId := strconv.Itoa(id) + + var requestBody generated.PutBuyReportStatusBuyReportIdJSONRequestBody + if err := c.Bind(&requestBody); err != nil { + return c.String(http.StatusBadRequest, "Bad Request") + } + + buyReportDetail, err := h.buyReportUseCase.UpdateBuyReportStatus(ctx, buyReportId, requestBody) + if err != nil { + return c.String(http.StatusBadRequest, "failed update buy_reports") + } + + return c.JSON(http.StatusOK, buyReportDetail) } // router.POST(baseURL+"/buy_reports", wrapper.PostBuyReports) @@ -50,8 +62,18 @@ func (h *Handler) PostBuyReports(c echo.Context) error { // router.GET(baseURL+"/buy_reports/details", wrapper.GetBuyReportsDetails) func (h *Handler) GetBuyReportsDetails(c echo.Context, params generated.GetBuyReportsDetailsParams) error { - //未実装 - return c.String(http.StatusNotImplemented, "GetBuyReportsDetails is not implemented") + ctx := c.Request().Context() + var yearStr string + if params.Year != nil { + yearStr = strconv.Itoa(*params.Year) + } + + buyReportDetails, err := h.buyReportUseCase.GetBuyReports(ctx, yearStr) + if err != nil { + return c.String(http.StatusBadRequest, "failed to buy_reports") + } + + return c.JSON(http.StatusOK, buyReportDetails) } // router.DELETE(baseURL+"/buy_reports/:id", wrapper.DeleteBuyReportsId) diff --git a/api/externals/handler/division_handler.go b/api/externals/handler/division_handler.go index 480defb67..39f594114 100644 --- a/api/externals/handler/division_handler.go +++ b/api/externals/handler/division_handler.go @@ -11,10 +11,16 @@ import ( // router.GET(baseURL+"/divisions", wrapper.GetDivisions) func (h *Handler) GetDivisions(c echo.Context, params generated.GetDivisionsParams) error { ctx := c.Request().Context() - year := strconv.Itoa(*params.Year) - financialRecordId := strconv.Itoa(*params.FinancialRecordId) + var yearStr string + if params.Year != nil { + yearStr = strconv.Itoa(*params.Year) + } + var financialRecordIdStr string + if params.FinancialRecordId != nil { + financialRecordIdStr = strconv.Itoa(*params.FinancialRecordId) + } - divisionDetails, err := h.divisionUseCase.GetDivisions(ctx, year, financialRecordId) + divisionDetails, err := h.divisionUseCase.GetDivisions(ctx, yearStr, financialRecordIdStr) if err != nil { return err } diff --git a/api/externals/handler/festival_item_handler.go b/api/externals/handler/festival_item_handler.go index ffd832455..d73e30eba 100644 --- a/api/externals/handler/festival_item_handler.go +++ b/api/externals/handler/festival_item_handler.go @@ -11,11 +11,17 @@ import ( // router.GET(baseURL+"/festival_items", wrapper.GetFestivalItems) func (h *Handler) GetFestivalItems(c echo.Context, params generated.GetFestivalItemsParams) error { ctx := c.Request().Context() - year := strconv.Itoa(*params.Year) - divisionId := strconv.Itoa(*params.DivisionId) + var yearStr string + var divisionIdStr string + if params.Year != nil { + yearStr = strconv.Itoa(*params.Year) + } + if params.DivisionId != nil { + divisionIdStr = strconv.Itoa(*params.DivisionId) + } var festivalItemDetails FestivalItemDetails - festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItems(ctx, year, divisionId) + festivalItemDetails, err := h.festivalItemUseCase.GetFestivalItems(ctx, yearStr, divisionIdStr) if err != nil { return err } diff --git a/api/externals/handler/financial_record_handler.go b/api/externals/handler/financial_record_handler.go index c8aea2124..f47e7f944 100644 --- a/api/externals/handler/financial_record_handler.go +++ b/api/externals/handler/financial_record_handler.go @@ -14,8 +14,23 @@ import ( // router.GET(baseURL+"/financial_records", wrapper.GetFinancialRecords) func (h *Handler) GetFinancialRecords(c echo.Context, params generated.GetFinancialRecordsParams) error { - yearStr := strconv.Itoa(*params.Year) - financialRecordDetails, err := h.financialRecordUseCase.GetFinancialRecordsByYears(c.Request().Context(), yearStr) + var financialRecordDetails FinancialRecordDetails + var err error + ctx := c.Request().Context() + var yearStr string + if params.Year == nil { + financialRecordDetails, err = h.financialRecordUseCase.GetFinancialRecords(ctx) + if err != nil { + return err + } + return c.JSON(http.StatusOK, financialRecordDetails) + } + yearStr = strconv.Itoa(*params.Year) + + if yearStr != "" { + } + + financialRecordDetails, err = h.financialRecordUseCase.GetFinancialRecordsByYears(ctx, yearStr) if err != nil { return err } diff --git a/api/externals/handler/income_expenditure_management_handler.go b/api/externals/handler/income_expenditure_management_handler.go index b3d7807f1..7b904d423 100644 --- a/api/externals/handler/income_expenditure_management_handler.go +++ b/api/externals/handler/income_expenditure_management_handler.go @@ -11,8 +11,11 @@ import ( // Index func (h *Handler) GetIncomeExpenditureManagements(c echo.Context, params generated.GetIncomeExpenditureManagementsParams) error { ctx := c.Request().Context() - year := strconv.Itoa(*params.Year) - incomeExpenditureManagements, err := h.incomeExpenditureManagementUseCase.IndexIncomeExpenditureManagements(ctx, year) + var yearStr string + if params.Year != nil { + yearStr = strconv.Itoa(*params.Year) + } + incomeExpenditureManagements, err := h.incomeExpenditureManagementUseCase.IndexIncomeExpenditureManagements(ctx, yearStr) if err != nil { return err } diff --git a/api/externals/handler/user_handler.go b/api/externals/handler/user_handler.go index 84419153d..e6ea43344 100644 --- a/api/externals/handler/user_handler.go +++ b/api/externals/handler/user_handler.go @@ -75,3 +75,14 @@ func (h *Handler) PutUsersId(c echo.Context, id int, params generated.PutUsersId } return c.JSON(http.StatusOK, updatedUser) } + +// ログインユーザーの取得 +func (h *Handler) GetCurrentUser(c echo.Context, params generated.GetCurrentUserParams) error { + // headerからトークンを取得する + user, err := h.userUseCase.GetCurrentUser(c.Request().Context(), *params.AccessToken) + if err != nil { + return c.JSON(http.StatusNotFound, user) + } else { + return c.JSON(http.StatusOK, user) + } +} diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index 59052f732..328f7e42c 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -302,6 +302,17 @@ type Total struct { Expense *int `json:"expense,omitempty"` } +// User defines model for user. +type User struct { + BureauID int `json:"bureauID"` + CreatedAt string `json:"createdAt"` + Id int `json:"id"` + IsDeleted bool `json:"isDeleted"` + Name string `json:"name"` + RoleID int `json:"roleID"` + UpdatedAt string `json:"updatedAt"` +} + // YearPeriods defines model for year_periods. type YearPeriods struct { EndedAt string `json:"endedAt"` @@ -388,6 +399,11 @@ type PutBuyReportsIdMultipartBody struct { File *openapi_types.File `json:"file,omitempty"` } +// GetCurrentUserParams defines parameters for GetCurrentUser. +type GetCurrentUserParams struct { + AccessToken *string `json:"Access-Token,omitempty"` +} + // PostDepartmentsParams defines parameters for PostDepartments. type PostDepartmentsParams struct { // Name name @@ -784,6 +800,9 @@ type ServerInterface interface { // (PUT /buy_reports/{id}) PutBuyReportsId(ctx echo.Context, id int) error + // (GET /current_user) + GetCurrentUser(ctx echo.Context, params GetCurrentUserParams) error + // (GET /departments) GetDepartments(ctx echo.Context) error @@ -1505,6 +1524,35 @@ func (w *ServerInterfaceWrapper) PutBuyReportsId(ctx echo.Context) error { return err } +// GetCurrentUser converts echo context to params. +func (w *ServerInterfaceWrapper) GetCurrentUser(ctx echo.Context) error { + var err error + + // Parameter object where we will unmarshal all parameters from the context + var params GetCurrentUserParams + + headers := ctx.Request().Header + // ------------- Optional header parameter "Access-Token" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Access-Token")]; found { + var AccessToken string + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Access-Token, got %d", n)) + } + + err = runtime.BindStyledParameterWithOptions("simple", "Access-Token", valueList[0], &AccessToken, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Access-Token: %s", err)) + } + + params.AccessToken = &AccessToken + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetCurrentUser(ctx, params) + return err +} + // GetDepartments converts echo context to params. func (w *ServerInterfaceWrapper) GetDepartments(ctx echo.Context) error { var err error @@ -2878,6 +2926,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.DELETE(baseURL+"/buy_reports/:id", wrapper.DeleteBuyReportsId) router.GET(baseURL+"/buy_reports/:id", wrapper.GetBuyReportsId) router.PUT(baseURL+"/buy_reports/:id", wrapper.PutBuyReportsId) + router.GET(baseURL+"/current_user", wrapper.GetCurrentUser) router.GET(baseURL+"/departments", wrapper.GetDepartments) router.POST(baseURL+"/departments", wrapper.PostDepartments) router.DELETE(baseURL+"/departments/:id", wrapper.DeleteDepartmentsId) diff --git a/api/router/router.go b/api/router/router.go deleted file mode 100644 index 8a79a7497..000000000 --- a/api/router/router.go +++ /dev/null @@ -1,334 +0,0 @@ -package router - -import ( - "github.com/NUTFes/FinanSu/api/externals/controller" - "github.com/labstack/echo/v4" -) - -type router struct { - activityController controller.ActivityController - activityInformationController controller.ActivityInformationController - activityStyleController controller.ActivityStyleController - budgetController controller.BudgetController - bureauController controller.BureauController - buyReportController controller.BuyReportController - departmentController controller.DepartmentController - expenseController controller.ExpenseController - festivalItemController controller.FestivalItemController - financialRecordController controller.FinancialRecordController - divisionController controller.DivisionController - healthcheckController controller.HealthcheckController - incomeController controller.IncomeController - incomeExpenditureManagementController controller.IncomeExpenditureManagementController - mailAuthController controller.MailAuthController - objectUploadController controller.ObjectUploadController - passwordResetTokenController controller.PasswordResetTokenController - purchaseItemController controller.PurchaseItemController - purchaseOrderController controller.PurchaseOrderController - purchaseReportController controller.PurchaseReportController - receiptController controller.ReceiptController - sourceController controller.SourceController - sponsorController controller.SponsorController - sponsorStyleController controller.SponsorStyleController - teacherController controller.TeacherController - userController controller.UserController - yearController controller.YearController -} - -type Router interface { - ProvideRouter(*echo.Echo) -} - -func NewRouter( - activityController controller.ActivityController, - activityInformationController controller.ActivityInformationController, - activitystyleController controller.ActivityStyleController, - budgetController controller.BudgetController, - bureauController controller.BureauController, - buyReportController controller.BuyReportController, - departmentController controller.DepartmentController, - divisionController controller.DivisionController, - expenseController controller.ExpenseController, - festivalItemController controller.FestivalItemController, - financialRecordController controller.FinancialRecordController, - healthController controller.HealthcheckController, - incomeController controller.IncomeController, - incomeExpenditureManagementController controller.IncomeExpenditureManagementController, - mailAuthController controller.MailAuthController, - objectUploadController controller.ObjectUploadController, - passwordResetTokenController controller.PasswordResetTokenController, - purchaseItemController controller.PurchaseItemController, - purchaseOrderController controller.PurchaseOrderController, - purchaseReportController controller.PurchaseReportController, - receiptController controller.ReceiptController, - sourceController controller.SourceController, - sponsorController controller.SponsorController, - sponsorStyleController controller.SponsorStyleController, - teacherController controller.TeacherController, - userController controller.UserController, - yearController controller.YearController, -) Router { - return router{ - activityController, - activityInformationController, - activitystyleController, - budgetController, - bureauController, - buyReportController, - departmentController, - expenseController, - festivalItemController, - financialRecordController, - divisionController, - healthController, - incomeController, - incomeExpenditureManagementController, - mailAuthController, - objectUploadController, - passwordResetTokenController, - purchaseItemController, - purchaseOrderController, - purchaseReportController, - receiptController, - sourceController, - sponsorController, - sponsorStyleController, - teacherController, - userController, - yearController, - } -} - -func (r router) ProvideRouter(e *echo.Echo) { - // Healthcheck - e.GET("/", r.healthcheckController.IndexHealthcheck) - - // activitiesのRoute - e.GET("/activities", r.activityController.IndexActivity) - e.GET("/activities/:id", r.activityController.ShowActivity) - e.POST("/activities", r.activityController.CreateActivity) - e.PUT("/activities/:id", r.activityController.UpdateActivity) - e.DELETE("/activities/:id", r.activityController.DestroyActivity) - e.GET("/activities/details", r.activityController.IndexActivityDetail) - e.GET("/activities/details/:year", r.activityController.IndexActivityDetailsByPeriod) - e.GET("/activities/filtered_details", r.activityController.IndexFilteredActivityDetail) - e.GET( - "/activities/filtered_details/:year", - r.activityController.IndexFilteredActivityDetailByPeriod, - ) - - // activityInformationsのRoute - e.GET("/activity_informations", r.activityInformationController.IndexActivityInformation) - e.GET("/activity_informations/:id", r.activityInformationController.ShowActivityInformation) - e.POST("/activity_informations", r.activityInformationController.CreateActivityInformation) - e.PUT("/activity_informations/:id", r.activityInformationController.UpdateActivityInformation) - e.DELETE( - "/activity_informations/:id", - r.activityInformationController.DestroyActivityInformation, - ) - - // activityStyleのRoute - e.GET("/activity_styles", r.activityStyleController.IndexActivityStyle) - e.GET("/activity_styles/:id", r.activityStyleController.ShowActivityStyle) - e.POST("/activity_styles", r.activityStyleController.CreateActivityStyle) - e.PUT("/activity_styles/:id", r.activityStyleController.UpdateActivityStyle) - e.DELETE("/activity_styles/:id", r.activityStyleController.DestroyActivityStyle) - - // budgetsのRoute - e.GET("/budgets", r.budgetController.IndexBudget) - e.GET("/budgets/:id", r.budgetController.ShowBudget) - e.POST("/budgets", r.budgetController.CreateBudget) - e.PUT("/budgets/:id", r.budgetController.UpdateBudget) - e.DELETE("/budgets/:id", r.budgetController.DestroyBudget) - e.GET("/budgets/:id/details", r.budgetController.ShowBudgetDetailById) - e.GET("/budgets/details", r.budgetController.ShowBudgetDetails) - e.GET("/budgets/details/:year", r.budgetController.ShowBudgetDetailsByPeriods) - - //bureauのRoute - e.GET("/bureaus", r.bureauController.IndexBureau) - e.GET("/bureaus/:id", r.bureauController.ShowBureau) - e.POST("/bureaus", r.bureauController.CreateBureau) - e.PUT("/bureaus/:id", r.bureauController.UpdateBureau) - e.DELETE("/bureaus/:id", r.bureauController.DestroyBureau) - - // buyReportsのRoute - e.POST("/buy_reports", r.buyReportController.CreateBuyReport) - e.GET("/buy_reports/:id", r.buyReportController.GetBuyReportById) - e.PUT("/buy_reports/:id", r.buyReportController.UpdateBuyReport) - e.DELETE("/buy_reports/:id", r.buyReportController.DeleteBuyReport) - e.GET("/buy_reports/details", r.buyReportController.IndexBuyReport) - e.GET("/buy_reports/csv/download", r.buyReportController.GetBuyReportsCsvDownload) - e.PUT("/buy_report/status/:buy_report_id", r.buyReportController.UpdateBuyReportStatus) - - // current_user - e.GET("/current_user", r.userController.GetCurrentUser) - - // departments - e.GET("/departments", r.departmentController.IndexDepartment) - e.GET("/departments/:id", r.departmentController.ShowDepartment) - e.POST("/departments", r.departmentController.CreateDepartment) - e.PUT("/departments/:id", r.departmentController.UpdateDepartment) - e.DELETE("/departments/:id", r.departmentController.DestroyDepartment) - - // divisions - e.GET("/divisions", r.divisionController.IndexDivisions) - e.GET("/divisions/users", r.divisionController.GetDivisionOptions) - e.GET("/divisions/:id", r.divisionController.GetDivision) - e.GET("/divisions/years", r.divisionController.GetDivisionsYears) - e.POST("/divisions", r.divisionController.CreateDivision) - e.PUT("/divisions/:id", r.divisionController.UpdateDivision) - e.DELETE("/divisions/:id", r.divisionController.DestroyDivision) - - // expenseのRoute - e.GET("/expenses", r.expenseController.IndexExpense) - e.GET("/expenses/updateTP", r.expenseController.UpdateExpenseTP) - e.GET("/expenses/details", r.expenseController.IndexExpenseDetails) - e.GET("/expenses/details/:year", r.expenseController.IndexExpenseDetailsByPeriod) - e.GET("/expenses/:id", r.expenseController.ShowExpense) - e.GET("/expenses/:id/details", r.expenseController.ShowExpenseDetail) - e.GET("/expenses/fiscalyear/:year", r.expenseController.IndexExpenseByPeriod) - e.POST("/expenses", r.expenseController.CreateExpense) - e.PUT("/expenses/:id", r.expenseController.UpdateExpense) - e.DELETE("/expenses/:id", r.expenseController.DestroyExpense) - - // festival items - e.GET("/festival_items", r.festivalItemController.IndexFestivalItems) - e.GET("/festival_items/details/:user_id", r.festivalItemController.IndexFestivalItemsForMypage) - e.GET("/festival_items/:id", r.festivalItemController.GetFestivalItem) - e.GET("/festival_items/users", r.festivalItemController.IndexFestivalItemOption) - e.POST("/festival_items", r.festivalItemController.CreateFestivalItem) - e.PUT("/festival_items/:id", r.festivalItemController.UpdateFestivalItem) - e.DELETE("/festival_items/:id", r.festivalItemController.DestroyFestivalItem) - - // financial_records - e.GET("/financial_records", r.financialRecordController.IndexFinancialRecords) - e.GET("/financial_records/:id", r.financialRecordController.GetFinancialRecord) - e.POST("/financial_records", r.financialRecordController.CreateFinancialRecord) - e.PUT("/financial_records/:id", r.financialRecordController.UpdateFinancialRecord) - e.DELETE("/financial_records/:id", r.financialRecordController.DestroyFinancialRecord) - e.GET("/financial_records/csv/download", r.financialRecordController.DownloadFinancialRecordsCSV) - - // incomes - e.GET("/incomes", r.incomeController.IndexIncome) - e.POST("/incomes", r.incomeController.PostIncome) - e.GET("/incomes/:id", r.incomeController.GetIncome) - e.PUT("/incomes/:id", r.incomeController.PutIncome) - e.DELETE("/incomes/:id", r.incomeController.DeleteIncome) - - // income_expenditure_managements - e.GET("income_expenditure_managements", r.incomeExpenditureManagementController.IndexIncomeExpenditureManagements) - e.PUT("/income_expenditure_managements/check/:id", r.incomeExpenditureManagementController.PutIncomeExpenditureManagementCheck) - - // mail auth - e.POST("/mail_auth/signup", r.mailAuthController.SignUp) - e.POST("/mail_auth/signin", r.mailAuthController.SignIn) - e.DELETE("/mail_auth/signout", r.mailAuthController.SignOut) - e.GET("/mail_auth/is_signin", r.mailAuthController.IsSignIn) - - // objectUploadテスト - e.POST("/upload_file", r.objectUploadController.UploadObject) - - //password_reset - e.POST("/password_reset/:id", r.passwordResetTokenController.ChangePassword) - e.POST("/password_reset/request", r.passwordResetTokenController.SendPasswordResetRequest) - e.POST("/password_reset/:id/valid", r.passwordResetTokenController.ValidPasswordResetToken) - - // purchaseitemsのRoute - e.GET("/purchaseitems", r.purchaseItemController.IndexPurchaseItem) - e.GET("/purchaseitems/:id", r.purchaseItemController.ShowPurchaseItem) - e.POST("/purchaseitems", r.purchaseItemController.CreatePurchaseItem) - e.PUT("/purchaseitems/:id", r.purchaseItemController.UpdatePurchaseItem) - e.DELETE("/purchaseitems/:id", r.purchaseItemController.DestroyPurchaseItem) - e.GET("/purchaseitems/details", r.purchaseItemController.IndexPurchaseItemDetails) - e.GET("/purchaseitems/:id/details", r.purchaseItemController.ShowPurchaseItemDetails) - - // parcahseordersのRoute - e.GET("/purchaseorders", r.purchaseOrderController.IndexPurchaseOrder) - e.GET("/purchaseorders/:id", r.purchaseOrderController.ShowPurchaseOrder) - e.POST("/purchaseorders", r.purchaseOrderController.CreatePurchaseOrder) - e.POST("/purchaseorders/send/:id", r.purchaseOrderController.NotifySlack) - e.PUT("/purchaseorders/:id", r.purchaseOrderController.UpdatePurchaseOrder) - e.DELETE("/purchaseorders/:id", r.purchaseOrderController.DestroyPurchaseOrder) - e.GET("/purchaseorders/details", r.purchaseOrderController.IndexOrderDetail) - e.GET("/purchaseorders/:id/details", r.purchaseOrderController.ShowOrderDetail) - e.GET("/purchaseorders/details/:year", r.purchaseOrderController.IndexOrderDetailByYear) - e.GET( - "/purchaseorders/details/unregistered/:year", - r.purchaseOrderController.IndexUnregisteredOrderDetailByYear, - ) - - // purchasereportsのRoute - e.GET("/purchasereports", r.purchaseReportController.IndexPurchaseReport) - e.GET("/purchasereports/:id", r.purchaseReportController.ShowPurchaseReport) - e.POST("/purchasereports", r.purchaseReportController.CreatePurchaseReport) - e.PUT("/purchasereports/:id", r.purchaseReportController.UpdatePurchaseReport) - e.DELETE("/purchasereports/:id", r.purchaseReportController.DestroyPurchaseReport) - e.GET("/purchasereports/details", r.purchaseReportController.IndexPurchaseReportDetails) - e.GET("/purchasereports/:id/details", r.purchaseReportController.ShowPurchaseReportDetail) - e.GET( - "/purchasereports/details/:year", - r.purchaseReportController.IndexPurchaseReportDetailsByYear, - ) - - // receiptsのRoute - e.GET("/receipts", r.receiptController.IndexReceipt) - e.GET("/receipts/:id", r.receiptController.ShowReceipt) - e.GET("/receipts/reports/:id", r.receiptController.FindReceiptsByReportID) - e.POST("/receipts", r.receiptController.CreateReceipt) - e.PUT("/receipts/:id", r.receiptController.UpdateReceipt) - e.DELETE("/receipts/:id", r.receiptController.DestroyReceipt) - - // sources - e.GET("/sources", r.sourceController.IndexSource) - e.GET("/sources/:id", r.sourceController.ShowSource) - e.POST("/sources", r.sourceController.CreateSource) - e.PUT("/sources/:id", r.sourceController.UpdateSource) - e.DELETE("/sources/:id", r.sourceController.DestroySource) - - // sponsorのRoute - e.GET("/sponsors", r.sponsorController.IndexSponsor) - e.GET("/sponsors/:id", r.sponsorController.ShowSponsor) - e.POST("/sponsors", r.sponsorController.CreateSponsor) - e.PUT("/sponsors/:id", r.sponsorController.UpdateSponsor) - e.DELETE("/sponsors/:id", r.sponsorController.DestroySponsor) - e.GET("/sponsors/periods/:year", r.sponsorController.IndexSponsorByPeriod) - e.POST("/sponsors/csv", r.sponsorController.CreateSponsorsByCsv) - e.GET("/sponsors/rowAffected/:row", r.sponsorController.IndexSponsorsByRowAffected) - - // sponsorstylesのRoute - e.GET("/sponsorstyles", r.sponsorStyleController.IndexSponsorStyle) - e.GET("/sponsorstyles/:id", r.sponsorStyleController.ShowSponsorStyle) - e.POST("/sponsorstyles", r.sponsorStyleController.CreateSponsorStyle) - e.PUT("/sponsorstyles/:id", r.sponsorStyleController.UpdateSponsorStyle) - e.DELETE("/sponsorstyles/:id", r.sponsorStyleController.DestroySponsorStyle) - - // teacherのRoute - e.GET("/teachers", r.teacherController.IndexTeacher) - e.GET("/teachers/:id", r.teacherController.ShowTeacher) - e.GET("/teachers/fundRegistered/:year", r.teacherController.IndexFundRegisteredTeacher) - e.POST("/teachers", r.teacherController.CreateTeacher) - e.PUT("/teachers/:id", r.teacherController.UpdateTeacher) - e.DELETE("/teachers/:id", r.teacherController.DestroyTeacher) - e.DELETE("/teachers/delete", r.teacherController.DestroyMultiTeachers) - - // users - e.GET("/users", r.userController.IndexUser) - e.GET("/users/:id", r.userController.ShowUser) - e.POST("/users", r.userController.CreateUser) - e.PUT("/users/:id", r.userController.UpdateUser) - e.DELETE("/users/:id", r.userController.DestroyUser) - e.DELETE("/users/delete", r.userController.DestroyMultiUsers) - - // years - e.GET("/years", r.yearController.IndexYear) - e.GET("/years/:id", r.yearController.ShowYear) - e.POST("/years", r.yearController.CreateYear) - e.PUT("/years/:id", r.yearController.UpdateYear) - e.DELETE("/years/:id", r.yearController.DestroyYear) - - // year_periods - e.GET("/years/periods", r.yearController.IndexYearPeriods) - e.POST("/years/periods", r.yearController.CreateYearPeriod) - e.PUT("/years/periods/:id", r.yearController.UpdateYearPeriod) - e.DELETE("/years/periods/:id", r.yearController.DestroyYearPeriod) -} diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 2dd2f1266..f5630e344 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -681,7 +681,23 @@ paths: schema: type: string format: binary - + /current_user: + get: + tags: + - user + description: 現在ログインしているユーザーの情報を取得 + parameters: + - in: header + name: Access-Token + schema: + type: string + responses: + "200": + description: 現在ログインしているユーザーの情報を取得 + content: + application/json: + schema: + $ref: "#/components/schemas/user" /departments: get: tags: @@ -2844,5 +2860,37 @@ components: - room_number - is_black - remark + user: + type: object + properties: + id: + type: integer + example: 1 + name: + type: string + example: test-user + bureauID: + type: integer + example: 1 + roleID: + type: integer + example: 1 + isDeleted: + type: boolean + example: false + createdAt: + type: string + example: 0000-00-00T00:00:00Z + updatedAt: + type: string + example: 0000-00-00T00:00:00Z + required: + - id + - name + - bureauID + - roleID + - isDeleted + - createdAt + - updatedAt x-original-swagger-version: "2.0" diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index 2761a72db..197a208ce 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -138,6 +138,7 @@ import type { Sponsor, SponsorStyle, Teacher, + User, YearPeriods, } from './model'; @@ -2277,6 +2278,57 @@ export const useGetBuyReportsCsvDownload = ( }; }; +/** + * 現在ログインしているユーザーの情報を取得 + */ +export type getCurrentUserResponse200 = { + data: User; + status: 200; +}; + +export type getCurrentUserResponseComposite = getCurrentUserResponse200; + +export type getCurrentUserResponse = getCurrentUserResponseComposite & { + headers: Headers; +}; + +export const getGetCurrentUserUrl = () => { + return `/current_user`; +}; + +export const getCurrentUser = async (options?: RequestInit): Promise => { + return customFetch(getGetCurrentUserUrl(), { + ...options, + method: 'GET', + }); +}; + +export const getGetCurrentUserKey = () => [`/current_user`] as const; + +export type GetCurrentUserQueryResult = NonNullable>>; +export type GetCurrentUserQueryError = unknown; + +export const useGetCurrentUser = (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 ? getGetCurrentUserKey() : null)); + const swrFn = () => getCurrentUser(requestOptions); + + const query = useSwr>, TError>(swrKey, swrFn, swrOptions); + + return { + swrKey, + ...query, + }; +}; + /** * departmentの一覧の取得 */ diff --git a/view/next-project/src/generated/model/index.ts b/view/next-project/src/generated/model/index.ts index d719fe42b..16cda04fb 100644 --- a/view/next-project/src/generated/model/index.ts +++ b/view/next-project/src/generated/model/index.ts @@ -192,4 +192,5 @@ export * from './sponsor'; export * from './sponsorStyle'; export * from './teacher'; export * from './total'; +export * from './user'; export * from './yearPeriods'; diff --git a/view/next-project/src/generated/model/user.ts b/view/next-project/src/generated/model/user.ts new file mode 100644 index 000000000..e96240dbd --- /dev/null +++ b/view/next-project/src/generated/model/user.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export interface User { + id: number; + name: string; + bureauID: number; + roleID: number; + isDeleted: boolean; + createdAt: string; + updatedAt: string; +} From 8ad74c1db1f2d967ea78d40a82e5fb629edc3e2a Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Fri, 26 Sep 2025 23:50:16 +0900 Subject: [PATCH 13/14] =?UTF-8?q?typo=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/externals/handler/activity_handler.go | 1 - .../handler/activity_style_handler.go | 4 +-- api/externals/handler/bureau_handler.go | 4 +-- api/externals/handler/department_handler.go | 4 +-- api/externals/handler/sponsor_handler.go | 4 +-- .../handler/sponsor_style_handler.go | 26 +++++++++---------- api/externals/handler/user_handler.go | 4 +-- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/api/externals/handler/activity_handler.go b/api/externals/handler/activity_handler.go index ec90076f3..2b36032f5 100644 --- a/api/externals/handler/activity_handler.go +++ b/api/externals/handler/activity_handler.go @@ -33,7 +33,6 @@ func (h *Handler) GetActivitiesId(c echo.Context, id int) error { func (h *Handler) PostActivities(c echo.Context) error { activities := new(domain.Activity) if err := c.Bind(activities); err != nil { - fmt.Println("err") return err } latastActivity, err := h.activityUseCase.CreateActivity(c.Request().Context(), strconv.Itoa(int(activities.UserID)), strconv.FormatBool(activities.IsDone), strconv.Itoa(int(activities.SponsorID)), activities.Feature, strconv.Itoa(int(activities.Expense)), activities.Remark, strconv.Itoa(int(activities.Design)), activities.Url) diff --git a/api/externals/handler/activity_style_handler.go b/api/externals/handler/activity_style_handler.go index 6698caa41..3b31573fa 100644 --- a/api/externals/handler/activity_style_handler.go +++ b/api/externals/handler/activity_style_handler.go @@ -24,14 +24,14 @@ func (h *Handler) PostActivityStyles(c echo.Context) error { return err } - latastActivityStyle, err := h.activityStyleUseCase.CreateActivityStyle(c.Request().Context(), + latestActivityStyle, err := h.activityStyleUseCase.CreateActivityStyle(c.Request().Context(), strconv.Itoa(int(activityStyle.ActivityID)), strconv.Itoa(int(activityStyle.SponsoStyleID)), ) if err != nil { return err } - return c.JSON(http.StatusOK, latastActivityStyle) + return c.JSON(http.StatusOK, latestActivityStyle) } // router.DELETE(baseURL+"/activity_styles/:id", wrapper.DeleteActivityStylesId) diff --git a/api/externals/handler/bureau_handler.go b/api/externals/handler/bureau_handler.go index 9514547d5..fde45761c 100644 --- a/api/externals/handler/bureau_handler.go +++ b/api/externals/handler/bureau_handler.go @@ -20,13 +20,13 @@ func (h *Handler) GetBureaus(c echo.Context) error { // router.POST(baseURL+"/bureaus", wrapper.PostBureaus) func (h *Handler) PostBureaus(c echo.Context, params generated.PostBureausParams) error { name := params.Name - latastBureau, err := h.bureauUseCase.CreateBureau(c.Request().Context(), + latestBureau, err := h.bureauUseCase.CreateBureau(c.Request().Context(), name, ) if err != nil { return err } - return c.JSON(http.StatusOK, latastBureau) + return c.JSON(http.StatusOK, latestBureau) } // router.DELETE(baseURL+"/bureaus/:id", wrapper.DeleteBureausId) diff --git a/api/externals/handler/department_handler.go b/api/externals/handler/department_handler.go index 5424986c2..15b7dd52c 100644 --- a/api/externals/handler/department_handler.go +++ b/api/externals/handler/department_handler.go @@ -19,11 +19,11 @@ func (h *Handler) GetDepartments(c echo.Context) error { // router.POST(baseURL+"/departments", wrapper.PostDepartments) func (h *Handler) PostDepartments(c echo.Context, params generated.PostDepartmentsParams) error { - latastDepartment, err := h.departmentUseCase.CreateDepartment(c.Request().Context(), *params.Name) + latestDepartment, err := h.departmentUseCase.CreateDepartment(c.Request().Context(), *params.Name) if err != nil { return err } - return c.JSON(http.StatusOK, latastDepartment) + return c.JSON(http.StatusOK, latestDepartment) } // router.DELETE(baseURL+"/departments/:id", wrapper.DeleteDepartmentsId) diff --git a/api/externals/handler/sponsor_handler.go b/api/externals/handler/sponsor_handler.go index f16829f8a..4cc38604a 100644 --- a/api/externals/handler/sponsor_handler.go +++ b/api/externals/handler/sponsor_handler.go @@ -24,7 +24,7 @@ func (h *Handler) PostSponsors(c echo.Context) error { return err } - latastSponsor, err := h.sponsorUseCase.CreateSponsor(c.Request().Context(), + latestSponsor, err := h.sponsorUseCase.CreateSponsor(c.Request().Context(), sponsor.Name, sponsor.Tel, sponsor.Email, @@ -34,7 +34,7 @@ func (h *Handler) PostSponsors(c echo.Context) error { if err != nil { return err } - return c.JSON(http.StatusOK, latastSponsor) + return c.JSON(http.StatusOK, latestSponsor) } // router.GET(baseURL+"/sponsors/periods/:year", wrapper.GetSponsorsPeriodsYear) diff --git a/api/externals/handler/sponsor_style_handler.go b/api/externals/handler/sponsor_style_handler.go index a6e704b8c..7654a486e 100644 --- a/api/externals/handler/sponsor_style_handler.go +++ b/api/externals/handler/sponsor_style_handler.go @@ -10,29 +10,29 @@ import ( // router.GET(baseURL+"/sponsorstyles", wrapper.GetSponsorstyles) func (h *Handler) GetSponsorstyles(c echo.Context) error { - sponsorstyles, err := h.sponsorStyleUseCase.GetSponsorStyles(c.Request().Context()) + sponsorStyles, err := h.sponsorStyleUseCase.GetSponsorStyles(c.Request().Context()) if err != nil { return err } - return c.JSON(http.StatusOK, sponsorstyles) + return c.JSON(http.StatusOK, sponsorStyles) } // router.POST(baseURL+"/sponsorstyles", wrapper.PostSponsorstyles) func (h *Handler) PostSponsorstyles(c echo.Context) error { - sponsorstyle := new(domain.SponsorStyle) - if err := c.Bind(sponsorstyle); err != nil { + sponsorStyle := new(domain.SponsorStyle) + if err := c.Bind(sponsorStyle); err != nil { return err } - latastSponsorstyle, err := h.sponsorStyleUseCase.CreateSponsorStyle(c.Request().Context(), - sponsorstyle.Style, - sponsorstyle.Feature, - sponsorstyle.Price, + latestSponsorStyle, err := h.sponsorStyleUseCase.CreateSponsorStyle(c.Request().Context(), + sponsorStyle.Style, + sponsorStyle.Feature, + sponsorStyle.Price, ) if err != nil { return err } - return c.JSON(http.StatusOK, latastSponsorstyle) + return c.JSON(http.StatusOK, latestSponsorStyle) } // router.DELETE(baseURL+"/sponsorstyles/:id", wrapper.DeleteSponsorstylesId) @@ -48,11 +48,11 @@ func (h *Handler) DeleteSponsorstylesId(c echo.Context, id int) error { // router.GET(baseURL+"/sponsorstyles/:id", wrapper.GetSponsorstylesId) func (h *Handler) GetSponsorstylesId(c echo.Context, id int) error { idStr := strconv.Itoa(id) - sponsorstyle, err := h.sponsorStyleUseCase.GetSponsorStylesByID(c.Request().Context(), idStr) + sponsorStyle, err := h.sponsorStyleUseCase.GetSponsorStylesByID(c.Request().Context(), idStr) if err != nil { return err } - return c.JSON(http.StatusOK, sponsorstyle) + return c.JSON(http.StatusOK, sponsorStyle) } // router.PUT(baseURL+"/sponsorstyles/:id", wrapper.PutSponsorstylesId) @@ -63,9 +63,9 @@ func (h *Handler) PutSponsorstylesId(c echo.Context, id int) error { return err } - updatedSponsorstyle, err := h.sponsorStyleUseCase.UpdateSponsorStyle(c.Request().Context(), idStr, sponsorstyle.Style, sponsorstyle.Feature, sponsorstyle.Price) + updatedSponsorStyle, err := h.sponsorStyleUseCase.UpdateSponsorStyle(c.Request().Context(), idStr, sponsorstyle.Style, sponsorstyle.Feature, sponsorstyle.Price) if err != nil { return err } - return c.JSON(http.StatusOK, updatedSponsorstyle) + return c.JSON(http.StatusOK, updatedSponsorStyle) } diff --git a/api/externals/handler/user_handler.go b/api/externals/handler/user_handler.go index e6ea43344..d57759f46 100644 --- a/api/externals/handler/user_handler.go +++ b/api/externals/handler/user_handler.go @@ -23,11 +23,11 @@ func (h *Handler) PostUsers(c echo.Context, params generated.PostUsersParams) er name := params.Name bureauID := strconv.Itoa(params.BureauId) roleID := strconv.Itoa(params.RoleId) - latastUser, err := h.userUseCase.CreateUser(c.Request().Context(), name, bureauID, roleID) + latestUser, err := h.userUseCase.CreateUser(c.Request().Context(), name, bureauID, roleID) if err != nil { return err } - return c.JSON(http.StatusCreated, latastUser) + return c.JSON(http.StatusCreated, latestUser) } // router.DELETE(baseURL+"/users/delete", wrapper.DeleteUsersDelete) From 766da3680172dfa9e7bc4ed1441a5ada4f752524 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 27 Nov 2025 16:50:32 +0900 Subject: [PATCH 14/14] =?UTF-8?q?=E4=B8=8D=E8=B6=B3=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9Fseed=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql/seed/000001_initial_schema_seed.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql/seed/000001_initial_schema_seed.sql b/mysql/seed/000001_initial_schema_seed.sql index 7f42cd58c..1c094ecde 100644 --- a/mysql/seed/000001_initial_schema_seed.sql +++ b/mysql/seed/000001_initial_schema_seed.sql @@ -449,6 +449,12 @@ VALUES ("繰越金", NOW(), NOW()), ("企業協賛金", NOW(), NOW()); +INSERT INTO + income_income_expenditure_managements (income_expenditure_id, income_id, created_at, updated_at) +VALUES + (1, 4, NOW(), NOW()), + (2, 6, NOW(), NOW()); + INSERT INTO buildings (name) VALUES