From 775b06ac89ada417a958071972051f412d3b3173 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Thu, 8 Jan 2026 09:05:01 +0700 Subject: [PATCH] feat:upload ai chat files --- .../ai_chat_files/ai_chat_files.module.go | 2 +- ...troller.go => ai_chat_files.controller.go} | 61 ++- .../repository/article_files.repository.go | 12 +- .../service/ai_chat_files.service.go | 26 + config/toml/config.toml | 6 +- docs/swagger/docs.go | 485 ++++++++++-------- docs/swagger/swagger.json | 485 ++++++++++-------- docs/swagger/swagger.yaml | 312 ++++++----- 8 files changed, 798 insertions(+), 591 deletions(-) rename app/module/ai_chat_files/controller/{article_files.controller.go => ai_chat_files.controller.go} (80%) diff --git a/app/module/ai_chat_files/ai_chat_files.module.go b/app/module/ai_chat_files/ai_chat_files.module.go index 2d447aa..0f86977 100644 --- a/app/module/ai_chat_files/ai_chat_files.module.go +++ b/app/module/ai_chat_files/ai_chat_files.module.go @@ -54,6 +54,6 @@ func (_i *AiChatFilesRouter) RegisterAiChatFilesRoutes() { router.Delete("/:id", aiChatFilesController.Delete) router.Get("/viewer/:filename", aiChatFilesController.Viewer) router.Get("/upload-status/:uploadId", aiChatFilesController.GetUploadStatus) - + router.Get("/by-message/:messageId", aiChatFilesController.GetByMessageId) }) } diff --git a/app/module/ai_chat_files/controller/article_files.controller.go b/app/module/ai_chat_files/controller/ai_chat_files.controller.go similarity index 80% rename from app/module/ai_chat_files/controller/article_files.controller.go rename to app/module/ai_chat_files/controller/ai_chat_files.controller.go index 988fcc9..dc3ad48 100644 --- a/app/module/ai_chat_files/controller/article_files.controller.go +++ b/app/module/ai_chat_files/controller/ai_chat_files.controller.go @@ -24,6 +24,8 @@ type AiChatFilesController interface { Delete(c *fiber.Ctx) error Viewer(c *fiber.Ctx) error GetUploadStatus(c *fiber.Ctx) error + GetByMessageId(c *fiber.Ctx) error + } @@ -110,7 +112,7 @@ func (_i *aiChatFilesController) Show(c *fiber.Ctx) error { // @Produce json // @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" // @Param files formData file true "Upload file" multiple true -// @Param aiChatId path int true "AiChat ID" +// @Param messageId path int true "Message Id" // @Success 200 {object} response.Response // @Failure 400 {object} response.BadRequestError // @Failure 401 {object} response.UnauthorizedError @@ -146,7 +148,7 @@ func (_i *aiChatFilesController) Save(c *fiber.Ctx) error { // @Failure 400 {object} response.BadRequestError // @Failure 401 {object} response.UnauthorizedError // @Failure 500 {object} response.InternalServerError -// @Router /aiChat-files/{id} [put] +// @Router /ai-chat-files/{id} [put] func (_i *aiChatFilesController) Update(c *fiber.Ctx) error { // Get from context id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -181,7 +183,7 @@ func (_i *aiChatFilesController) Update(c *fiber.Ctx) error { // @Failure 400 {object} response.BadRequestError // @Failure 401 {object} response.UnauthorizedError // @Failure 500 {object} response.InternalServerError -// @Router /aiChat-files/{id} [delete] +// @Router /ai-chat-files/{id} [delete] func (_i *aiChatFilesController) Delete(c *fiber.Ctx) error { // Get from context id, err := strconv.ParseUint(c.Params("id"), 10, 0) @@ -210,7 +212,7 @@ func (_i *aiChatFilesController) Delete(c *fiber.Ctx) error { // @Failure 400 {object} response.BadRequestError // @Failure 401 {object} response.UnauthorizedError // @Failure 500 {object} response.InternalServerError -// @Router /aiChat-files/viewer/{filename} [get] +// @Router /ai-chat-files/viewer/{filename} [get] func (_i *aiChatFilesController) Viewer(c *fiber.Ctx) error { // Get from context return _i.aiChatFilesService.Viewer(c) @@ -226,7 +228,7 @@ func (_i *aiChatFilesController) Viewer(c *fiber.Ctx) error { // @Failure 400 {object} response.BadRequestError // @Failure 401 {object} response.UnauthorizedError // @Failure 500 {object} response.InternalServerError -// @Router /aiChat-files/upload-status/{uploadId} [get] +// @Router /ai-chat-files/upload-status/{uploadId} [get] func (_i *aiChatFilesController) GetUploadStatus(c *fiber.Ctx) error { progress, _ := _i.aiChatFilesService.GetUploadStatus(c) progressMessage := fmt.Sprintf("Upload Progress: %d%%", progress) @@ -237,3 +239,52 @@ func (_i *aiChatFilesController) GetUploadStatus(c *fiber.Ctx) error { Data: progressMessage, }) } + +// Show AiChatFiles +// @Summary Get one AiChatFiles +// @Description API for getting one AiChatFiles by messageId +// @Tags AiChat Files +// @Security Bearer +// @Param messageId path int true "AiChatFiles MessageId" +// @Success 200 {object} response.Response +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError +// @Router /ai-chat-files/by-message/{messageId} [get] +func (_i *aiChatFilesController) GetByMessageId(c *fiber.Ctx) error { + // ambil messageId dari path + messageId, err := strconv.ParseUint(c.Params("messageId"), 10, 0) + if err != nil { + return utilRes.Resp(c, utilRes.Response{ + Success: false, + Messages: utilRes.Messages{"messageId must be numeric"}, + }) + } + + // pagination (SAMA DENGAN All) + paginate, err := paginator.Paginate(c) + if err != nil { + return err + } + + // bangun request context (reuse pattern All) + reqContext := request.AiChatFilesQueryRequestContext{ + MessageId: fmt.Sprint(messageId), + } + + req := reqContext.ToParamRequest() + req.Pagination = paginate + + // panggil service + data, paging, err := _i.aiChatFilesService.GetByMessageId(req) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"AiChatFiles successfully retrieved by messageId"}, + Data: data, + Meta: paging, + }) +} diff --git a/app/module/ai_chat_files/repository/article_files.repository.go b/app/module/ai_chat_files/repository/article_files.repository.go index e9c01e7..443b7b4 100644 --- a/app/module/ai_chat_files/repository/article_files.repository.go +++ b/app/module/ai_chat_files/repository/article_files.repository.go @@ -18,11 +18,12 @@ type aiChatFilesRepository struct { type AiChatFilesRepository interface { GetAll(req request.AiChatFilesQueryRequest) (aiChatFiles []*entity.AiChatFiles, paging paginator.Pagination, err error) FindOne(id uint) (aiChatFiles *entity.AiChatFiles, err error) - FindByAiChat(messageId uint) (aiChatFiles []*entity.AiChatFiles, err error) + FindByMessageId(messageId uint) (aiChatFiles []*entity.AiChatFiles, err error) FindByFilename(filename string) (aiChatFiles *entity.AiChatFiles, err error) Create(aiChatFiles *entity.AiChatFiles) (err error) Update(id uint, aiChatFiles *entity.AiChatFiles) (err error) Delete(id uint) (err error) + } func NewAiChatFilesRepository(db *database.Database) AiChatFilesRepository { @@ -84,10 +85,15 @@ func (_i *aiChatFilesRepository) FindOne(id uint) (aiChatFiles *entity.AiChatFil return aiChatFiles, nil } -func (_i *aiChatFilesRepository) FindByAiChat(messageId uint) (aiChatFiles []*entity.AiChatFiles, err error) { +func (_i *aiChatFilesRepository) FindByMessageId( + messageId uint, +) (aiChatFiles []*entity.AiChatFiles, err error) { + query := _i.DB.DB.Where("message_id = ?", messageId) - if err := query.Find(&aiChatFiles).Error; err != nil { + if err := query. + Order("created_at ASC"). + Find(&aiChatFiles).Error; err != nil { return nil, err } diff --git a/app/module/ai_chat_files/service/ai_chat_files.service.go b/app/module/ai_chat_files/service/ai_chat_files.service.go index 30de548..9cdfa7c 100644 --- a/app/module/ai_chat_files/service/ai_chat_files.service.go +++ b/app/module/ai_chat_files/service/ai_chat_files.service.go @@ -45,6 +45,11 @@ type AiChatFilesService interface { GetUploadStatus(c *fiber.Ctx) (progress int, err error) Delete(id uint) error Viewer(c *fiber.Ctx) error + GetByMessageId(req request.AiChatFilesQueryRequest) ( + aiChatFiles []*response.AiChatFilesResponse, + paging paginator.Pagination, + err error, + ) } // NewAiChatFilesService init AiChatFilesService @@ -444,3 +449,24 @@ func (_i *aiChatFilesService) GetUploadStatus(c *fiber.Ctx) (progress int, err e return progress, nil } + +func (_i *aiChatFilesService) GetByMessageId( + req request.AiChatFilesQueryRequest, +) (aiChatFiles []*response.AiChatFilesResponse, paging paginator.Pagination, err error) { + + results, paging, err := _i.Repo.GetAll(req) + if err != nil { + return + } + + host := _i.Cfg.App.Domain + + for _, result := range results { + aiChatFiles = append( + aiChatFiles, + mapper.AiChatFilesResponseMapper(result, host), + ) + } + + return +} diff --git a/config/toml/config.toml b/config/toml/config.toml index 25ead14..032d71f 100644 --- a/config/toml/config.toml +++ b/config/toml/config.toml @@ -25,9 +25,9 @@ prettier = true [objectstorage.miniostorage] endpoint = "is3.cloudhost.id" -access-key-id = "lBtjqWidHz1ktBbduwGy" -secret-access-key = "nsedJIa2FI7SqsEVcSFqJrlP4JuFRWGLauNpzD0i" -use-ssl = false +access-key-id = "YRP1RM617986USRU6NN8" +secret-access-key = "vfbwQDYb1m7nfzo4LVEz90BIyOWfBMZ6bfGQbqDO" +use-ssl = true bucket-name = "narasiahli" location = "us-east-1" diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index 2d58025..6f94d76 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -1016,6 +1016,153 @@ const docTemplate = `{ } } }, + "/ai-chat-files/by-message/{messageId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for getting one AiChatFiles by messageId", + "tags": [ + "AiChat Files" + ], + "summary": "Get one AiChatFiles", + "parameters": [ + { + "type": "integer", + "description": "AiChatFiles MessageId", + "name": "messageId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, + "/ai-chat-files/upload-status/{uploadId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for GetUploadStatus AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "GetUploadStatus AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "Upload ID of AiChatFiles", + "name": "uploadId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, + "/ai-chat-files/viewer/{filename}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for Viewer AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "Viewer AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "AiChat File Name", + "name": "filename", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, "/ai-chat-files/{id}": { "get": { "security": [ @@ -1063,6 +1210,123 @@ const docTemplate = `{ } } } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for update AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "Update AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "Insert the X-Csrf-Token", + "name": "X-Csrf-Token", + "in": "header", + "required": true + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AiChatFilesUpdateRequest" + } + }, + { + "type": "integer", + "description": "AiChatFiles ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for delete AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "Delete AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "Insert the X-Csrf-Token", + "name": "X-Csrf-Token", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "AiChatFiles ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } } }, "/ai-chat-files/{messageId}": { @@ -1097,8 +1361,8 @@ const docTemplate = `{ }, { "type": "integer", - "description": "AiChat ID", - "name": "aiChatId", + "description": "Message Id", + "name": "messageId", "in": "path", "required": true } @@ -1917,223 +2181,6 @@ const docTemplate = `{ } } }, - "/aiChat-files/upload-status/{uploadId}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for GetUploadStatus AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "GetUploadStatus AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "Upload ID of AiChatFiles", - "name": "uploadId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/aiChat-files/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Viewer AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "Viewer AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "AiChat File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/aiChat-files/{id}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "Update AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AiChatFilesUpdateRequest" - } - }, - { - "type": "integer", - "description": "AiChatFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "Delete AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "AiChatFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/article-approvals": { "get": { "security": [ diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index e713a00..924c693 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -1005,6 +1005,153 @@ } } }, + "/ai-chat-files/by-message/{messageId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for getting one AiChatFiles by messageId", + "tags": [ + "AiChat Files" + ], + "summary": "Get one AiChatFiles", + "parameters": [ + { + "type": "integer", + "description": "AiChatFiles MessageId", + "name": "messageId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, + "/ai-chat-files/upload-status/{uploadId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for GetUploadStatus AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "GetUploadStatus AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "Upload ID of AiChatFiles", + "name": "uploadId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, + "/ai-chat-files/viewer/{filename}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for Viewer AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "Viewer AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "AiChat File Name", + "name": "filename", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, "/ai-chat-files/{id}": { "get": { "security": [ @@ -1052,6 +1199,123 @@ } } } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for update AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "Update AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "Insert the X-Csrf-Token", + "name": "X-Csrf-Token", + "in": "header", + "required": true + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AiChatFilesUpdateRequest" + } + }, + { + "type": "integer", + "description": "AiChatFiles ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for delete AiChatFiles", + "tags": [ + "AiChat Files" + ], + "summary": "Delete AiChatFiles", + "parameters": [ + { + "type": "string", + "description": "Insert the X-Csrf-Token", + "name": "X-Csrf-Token", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "AiChatFiles ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } } }, "/ai-chat-files/{messageId}": { @@ -1086,8 +1350,8 @@ }, { "type": "integer", - "description": "AiChat ID", - "name": "aiChatId", + "description": "Message Id", + "name": "messageId", "in": "path", "required": true } @@ -1906,223 +2170,6 @@ } } }, - "/aiChat-files/upload-status/{uploadId}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for GetUploadStatus AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "GetUploadStatus AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "Upload ID of AiChatFiles", - "name": "uploadId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/aiChat-files/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Viewer AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "Viewer AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "AiChat File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/aiChat-files/{id}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "Update AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AiChatFilesUpdateRequest" - } - }, - { - "type": "integer", - "description": "AiChatFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete AiChatFiles", - "tags": [ - "AiChat Files" - ], - "summary": "Delete AiChatFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "AiChatFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/article-approvals": { "get": { "security": [ diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 3e893cd..45f150f 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -2020,6 +2020,41 @@ paths: tags: - AiChat Files /ai-chat-files/{id}: + delete: + description: API for delete AiChatFiles + parameters: + - description: Insert the X-Csrf-Token + in: header + name: X-Csrf-Token + required: true + type: string + - description: AiChatFiles ID + in: path + name: id + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: Delete AiChatFiles + tags: + - AiChat Files get: description: API for getting one AiChatFiles parameters: @@ -2050,6 +2085,47 @@ paths: summary: Get one AiChatFiles tags: - AiChat Files + put: + description: API for update AiChatFiles + parameters: + - description: Insert the X-Csrf-Token + in: header + name: X-Csrf-Token + required: true + type: string + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.AiChatFilesUpdateRequest' + - description: AiChatFiles ID + in: path + name: id + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: Update AiChatFiles + tags: + - AiChat Files /ai-chat-files/{messageId}: post: description: API for create AiChatFiles @@ -2064,9 +2140,9 @@ paths: name: files required: true type: file - - description: AiChat ID + - description: Message Id in: path - name: aiChatId + name: messageId required: true type: integer produces: @@ -2093,6 +2169,99 @@ paths: summary: Upload AiChatFiles tags: - AiChat Files + /ai-chat-files/by-message/{messageId}: + get: + description: API for getting one AiChatFiles by messageId + parameters: + - description: AiChatFiles MessageId + in: path + name: messageId + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: Get one AiChatFiles + tags: + - AiChat Files + /ai-chat-files/upload-status/{uploadId}: + get: + description: API for GetUploadStatus AiChatFiles + parameters: + - description: Upload ID of AiChatFiles + in: path + name: uploadId + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: GetUploadStatus AiChatFiles + tags: + - AiChat Files + /ai-chat-files/viewer/{filename}: + get: + description: API for Viewer AiChatFiles + parameters: + - description: AiChat File Name + in: path + name: filename + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: Viewer AiChatFiles + tags: + - AiChat Files /ai-chat/logs: get: description: API for getting all AI chat logs for authenticated user @@ -2595,145 +2764,6 @@ paths: summary: Update AI chat message tags: - AI Chat - /aiChat-files/{id}: - delete: - description: API for delete AiChatFiles - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: AiChatFiles ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete AiChatFiles - tags: - - AiChat Files - put: - description: API for update AiChatFiles - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AiChatFilesUpdateRequest' - - description: AiChatFiles ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update AiChatFiles - tags: - - AiChat Files - /aiChat-files/upload-status/{uploadId}: - get: - description: API for GetUploadStatus AiChatFiles - parameters: - - description: Upload ID of AiChatFiles - in: path - name: uploadId - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: GetUploadStatus AiChatFiles - tags: - - AiChat Files - /aiChat-files/viewer/{filename}: - get: - description: API for Viewer AiChatFiles - parameters: - - description: AiChat File Name - in: path - name: filename - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Viewer AiChatFiles - tags: - - AiChat Files /article-approvals: get: description: API for getting all ArticleApprovals