diff --git a/api/externals/controller/cmapus_donation_controller.go b/api/externals/controller/cmapus_donation_controller.go index 2f532857..ffc99029 100644 --- a/api/externals/controller/cmapus_donation_controller.go +++ b/api/externals/controller/cmapus_donation_controller.go @@ -14,6 +14,8 @@ type campusDonationController struct { type CampusDonationController interface { IndexCampusDonationByFloor(echo.Context) error IndexCampusDonationBuildingByPeriod(echo.Context) error + CreateCampusDonation(echo.Context) error + UpdateCampusDonation(echo.Context) error } func NewCampusDonationController(u usecase.CampusDonationUseCase) CampusDonationController { @@ -46,3 +48,69 @@ func (f *campusDonationController) IndexCampusDonationBuildingByPeriod(c echo.Co } return c.JSON(http.StatusOK, fundInformationBuildingByPeriod) } + +func (f *campusDonationController) CreateCampusDonation(c echo.Context) error { + ctx := c.Request().Context() + userId := c.QueryParam("user_id") + teacherId := c.QueryParam("teacher_id") + price := c.QueryParam("price") + receivedAt := c.QueryParam("received_at") + yearId := c.QueryParam("year_id") + + if userId == "" { + return c.String(http.StatusBadRequest, "user_id is required") + } + if teacherId == "" { + return c.String(http.StatusBadRequest, "teacher_id is required") + } + if price == "" { + return c.String(http.StatusBadRequest, "price is required") + } + if receivedAt == "" { + return c.String(http.StatusBadRequest, "received_at is required") + } + if yearId == "" { + return c.String(http.StatusBadRequest, "year_id is required") + } + + err := f.u.CreateCampusDonation(ctx, userId, teacherId, price, receivedAt, yearId) + if err != nil { + return err + } + return c.NoContent(http.StatusCreated) +} + +func (f *campusDonationController) UpdateCampusDonation(c echo.Context) error { + ctx := c.Request().Context() + id := c.QueryParam("id") + userId := c.QueryParam("user_id") + teacherId := c.QueryParam("teacher_id") + price := c.QueryParam("price") + receivedAt := c.QueryParam("received_at") + yearId := c.QueryParam("year_id") + + if id == "" { + return c.String(http.StatusBadRequest, "id is required") + } + if userId == "" { + return c.String(http.StatusBadRequest, "user_id is required") + } + if teacherId == "" { + return c.String(http.StatusBadRequest, "teacher_id is required") + } + if price == "" { + return c.String(http.StatusBadRequest, "price is required") + } + if receivedAt == "" { + return c.String(http.StatusBadRequest, "received_at is required") + } + if yearId == "" { + return c.String(http.StatusBadRequest, "year_id is required") + } + + err := f.u.UpdateCampusDonation(ctx, id, userId, teacherId, price, receivedAt, yearId) + if err != nil { + return err + } + return c.NoContent(http.StatusOK) +} diff --git a/api/externals/repository/campus_donation_repository.go b/api/externals/repository/campus_donation_repository.go index 1df7d620..411b4001 100644 --- a/api/externals/repository/campus_donation_repository.go +++ b/api/externals/repository/campus_donation_repository.go @@ -18,6 +18,8 @@ type campusDonationRepository struct { type CampusDonationRepository interface { AllCampusDonationByFloor(context.Context, string, string) (*sql.Rows, error) AllBuildingsByPeriod(context.Context, string) (*sql.Rows, error) + CreateCampusDonation(context.Context, string, string, string, string, string) error + UpdateCampusDonation(context.Context, string, string, string, string, string, string) error } func NewCampusDonationRepository(c db.Client, ac abstract.Crud) CampusDonationRepository { @@ -143,3 +145,35 @@ func (fir *campusDonationRepository) AllBuildingsByPeriod(c context.Context, yea return fir.crud.Read(c, query) } + +func (fir *campusDonationRepository) CreateCampusDonation(c context.Context, userId string, teacherId string, price string, receivedAt string, yearId string) error { + dbDialect := goqu.Dialect("mysql") + ds := dbDialect.Insert("campus_donations").Rows(goqu.Record{ + "user_id": userId, + "teacher_id": teacherId, + "price": price, + "received_at": receivedAt, + "year_id": yearId, + }) + query, _, err := ds.ToSQL() + if err != nil { + return err + } + return fir.crud.UpdateDB(c, query) +} + +func (fir *campusDonationRepository) UpdateCampusDonation(c context.Context, id string, userId string, teacherId string, price string, receivedAt string, yearId string) error { + dbDialect := goqu.Dialect("mysql") + ds := dbDialect.Update("campus_donations").Set(goqu.Record{ + "user_id": userId, + "teacher_id": teacherId, + "price": price, + "received_at": receivedAt, + "year_id": yearId, + }).Where(goqu.Ex{"id": id}) + query, _, err := ds.ToSQL() + if err != nil { + return err + } + return fir.crud.UpdateDB(c, query) +} diff --git a/api/generated/openapi_gen.go b/api/generated/openapi_gen.go index b5077286..67631c67 100644 --- a/api/generated/openapi_gen.go +++ b/api/generated/openapi_gen.go @@ -285,6 +285,25 @@ type PasswordResetData struct { Token *string `json:"token,omitempty"` } +// PostRequestBodyCampusDonation defines model for postRequestBodyCampusDonation. +type PostRequestBodyCampusDonation struct { + Price *int `json:"price,omitempty"` + ReceivedAt *string `json:"received_at,omitempty"` + TeacherId *int `json:"teacher_id,omitempty"` + UserId *int `json:"user_id,omitempty"` + YearId *int `json:"year_id,omitempty"` +} + +// PutRequestBodyCampusDonation defines model for putRequestBodyCampusDonation. +type PutRequestBodyCampusDonation struct { + Id *int `json:"id,omitempty"` + Price *int `json:"price,omitempty"` + ReceivedAt *string `json:"received_at,omitempty"` + TeacherId *int `json:"teacher_id,omitempty"` + UserId *int `json:"user_id,omitempty"` + YearId *int `json:"year_id,omitempty"` +} + // Receipt defines model for receipt. type Receipt struct { BucketName *string `json:"bucketName,omitempty"` @@ -670,6 +689,12 @@ type PostBuyReportsMultipartRequestBody PostBuyReportsMultipartBody // PutBuyReportsIdMultipartRequestBody defines body for PutBuyReportsId for multipart/form-data ContentType. type PutBuyReportsIdMultipartRequestBody PutBuyReportsIdMultipartBody +// PostCampusDonationsJSONRequestBody defines body for PostCampusDonations for application/json ContentType. +type PostCampusDonationsJSONRequestBody = PostRequestBodyCampusDonation + +// PutCampusDonationsIdJSONRequestBody defines body for PutCampusDonationsId for application/json ContentType. +type PutCampusDonationsIdJSONRequestBody = PutRequestBodyCampusDonation + // PostDivisionsJSONRequestBody defines body for PostDivisions for application/json ContentType. type PostDivisionsJSONRequestBody = Division @@ -847,12 +872,18 @@ type ServerInterface interface { // (PUT /buy_reports/{id}) PutBuyReportsId(ctx echo.Context, id int) error + // (POST /campus_donations) + PostCampusDonations(ctx echo.Context) error + // (GET /campus_donations/building/{building_id}/floor/{floor_id}) GetCampusDonationsBuildingBuildingIdFloorFloorId(ctx echo.Context, buildingId int, floorId int) error // (GET /campus_donations/buildings/{year}) GetCampusDonationsBuildingsYear(ctx echo.Context, year int) error + // (PUT /campus_donations/{id}) + PutCampusDonationsId(ctx echo.Context, id int) error + // (GET /departments) GetDepartments(ctx echo.Context) error @@ -1745,6 +1776,15 @@ func (w *ServerInterfaceWrapper) PutBuyReportsId(ctx echo.Context) error { return err } +// PostCampusDonations converts echo context to params. +func (w *ServerInterfaceWrapper) PostCampusDonations(ctx echo.Context) error { + var err error + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.PostCampusDonations(ctx) + return err +} + // GetCampusDonationsBuildingBuildingIdFloorFloorId converts echo context to params. func (w *ServerInterfaceWrapper) GetCampusDonationsBuildingBuildingIdFloorFloorId(ctx echo.Context) error { var err error @@ -1785,6 +1825,22 @@ func (w *ServerInterfaceWrapper) GetCampusDonationsBuildingsYear(ctx echo.Contex return err } +// PutCampusDonationsId converts echo context to params. +func (w *ServerInterfaceWrapper) PutCampusDonationsId(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.PutCampusDonationsId(ctx, id) + return err +} + // GetDepartments converts echo context to params. func (w *ServerInterfaceWrapper) GetDepartments(ctx echo.Context) error { var err error @@ -3352,8 +3408,10 @@ 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.POST(baseURL+"/campus_donations", wrapper.PostCampusDonations) router.GET(baseURL+"/campus_donations/building/:building_id/floor/:floor_id", wrapper.GetCampusDonationsBuildingBuildingIdFloorFloorId) router.GET(baseURL+"/campus_donations/buildings/:year", wrapper.GetCampusDonationsBuildingsYear) + router.PUT(baseURL+"/campus_donations/:id", wrapper.PutCampusDonationsId) router.GET(baseURL+"/departments", wrapper.GetDepartments) router.POST(baseURL+"/departments", wrapper.PostDepartments) router.DELETE(baseURL+"/departments/:id", wrapper.DeleteDepartmentsId) diff --git a/api/internals/usecase/campus_donation_usecase.go b/api/internals/usecase/campus_donation_usecase.go index 4f908126..ef89efcb 100644 --- a/api/internals/usecase/campus_donation_usecase.go +++ b/api/internals/usecase/campus_donation_usecase.go @@ -17,6 +17,8 @@ type campusDonationUseCase struct { type CampusDonationUseCase interface { GetCampusDonationByFloors(context.Context, string, string) ([]CampusDonationByFloor, error) GetCampusDonationBuildingByPeriod(context.Context, string) ([]BuildingTotal, error) + CreateCampusDonation(context.Context, string, string, string, string, string) error + UpdateCampusDonation(context.Context, string, string, string, string, string, string) error } func NewCampusDonationUseCase(rep rep.CampusDonationRepository) CampusDonationUseCase { @@ -104,4 +106,20 @@ func (f *campusDonationUseCase) GetCampusDonationBuildingByPeriod(c context.Cont return result, nil } +func (f *campusDonationUseCase) CreateCampusDonation(c context.Context, userId string, teacherId string, price string, receivedAt string, yearId string) error { + err := f.rep.CreateCampusDonation(c, userId, teacherId, price, receivedAt, yearId) + if err != nil { + return err + } + return nil +} + +func (f *campusDonationUseCase) UpdateCampusDonation(c context.Context, id string, userId string, teacherId string, price string, receivedAt string, yearId string) error { + err := f.rep.UpdateCampusDonation(c, id, userId, teacherId, price, receivedAt, yearId) + if err != nil { + return err + } + return nil +} + type BuildingTotal generated.BuildingTotal diff --git a/api/router/router.go b/api/router/router.go index 8d780f83..d34b566d 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -164,6 +164,9 @@ func (r router) ProvideRouter(e *echo.Echo) { // campus_donationsのRoute e.GET("/campus_donations/building/:building_id/floor/:floor_id", r.campusDonationController.IndexCampusDonationByFloor) + e.GET("/campus_donations/building/:building_id", r.campusDonationController.IndexCampusDonationBuildingByPeriod) + e.POST("/campus_donations", r.campusDonationController.CreateCampusDonation) + e.PUT("/campus_donations/:id", r.campusDonationController.UpdateCampusDonation) // current_user e.GET("/current_user", r.userController.GetCurrentUser) diff --git a/er/columns.html b/er/columns.html index 4c1d6144..f3a57598 100644 --- a/er/columns.html +++ b/er/columns.html @@ -978,6 +978,146 @@

Columns

"defaultValue": "CURRENT_TIMESTAMP", "comments": "" }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "primaryKey", + "keyTitle": "Primary Key", + "name": "id", + "type": "INT UNSIGNED", + "length": 10, + "nullable": "", + "autoUpdated": "√", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "user_id", + "type": "INT", + "length": 10, + "nullable": "", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "teacher_id", + "type": "INT", + "length": 10, + "nullable": "", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "price", + "type": "INT", + "length": 10, + "nullable": "", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "remark", + "type": "VARCHAR", + "length": 255, + "nullable": "√", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "is_first_check", + "type": "BIT", + "length": 1, + "nullable": "√", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "is_last_check", + "type": "BIT", + "length": 1, + "nullable": "√", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "received_at", + "type": "VARCHAR", + "length": 255, + "nullable": "", + "autoUpdated": "", + "defaultValue": "null", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "created_at", + "type": "DATETIME", + "length": 19, + "nullable": "", + "autoUpdated": "", + "defaultValue": "CURRENT_TIMESTAMP", + "comments": "" + }, + { + "tableName": "campus_donations", + "tableFileName": "campus_donations", + "tableType": "Table", + "keyClass": "", + "keyTitle": "", + "name": "updated_at", + "type": "DATETIME", + "length": 19, + "nullable": "", + "autoUpdated": "", + "defaultValue": "CURRENT_TIMESTAMP", + "comments": "" + }, { "tableName": "departments", "tableFileName": "departments", @@ -1328,146 +1468,6 @@

Columns

"defaultValue": "CURRENT_TIMESTAMP", "comments": "" }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "primaryKey", - "keyTitle": "Primary Key", - "name": "id", - "type": "INT UNSIGNED", - "length": 10, - "nullable": "", - "autoUpdated": "√", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "user_id", - "type": "INT", - "length": 10, - "nullable": "", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "teacher_id", - "type": "INT", - "length": 10, - "nullable": "", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "price", - "type": "INT", - "length": 10, - "nullable": "", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "remark", - "type": "VARCHAR", - "length": 255, - "nullable": "√", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "is_first_check", - "type": "BIT", - "length": 1, - "nullable": "√", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "is_last_check", - "type": "BIT", - "length": 1, - "nullable": "√", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "received_at", - "type": "VARCHAR", - "length": 255, - "nullable": "", - "autoUpdated": "", - "defaultValue": "null", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "created_at", - "type": "DATETIME", - "length": 19, - "nullable": "", - "autoUpdated": "", - "defaultValue": "CURRENT_TIMESTAMP", - "comments": "" - }, - { - "tableName": "fund_informations", - "tableFileName": "fund_informations", - "tableType": "Table", - "keyClass": "", - "keyTitle": "", - "name": "updated_at", - "type": "DATETIME", - "length": 19, - "nullable": "", - "autoUpdated": "", - "defaultValue": "CURRENT_TIMESTAMP", - "comments": "" - }, { "tableName": "income_expenditure_managements", "tableFileName": "income_expenditure_managements", diff --git a/er/constraints.html b/er/constraints.html index 4aa05faa..aba8f1bc 100644 --- a/er/constraints.html +++ b/er/constraints.html @@ -266,54 +266,54 @@

22 Foreign Key Constraints

Cascade on delete - item_budgets_ibfk_1 + income_income_expenditure_managements_ibfk_1 - +
item_budgets.festival_item_idincome_income_expenditure_managements.income_expenditure_id
- +
festival_items.idincome_expenditure_managements.id
Cascade on delete - income_income_expenditure_managements_ibfk_1 + income_income_expenditure_managements_ibfk_2 - +
income_income_expenditure_managements.income_expenditure_idincome_income_expenditure_managements.income_id
- +
income_expenditure_managements.idincomes.id
Cascade on delete - income_income_expenditure_managements_ibfk_2 + item_budgets_ibfk_1 - +
income_income_expenditure_managements.income_iditem_budgets.festival_item_id
- +
incomes.idfestival_items.id
diff --git a/er/deletionOrder.txt b/er/deletionOrder.txt index 266a994c..0f8c7f0a 100644 --- a/er/deletionOrder.txt +++ b/er/deletionOrder.txt @@ -10,8 +10,8 @@ purchase_orders purchase_items password_reset_tokens mail_auth -fund_informations departments +campus_donations bureaus budgets activity_styles diff --git a/er/diagrams/orphans/orphans.dot b/er/diagrams/orphans/orphans.dot index 6f75cd55..6c7e34de 100644 --- a/er/diagrams/orphans/orphans.dot +++ b/er/diagrams/orphans/orphans.dot @@ -64,6 +64,26 @@ digraph "orphans" { target="_top" tooltip="bureaus" ]; + "campus_donations" [ + label=< + + + + + + + + + + + + + +
campus_donations[table]
id
int unsigned[10]
user_id
int[10]
teacher_id
int[10]
price
int[10]
remark
varchar[255]
is_first_check
bit[1]
is_last_check
bit[1]
received_at
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 02 rows0 >
> + URL="tables/campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "departments" [ label=< @@ -78,26 +98,6 @@ digraph "orphans" { target="_top" tooltip="departments" ]; - "fund_informations" [ - label=< -
- - - - - - - - - - - - -
fund_informations[table]
id
int unsigned[10]
user_id
int[10]
teacher_id
int[10]
price
int[10]
remark
varchar[255]
is_first_check
bit[1]
is_last_check
bit[1]
received_at
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 02 rows0 >
> - URL="tables/fund_informations.html" - target="_top" - tooltip="fund_informations" - ]; "mail_auth" [ label=< diff --git a/er/diagrams/orphans/orphans.png b/er/diagrams/orphans/orphans.png index a92d087e..4b5de1fb 100644 Binary files a/er/diagrams/orphans/orphans.png and b/er/diagrams/orphans/orphans.png differ diff --git a/er/diagrams/summary/relationships.real.compact.dot b/er/diagrams/summary/relationships.real.compact.dot index dd96e684..5fd33158 100644 --- a/er/diagrams/summary/relationships.real.compact.dot +++ b/er/diagrams/summary/relationships.real.compact.dot @@ -62,6 +62,18 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="purchase_reports" ]; + "campus_donations" [ + label=< +
+ + + + +
campus_donations[table]
id
...
2 rows
> + URL="tables/campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "receipts" [ label=< @@ -147,18 +159,6 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="activity_styles" ]; - "fund_informations" [ - label=< -
- - - - -
fund_informations[table]
id
...
2 rows
> - URL="tables/fund_informations.html" - target="_top" - tooltip="fund_informations" - ]; "user_groups" [ label=< @@ -274,19 +274,6 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="budgets" ]; - "item_budgets" [ - label=< -
- - - - - -
item_budgets[table]
id
festival_item_id
...
< 17 rows
> - URL="tables/item_budgets.html" - target="_top" - tooltip="item_budgets" - ]; "income_income_expenditure_managements" [ label=< @@ -301,6 +288,19 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="income_income_expenditure_managements" ]; + "item_budgets" [ + label=< +
+ + + + + +
item_budgets[table]
id
festival_item_id
...
< 17 rows
> + URL="tables/item_budgets.html" + target="_top" + tooltip="item_budgets" + ]; "session" [ label=< @@ -468,18 +468,6 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="payment_receipts" ]; - "users" [ - label=< -
- - - - -
users[table]
id
...
4 rows1 >
> - URL="tables/users.html" - target="_top" - tooltip="users" - ]; "teachers" [ label=< @@ -492,6 +480,18 @@ digraph "compactRelationshipsDiagram" { target="_top" tooltip="teachers" ]; + "users" [ + label=< +
+ + + + +
users[table]
id
...
4 rows1 >
> + URL="tables/users.html" + target="_top" + tooltip="users" + ]; "password_reset_tokens" [ label=< diff --git a/er/diagrams/summary/relationships.real.compact.png b/er/diagrams/summary/relationships.real.compact.png index beee0bb6..8ce8f2bc 100644 Binary files a/er/diagrams/summary/relationships.real.compact.png and b/er/diagrams/summary/relationships.real.compact.png differ diff --git a/er/diagrams/summary/relationships.real.large.dot b/er/diagrams/summary/relationships.real.large.dot index 009f6ac3..a1efdb7c 100644 --- a/er/diagrams/summary/relationships.real.large.dot +++ b/er/diagrams/summary/relationships.real.large.dot @@ -85,6 +85,26 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="purchase_reports" ]; + "campus_donations" [ + label=< +
+ + + + + + + + + + + + +
campus_donations[table]
id
user_id
teacher_id
price
remark
is_first_check
is_last_check
received_at
created_at
updated_at
2 rows
> + URL="tables/campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; "receipts" [ label=< @@ -196,26 +216,6 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="activity_styles" ]; - "fund_informations" [ - label=< -
- - - - - - - - - - - - -
fund_informations[table]
id
user_id
teacher_id
price
remark
is_first_check
is_last_check
received_at
created_at
updated_at
2 rows
> - URL="tables/fund_informations.html" - target="_top" - tooltip="fund_informations" - ]; "user_groups" [ label=< @@ -361,21 +361,6 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="budgets" ]; - "item_budgets" [ - label=< -
- - - - - - - -
item_budgets[table]
id
amount
festival_item_id
created_at
updated_at
< 17 rows
> - URL="tables/item_budgets.html" - target="_top" - tooltip="item_budgets" - ]; "income_income_expenditure_managements" [ label=< @@ -391,6 +376,21 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="income_income_expenditure_managements" ]; + "item_budgets" [ + label=< +
+ + + + + + + +
item_budgets[table]
id
amount
festival_item_id
created_at
updated_at
< 17 rows
> + URL="tables/item_budgets.html" + target="_top" + tooltip="item_budgets" + ]; "session" [ label=< @@ -598,23 +598,6 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="payment_receipts" ]; - "users" [ - label=< -
- - - - - - - - - -
users[table]
id
name
bureau_id
role_id
is_deleted
created_at
updated_at
4 rows1 >
> - URL="tables/users.html" - target="_top" - tooltip="users" - ]; "teachers" [ label=< @@ -635,6 +618,23 @@ digraph "largeRelationshipsDiagram" { target="_top" tooltip="teachers" ]; + "users" [ + label=< +
+ + + + + + + + + +
users[table]
id
name
bureau_id
role_id
is_deleted
created_at
updated_at
4 rows1 >
> + URL="tables/users.html" + target="_top" + tooltip="users" + ]; "password_reset_tokens" [ label=< diff --git a/er/diagrams/summary/relationships.real.large.png b/er/diagrams/summary/relationships.real.large.png index 9608a022..27e8e2bb 100644 Binary files a/er/diagrams/summary/relationships.real.large.png and b/er/diagrams/summary/relationships.real.large.png differ diff --git a/er/diagrams/tables/campus_donations.1degree.dot b/er/diagrams/tables/campus_donations.1degree.dot new file mode 100644 index 00000000..a3d1bce2 --- /dev/null +++ b/er/diagrams/tables/campus_donations.1degree.dot @@ -0,0 +1,23 @@ +digraph "oneDegreeRelationshipsDiagram" { + graph [ rankdir="RL" bgcolor="#ffffff" label="\nGenerated by SchemaSpy" labeljust="l" nodesep="0.18" ranksep="0.46" fontname="Helvetica" fontsize="11" packmode="graph" ]; node [ fontname="Helvetica" fontsize="11" shape="plaintext" ]; edge [ arrowsize="0.8" ]; + "campus_donations" [ + label=< +
+ + + + + + + + + + + + +
campus_donations[table]
id
int unsigned[10]
user_id
int[10]
teacher_id
int[10]
price
int[10]
remark
varchar[255]
is_first_check
bit[1]
is_last_check
bit[1]
received_at
varchar[255]
created_at
datetime[19]
updated_at
datetime[19]
< 02 rows0 >
> + URL="campus_donations.html" + target="_top" + tooltip="campus_donations" + ]; +} diff --git a/er/diagrams/tables/campus_donations.1degree.png b/er/diagrams/tables/campus_donations.1degree.png new file mode 100644 index 00000000..34f487ac Binary files /dev/null and b/er/diagrams/tables/campus_donations.1degree.png differ diff --git a/er/finansu_db.finansu_db.xml b/er/finansu_db.finansu_db.xml index 176040db..a14ccdda 100644 --- a/er/finansu_db.finansu_db.xml +++ b/er/finansu_db.finansu_db.xml @@ -158,6 +158,22 @@ + + + + + + + + + + + + + + + +
@@ -243,22 +259,6 @@
- - - - - - - - - - - - - - - -
diff --git a/er/index.html b/er/index.html index de71e32c..0cf036b8 100644 --- a/er/index.html +++ b/er/index.html @@ -78,7 +78,7 @@

Tables


SchemaSpy Analysis of finansu_db.finansu_db

-

Generated on Fri May 02 07:50 UTC 2025

+

Generated on Thu May 15 19:13 UTC 2025

@@ -241,6 +241,15 @@

Tables

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

Tables

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

Tables

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

Tables

- + - - + + - + - - + + diff --git a/er/info-html.txt b/er/info-html.txt index 1446ed1e..ea2b2e58 100644 --- a/er/info-html.txt +++ b/er/info-html.txt @@ -1,4 +1,4 @@ -date=2025-05-02 07:50:56+0000 +date=2025-05-15 19:13:51+0000 os=Linux 5.15.167.4-microsoft-standard-WSL2 schemaspy-version=7.0.2-SNAPSHOT schemaspy-revision=bf4d5fddd535dd213a512a6a521bcadb8260168d diff --git a/er/insertionOrder.txt b/er/insertionOrder.txt index cdbe46d5..d828e434 100644 --- a/er/insertionOrder.txt +++ b/er/insertionOrder.txt @@ -25,8 +25,8 @@ activity_informations activity_styles budgets bureaus +campus_donations departments -fund_informations mail_auth password_reset_tokens purchase_items diff --git a/er/orphans.html b/er/orphans.html index 3c947df9..feb3bb03 100644 --- a/er/orphans.html +++ b/er/orphans.html @@ -89,8 +89,8 @@

Orphan Tables

- - + + diff --git a/er/relationships.html b/er/relationships.html index 98aea75d..89b0b1b0 100644 --- a/er/relationships.html +++ b/er/relationships.html @@ -99,16 +99,16 @@
By default only columns that are primary keys, foreign keys or indexes are s - - - - - - - - + + + + + + + + - + @@ -120,8 +120,8 @@
By default only columns that are primary keys, foreign keys or indexes are s - - + + @@ -129,7 +129,7 @@
By default only columns that are primary keys, foreign keys or indexes are s - + @@ -145,16 +145,16 @@
By default only columns that are primary keys, foreign keys or indexes are s - - - - - - - - + + + + + + + + - + @@ -166,8 +166,8 @@
By default only columns that are primary keys, foreign keys or indexes are s - - + + @@ -175,7 +175,7 @@
By default only columns that are primary keys, foreign keys or indexes are s - + diff --git a/er/tables/campus_donations.html b/er/tables/campus_donations.html new file mode 100644 index 00000000..480fa122 --- /dev/null +++ b/er/tables/campus_donations.html @@ -0,0 +1,402 @@ + + + + + + campus_donations - finansu_db.finansu_db + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + +
+ +
+

campus_donations

2 rows


+
+ +
+
+
+ +

Columns

+
+ + +
+
+
+
Table
campus_donations00102Table
receipts 0 Table
fund_informations00102Table
user_groups 0
item_budgetsincome_income_expenditure_managements 012 570 Table
income_income_expenditure_managementsitem_budgets 021 507 Table
usersteachers 1 074100 Table
teachersusers 1 010074 Table
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ColumnTypeSizeNullsAutoDefaultChildrenParentsComments
idINT UNSIGNED10null + +
+
+ +
+
user_idINT10null + +
+
+ +
+
teacher_idINT10null + +
+
+ +
+
priceINT10null + +
+
+ +
+
remarkVARCHAR255null + +
+
+ +
+
is_first_checkBIT1null + +
+
+ +
+
is_last_checkBIT1null + +
+
+ +
+
received_atVARCHAR255null + +
+
+ +
+
created_atDATETIME19CURRENT_TIMESTAMP + +
+
+ +
+
updated_atDATETIME19CURRENT_TIMESTAMP + +
+
+ +
+
+ + +
+
+ +

Indexes

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

Relationships

+
+ + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mysql/db/20_campus_donations.sql b/mysql/db/20_campus_donations.sql index e48a8e10..0f9568de 100644 --- a/mysql/db/20_campus_donations.sql +++ b/mysql/db/20_campus_donations.sql @@ -1,22 +1,18 @@ use finansu_db; -CREATE TABLE - campus_donations ( - id int(10) unsigned not null auto_increment, - user_id int(10) not null, - teacher_id int(10) not null, - price int(10) not null, - remark varchar(255), - is_first_check boolean, - is_last_check boolean, - received_at varchar(255) not null, - created_at datetime not null default current_timestamp, - updated_at datetime not null default current_timestamp on update current_timestamp, - PRIMARY KEY (id) - ); +CREATE TABLE campus_donations ( + id int(10) unsigned not null auto_increment, + user_id int(10) not null, + teacher_id int(10) not null, + price int(10) not null, + remark varchar(255), + received_at varchar(255) not null, + year_id INT(10) UNSIGNED NOT NULL, + created_at datetime not null default current_timestamp, + updated_at datetime not null default current_timestamp on update current_timestamp, + PRIMARY KEY (id) +); -INSERT INTO - campus_donations (user_id, teacher_id, price, remark, is_first_check, is_last_check, received_at) -VALUES - (1, 1, 2000, "nothing", false, false, '2023-02-22'), - (2, 2, 2000, "nothing", false, false, '2022-02-22'); +INSERT INTO campus_donations (user_id, teacher_id, price, remark, received_at, year_id) +VALUES (1, 1, 2000, "nothing", '2023-02-22', 2023), + (2, 2, 2000, "nothing", '2022-02-22', 2022); diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 733f0b8b..d208e6fa 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -815,7 +815,49 @@ paths: application/json: schema: $ref: "#/components/schemas/buyReportDetail" - + /campus_donations: + post: + tags: + - campus_donation + description: 学内募金の作成 + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/postRequestBodyCampusDonation" + required: true + responses: + "200": + description: 作成された学内募金が返ってくる + content: + application/json: + schema: + type: object + /campus_donations/{id}: + put: + tags: + - campus_donation + description: 学内募金の更新 + parameters: + - name: id + in: path + description: id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/putRequestBodyCampusDonation" + required: true + responses: + "200": + description: 更新された学内募金が返ってくる + content: + application/json: + schema: + type: object /campus_donations/building/{building_id}/floor/{floor_id}: get: tags: @@ -3355,5 +3397,44 @@ components: - teacher_name - price - is_black + postRequestBodyCampusDonation: + type: object + properties: + user_id: + type: integer + example: 1 + teacher_id: + type: integer + example: 1 + price: + type: integer + example: 10000 + received_at: + type: string + example: 2024-01-01 + year_id: + type: integer + example: 1 + putRequestBodyCampusDonation: + type: object + properties: + id: + type: integer + example: 1 + user_id: + type: integer + example: 1 + teacher_id: + type: integer + example: 1 + price: + type: integer + example: 10000 + received_at: + type: string + example: 2024-01-01 + year_id: + type: integer + example: 1 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 714625b8..36542fc8 100644 --- a/view/next-project/src/generated/hooks.ts +++ b/view/next-project/src/generated/hooks.ts @@ -113,6 +113,7 @@ import type { PostBureaus200, PostBureausParams, PostBuyReportsBody, + PostCampusDonations200, PostDepartments200, PostDepartmentsParams, PostExpenses200, @@ -123,6 +124,7 @@ import type { PostPasswordResetRequest200, PostPasswordResetRequestParams, PostReceipts200, + PostRequestBodyCampusDonation, PostSources200, PostSourcesParams, PostSponsors200, @@ -145,6 +147,7 @@ import type { PutBureausIdParams, PutBuyReportStatusBuyReportIdBody, PutBuyReportsIdBody, + PutCampusDonationsId200, PutDepartmentsId200, PutDepartmentsIdParams, PutExpensesId200, @@ -152,6 +155,7 @@ import type { PutIncomeExpenditureManagementsCheckId200, PutIncomeExpenditureManagementsCheckIdBody, PutReceiptsId200, + PutRequestBodyCampusDonation, PutSourcesId200, PutSourcesIdParams, PutSponsorsId200, @@ -2692,6 +2696,152 @@ export const usePutBuyReportStatusBuyReportId = ( }; }; +/** + * 学内募金の作成 + */ +export type postCampusDonationsResponse200 = { + data: PostCampusDonations200; + status: 200; +}; + +export type postCampusDonationsResponseComposite = postCampusDonationsResponse200; + +export type postCampusDonationsResponse = postCampusDonationsResponseComposite & { + headers: Headers; +}; + +export const getPostCampusDonationsUrl = () => { + return `/campus_donations`; +}; + +export const postCampusDonations = async ( + postRequestBodyCampusDonation: PostRequestBodyCampusDonation, + options?: RequestInit, +): Promise => { + return customFetch(getPostCampusDonationsUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(postRequestBodyCampusDonation), + }); +}; + +export const getPostCampusDonationsMutationFetcher = ( + options?: SecondParameter, +) => { + return ( + _: Key, + { arg }: { arg: PostRequestBodyCampusDonation }, + ): Promise => { + return postCampusDonations(arg, options); + }; +}; +export const getPostCampusDonationsMutationKey = () => [`/campus_donations`] as const; + +export type PostCampusDonationsMutationResult = NonNullable< + Awaited> +>; +export type PostCampusDonationsMutationError = unknown; + +export const usePostCampusDonations = (options?: { + swr?: SWRMutationConfiguration< + Awaited>, + TError, + Key, + PostRequestBodyCampusDonation, + Awaited> + > & { swrKey?: string }; + request?: SecondParameter; +}) => { + const { swr: swrOptions, request: requestOptions } = options ?? {}; + + const swrKey = swrOptions?.swrKey ?? getPostCampusDonationsMutationKey(); + const swrFn = getPostCampusDonationsMutationFetcher(requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions); + + return { + swrKey, + ...query, + }; +}; + +/** + * 学内募金の更新 + */ +export type putCampusDonationsIdResponse200 = { + data: PutCampusDonationsId200; + status: 200; +}; + +export type putCampusDonationsIdResponseComposite = putCampusDonationsIdResponse200; + +export type putCampusDonationsIdResponse = putCampusDonationsIdResponseComposite & { + headers: Headers; +}; + +export const getPutCampusDonationsIdUrl = (id: number) => { + return `/campus_donations/${id}`; +}; + +export const putCampusDonationsId = async ( + id: number, + putRequestBodyCampusDonation: PutRequestBodyCampusDonation, + options?: RequestInit, +): Promise => { + return customFetch(getPutCampusDonationsIdUrl(id), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(putRequestBodyCampusDonation), + }); +}; + +export const getPutCampusDonationsIdMutationFetcher = ( + id: number, + options?: SecondParameter, +) => { + return ( + _: Key, + { arg }: { arg: PutRequestBodyCampusDonation }, + ): Promise => { + return putCampusDonationsId(id, arg, options); + }; +}; +export const getPutCampusDonationsIdMutationKey = (id: number) => + [`/campus_donations/${id}`] as const; + +export type PutCampusDonationsIdMutationResult = NonNullable< + Awaited> +>; +export type PutCampusDonationsIdMutationError = unknown; + +export const usePutCampusDonationsId = ( + id: number, + options?: { + swr?: SWRMutationConfiguration< + Awaited>, + TError, + Key, + PutRequestBodyCampusDonation, + Awaited> + > & { swrKey?: string }; + request?: SecondParameter; + }, +) => { + const { swr: swrOptions, request: requestOptions } = options ?? {}; + + const swrKey = swrOptions?.swrKey ?? getPutCampusDonationsIdMutationKey(id); + const swrFn = getPutCampusDonationsIdMutationFetcher(id, requestOptions); + + const query = useSWRMutation(swrKey, swrFn, swrOptions); + + return { + swrKey, + ...query, + }; +}; + /** * 各棟の各階の学内募金情報を取得するAPI */ diff --git a/view/next-project/src/generated/model/index.ts b/view/next-project/src/generated/model/index.ts index 636db86f..3f2c29c5 100644 --- a/view/next-project/src/generated/model/index.ts +++ b/view/next-project/src/generated/model/index.ts @@ -126,6 +126,7 @@ export * from './postBudgetsParams'; export * from './postBureaus200'; export * from './postBureausParams'; export * from './postBuyReportsBody'; +export * from './postCampusDonations200'; export * from './postDepartments200'; export * from './postDepartmentsParams'; export * from './postExpenses200'; @@ -140,6 +141,7 @@ export * from './postPasswordResetIdValidParams'; export * from './postPasswordResetRequest200'; export * from './postPasswordResetRequestParams'; export * from './postReceipts200'; +export * from './postRequestBodyCampusDonation'; export * from './postSources200'; export * from './postSourcesParams'; export * from './postSponsors200'; @@ -162,6 +164,7 @@ export * from './putBureausId200'; export * from './putBureausIdParams'; export * from './putBuyReportStatusBuyReportIdBody'; export * from './putBuyReportsIdBody'; +export * from './putCampusDonationsId200'; export * from './putDepartmentsId200'; export * from './putDepartmentsIdParams'; export * from './putExpensesId200'; @@ -172,6 +175,7 @@ export * from './putIncomeExpenditureManagementsCheckId200'; export * from './putIncomeExpenditureManagementsCheckIdBody'; export * from './putIncomesId200'; export * from './putReceiptsId200'; +export * from './putRequestBodyCampusDonation'; export * from './putSourcesId200'; export * from './putSourcesIdParams'; export * from './putSponsorsId200'; @@ -184,6 +188,7 @@ export * from './putYearsId200'; export * from './putYearsIdParams'; export * from './putYearsPeriodsId200'; export * from './receipt'; +export * from './requestBodyCampusDonation'; export * from './sponsor'; export * from './sponsorStyle'; export * from './teacher'; diff --git a/view/next-project/src/generated/model/postCampusDonations200.ts b/view/next-project/src/generated/model/postCampusDonations200.ts new file mode 100644 index 00000000..e530c7c1 --- /dev/null +++ b/view/next-project/src/generated/model/postCampusDonations200.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export type PostCampusDonations200 = { [key: string]: unknown }; diff --git a/view/next-project/src/generated/model/postRequestBodyCampusDonation.ts b/view/next-project/src/generated/model/postRequestBodyCampusDonation.ts new file mode 100644 index 00000000..c985ff43 --- /dev/null +++ b/view/next-project/src/generated/model/postRequestBodyCampusDonation.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export interface PostRequestBodyCampusDonation { + user_id?: number; + teacher_id?: number; + price?: number; + received_at?: string; + year_id?: number; +} diff --git a/view/next-project/src/generated/model/putCampusDonationsId200.ts b/view/next-project/src/generated/model/putCampusDonationsId200.ts new file mode 100644 index 00000000..db08e73e --- /dev/null +++ b/view/next-project/src/generated/model/putCampusDonationsId200.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export type PutCampusDonationsId200 = { [key: string]: unknown }; diff --git a/view/next-project/src/generated/model/putRequestBodyCampusDonation.ts b/view/next-project/src/generated/model/putRequestBodyCampusDonation.ts new file mode 100644 index 00000000..7ab66c3a --- /dev/null +++ b/view/next-project/src/generated/model/putRequestBodyCampusDonation.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export interface PutRequestBodyCampusDonation { + id?: number; + user_id?: number; + teacher_id?: number; + price?: number; + received_at?: string; + year_id?: number; +} diff --git a/view/next-project/src/generated/model/requestBodyCampusDonation.ts b/view/next-project/src/generated/model/requestBodyCampusDonation.ts new file mode 100644 index 00000000..1fd3bd22 --- /dev/null +++ b/view/next-project/src/generated/model/requestBodyCampusDonation.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v7.6.0 🍺 + * Do not edit manually. + * NUTFes FinanSu API + * FinanSu APIドキュメント + * OpenAPI spec version: 2.0.0 + */ + +export interface RequestBodyCampusDonation { + user_id?: number; + teacher_id?: number; + price?: number; + received_at?: string; + year_id?: number; +}