From c97c44fbf11d924e0d337af2b4c9435e3a4781dc Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 16 Jan 2025 22:08:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?api=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openapi/openapi.yaml | 136 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 1 deletion(-) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 527082d1..693912e6 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -665,7 +665,50 @@ paths: application/json: schema: type: object - + /buy_reports: + post: + tags: + - buy_report + description: buy_reportの作成 + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/buyReport" + required: true + responses: + "200": + description: 作成されたbuyReportが返ってくる + content: + application/json: + schema: + $ref: "#/components/schemas/buyReport" + /buy_reports/{id}: + put: + tags: + - buy_report + description: buy_reportの更新 + parameters: + - name: id + in: path + description: id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/buyReport" + required: true + responses: + "200": + description: 更新されたbuy_reportが返ってくる + content: + application/json: + schema: + $ref: "#/components/schemas/buyReport" + x-codegen-request-body-name: buy_report /departments: get: tags: @@ -1086,6 +1129,25 @@ paths: application/json: schema: type: object + /festival_items/details/{division_id}: + get: + tags: + - division + description: divisionの予算一覧の取得 + parameters: + - name: division_id + in: path + description: division_id + required: true + schema: + type: integer + responses: + "200": + description: divisionの一覧を取得 + content: + application/json: + schema: + $ref: "#/components/schemas/festivalItemsForMyPage" /financial_records: get: tags: @@ -2429,6 +2491,51 @@ components: sponsorStyleID: type: integer example: 1 + buyReport: + type: object + properties: + id: + type: integer + example: 1 + festivalItemID: + type: integer + example: 1 + amount: + type: integer + example: 1000 + paidBy: + type: string + example: 企画局_技大太郎 + receiptIDs: + type: array + items: + type: integer + example: [1, 2] + required: + - festivalItemID + - amount + - paidBy + buyReportInformation: + type: object + properties: + ID: + type: integer + example: 1 + buyReportName: + type: string + example: 段ボール + amount: + type: integer + example: 1000 + reportDate: + type: string + example: 2024-01-01 + status: + type: string + enum: + - 確認中 + - 封詰め + - 生産完了 division: required: - name @@ -2499,6 +2606,33 @@ components: type: array items: $ref: "#/components/schemas/festivalItemWithBalance" + festivalItemsForMyPage: + type: object + properties: + total: + $ref: "#/components/schemas/total" + financialRecordName: + type: string + example: 企画局 + divisionName: + type: string + example: ビンゴ部門 + festivalItems: + type: array + items: + $ref: "#/components/schemas/festivalItemWithReport" + festivalItemWithReport: + type: object + properties: + total: + $ref: "#/components/schemas/total" + festivalItemName: + type: string + example: ビンゴ景品 + buyReports: + type: array + items: + $ref: "#/components/schemas/buyReportInformation" festivalItemWithBalance: type: object properties: From dfa07a96e529d461276b5da15ea76f4198d5f67a Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 16 Jan 2025 23:22:46 +0900 Subject: [PATCH 2/2] =?UTF-8?q?api=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/generated/openapi_gen.go | 211 +++++++++++ openapi/openapi.yaml | 146 +++++++- view/next-project/src/generated/hooks.ts | 354 ++++++++++++++++++ .../next-project/src/generated/model/index.ts | 11 + 4 files changed, 708 insertions(+), 14 deletions(-) diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index 4133a930..168fa8f5 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -9,6 +9,14 @@ import ( "github.com/labstack/echo/v4" "github.com/oapi-codegen/runtime" + openapi_types "github.com/oapi-codegen/runtime/types" +) + +// Defines values for BuyReportInformationStatus. +const ( + Empty BuyReportInformationStatus = "確認中" + N1 BuyReportInformationStatus = "封詰め" + N2 BuyReportInformationStatus = "生産完了" ) // Defines values for GetActivitiesFilteredDetailsParamsIsDone. @@ -53,6 +61,39 @@ type ActivityStyle struct { SponsorStyleID int `json:"sponsorStyleID"` } +// BuyReport 購入報告の際のパラメータ +type BuyReport struct { + Amount int `json:"amount"` + FestivalItemID int `json:"festivalItemID"` + Id *int `json:"id,omitempty"` + PaidBy string `json:"paidBy"` +} + +// BuyReportDetail 購入報告ページで表示する詳細情報 +type BuyReportDetail struct { + ID *int `json:"ID,omitempty"` + Amount *int `json:"amount,omitempty"` + DivisionName *string `json:"divisionName,omitempty"` + FestivalItemName *string `json:"festivalItemName,omitempty"` + FinancialRecordName *string `json:"financialRecordName,omitempty"` + IsPacked *bool `json:"isPacked,omitempty"` + IsSettled *bool `json:"isSettled,omitempty"` + PaidBy *string `json:"paidBy,omitempty"` + ReportDate *string `json:"reportDate,omitempty"` +} + +// BuyReportInformation マイページで表示する購入報告の情報 +type BuyReportInformation struct { + ID *int `json:"ID,omitempty"` + Amount *int `json:"amount,omitempty"` + BuyReportName *string `json:"buyReportName,omitempty"` + ReportDate *string `json:"reportDate,omitempty"` + Status *BuyReportInformationStatus `json:"status,omitempty"` +} + +// BuyReportInformationStatus defines model for BuyReportInformation.Status. +type BuyReportInformationStatus string + // DestroyTeacherIDs defines model for destroyTeacherIDs. type DestroyTeacherIDs struct { DeleteIDs []float32 `json:"deleteIDs"` @@ -111,6 +152,21 @@ type FestivalItemWithBalance struct { Name *string `json:"name,omitempty"` } +// FestivalItemWithReport defines model for festivalItemWithReport. +type FestivalItemWithReport struct { + BuyReports *[]BuyReportInformation `json:"buyReports,omitempty"` + FestivalItemName *string `json:"festivalItemName,omitempty"` + FestivalItemTotal *Total `json:"festivalItemTotal,omitempty"` +} + +// FestivalItemsForMyPage defines model for festivalItemsForMyPage. +type FestivalItemsForMyPage struct { + DivisionName *string `json:"divisionName,omitempty"` + DivisionTotal *Total `json:"divisionTotal,omitempty"` + FestivalItems *[]FestivalItemWithReport `json:"festivalItems,omitempty"` + FinancialRecordName *string `json:"financialRecordName,omitempty"` +} + // FinancialRecord defines model for financialRecord. type FinancialRecord struct { Name string `json:"name"` @@ -246,6 +302,37 @@ type PutBureausIdParams struct { Name *string `form:"name,omitempty" json:"name,omitempty"` } +// PutBuyReportStatusBuyReportIdJSONBody defines parameters for PutBuyReportStatusBuyReportId. +type PutBuyReportStatusBuyReportIdJSONBody struct { + // IsPacked 封筒に詰めたか + IsPacked *bool `json:"isPacked,omitempty"` + + // IsSettled 精算済みか + IsSettled *bool `json:"isSettled,omitempty"` +} + +// PostBuyReportsMultipartBody defines parameters for PostBuyReports. +type PostBuyReportsMultipartBody struct { + // BuyReport 購入報告の際のパラメータ + BuyReport BuyReport `json:"buy_report"` + File openapi_types.File `json:"file"` +} + +// GetBuyReportsListParams defines parameters for GetBuyReportsList. +type GetBuyReportsListParams struct { + // Year year + Year *int `form:"year,omitempty" json:"year,omitempty"` +} + +// PutBuyReportsIdMultipartBody defines parameters for PutBuyReportsId. +type PutBuyReportsIdMultipartBody struct { + // BuyReport 購入報告の際のパラメータ + BuyReport BuyReport `json:"buy_report"` + + // File 購入報告書のファイル、ない場合更新しないようにする + File *openapi_types.File `json:"file,omitempty"` +} + // PostDepartmentsParams defines parameters for PostDepartments. type PostDepartmentsParams struct { // Name name @@ -459,6 +546,15 @@ type PostActivityStylesJSONRequestBody = ActivityStyle // PutActivityStylesIdJSONRequestBody defines body for PutActivityStylesId for application/json ContentType. type PutActivityStylesIdJSONRequestBody = ActivityStyle +// PutBuyReportStatusBuyReportIdJSONRequestBody defines body for PutBuyReportStatusBuyReportId for application/json ContentType. +type PutBuyReportStatusBuyReportIdJSONRequestBody PutBuyReportStatusBuyReportIdJSONBody + +// PostBuyReportsMultipartRequestBody defines body for PostBuyReports for multipart/form-data ContentType. +type PostBuyReportsMultipartRequestBody PostBuyReportsMultipartBody + +// PutBuyReportsIdMultipartRequestBody defines body for PutBuyReportsId for multipart/form-data ContentType. +type PutBuyReportsIdMultipartRequestBody PutBuyReportsIdMultipartBody + // PostDivisionsJSONRequestBody defines body for PostDivisions for application/json ContentType. type PostDivisionsJSONRequestBody = Division @@ -606,6 +702,21 @@ type ServerInterface interface { // (PUT /bureaus/{id}) PutBureausId(ctx echo.Context, id int, params PutBureausIdParams) error + // (PUT /buy_report/status/{buy_report_id}) + PutBuyReportStatusBuyReportId(ctx echo.Context, buyReportId int) error + + // (POST /buy_reports) + PostBuyReports(ctx echo.Context) error + + // (GET /buy_reports/list) + GetBuyReportsList(ctx echo.Context, params GetBuyReportsListParams) error + + // (DELETE /buy_reports/{id}) + DeleteBuyReportsId(ctx echo.Context, id int) error + + // (PUT /buy_reports/{id}) + PutBuyReportsId(ctx echo.Context, id int) error + // (GET /departments) GetDepartments(ctx echo.Context) error @@ -666,6 +777,9 @@ type ServerInterface interface { // (POST /festival_items) PostFestivalItems(ctx echo.Context) error + // (GET /festival_items/details/{division_id}) + GetFestivalItemsDetailsDivisionId(ctx echo.Context, divisionId int) error + // (DELETE /festival_items/{id}) DeleteFestivalItemsId(ctx echo.Context, id int) error @@ -1386,6 +1500,81 @@ func (w *ServerInterfaceWrapper) PutBureausId(ctx echo.Context) error { return err } +// PutBuyReportStatusBuyReportId converts echo context to params. +func (w *ServerInterfaceWrapper) PutBuyReportStatusBuyReportId(ctx echo.Context) error { + var err error + // ------------- Path parameter "buy_report_id" ------------- + var buyReportId int + + err = runtime.BindStyledParameterWithOptions("simple", "buy_report_id", ctx.Param("buy_report_id"), &buyReportId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter buy_report_id: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.PutBuyReportStatusBuyReportId(ctx, buyReportId) + return err +} + +// PostBuyReports converts echo context to params. +func (w *ServerInterfaceWrapper) PostBuyReports(ctx echo.Context) error { + var err error + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.PostBuyReports(ctx) + return err +} + +// GetBuyReportsList converts echo context to params. +func (w *ServerInterfaceWrapper) GetBuyReportsList(ctx echo.Context) error { + var err error + + // Parameter object where we will unmarshal all parameters from the context + var params GetBuyReportsListParams + // ------------- Optional query parameter "year" ------------- + + err = runtime.BindQueryParameter("form", true, false, "year", ctx.QueryParams(), ¶ms.Year) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter year: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetBuyReportsList(ctx, params) + return err +} + +// DeleteBuyReportsId converts echo context to params. +func (w *ServerInterfaceWrapper) DeleteBuyReportsId(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.DeleteBuyReportsId(ctx, id) + return err +} + +// PutBuyReportsId converts echo context to params. +func (w *ServerInterfaceWrapper) PutBuyReportsId(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.PutBuyReportsId(ctx, id) + return err +} + // GetDepartments converts echo context to params. func (w *ServerInterfaceWrapper) GetDepartments(ctx echo.Context) error { var err error @@ -1709,6 +1898,22 @@ func (w *ServerInterfaceWrapper) PostFestivalItems(ctx echo.Context) error { return err } +// GetFestivalItemsDetailsDivisionId converts echo context to params. +func (w *ServerInterfaceWrapper) GetFestivalItemsDetailsDivisionId(ctx echo.Context) error { + var err error + // ------------- Path parameter "division_id" ------------- + var divisionId int + + err = runtime.BindStyledParameterWithOptions("simple", "division_id", ctx.Param("division_id"), &divisionId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter division_id: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetFestivalItemsDetailsDivisionId(ctx, divisionId) + return err +} + // DeleteFestivalItemsId converts echo context to params. func (w *ServerInterfaceWrapper) DeleteFestivalItemsId(ctx echo.Context) error { var err error @@ -2876,6 +3081,11 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.DELETE(baseURL+"/bureaus/:id", wrapper.DeleteBureausId) router.GET(baseURL+"/bureaus/:id", wrapper.GetBureausId) router.PUT(baseURL+"/bureaus/:id", wrapper.PutBureausId) + router.PUT(baseURL+"/buy_report/status/:buy_report_id", wrapper.PutBuyReportStatusBuyReportId) + router.POST(baseURL+"/buy_reports", wrapper.PostBuyReports) + router.GET(baseURL+"/buy_reports/list", wrapper.GetBuyReportsList) + router.DELETE(baseURL+"/buy_reports/:id", wrapper.DeleteBuyReportsId) + router.PUT(baseURL+"/buy_reports/:id", wrapper.PutBuyReportsId) router.GET(baseURL+"/departments", wrapper.GetDepartments) router.POST(baseURL+"/departments", wrapper.PostDepartments) router.DELETE(baseURL+"/departments/:id", wrapper.DeleteDepartmentsId) @@ -2896,6 +3106,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL 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/:division_id", wrapper.GetFestivalItemsDetailsDivisionId) router.DELETE(baseURL+"/festival_items/:id", wrapper.DeleteFestivalItemsId) router.PUT(baseURL+"/festival_items/:id", wrapper.PutFestivalItemsId) router.GET(baseURL+"/financial_records", wrapper.GetFinancialRecords) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 693912e6..648c5eb3 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -669,12 +669,21 @@ paths: post: tags: - buy_report - description: buy_reportの作成 + description: 購入報告を行うAPI requestBody: content: - application/json: + multipart/form-data: schema: - $ref: "#/components/schemas/buyReport" + type: object + properties: + file: + type: string + format: binary + buy_report: + $ref: "#/components/schemas/buyReport" + required: + - file + - buy_report required: true responses: "200": @@ -687,7 +696,7 @@ paths: put: tags: - buy_report - description: buy_reportの更新 + description: 購入報告を修正するAPI、画像がある場合は画像も更新 parameters: - name: id in: path @@ -697,9 +706,18 @@ paths: type: integer requestBody: content: - application/json: + multipart/form-data: schema: - $ref: "#/components/schemas/buyReport" + type: object + properties: + file: + type: string + format: binary + description: 購入報告書のファイル、ない場合更新しないようにする + buy_report: + $ref: "#/components/schemas/buyReport" + required: + - buy_report required: true responses: "200": @@ -709,6 +727,78 @@ paths: schema: $ref: "#/components/schemas/buyReport" x-codegen-request-body-name: buy_report + delete: + tags: + - buy_report + description: IDを指定してbuy_reportの削除、紐づいた画像も削除、マイページから削除できる + parameters: + - name: id + in: path + description: id + required: true + schema: + type: integer + responses: + "200": + description: buy_reportの削除完了 + content: + application/json: + schema: + type: object + /buy_reports/list: + get: + tags: + - buy_report + description: 購入報告で表示するbuyReport一覧の取得、主に財務向けのページ + parameters: + - name: year + in: query + description: year + schema: + type: integer + responses: + "200": + description: buy_reportの一覧を取得 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/buyReportDetail" + /buy_report/status/{buy_report_id}: + put: + tags: + - buy_report + description: buy_reportのステータス更新、財務が封詰め、精算済みにするAPI + parameters: + - name: buy_report_id + in: path + description: buy_report_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + type: object + properties: + isPacked: + type: boolean + example: false + description: 封筒に詰めたか + isSettled: + type: boolean + example: false + description: 精算済みか + responses: + "200": + description: 更新されたbuy_reportが返ってくる + content: + application/json: + schema: + $ref: "#/components/schemas/buyReportDetail" + /departments: get: tags: @@ -1132,7 +1222,7 @@ paths: /festival_items/details/{division_id}: get: tags: - - division + - festival_item description: divisionの予算一覧の取得 parameters: - name: division_id @@ -2492,6 +2582,7 @@ components: type: integer example: 1 buyReport: + description: 購入報告の際のパラメータ type: object properties: id: @@ -2506,16 +2597,12 @@ components: paidBy: type: string example: 企画局_技大太郎 - receiptIDs: - type: array - items: - type: integer - example: [1, 2] required: - festivalItemID - amount - paidBy buyReportInformation: + description: マイページで表示する購入報告の情報 type: object properties: ID: @@ -2536,6 +2623,37 @@ components: - 確認中 - 封詰め - 生産完了 + buyReportDetail: + description: 購入報告ページで表示する詳細情報 + type: object + properties: + ID: + type: integer + example: 1 + financialRecordName: + type: string + example: 企画局 + divisionName: + type: string + example: ビンゴ部門 + festivalItemName: + type: string + example: 段ボール + amount: + type: integer + example: 1000 + reportDate: + type: string + example: 2024-01-01 + paidBy: + type: string + example: 企画局_技大太郎 + isPacked: + type: boolean + example: false + isSettled: + type: boolean + example: false division: required: - name @@ -2609,7 +2727,7 @@ components: festivalItemsForMyPage: type: object properties: - total: + divisionTotal: $ref: "#/components/schemas/total" financialRecordName: type: string @@ -2624,7 +2742,7 @@ components: festivalItemWithReport: type: object properties: - total: + festivalItemTotal: $ref: "#/components/schemas/total" festivalItemName: type: string diff --git a/view/next-project/src/generated/hooks.ts b/view/next-project/src/generated/hooks.ts index deb2b5c0..d8eb7f63 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -19,11 +19,14 @@ import type { Activity, ActivityInformation, ActivityStyle, + BuyReport, + BuyReportDetail, DeleteActivitiesId200, DeleteActivityInformationsId200, DeleteActivityStylesId200, DeleteBudgetsId200, DeleteBureausId200, + DeleteBuyReportsId200, DeleteDepartmentsId200, DeleteDivisionsId200, DeleteExpensesId200, @@ -48,6 +51,7 @@ import type { FestivalItem, FestivalItemDetails, FestivalItemWithBalance, + FestivalItemsForMyPage, FinancialRecord, FinancialRecordDetails, FinancialRecordWithBalance, @@ -70,6 +74,7 @@ import type { GetBudgetsIdDetails200, GetBureaus200, GetBureausId200, + GetBuyReportsListParams, GetDepartments200, GetDepartmentsId200, GetExpenses200, @@ -103,6 +108,7 @@ import type { PostBudgetsParams, PostBureaus200, PostBureausParams, + PostBuyReportsBody, PostDepartments200, PostDepartmentsParams, PostExpenses200, @@ -133,6 +139,8 @@ import type { PutBudgetsIdParams, PutBureausId200, PutBureausIdParams, + PutBuyReportStatusBuyReportIdBody, + PutBuyReportsIdBody, PutDepartmentsId200, PutDepartmentsIdParams, PutExpensesId200, @@ -1939,6 +1947,301 @@ export const useDeleteBureausId = ( } } +/** + * 購入報告を行うAPI + */ +export type postBuyReportsResponse = { + data: BuyReport; + status: number; + headers: Headers; +} + +export const getPostBuyReportsUrl = () => { + + + return `/buy_reports` +} + +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: 'POST' + , + body: + formData, + } +);} + + + + +export const getPostBuyReportsMutationFetcher = ( options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PostBuyReportsBody }): Promise => { + return postBuyReports(arg, options); + } +} +export const getPostBuyReportsMutationKey = () => [`/buy_reports`] as const; + +export type PostBuyReportsMutationResult = NonNullable>> +export type PostBuyReportsMutationError = unknown + +export const usePostBuyReports = ( + options?: { swr?:SWRMutationConfiguration>, TError, Key, PostBuyReportsBody, Awaited>> & { swrKey?: string }, request?: SecondParameter} +) => { + + const {swr: swrOptions, request: requestOptions} = options ?? {} + + const swrKey = swrOptions?.swrKey ?? getPostBuyReportsMutationKey(); + const swrFn = getPostBuyReportsMutationFetcher(requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * 購入報告を修正するAPI、画像がある場合は画像も更新 + */ +export type putBuyReportsIdResponse = { + data: BuyReport; + status: number; + headers: Headers; +} + +export const getPutBuyReportsIdUrl = (id: number,) => { + + + return `/buy_reports/${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: 'PUT' + , + body: + formData, + } +);} + + + + +export const getPutBuyReportsIdMutationFetcher = (id: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PutBuyReportsIdBody }): Promise => { + return putBuyReportsId(id, arg, options); + } +} +export const getPutBuyReportsIdMutationKey = (id: number,) => [`/buy_reports/${id}`] as const; + +export type PutBuyReportsIdMutationResult = NonNullable>> +export type PutBuyReportsIdMutationError = unknown + +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 ?? getPutBuyReportsIdMutationKey(id); + const swrFn = getPutBuyReportsIdMutationFetcher(id, requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * IDを指定してbuy_reportの削除、紐づいた画像も削除、マイページから削除できる + */ +export type deleteBuyReportsIdResponse = { + data: DeleteBuyReportsId200; + status: number; + headers: Headers; +} + +export const getDeleteBuyReportsIdUrl = (id: number,) => { + + + return `/buy_reports/${id}` +} + +export const deleteBuyReportsId = async (id: number, options?: RequestInit): Promise => { + + return customFetch>(getDeleteBuyReportsIdUrl(id), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +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 DeleteBuyReportsIdMutationResult = NonNullable>> +export type DeleteBuyReportsIdMutationError = unknown + +export const useDeleteBuyReportsId = ( + id: number, options?: { swr?:SWRMutationConfiguration>, TError, Key, Arguments, Awaited>> & { swrKey?: string }, request?: SecondParameter} +) => { + + const {swr: swrOptions, request: requestOptions} = options ?? {} + + const swrKey = swrOptions?.swrKey ?? getDeleteBuyReportsIdMutationKey(id); + const swrFn = getDeleteBuyReportsIdMutationFetcher(id, requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * 購入報告で表示するbuyReport一覧の取得、主に財務向けのページ + */ +export type getBuyReportsListResponse = { + data: BuyReportDetail[]; + status: number; + headers: Headers; +} + +export const getGetBuyReportsListUrl = (params?: GetBuyReportsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + return normalizedParams.size ? `/buy_reports/list?${normalizedParams.toString()}` : `/buy_reports/list` +} + +export const getBuyReportsList = async (params?: GetBuyReportsListParams, options?: RequestInit): Promise => { + + return customFetch>(getGetBuyReportsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + + +export const getGetBuyReportsListKey = (params?: GetBuyReportsListParams,) => [`/buy_reports/list`, ...(params ? [params]: [])] as const; + +export type GetBuyReportsListQueryResult = NonNullable>> +export type GetBuyReportsListQueryError = unknown + +export const useGetBuyReportsList = ( + params?: GetBuyReportsListParams, 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 ? getGetBuyReportsListKey(params) : null); + const swrFn = () => getBuyReportsList(params, requestOptions) + + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + +/** + * buy_reportのステータス更新、財務が封詰め、精算済みにするAPI + */ +export type putBuyReportStatusBuyReportIdResponse = { + data: BuyReportDetail; + status: number; + headers: Headers; +} + +export const getPutBuyReportStatusBuyReportIdUrl = (buyReportId: number,) => { + + + return `/buy_report/status/${buyReportId}` +} + +export const putBuyReportStatusBuyReportId = async (buyReportId: number, + putBuyReportStatusBuyReportIdBody: PutBuyReportStatusBuyReportIdBody, options?: RequestInit): Promise => { + + return customFetch>(getPutBuyReportStatusBuyReportIdUrl(buyReportId), + { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + putBuyReportStatusBuyReportIdBody,) + } +);} + + + + +export const getPutBuyReportStatusBuyReportIdMutationFetcher = (buyReportId: number, options?: SecondParameter) => { + return (_: Key, { arg }: { arg: PutBuyReportStatusBuyReportIdBody }): Promise => { + return putBuyReportStatusBuyReportId(buyReportId, arg, options); + } +} +export const getPutBuyReportStatusBuyReportIdMutationKey = (buyReportId: number,) => [`/buy_report/status/${buyReportId}`] as const; + +export type PutBuyReportStatusBuyReportIdMutationResult = NonNullable>> +export type PutBuyReportStatusBuyReportIdMutationError = unknown + +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 ?? getPutBuyReportStatusBuyReportIdMutationKey(buyReportId); + const swrFn = getPutBuyReportStatusBuyReportIdMutationFetcher(buyReportId, requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + /** * departmentの一覧の取得 */ @@ -3172,6 +3475,57 @@ export const useDeleteFestivalItemsId = ( } } +/** + * divisionの予算一覧の取得 + */ +export type getFestivalItemsDetailsDivisionIdResponse = { + data: FestivalItemsForMyPage; + status: number; + headers: Headers; +} + +export const getGetFestivalItemsDetailsDivisionIdUrl = (divisionId: number,) => { + + + return `/festival_items/details/${divisionId}` +} + +export const getFestivalItemsDetailsDivisionId = async (divisionId: number, options?: RequestInit): Promise => { + + return customFetch>(getGetFestivalItemsDetailsDivisionIdUrl(divisionId), + { + ...options, + method: 'GET' + + + } +);} + + + + +export const getGetFestivalItemsDetailsDivisionIdKey = (divisionId: number,) => [`/festival_items/details/${divisionId}`] as const; + +export type GetFestivalItemsDetailsDivisionIdQueryResult = NonNullable>> +export type GetFestivalItemsDetailsDivisionIdQueryError = unknown + +export const useGetFestivalItemsDetailsDivisionId = ( + divisionId: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, request?: SecondParameter } +) => { + const {swr: swrOptions, request: requestOptions} = options ?? {} + + const isEnabled = swrOptions?.enabled !== false && !!(divisionId) + const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetFestivalItemsDetailsDivisionIdKey(divisionId) : null); + const swrFn = () => getFestivalItemsDetailsDivisionId(divisionId, requestOptions) + + const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + + return { + swrKey, + ...query + } +} + /** * financial_recordの一覧を取得 */ diff --git a/view/next-project/src/generated/model/index.ts b/view/next-project/src/generated/model/index.ts index 7858bbb1..1bbef43a 100644 --- a/view/next-project/src/generated/model/index.ts +++ b/view/next-project/src/generated/model/index.ts @@ -9,11 +9,16 @@ export * from './activity'; export * from './activityInformation'; export * from './activityStyle'; +export * from './buyReport'; +export * from './buyReportDetail'; +export * from './buyReportInformation'; +export * from './buyReportInformationStatus'; export * from './deleteActivitiesId200'; export * from './deleteActivityInformationsId200'; export * from './deleteActivityStylesId200'; export * from './deleteBudgetsId200'; export * from './deleteBureausId200'; +export * from './deleteBuyReportsId200'; export * from './deleteDepartmentsId200'; export * from './deleteDivisionsId200'; export * from './deleteExpensesId200'; @@ -39,6 +44,8 @@ export * from './divisionWithBalance'; export * from './festivalItem'; export * from './festivalItemDetails'; export * from './festivalItemWithBalance'; +export * from './festivalItemWithReport'; +export * from './festivalItemsForMyPage'; export * from './financialRecord'; export * from './financialRecordDetails'; export * from './financialRecordWithBalance'; @@ -63,6 +70,7 @@ export * from './getBudgetsId200'; export * from './getBudgetsIdDetails200'; export * from './getBureaus200'; export * from './getBureausId200'; +export * from './getBuyReportsListParams'; export * from './getDepartments200'; export * from './getDepartmentsId200'; export * from './getExpenses200'; @@ -96,6 +104,7 @@ export * from './postBudgets200'; export * from './postBudgetsParams'; export * from './postBureaus200'; export * from './postBureausParams'; +export * from './postBuyReportsBody'; export * from './postDepartments200'; export * from './postDepartmentsParams'; export * from './postExpenses200'; @@ -126,6 +135,8 @@ export * from './putBudgetsId200'; export * from './putBudgetsIdParams'; export * from './putBureausId200'; export * from './putBureausIdParams'; +export * from './putBuyReportStatusBuyReportIdBody'; +export * from './putBuyReportsIdBody'; export * from './putDepartmentsId200'; export * from './putDepartmentsIdParams'; export * from './putExpensesId200';