Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #18 from SystemEngineeringTeam/backend/new_endpoint
Browse files Browse the repository at this point in the history
update: swag の更新
  • Loading branch information
harutiro authored Sep 9, 2023
2 parents 732bdfb + 2965aa2 commit 9871557
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 33 deletions.
11 changes: 9 additions & 2 deletions backend/server.log
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@

[GIN-debug] GET /api/v1/staycount/get/ --> github.com/SystemEngineeringTeam/geekcamp-2023-vol9/controller.StayCountGet (4 handlers)
[GIN-debug] GET /api/v1/congestion/get/ --> github.com/SystemEngineeringTeam/geekcamp-2023-vol9/controller.GetCongestionDegree (4 handlers)
[GIN-debug] GET /api/v1/staycount/history/ --> github.com/SystemEngineeringTeam/geekcamp-2023-vol9/controller.StayCountHistoriesGet (4 handlers)
[GIN-debug] POST /api/v1/staycount/post/:room_id --> github.com/SystemEngineeringTeam/geekcamp-2023-vol9/controller.StayCountPost (4 handlers)
[GIN-debug] GET /api/v1/swagger/*any --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (4 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on :8080
[GIN] 2023/09/10 - 02:25:20 | 200 | 8.708584ms | 127.0.0.1 | GET "/api/v1/staycount/get/"
[GIN] 2023/09/10 - 02:25:29 | 200 | 85.444917ms | 127.0.0.1 | GET "/api/v1/congestion/get/"
[GIN] 2023/09/10 - 04:27:30 | 200 | 2.238333ms | ::1 | GET "/api/v1/swagger/index.html"
[GIN] 2023/09/10 - 04:27:30 | 200 | 626.709µs | ::1 | GET "/api/v1/swagger/swagger-ui.css"
[GIN] 2023/09/10 - 04:27:30 | 200 | 350µs | ::1 | GET "/api/v1/swagger/swagger-ui-standalone-preset.js"
[GIN] 2023/09/10 - 04:27:30 | 200 | 18.631291ms | ::1 | GET "/api/v1/swagger/swagger-ui-bundle.js"
[GIN] 2023/09/10 - 04:27:30 | 200 | 290.25µs | ::1 | GET "/api/v1/swagger/swagger-ui-standalone-preset.js"
[GIN] 2023/09/10 - 04:27:30 | 200 | 7.371458ms | ::1 | GET "/api/v1/swagger/swagger-ui-bundle.js"
[GIN] 2023/09/10 - 04:27:30 | 200 | 337.458µs | ::1 | GET "/api/v1/swagger/doc.json"
[GIN] 2023/09/10 - 04:27:30 | 200 | 49.25µs | ::1 | GET "/api/v1/swagger/favicon-32x32.png"
2 changes: 1 addition & 1 deletion backend/src/controller/staycount_history_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// @Description 滞在者数の履歴を取得する。これは24時間分のデータを取得する。
// @Tag StayCount
// @Produce json
// @Success 200 {object} model.GetStayCountResponseModel
// @Success 200 {object} model.GetStayCountHistoryRequestModel
// @Router /api/v1/staycount/history/ [get]
func StayCountHistoriesGet(c *gin.Context) {
// TODO: しっかりとMySQLからデータを取得する
Expand Down
61 changes: 50 additions & 11 deletions backend/src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ const docTemplate = `{
}
}
},
"/api/v1/staycount/history/": {
"get": {
"description": "滞在者数の履歴を取得する。これは24時間分のデータを取得する。",
"produces": [
"application/json"
],
"summary": "滞在者数の履歴を取得する(今日だけ)",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.GetStayCountHistoryRequestModel"
}
}
}
}
},
"/api/v1/staycount/post/{building_name}": {
"post": {
"description": "arpscanによって取得したデータを元に滞在者数を登録する",
Expand All @@ -71,14 +88,14 @@ const docTemplate = `{
"model.GetCongestionBuildingModel": {
"type": "object",
"properties": {
"building": {
"type": "string"
},
"floors": {
"type": "array",
"items": {
"$ref": "#/definitions/model.GetCongestionFloorModel"
}
},
"name": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -113,25 +130,25 @@ const docTemplate = `{
"congestion": {
"type": "number"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"room_id": {
"type": "integer"
}
}
},
"model.GetStayCountBuildingModel": {
"type": "object",
"properties": {
"building": {
"type": "string"
},
"floors": {
"type": "array",
"items": {
"$ref": "#/definitions/model.GetStayCountFloorModel"
}
},
"name": {
"type": "string"
}
}
},
Expand All @@ -149,6 +166,28 @@ const docTemplate = `{
}
}
},
"model.GetStayCountHistoryModel": {
"type": "object",
"properties": {
"0": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"model.GetStayCountHistoryRequestModel": {
"type": "object",
"properties": {
"histories": {
"type": "array",
"items": {
"$ref": "#/definitions/model.GetStayCountHistoryModel"
}
}
}
},
"model.GetStayCountResponseModel": {
"type": "object",
"properties": {
Expand All @@ -163,13 +202,13 @@ const docTemplate = `{
"model.GetStayCountRoomModel": {
"type": "object",
"properties": {
"headcount": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"room_id": {
"staycount": {
"type": "integer"
}
}
Expand Down
61 changes: 50 additions & 11 deletions backend/src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@
}
}
},
"/api/v1/staycount/history/": {
"get": {
"description": "滞在者数の履歴を取得する。これは24時間分のデータを取得する。",
"produces": [
"application/json"
],
"summary": "滞在者数の履歴を取得する(今日だけ)",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.GetStayCountHistoryRequestModel"
}
}
}
}
},
"/api/v1/staycount/post/{building_name}": {
"post": {
"description": "arpscanによって取得したデータを元に滞在者数を登録する",
Expand All @@ -63,14 +80,14 @@
"model.GetCongestionBuildingModel": {
"type": "object",
"properties": {
"building": {
"type": "string"
},
"floors": {
"type": "array",
"items": {
"$ref": "#/definitions/model.GetCongestionFloorModel"
}
},
"name": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -105,25 +122,25 @@
"congestion": {
"type": "number"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"room_id": {
"type": "integer"
}
}
},
"model.GetStayCountBuildingModel": {
"type": "object",
"properties": {
"building": {
"type": "string"
},
"floors": {
"type": "array",
"items": {
"$ref": "#/definitions/model.GetStayCountFloorModel"
}
},
"name": {
"type": "string"
}
}
},
Expand All @@ -141,6 +158,28 @@
}
}
},
"model.GetStayCountHistoryModel": {
"type": "object",
"properties": {
"0": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"model.GetStayCountHistoryRequestModel": {
"type": "object",
"properties": {
"histories": {
"type": "array",
"items": {
"$ref": "#/definitions/model.GetStayCountHistoryModel"
}
}
}
},
"model.GetStayCountResponseModel": {
"type": "object",
"properties": {
Expand All @@ -155,13 +194,13 @@
"model.GetStayCountRoomModel": {
"type": "object",
"properties": {
"headcount": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"room_id": {
"staycount": {
"type": "integer"
}
}
Expand Down
41 changes: 33 additions & 8 deletions backend/src/docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
definitions:
model.GetCongestionBuildingModel:
properties:
building:
type: string
floors:
items:
$ref: '#/definitions/model.GetCongestionFloorModel'
type: array
name:
type: string
type: object
model.GetCongestionFloorModel:
properties:
Expand All @@ -28,19 +28,19 @@ definitions:
properties:
congestion:
type: number
id:
type: integer
name:
type: string
room_id:
type: integer
type: object
model.GetStayCountBuildingModel:
properties:
building:
type: string
floors:
items:
$ref: '#/definitions/model.GetStayCountFloorModel'
type: array
name:
type: string
type: object
model.GetStayCountFloorModel:
properties:
Expand All @@ -51,6 +51,20 @@ definitions:
$ref: '#/definitions/model.GetStayCountRoomModel'
type: array
type: object
model.GetStayCountHistoryModel:
properties:
"0":
items:
type: integer
type: array
type: object
model.GetStayCountHistoryRequestModel:
properties:
histories:
items:
$ref: '#/definitions/model.GetStayCountHistoryModel'
type: array
type: object
model.GetStayCountResponseModel:
properties:
building:
Expand All @@ -60,11 +74,11 @@ definitions:
type: object
model.GetStayCountRoomModel:
properties:
headcount:
id:
type: integer
name:
type: string
room_id:
staycount:
type: integer
type: object
model.PostStayCountRequestModel:
Expand Down Expand Up @@ -102,6 +116,17 @@ paths:
schema:
$ref: '#/definitions/model.GetStayCountResponseModel'
summary: 滞在者数を取得する
/api/v1/staycount/history/:
get:
description: 滞在者数の履歴を取得する。これは24時間分のデータを取得する。
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/model.GetStayCountHistoryRequestModel'
summary: 滞在者数の履歴を取得する(今日だけ)
/api/v1/staycount/post/{building_name}:
post:
description: arpscanによって取得したデータを元に滞在者数を登録する
Expand Down
8 changes: 8 additions & 0 deletions backend/src/model/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ type GetCongestionResponseModel struct {
type PostStayCountRequestModel struct {
Time time.Time `json:"time"`
Headcount int `json:"headcount"`
}

type GetStayCountHistoryRequestModel struct {
Histories []GetStayCountHistoryModel `json:"histories"`
}

type GetStayCountHistoryModel struct {
StayCount [24]int `json:"0"`
}
3 changes: 3 additions & 0 deletions backend/test/localhost/staycount.http
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ Accept: application/json
"time" : "2022-09-04T19:08:48.000Z",
"headcount" : 30
}

### Swagger
http://localhost:8080/api/v1/swagger/index.html

0 comments on commit 9871557

Please sign in to comment.