From c637ddb321e960cbc9d46a7905e0a07799c40f2b Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Wed, 28 May 2025 13:46:28 +0300 Subject: [PATCH] recommendation service --- docs/docs.go | 103 +++++++++++++++++- docs/swagger.json | 103 +++++++++++++++++- docs/swagger.yaml | 69 +++++++++++- internal/domain/recommendation.go | 6 + internal/domain/virtual_game.go | 16 +++ .../web_server/handlers/recommendation.go | 2 +- 6 files changed, 292 insertions(+), 7 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index fcbae21..b8decff 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -519,8 +519,7 @@ const docTemplate = `{ "200": { "description": "Recommended games fetched successfully", "schema": { - "type": "object", - "additionalProperties": true + "$ref": "#/definitions/domain.RecommendationSuccessfulResponse" } }, "500": { @@ -3389,6 +3388,44 @@ const docTemplate = `{ } } }, + "/user/bets": { + "get": { + "description": "Gets user bets", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Gets user bets", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.BetRes" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/user/checkPhoneEmailExist": { "post": { "description": "Check if phone number or email exist", @@ -4332,6 +4369,10 @@ const docTemplate = `{ "type": "boolean", "example": false }, + "created_at": { + "type": "string", + "example": "2025-04-08T12:00:00Z" + }, "full_name": { "type": "string", "example": "John" @@ -4725,6 +4766,20 @@ const docTemplate = `{ } } }, + "domain.RecommendationSuccessfulResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "recommended_games": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.VirtualGame" + } + } + } + }, "domain.ReferralSettings": { "type": "object", "properties": { @@ -5069,6 +5124,50 @@ const docTemplate = `{ } } }, + "domain.VirtualGame": { + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "is_featured": { + "type": "boolean" + }, + "max_bet": { + "type": "number" + }, + "min_bet": { + "type": "number" + }, + "name": { + "type": "string" + }, + "popularity_score": { + "type": "integer" + }, + "provider": { + "type": "string" + }, + "rtp": { + "type": "number" + }, + "thumbnail_url": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "volatility": { + "type": "string" + } + } + }, "handlers.AdminRes": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 833f9b7..427127c 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -511,8 +511,7 @@ "200": { "description": "Recommended games fetched successfully", "schema": { - "type": "object", - "additionalProperties": true + "$ref": "#/definitions/domain.RecommendationSuccessfulResponse" } }, "500": { @@ -3381,6 +3380,44 @@ } } }, + "/user/bets": { + "get": { + "description": "Gets user bets", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Gets user bets", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.BetRes" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/user/checkPhoneEmailExist": { "post": { "description": "Check if phone number or email exist", @@ -4324,6 +4361,10 @@ "type": "boolean", "example": false }, + "created_at": { + "type": "string", + "example": "2025-04-08T12:00:00Z" + }, "full_name": { "type": "string", "example": "John" @@ -4717,6 +4758,20 @@ } } }, + "domain.RecommendationSuccessfulResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "recommended_games": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.VirtualGame" + } + } + } + }, "domain.ReferralSettings": { "type": "object", "properties": { @@ -5061,6 +5116,50 @@ } } }, + "domain.VirtualGame": { + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "is_featured": { + "type": "boolean" + }, + "max_bet": { + "type": "number" + }, + "min_bet": { + "type": "number" + }, + "name": { + "type": "string" + }, + "popularity_score": { + "type": "integer" + }, + "provider": { + "type": "string" + }, + "rtp": { + "type": "number" + }, + "thumbnail_url": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "volatility": { + "type": "string" + } + } + }, "handlers.AdminRes": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a1429f6..265ce0e 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -94,6 +94,9 @@ definitions: cashed_out: example: false type: boolean + created_at: + example: "2025-04-08T12:00:00Z" + type: string full_name: example: John type: string @@ -362,6 +365,15 @@ definitions: message: type: string type: object + domain.RecommendationSuccessfulResponse: + properties: + message: + type: string + recommended_games: + items: + $ref: '#/definitions/domain.VirtualGame' + type: array + type: object domain.ReferralSettings: properties: betReferralBonusPercentage: @@ -601,6 +613,35 @@ definitions: status: type: string type: object + domain.VirtualGame: + properties: + category: + type: string + created_at: + type: string + id: + type: integer + is_featured: + type: boolean + max_bet: + type: number + min_bet: + type: number + name: + type: string + popularity_score: + type: integer + provider: + type: string + rtp: + type: number + thumbnail_url: + type: string + updated_at: + type: string + volatility: + type: string + type: object handlers.AdminRes: properties: created_at: @@ -1783,8 +1824,7 @@ paths: "200": description: Recommended games fetched successfully schema: - additionalProperties: true - type: object + $ref: '#/definitions/domain.RecommendationSuccessfulResponse' "500": description: Failed to fetch recommendations schema: @@ -3670,6 +3710,31 @@ paths: summary: Get transfer by wallet tags: - transfer + /user/bets: + get: + consumes: + - application/json + description: Gets user bets + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/domain.BetRes' + type: array + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Gets user bets + tags: + - user /user/checkPhoneEmailExist: post: consumes: diff --git a/internal/domain/recommendation.go b/internal/domain/recommendation.go index aacf605..53a7e9a 100644 --- a/internal/domain/recommendation.go +++ b/internal/domain/recommendation.go @@ -1,5 +1,11 @@ package domain +type RecommendationSuccessfulResponse struct { + Message string `json:"message"` + RecommendedGames []VirtualGame `json:"recommended_games"` +} + type RecommendationErrorResponse struct { Message string `json:"message"` } + diff --git a/internal/domain/virtual_game.go b/internal/domain/virtual_game.go index 3663aee..d0e374b 100644 --- a/internal/domain/virtual_game.go +++ b/internal/domain/virtual_game.go @@ -4,6 +4,22 @@ import ( "time" ) +type VirtualGame struct { + ID int64 `json:"id"` + Name string `json:"name"` + Provider string `json:"provider"` + Category string `json:"category"` + MinBet float64 `json:"min_bet"` + MaxBet float64 `json:"max_bet"` + Volatility string `json:"volatility"` + RTP float64 `json:"rtp"` + IsFeatured bool `json:"is_featured"` + PopularityScore int `json:"popularity_score"` + ThumbnailURL string `json:"thumbnail_url"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + type VirtualGameSession struct { ID int64 `json:"id"` UserID int64 `json:"user_id"` diff --git a/internal/web_server/handlers/recommendation.go b/internal/web_server/handlers/recommendation.go index c62215a..cdd8cdf 100644 --- a/internal/web_server/handlers/recommendation.go +++ b/internal/web_server/handlers/recommendation.go @@ -10,7 +10,7 @@ import ( // @Accept json // @Produce json // @Param userID path string true "User ID" -// @Success 200 {object} map[string]interface{} "Recommended games fetched successfully" +// @Success 200 {object} domain.RecommendationSuccessfulResponse "Recommended games fetched successfully" // @Failure 500 {object} domain.RecommendationErrorResponse "Failed to fetch recommendations" // @Router /api/v1/virtual-games/recommendations/{userID} [get] func (h *Handler) GetRecommendations(c *fiber.Ctx) error {