CHANGE: added autoLogout to Doc + json in struct
This commit is contained in:
@@ -69,13 +69,13 @@ func logoutHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
setCors(w)
|
setCors(w)
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "GET":
|
||||||
autoLogout(w, r)
|
autoLogout(w)
|
||||||
default:
|
default:
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoLogout(w http.ResponseWriter, r *http.Request) {
|
func autoLogout(w http.ResponseWriter) {
|
||||||
users, err := (*models.User).GetAll(nil)
|
users, err := (*models.User).GetAll(nil)
|
||||||
var logged_out_users []models.User
|
var logged_out_users []models.User
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
CardUID string
|
CardUID string `json:"card_uid"`
|
||||||
Name string
|
Name string `json:"name"`
|
||||||
Vorname string
|
Vorname string `json:"vorname"`
|
||||||
HauptbeschaeftigungsOrt int8
|
HauptbeschaeftigungsOrt int8 `json:"hauptbeschaeftigungsort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetAll() ([]User, error) {
|
func (u *User) GetAll() ([]User, error) {
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
"tags": ["booking"],
|
"tags": ["booking"],
|
||||||
"summary": "Gets all the bookings limited",
|
"summary": "Gets all the bookings limited",
|
||||||
"description": "Returns all the bookings optionally filtered with cardID",
|
"description": "Returns all the bookings optionally filtered with cardID",
|
||||||
|
"operationId": "getBooking",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "card_uid",
|
"name": "card_uid",
|
||||||
@@ -83,7 +84,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"operationId": "addPet",
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful operation",
|
"description": "Successful operation",
|
||||||
@@ -207,6 +207,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/logout": {
|
||||||
|
"get": {
|
||||||
|
"tags": ["booking"],
|
||||||
|
"summary": "Logs out all logged in users",
|
||||||
|
"description": "With this call all actively logged in users (last booking today has check_in_out=1) will be logged out automaticly (check_in_out=255)",
|
||||||
|
"operationId": "autoLogout",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Succesful",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/User"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
@@ -241,6 +264,28 @@
|
|||||||
"xml": {
|
"xml": {
|
||||||
"name": "booking"
|
"name": "booking"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"User": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Mustermann"
|
||||||
|
},
|
||||||
|
"vorname": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Max"
|
||||||
|
},
|
||||||
|
"hauptbeschäftigungsort": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int8",
|
||||||
|
"example": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Arbeitszeitmessung - OpenAPI 3.0
|
title: Arbeitszeitmessung - OpenAPI 3.0
|
||||||
description: |-
|
description: 'This demos the API for the Arbeitszeitmessung Project '
|
||||||
This demos the API for the Arbeitszeitmessung Project
|
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Git-Repository
|
description: Git-Repository
|
||||||
@@ -28,7 +27,9 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Update an existent booking in the db. Not all values have to be updated
|
description: >-
|
||||||
|
Update an existent booking in the db. Not all values have to be
|
||||||
|
updated
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
@@ -50,6 +51,7 @@ paths:
|
|||||||
- booking
|
- booking
|
||||||
summary: Gets all the bookings limited
|
summary: Gets all the bookings limited
|
||||||
description: Returns all the bookings optionally filtered with cardID
|
description: Returns all the bookings optionally filtered with cardID
|
||||||
|
operationId: getBooking
|
||||||
parameters:
|
parameters:
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
@@ -57,7 +59,6 @@ paths:
|
|||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
operationId: addPet
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
@@ -75,7 +76,7 @@ paths:
|
|||||||
- booking
|
- booking
|
||||||
summary: Create new Booking
|
summary: Create new Booking
|
||||||
description: Creates a new booking with the supplied parameters
|
description: Creates a new booking with the supplied parameters
|
||||||
operationId: createBooking
|
operationId: pcreateBooking
|
||||||
parameters:
|
parameters:
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
@@ -108,6 +109,60 @@ paths:
|
|||||||
$ref: '#/components/schemas/Booking'
|
$ref: '#/components/schemas/Booking'
|
||||||
'409':
|
'409':
|
||||||
description: Same booking type as last booking
|
description: Same booking type as last booking
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
summary: Create new Booking
|
||||||
|
description: Creates a new booking with the supplied parameters
|
||||||
|
operationId: gcreateBooking
|
||||||
|
parameters:
|
||||||
|
- name: card_uid
|
||||||
|
in: query
|
||||||
|
description: id of the RFID card scanned
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: geraet_id
|
||||||
|
in: query
|
||||||
|
description: id of the RFID reader scanning the card
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: check_in_out
|
||||||
|
in: query
|
||||||
|
description: booking Type
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
enum:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 255
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successfully created booking
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Booking'
|
||||||
|
'409':
|
||||||
|
description: Same booking type as last booking
|
||||||
|
/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
summary: Logs out all logged in users
|
||||||
|
description: With this call all actively logged in users (last booking today has check_in_out=1) will be logged out automaticly (check_in_out=255)
|
||||||
|
operationId: autoLogout
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Succesful
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
Booking:
|
Booking:
|
||||||
@@ -133,6 +188,22 @@ components:
|
|||||||
timestamp:
|
timestamp:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
example: 2024-09-05T08:51:12.670827Z
|
example: '2024-09-05T08:51:12.670Z'
|
||||||
xml:
|
xml:
|
||||||
name: booking
|
name: booking
|
||||||
|
User:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
card_uid:
|
||||||
|
type: string
|
||||||
|
example: test_card
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: Mustermann
|
||||||
|
vorname:
|
||||||
|
type: string
|
||||||
|
example: Max
|
||||||
|
hauptbeschäftigungsort:
|
||||||
|
type: integer
|
||||||
|
format: int8
|
||||||
|
example: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user