From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- .../shop/src/main/resources/application.properties | 13 ++ .../src/main/resources/db/migration/V1__Init.sql | 15 ++ jws/epibazaar/shop/src/main/resources/openapi.yaml | 242 +++++++++++++++++++++ 3 files changed, 270 insertions(+) create mode 100644 jws/epibazaar/shop/src/main/resources/application.properties create mode 100644 jws/epibazaar/shop/src/main/resources/db/migration/V1__Init.sql create mode 100644 jws/epibazaar/shop/src/main/resources/openapi.yaml (limited to 'jws/epibazaar/shop/src/main/resources') diff --git a/jws/epibazaar/shop/src/main/resources/application.properties b/jws/epibazaar/shop/src/main/resources/application.properties new file mode 100644 index 0000000..e2fa130 --- /dev/null +++ b/jws/epibazaar/shop/src/main/resources/application.properties @@ -0,0 +1,13 @@ +%dev.quarkus.http.port=8082 +quarkus.datasource.db-kind=postgresql +quarkus.datasource.username=postgres +quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/shop?currentSchema=public +quarkus.transaction-manager.default-transaction-timeout=3000s +quarkus.hibernate-orm.log.queries-slower-than-ms=200 +quarkus.http.cors=true +quarkus.http.cors.origins=* +quarkus.hibernate-orm.database.generation=drop-and-create + +quarkus.kafka.devservices.image-name=reg.undercloud.cri.epita.fr/docker/redpandadata/redpanda:v24.1.2 +quarkus.devservices.enabled=true +%test.quarkus.devservices.enabled=false diff --git a/jws/epibazaar/shop/src/main/resources/db/migration/V1__Init.sql b/jws/epibazaar/shop/src/main/resources/db/migration/V1__Init.sql new file mode 100644 index 0000000..0161cb5 --- /dev/null +++ b/jws/epibazaar/shop/src/main/resources/db/migration/V1__Init.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS "shop" +( + id SERIAL PRIMARY KEY NOT NULL, + + price_multiplier FLOAT NOT NULL, + upgrade_price FLOAT NOT NULL +); + +CREATE TABLE IF NOT EXISTS "item" +( + id SERIAL PRIMARY KEY NOT NULL, + + type VARCHAR(64) NOT NULL, + quantity FLOAT NOT NULL +); diff --git a/jws/epibazaar/shop/src/main/resources/openapi.yaml b/jws/epibazaar/shop/src/main/resources/openapi.yaml new file mode 100644 index 0000000..7b6928f --- /dev/null +++ b/jws/epibazaar/shop/src/main/resources/openapi.yaml @@ -0,0 +1,242 @@ +--- +openapi: 3.1.0 +tags: +- name: Game Management +- name: Inventory Management +- name: Shop Management +- name: Shop Operations +- name: Shop Upgrades +components: + schemas: + ItemRequest: + type: object + properties: + quantity: + type: number + format: float + type: + $ref: "#/components/schemas/ResourceType" + ItemResponse: + type: object + properties: + id: + type: integer + format: int32 + quantity: + type: number + format: float + type: + $ref: "#/components/schemas/ResourceType" + ItemsRequest: + type: object + properties: + itemsRequest: + type: array + items: + $ref: "#/components/schemas/ItemRequest" + ItemsResponse: + type: object + properties: + itemsResponse: + type: array + items: + $ref: "#/components/schemas/ItemResponse" + ResourceType: + type: string + enum: + - MONEY + - GROUND + - WATER + - ROCK + - WOOD + ShopPriceResponse: + type: object + properties: + shopPrice: + type: number + format: float + ShopResponse: + type: object + properties: + id: + type: integer + format: int32 + priceMultiplier: + type: number + format: float + upgradePrice: + type: number + format: float + ShopsResponse: + type: object + properties: + shops: + type: array + items: + $ref: "#/components/schemas/ShopResponse" +paths: + /: + get: + summary: Get all shops. + description: Retrieves all available shops. + x-quarkus-openapi-method-ref: m869844210_-222983088 + tags: + - Shop Management + responses: + "200": + description: The shops were successfully retrieved. + content: + application/json: + schema: + $ref: "#/components/schemas/ShopsResponse" + "400": + description: The game is not running. + servers: + - url: http://localhost:8082/ + post: + summary: Create a new shop. + description: Creates a new shop. + x-quarkus-openapi-method-ref: m869844210_1764851887 + tags: + - Shop Management + responses: + "204": + description: The shop creation request was successfully sent. + "400": + description: "The game has reached its max capacity, you do not have enough\ + \ money, or the game is not running." + "404": + description: No money item found. + servers: + - url: http://localhost:8082/ + /price: + get: + summary: Get the current shop price. + description: Retrieves the current shop price. + x-quarkus-openapi-method-ref: m869844210_-271831484 + tags: + - Shop Management + responses: + "200": + description: The shop price was successfully retrieved. + content: + application/json: + schema: + $ref: "#/components/schemas/ShopPriceResponse" + "400": + description: The game is not running. + servers: + - url: http://localhost:8082/ + /resources: + get: + summary: Retrieve available resources in inventory. + description: Fetch all resources currently available in the inventory. + x-quarkus-openapi-method-ref: m911209932_-1184004262 + tags: + - Inventory Management + responses: + "200": + description: The resources were successfully retrieved. + content: + application/json: + schema: + $ref: "#/components/schemas/ItemsResponse" + "400": + description: The game is not running or the request is invalid. + servers: + - url: http://localhost:8082/ + /sell/{id}: + patch: + summary: Sell items to a client. + description: Processes the sale of items to a client. + x-quarkus-openapi-method-ref: m869844210_-1356306674 + tags: + - Shop Operations + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int32 + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ItemsRequest" + required: true + responses: + "204": + description: The sell request was successfully sent. + "400": + description: "You do not have enough resources, an item is not sellable,\ + \ an amount is invalid, or the game is not running." + "404": + description: The shop or an item was not found. + servers: + - url: http://localhost:8082/ + /start: + post: + summary: Start the game. + description: Starts the game by sending a Kafka command. + x-quarkus-openapi-method-ref: m869844210_1873672464 + tags: + - Game Management + responses: + "204": + description: The game started successfully. + servers: + - url: http://localhost:8082/ + /upgrade/price/{id}: + patch: + summary: Upgrade the resource price for a specific shop. + description: Increases the resource price for a specific shop. + x-quarkus-openapi-method-ref: m869844210_-999917025 + tags: + - Shop Upgrades + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int32 + responses: + "204": + description: The price upgrade request was successfully sent. + "400": + description: You do not have enough money or the game is not running. + "404": + description: The shop was not found or the money was not found. + servers: + - url: http://localhost:8082/ + /{id}: + get: + summary: Get a specific shop. + description: Retrieves details of a specific shop. + x-quarkus-openapi-method-ref: m869844210_868322035 + tags: + - Shop Management + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int32 + responses: + "200": + description: The shop was successfully retrieved. + content: + application/json: + schema: + $ref: "#/components/schemas/ShopResponse" + "400": + description: The game is not running or the ID is not valid. + "404": + description: The shop was not found. + servers: + - url: http://localhost:8082/ +info: + title: shop API + version: 1.0.0 -- cgit v1.2.3