-
Notifications
You must be signed in to change notification settings - Fork 2
各棟の各階の教員情報を取得するAPI #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
各棟の各階の教員情報を取得するAPI #987
Conversation
Kubosaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とりあえずコメント
openapi/openapi.yaml
Outdated
| campusDonationByFloor: | ||
| type: object | ||
| properties: | ||
| teacher_id: | ||
| type: integer | ||
| building_name: | ||
| type: string | ||
| unit_number: | ||
| type: string | ||
| floor_number: | ||
| type: string | ||
| room_name: | ||
| type: string | ||
| teacher_name: | ||
| type: string | ||
| price: | ||
| type: integer | ||
| is_black: | ||
| type: boolean | ||
| required: | ||
| - teacher_id | ||
| - building_name | ||
| - unit_number | ||
| - floor_number | ||
| - room_name | ||
| - teacher_name | ||
| - price | ||
| - is_black | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ask]全部まとめて配列で返してるけど、棟ごとにまとめたりするのはフロントですか?
結構しんどそうだなって思って
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
絶賛作業中なんですけど以下みたいな感じでまとめたいって話で合ってますよね?それは確かにバックエンドで対応したいですね
type CampusDonation struct {
IsBlack *bool `json:"is_black,omitempty"`
Price int `json:"price"`
RoomName string `json:"room_name"`
TeacherId int `json:"teacher_id"`
TeacherName string `json:"teacher_name"`
}
// CampusDonationByFloorAndBuilding 棟ごと
type CampusDonationByFloorAndBuilding struct {
BuildingId int `json:"building_id"`
BuildingName *string `json:"building_name,omitempty"`
Floors []FloorGroup `json:"floors"`
}
type FloorGroup struct {
Donations []CampusDonation `json:"donations"`
FloorId *int `json:"floor_id,omitempty"`
FloorNumber string `json:"floor_number"`
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ぱっと見わかんないけど、フロントは表示するだけにしてあげると嬉しいだろうなって思って
ロジックの多いフロントはパフォーマンス低下とかバグの原因にもなりそうだし
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| GroupBy( | ||
| goqu.I("buildings.name"), | ||
| goqu.I("building_units.unit_number"), | ||
| goqu.I("floors.floor_number"), | ||
| goqu.I("rooms.room_name"), | ||
| goqu.I("teachers.id"), | ||
| goqu.I("teachers.name"), | ||
| goqu.I("teachers.is_black"), | ||
| ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ask] このGroup Byってどういう意味で使ってる?
棟の名前とか階層とか同じだと一緒になっちゃわないっけ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なりましたね。priceをsumで返してたのでgroupByが必要になってたです。
そもそもpriceをsumにする必要がなかったので消しました!
Deploying finansu with
|
| Latest commit: |
5d859d4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://aeb657a3.finansu.pages.dev |
| Branch Preview URL: | https://feat-hikahana-get-rooms-by-b.finansu.pages.dev |
|
あ、ごめん、push先間違えた、リセットします |
This reverts commit 4704f36.
…inanSu into feat/hikahana/get-rooms-by-building
…hub:NUTFes/FinanSu into feat/hikahana/get-rooms-by-building
…hub:NUTFes/FinanSu into feat/hikahana/get-rooms-by-building
Kubosaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしますた!
| parameters: | ||
| - name: building_id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: integer | ||
| description: ID of the building | ||
| - name: floor_id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: integer | ||
| description: ID of the floor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[imo]
dbでもコメントしたけどyear_idも指定できたほうが良さそう
| groupMap := make(map[int]*generated.CampusDonationByFloorAndBuilding) | ||
| for _, r := range campusDonationRecords { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[imo] 型の変換処置関数に切り分けても良さそう
時間あればやってもろて
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slackで特定の棟をまとめるみたいなのあったけど、ああいうロジック周りを構造体に持たせてメソッドにするといい感じにドメインロジックを集約できそうだなって思った
| IsBlack: r.IsBlack, | ||
| }) | ||
| } | ||
| // map→slice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このパッケージ使ってもいいかも
配列の処理とかいい感じに書ける
https://github.com/samber/lo?tab=readme-ov-file#maptoslice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こんな感じなの??なんかうまく使えてない感じする
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
良さそう
…hub:NUTFes/FinanSu into feat/hikahana/get-rooms-by-building
| goqu.I("teachers.id").As("teacher_id"), | ||
| goqu.I("teachers.name").As("teacher_name"), | ||
| goqu.I("rooms.room_name").As("room_name"), | ||
| goqu.I("campus_donations.price").As("price"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ask] これって値入ってない時エラーならない?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、確かになるかも
collapseみたいなのも一緒に消しちゃってた

対応Issue
resolve #0
概要
sqlクエリ
SELECT
buildings.name,building_units.unit_number,floors.floor_number,rooms.room_name,teachers.id,teachers.name,teachers.is_black, COALESCE(SUM(fund_informations.price), 0) FROMbuildingsINNER JOINbuilding_unitsON (building_units.building_id=buildings.id) INNER JOINfloorsON (floors.building_unit_id=building_units.id) INNER JOINroomsON (rooms.floor_id=floors.id) INNER JOINroom_teachersON (room_teachers.room_id=rooms.id) INNER JOINteachersON (teachers.id=room_teachers.teacher_id) LEFT JOINfund_informationsON (fund_informations.teacher_id=teachers.id) WHERE ((buildings.id= '1') AND (floors.id= '1')) GROUP BYbuildings.name,building_units.unit_number,floors.floor_number,rooms.room_name,teachers.id,teachers.name,teachers.is_blackORDER BYbuilding_units.unit_numberASC,floors.floor_numberASC,rooms.room_nameASC,teachers.nameASC画面スクリーンショット等
URLスクリーンショット
テスト項目
備考