Compare commits
3 Commits
27bac5ff84
...
dafcd95428
| Author | SHA1 | Date | |
|---|---|---|---|
| dafcd95428 | |||
| 23cb312644 | |||
| 4dbd1ced0d |
@@ -75,6 +75,12 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if r.Header.Get("Accept") == "application/json" {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
json.NewEncoder(w).Encode(bookings)
|
||||||
|
return
|
||||||
|
}
|
||||||
ctx := context.WithValue(r.Context(), "user", user)
|
ctx := context.WithValue(r.Context(), "user", user)
|
||||||
templates.TimePage(bookings).Render(ctx, w)
|
templates.TimePage(bookings).Render(ctx, w)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,5 +62,13 @@ func checkPassword(r *http.Request) bool {
|
|||||||
authToken := helper.GetEnv("API_TOKEN", "dont_access")
|
authToken := helper.GetEnv("API_TOKEN", "dont_access")
|
||||||
authHeaders := r.Header.Get("Authorization")
|
authHeaders := r.Header.Get("Authorization")
|
||||||
_authStart := len("Bearer ")
|
_authStart := len("Bearer ")
|
||||||
|
if len(authHeaders) <= _authStart {
|
||||||
|
authHeaders = r.URL.Query().Get("api_key")
|
||||||
|
_authStart = 0
|
||||||
|
if len(authHeaders) <= _authStart {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Println(authHeaders)
|
||||||
return authToken == authHeaders[_authStart:]
|
return authToken == authHeaders[_authStart:]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ import (
|
|||||||
//
|
//
|
||||||
// in DEBUG == "true" everything is set to "*" so that no cors errors will be happen
|
// in DEBUG == "true" everything is set to "*" so that no cors errors will be happen
|
||||||
func SetCors(w http.ResponseWriter) {
|
func SetCors(w http.ResponseWriter) {
|
||||||
if os.Getenv("DEBUG") == "true" {
|
if os.Getenv("NO_CORS") == "true" {
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
w.Header().Set("Access-Control-Allow-Methods", "*")
|
w.Header().Set("Access-Control-Allow-Methods", "*")
|
||||||
w.Header().Set("Access-Control-Allow-Headers", "*")
|
w.Header().Set("Access-Control-Allow-Headers", "*")
|
||||||
|
// log.Println("Setting cors to *")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ func checkLastBooking(b Booking) bool {
|
|||||||
log.Println("Error checking last booking: ", err)
|
log.Println("Error checking last booking: ", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if int16(check_in_out) == b.CheckInOut {
|
if int16(check_in_out)%2 == b.CheckInOut%2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type WorkDay struct {
|
type WorkDay struct {
|
||||||
Day time.Time
|
Day time.Time `json:"day"`
|
||||||
Bookings []Booking
|
Bookings []Booking `json:"bookings"`
|
||||||
workTime time.Duration
|
workTime time.Duration
|
||||||
pauseTime time.Duration
|
pauseTime time.Duration
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
|
|||||||
CREATE USER $POSTGRES_API_USER WITH ENCRYPTED PASSWORD '$POSTGRES_API_PASSWORD';
|
CREATE USER $POSTGRES_API_USER WITH ENCRYPTED PASSWORD '$POSTGRES_API_PASSWORD';
|
||||||
GRANT CONNECT ON DATABASE $POSTGRES_DB TO $POSTGRES_API_USER;
|
GRANT CONNECT ON DATABASE $POSTGRES_DB TO $POSTGRES_API_USER;
|
||||||
GRANT USAGE ON SCHEMA public TO $POSTGRES_API_USER;
|
GRANT USAGE ON SCHEMA public TO $POSTGRES_API_USER;
|
||||||
GRANT SELECT, INSERT, UPDATE ON anwesenheit, personal_daten, user_password, buchung_wochen TO $POSTGRES_API_USER;
|
GRANT SELECT, INSERT, UPDATE ON anwesenheit, personal_daten, user_password, wochen_report TO $POSTGRES_API_USER;
|
||||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO $POSTGRES_API_USER;
|
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO $POSTGRES_API_USER;
|
||||||
EOSQL
|
EOSQL
|
||||||
|
|
||||||
|
|||||||
@@ -1,292 +1,493 @@
|
|||||||
{
|
{
|
||||||
"openapi": "3.0.3",
|
"openapi": "3.0.3",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Arbeitszeitmessung - OpenAPI 3.0",
|
"title": "Arbeitszeitmessung - OpenAPI 3.0",
|
||||||
"description": "This demos the API for the Arbeitszeitmessung Project ",
|
"description": "This demos the API for the Arbeitszeitmessung Project ",
|
||||||
"version": "0.1.0"
|
"version": "0.1.0"
|
||||||
},
|
},
|
||||||
"externalDocs": {
|
"externalDocs": {
|
||||||
"description": "Git-Repository",
|
"description": "Git-Repository",
|
||||||
"url": "https://git.letsstein.de/tom/arbeitszeitmessung"
|
"url": "https://git.letsstein.de/tom/arbeitszeitmessung"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"url": "http://localhost:8000"
|
"url": "http://localhost:8000",
|
||||||
}
|
"description": "Docker Server"
|
||||||
],
|
},
|
||||||
"tags": [
|
{
|
||||||
{
|
"url": "http://localhost:8080",
|
||||||
"name": "booking",
|
"description": "Local Development"
|
||||||
"description": "all Bookings"
|
}
|
||||||
}
|
],
|
||||||
],
|
"tags": [
|
||||||
"paths": {
|
{
|
||||||
"/time": {
|
"name": "booking",
|
||||||
"put": {
|
"description": "all Bookings"
|
||||||
"tags": ["booking"],
|
}
|
||||||
"summary": "Update a existing booking",
|
],
|
||||||
"description": "Update an existing booking by Id",
|
"paths": {
|
||||||
"operationId": "updateBooking",
|
"/time": {
|
||||||
"parameters": [
|
"get": {
|
||||||
{
|
"tags": [
|
||||||
"name": "counter_id",
|
"booking"
|
||||||
"in": "query",
|
],
|
||||||
"description": "Booking ID to update",
|
"summary": "Gets all the bookings from one card_uid",
|
||||||
"required": true,
|
"description": "Returns all the bookings optionally filtered with cardID",
|
||||||
"schema": {
|
"operationId": "getBooking",
|
||||||
"type": "string"
|
"parameters": [
|
||||||
}
|
{
|
||||||
}
|
"name": "card_uid",
|
||||||
],
|
"in": "query",
|
||||||
"requestBody": {
|
"description": "CardID to filter for",
|
||||||
"description": "Update an existent booking in the db. Not all values have to be updated",
|
"required": true,
|
||||||
"content": {
|
"schema": {
|
||||||
"application/json": {
|
"type": "string"
|
||||||
"schema": {
|
}
|
||||||
"$ref": "#/components/schemas/Booking"
|
},
|
||||||
}
|
{
|
||||||
}
|
"name": "time_from",
|
||||||
},
|
"in": "query",
|
||||||
"required": true
|
"description": "Timestamp since when all bookings are shown (default=1 month ago)",
|
||||||
},
|
"required": false,
|
||||||
"responses": {
|
"schema": {
|
||||||
"200": {
|
"type": "string",
|
||||||
"description": "Booking Updated",
|
"example": "2025-02-28"
|
||||||
"content": {
|
}
|
||||||
"application/json": {
|
},
|
||||||
"schema": {
|
{
|
||||||
"$ref": "#/components/schemas/Booking"
|
"name": "time_to",
|
||||||
}
|
"in": "query",
|
||||||
}
|
"description": "Timestamp till when all bookings are shown (default=today)",
|
||||||
}
|
"required": false,
|
||||||
},
|
"schema": {
|
||||||
"400": {
|
"type": "string",
|
||||||
"description": "Invalid ID supplied"
|
"example": "2025-02-28"
|
||||||
},
|
}
|
||||||
"500": {
|
}
|
||||||
"description": "Server Error"
|
],
|
||||||
}
|
"responses": {
|
||||||
}
|
"200": {
|
||||||
},
|
"description": "Successful operation",
|
||||||
"get": {
|
"content": {
|
||||||
"tags": ["booking"],
|
"application/json": {
|
||||||
"summary": "Gets all the bookings limited",
|
"schema": {
|
||||||
"description": "Returns all the bookings optionally filtered with cardID",
|
"type": "array",
|
||||||
"operationId": "getBooking",
|
"items": {
|
||||||
"parameters": [
|
"type": "object",
|
||||||
{
|
"properties": {
|
||||||
"name": "card_uid",
|
"day": {
|
||||||
"in": "query",
|
"type": "string",
|
||||||
"description": "CardID to filter for",
|
"format": "date"
|
||||||
"required": false,
|
},
|
||||||
"schema": {
|
"bookings": {
|
||||||
"type": "string"
|
"type": "array",
|
||||||
}
|
"items": {
|
||||||
}
|
"type": "object",
|
||||||
],
|
"properties": {
|
||||||
"responses": {
|
"counter_id": {
|
||||||
"200": {
|
"type": "integer",
|
||||||
"description": "Successful operation",
|
"format": "int64",
|
||||||
"content": {
|
"example": 100
|
||||||
"application/json": {
|
},
|
||||||
"schema": {
|
"card_uid": {
|
||||||
"type": "array",
|
"type": "string",
|
||||||
"items": {
|
"example": "test_card"
|
||||||
"$ref": "#/components/schemas/Booking"
|
},
|
||||||
}
|
"geraet_id": {
|
||||||
}
|
"type": "string",
|
||||||
}
|
"example": "test_reader"
|
||||||
}
|
},
|
||||||
},
|
"check_in_out": {
|
||||||
"400": {
|
"type": "integer",
|
||||||
"description": "Invalid cardID"
|
"example": 1,
|
||||||
}
|
"enum": [
|
||||||
}
|
1,
|
||||||
}
|
2,
|
||||||
},
|
255
|
||||||
"/time/new": {
|
]
|
||||||
"put": {
|
},
|
||||||
"tags": ["booking"],
|
"timestamp": {
|
||||||
"summary": "Create new Booking",
|
"type": "string",
|
||||||
"description": "Creates a new booking with the supplied parameters",
|
"format": "date-time",
|
||||||
"operationId": "pcreateBooking",
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
"parameters": [
|
}
|
||||||
{
|
},
|
||||||
"name": "card_uid",
|
"xml": {
|
||||||
"in": "query",
|
"name": "booking"
|
||||||
"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",
|
"400": {
|
||||||
"required": true,
|
"description": "Invalid cardID"
|
||||||
"schema": {
|
}
|
||||||
"type": "string"
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"/time/new": {
|
||||||
"name": "check_in_out",
|
"put": {
|
||||||
"in": "query",
|
"tags": [
|
||||||
"description": "booking Type",
|
"booking"
|
||||||
"required": true,
|
],
|
||||||
"schema": {
|
"summary": "Create new Booking",
|
||||||
"type": "integer",
|
"description": "Creates a new booking with the supplied parameters",
|
||||||
"enum": [1, 2, 255]
|
"operationId": "pcreateBooking",
|
||||||
}
|
"parameters": [
|
||||||
}
|
{
|
||||||
],
|
"in": "header",
|
||||||
"responses": {
|
"name": "Authorization",
|
||||||
"200": {
|
"description": "Predefined API Key to authorize access",
|
||||||
"description": "successfully created booking",
|
"schema": {
|
||||||
"content": {
|
"type": "string"
|
||||||
"application/json": {
|
}
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/components/schemas/Booking"
|
{
|
||||||
}
|
"name": "card_uid",
|
||||||
}
|
"in": "query",
|
||||||
}
|
"description": "id of the RFID card scanned",
|
||||||
},
|
"required": true,
|
||||||
"409": {
|
"schema": {
|
||||||
"description": "Same booking type as last booking"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
{
|
||||||
"get": {
|
"name": "geraet_id",
|
||||||
"tags": ["booking"],
|
"in": "query",
|
||||||
"summary": "Create new Booking",
|
"description": "id of the RFID reader scanning the card",
|
||||||
"description": "Creates a new booking with the supplied parameters",
|
"required": true,
|
||||||
"operationId": "gcreateBooking",
|
"schema": {
|
||||||
"parameters": [
|
"type": "string"
|
||||||
{
|
}
|
||||||
"name": "card_uid",
|
},
|
||||||
"in": "query",
|
{
|
||||||
"description": "id of the RFID card scanned",
|
"name": "check_in_out",
|
||||||
"required": true,
|
"in": "query",
|
||||||
"schema": {
|
"description": "booking Type",
|
||||||
"type": "string"
|
"required": true,
|
||||||
}
|
"schema": {
|
||||||
},
|
"type": "integer",
|
||||||
{
|
"enum": [
|
||||||
"name": "geraet_id",
|
1,
|
||||||
"in": "query",
|
2,
|
||||||
"description": "id of the RFID reader scanning the card",
|
255
|
||||||
"required": true,
|
]
|
||||||
"schema": {
|
}
|
||||||
"type": "string"
|
}
|
||||||
}
|
],
|
||||||
},
|
"responses": {
|
||||||
{
|
"200": {
|
||||||
"name": "check_in_out",
|
"description": "successfully created booking",
|
||||||
"in": "query",
|
"content": {
|
||||||
"description": "booking Type",
|
"application/json": {
|
||||||
"required": true,
|
"schema": {
|
||||||
"schema": {
|
"type": "object",
|
||||||
"type": "integer",
|
"properties": {
|
||||||
"enum": [1, 2, 255]
|
"counter_id": {
|
||||||
}
|
"type": "integer",
|
||||||
}
|
"format": "int64",
|
||||||
],
|
"example": 100
|
||||||
"responses": {
|
},
|
||||||
"200": {
|
"card_uid": {
|
||||||
"description": "successfully created booking",
|
"type": "string",
|
||||||
"content": {
|
"example": "test_card"
|
||||||
"application/json": {
|
},
|
||||||
"schema": {
|
"geraet_id": {
|
||||||
"$ref": "#/components/schemas/Booking"
|
"type": "string",
|
||||||
}
|
"example": "test_reader"
|
||||||
}
|
},
|
||||||
}
|
"check_in_out": {
|
||||||
},
|
"type": "integer",
|
||||||
"409": {
|
"example": 1,
|
||||||
"description": "Same booking type as last booking"
|
"enum": [
|
||||||
}
|
1,
|
||||||
}
|
2,
|
||||||
}
|
255
|
||||||
},
|
]
|
||||||
"/logout": {
|
},
|
||||||
"get": {
|
"timestamp": {
|
||||||
"tags": ["booking"],
|
"type": "string",
|
||||||
"summary": "Logs out all logged in users",
|
"format": "date-time",
|
||||||
"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)",
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
"operationId": "autoLogout",
|
}
|
||||||
"responses": {
|
},
|
||||||
"200": {
|
"xml": {
|
||||||
"description": "Succesful",
|
"name": "booking"
|
||||||
"content": {
|
}
|
||||||
"application/json": {
|
}
|
||||||
"schema": {
|
}
|
||||||
"type": "array",
|
}
|
||||||
"items": {
|
},
|
||||||
"$ref": "#/components/schemas/User"
|
"409": {
|
||||||
}
|
"description": "Same booking type as last booking"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
"get": {
|
||||||
}
|
"tags": [
|
||||||
}
|
"booking"
|
||||||
}
|
],
|
||||||
},
|
"summary": "Create new Booking",
|
||||||
"components": {
|
"description": "Creates a new booking with the supplied parameters",
|
||||||
"schemas": {
|
"operationId": "gcreateBooking",
|
||||||
"Booking": {
|
"parameters": [
|
||||||
"type": "object",
|
{
|
||||||
"properties": {
|
"in": "header",
|
||||||
"counter_id": {
|
"name": "Authorization",
|
||||||
"type": "integer",
|
"description": "Predefined API Key to authorize access",
|
||||||
"format": "int64",
|
"schema": {
|
||||||
"example": 100
|
"type": "string"
|
||||||
},
|
}
|
||||||
"card_uid": {
|
},
|
||||||
"type": "string",
|
{
|
||||||
"example": "test_card"
|
"in": "query",
|
||||||
},
|
"name": "api_key",
|
||||||
"geraet_id": {
|
"description": "Predefined API Key to authorize access",
|
||||||
"type": "string",
|
"required": false,
|
||||||
"example": "test_reader"
|
"schema": {
|
||||||
},
|
"type": "string"
|
||||||
"check_in_out": {
|
}
|
||||||
"type": "integer",
|
},
|
||||||
"example": 1,
|
{
|
||||||
"enum": [1, 2, 255]
|
"name": "card_uid",
|
||||||
},
|
"in": "query",
|
||||||
"timestamp": {
|
"description": "id of the RFID card scanned",
|
||||||
"type": "string",
|
"required": true,
|
||||||
"format": "date-time",
|
"schema": {
|
||||||
"example": "2024-09-05T08:51:12.670Z"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xml": {
|
{
|
||||||
"name": "booking"
|
"name": "geraet_id",
|
||||||
}
|
"in": "query",
|
||||||
},
|
"description": "id of the RFID reader scanning the card",
|
||||||
"User": {
|
"required": true,
|
||||||
"type": "object",
|
"schema": {
|
||||||
"properties": {
|
"type": "string"
|
||||||
"card_uid": {
|
}
|
||||||
"type": "string",
|
},
|
||||||
"example": "test_card"
|
{
|
||||||
},
|
"name": "check_in_out",
|
||||||
"name": {
|
"in": "query",
|
||||||
"type": "string",
|
"description": "booking Type",
|
||||||
"example": "Mustermann"
|
"required": true,
|
||||||
},
|
"schema": {
|
||||||
"vorname": {
|
"type": "integer",
|
||||||
"type": "string",
|
"enum": [
|
||||||
"example": "Max"
|
1,
|
||||||
},
|
2,
|
||||||
"hauptbeschäftigungsort": {
|
255
|
||||||
"type": "integer",
|
]
|
||||||
"format": "int8",
|
}
|
||||||
"example": 1
|
}
|
||||||
}
|
],
|
||||||
}
|
"responses": {
|
||||||
}
|
"200": {
|
||||||
}
|
"description": "successfully created booking",
|
||||||
}
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"name": "booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "none or wrong api key provided!"
|
||||||
|
},
|
||||||
|
"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": {
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"BookingGrouped": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"day": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date"
|
||||||
|
},
|
||||||
|
"bookings": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"name": "booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Booking": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"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,74 +1,58 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Arbeitszeitmessung - OpenAPI 3.0
|
title: Arbeitszeitmessung - OpenAPI 3.0
|
||||||
description: 'This demos the API for the Arbeitszeitmessung Project '
|
description: "This demos the API for the Arbeitszeitmessung Project "
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Git-Repository
|
description: Git-Repository
|
||||||
url: https://git.letsstein.de/tom/arbeitszeitmessung
|
url: https://git.letsstein.de/tom/arbeitszeitmessung
|
||||||
servers:
|
servers:
|
||||||
- url: http://localhost:8000
|
- url: http://localhost:8000
|
||||||
|
description: Docker Server
|
||||||
|
- url: http://localhost:8080
|
||||||
|
description: Local Development
|
||||||
tags:
|
tags:
|
||||||
- name: booking
|
- name: booking
|
||||||
description: all Bookings
|
description: all Bookings
|
||||||
paths:
|
paths:
|
||||||
/time:
|
/time:
|
||||||
put:
|
|
||||||
tags:
|
|
||||||
- booking
|
|
||||||
summary: Update a existing booking
|
|
||||||
description: Update an existing booking by Id
|
|
||||||
operationId: updateBooking
|
|
||||||
parameters:
|
|
||||||
- name: counter_id
|
|
||||||
in: query
|
|
||||||
description: Booking ID to update
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
requestBody:
|
|
||||||
description: >-
|
|
||||||
Update an existent booking in the db. Not all values have to be
|
|
||||||
updated
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Booking'
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Booking Updated
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Booking'
|
|
||||||
'400':
|
|
||||||
description: Invalid ID supplied
|
|
||||||
'500':
|
|
||||||
description: Server Error
|
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- booking
|
- booking
|
||||||
summary: Gets all the bookings limited
|
summary: Gets all the bookings from one card_uid
|
||||||
description: Returns all the bookings optionally filtered with cardID
|
description: Returns all the bookings optionally filtered with cardID
|
||||||
operationId: getBooking
|
operationId: getBooking
|
||||||
parameters:
|
parameters:
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
description: CardID to filter for
|
description: CardID to filter for
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: time_from
|
||||||
|
in: query
|
||||||
|
description: Timestamp since when all bookings are shown (default=1 month ago)
|
||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
example: "2025-02-28"
|
||||||
|
- name: time_to
|
||||||
|
in: query
|
||||||
|
description: Timestamp till when all bookings are shown (default=today)
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: "2025-02-28"
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Booking'
|
$ref: "#/components/schemas/BookingGrouped"
|
||||||
'400':
|
"400":
|
||||||
description: Invalid cardID
|
description: Invalid cardID
|
||||||
/time/new:
|
/time/new:
|
||||||
put:
|
put:
|
||||||
@@ -78,6 +62,11 @@ paths:
|
|||||||
description: Creates a new booking with the supplied parameters
|
description: Creates a new booking with the supplied parameters
|
||||||
operationId: pcreateBooking
|
operationId: pcreateBooking
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: Authorization
|
||||||
|
description: Predefined API Key to authorize access
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
description: id of the RFID card scanned
|
description: id of the RFID card scanned
|
||||||
@@ -101,13 +90,13 @@ paths:
|
|||||||
- 2
|
- 2
|
||||||
- 255
|
- 255
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: successfully created booking
|
description: successfully created booking
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$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:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -116,6 +105,17 @@ paths:
|
|||||||
description: Creates a new booking with the supplied parameters
|
description: Creates a new booking with the supplied parameters
|
||||||
operationId: gcreateBooking
|
operationId: gcreateBooking
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: Authorization
|
||||||
|
description: Predefined API Key to authorize access
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: api_key
|
||||||
|
description: Predefined API Key to authorize access
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
description: id of the RFID card scanned
|
description: id of the RFID card scanned
|
||||||
@@ -139,13 +139,15 @@ paths:
|
|||||||
- 2
|
- 2
|
||||||
- 255
|
- 255
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: successfully created booking
|
description: successfully created booking
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Booking'
|
$ref: "#/components/schemas/Booking"
|
||||||
'409':
|
"401":
|
||||||
|
description: none or wrong api key provided!
|
||||||
|
"409":
|
||||||
description: Same booking type as last booking
|
description: Same booking type as last booking
|
||||||
/logout:
|
/logout:
|
||||||
get:
|
get:
|
||||||
@@ -155,16 +157,26 @@ paths:
|
|||||||
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)
|
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
|
operationId: autoLogout
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: Succesful
|
description: Succesful
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/User'
|
$ref: "#/components/schemas/User"
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
BookingGrouped:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
day:
|
||||||
|
type: string
|
||||||
|
format: date
|
||||||
|
bookings:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Booking"
|
||||||
Booking:
|
Booking:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -188,7 +200,7 @@ components:
|
|||||||
timestamp:
|
timestamp:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
example: '2024-09-05T08:51:12.670Z'
|
example: "2024-09-05T08:51:12.670Z"
|
||||||
xml:
|
xml:
|
||||||
name: booking
|
name: booking
|
||||||
User:
|
User:
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ services:
|
|||||||
- 8001:8080
|
- 8001:8080
|
||||||
backend:
|
backend:
|
||||||
build: ../Backend
|
build: ../Backend
|
||||||
image: git.letsstein.de/tom/arbeitszeit-backend
|
image: git.letsstein.de/tom/arbeitszeit-backend:0.1.1
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_HOST: db
|
POSTGRES_HOST: db
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
EXPOSED_PORT: ${EXPOSED_PORT}
|
EXPOSED_PORT: ${EXPOSED_PORT}
|
||||||
DEBUG: true
|
NO_CORS: true
|
||||||
ports:
|
ports:
|
||||||
- 8000:8080
|
- ${EXPOSED_PORT}:8080
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
swagger:
|
swagger:
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
||||||
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: git.letsstein.de/tom/arbeitszeit-backend
|
image: git.letsstein.de/tom/arbeitszeit-backend
|
||||||
|
|||||||
Reference in New Issue
Block a user