diff --git a/docs/docs.go b/docs/docs.go index ad01399..57671d3 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -120,6 +120,352 @@ const docTemplate = `{ } } }, + "/merch/labels": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Получить все метки товаров", + "produces": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Получить все метки товаров", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/merch.LabelsList" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Создать новую метку для товара", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Создать новую метку для товара", + "parameters": [ + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelDTO" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, + "/merch/labels/attach": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Прикрепить метку к товару", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Прикрепить метку к товару", + "parameters": [ + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelLink" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, + "/merch/labels/detach": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Удалить привязку метки к товару", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Удалить привязку метки к товару", + "parameters": [ + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelLink" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, + "/merch/labels/{uuid}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Получить метки товара по его uuid", + "produces": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Получить метки товара по его uuid", + "parameters": [ + { + "type": "string", + "description": "label uuid", + "name": "uuid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Изменить метку", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Изменить метку", + "parameters": [ + { + "type": "string", + "description": "label uuid", + "name": "uuid", + "in": "path", + "required": true + }, + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelDTO" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Пометить метку как удаленную", + "tags": [ + "Merch labels" + ], + "summary": "Пометить метку как удаленную", + "parameters": [ + { + "type": "string", + "description": "label uuid", + "name": "uuid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, "/merch/list": { "get": { "description": "Get all merch without origins", @@ -136,7 +482,7 @@ const docTemplate = `{ "schema": { "type": "array", "items": { - "$ref": "#/definitions/merch.merchDTO" + "$ref": "#/definitions/merch.ListResponse" } } }, @@ -652,6 +998,65 @@ const docTemplate = `{ } } }, + "merch.LabelDTO": { + "type": "object", + "properties": { + "bg_color": { + "type": "string" + }, + "color": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "merch.LabelLink": { + "type": "object", + "properties": { + "label_uuid": { + "type": "string" + }, + "merch_uuid": { + "type": "string" + } + } + }, + "merch.LabelsList": { + "type": "object", + "properties": { + "bg_color": { + "type": "string" + }, + "color": { + "type": "string" + }, + "label_uuid": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "merch.ListResponse": { + "type": "object", + "properties": { + "labels": { + "type": "array", + "items": { + "type": "string" + } + }, + "merch_uuid": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "merch.OriginWithPrices": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index d2a7c3f..f663ad2 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -113,6 +113,352 @@ } } }, + "/merch/labels": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Получить все метки товаров", + "produces": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Получить все метки товаров", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/merch.LabelsList" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Создать новую метку для товара", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Создать новую метку для товара", + "parameters": [ + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelDTO" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, + "/merch/labels/attach": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Прикрепить метку к товару", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Прикрепить метку к товару", + "parameters": [ + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelLink" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, + "/merch/labels/detach": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Удалить привязку метки к товару", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Удалить привязку метки к товару", + "parameters": [ + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelLink" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, + "/merch/labels/{uuid}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Получить метки товара по его uuid", + "produces": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Получить метки товара по его uuid", + "parameters": [ + { + "type": "string", + "description": "label uuid", + "name": "uuid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Изменить метку", + "consumes": [ + "application/json" + ], + "tags": [ + "Merch labels" + ], + "summary": "Изменить метку", + "parameters": [ + { + "type": "string", + "description": "label uuid", + "name": "uuid", + "in": "path", + "required": true + }, + { + "description": "payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/merch.LabelDTO" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Пометить метку как удаленную", + "tags": [ + "Merch labels" + ], + "summary": "Пометить метку как удаленную", + "parameters": [ + { + "type": "string", + "description": "label uuid", + "name": "uuid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.BadRequest" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.Unauthorized" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.InternalServerError" + } + } + } + } + }, "/merch/list": { "get": { "description": "Get all merch without origins", @@ -129,7 +475,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/merch.merchDTO" + "$ref": "#/definitions/merch.ListResponse" } } }, @@ -645,6 +991,65 @@ } } }, + "merch.LabelDTO": { + "type": "object", + "properties": { + "bg_color": { + "type": "string" + }, + "color": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "merch.LabelLink": { + "type": "object", + "properties": { + "label_uuid": { + "type": "string" + }, + "merch_uuid": { + "type": "string" + } + } + }, + "merch.LabelsList": { + "type": "object", + "properties": { + "bg_color": { + "type": "string" + }, + "color": { + "type": "string" + }, + "label_uuid": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "merch.ListResponse": { + "type": "object", + "properties": { + "labels": { + "type": "array", + "items": { + "type": "string" + } + }, + "merch_uuid": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "merch.OriginWithPrices": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index c064302..90c5e69 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -7,6 +7,44 @@ definitions: merch_uuid: type: string type: object + merch.LabelDTO: + properties: + bg_color: + type: string + color: + type: string + name: + type: string + type: object + merch.LabelLink: + properties: + label_uuid: + type: string + merch_uuid: + type: string + type: object + merch.LabelsList: + properties: + bg_color: + type: string + color: + type: string + label_uuid: + type: string + name: + type: string + type: object + merch.ListResponse: + properties: + labels: + items: + type: string + type: array + merch_uuid: + type: string + name: + type: string + type: object merch.OriginWithPrices: properties: origin: @@ -274,6 +312,225 @@ paths: summary: Update merch extra data tags: - Merch + /merch/labels: + get: + description: Получить все метки товаров + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/merch.LabelsList' + type: array + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Получить все метки товаров + tags: + - Merch labels + post: + consumes: + - application/json + description: Создать новую метку для товара + parameters: + - description: payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/merch.LabelDTO' + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Создать новую метку для товара + tags: + - Merch labels + /merch/labels/{uuid}: + delete: + description: Пометить метку как удаленную + parameters: + - description: label uuid + in: path + name: uuid + required: true + type: string + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Пометить метку как удаленную + tags: + - Merch labels + get: + description: Получить метки товара по его uuid + parameters: + - description: label uuid + in: path + name: uuid + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Получить метки товара по его uuid + tags: + - Merch labels + put: + consumes: + - application/json + description: Изменить метку + parameters: + - description: label uuid + in: path + name: uuid + required: true + type: string + - description: payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/merch.LabelDTO' + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Изменить метку + tags: + - Merch labels + /merch/labels/attach: + post: + consumes: + - application/json + description: Прикрепить метку к товару + parameters: + - description: payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/merch.LabelLink' + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Прикрепить метку к товару + tags: + - Merch labels + /merch/labels/detach: + post: + consumes: + - application/json + description: Удалить привязку метки к товару + parameters: + - description: payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/merch.LabelLink' + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.BadRequest' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.Unauthorized' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.InternalServerError' + security: + - BearerAuth: [] + summary: Удалить привязку метки к товару + tags: + - Merch labels /merch/list: get: description: Get all merch without origins @@ -284,7 +541,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/merch.merchDTO' + $ref: '#/definitions/merch.ListResponse' type: array "204": description: No Content diff --git a/internal/merch/controller.go b/internal/merch/controller.go index aff25c8..00e21e8 100644 --- a/internal/merch/controller.go +++ b/internal/merch/controller.go @@ -60,16 +60,16 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup) { // create godoc // -// @Summary Create new merch -// @Description Create new merch -// @Tags Merch -// @Accept json -// @Param merch body newMerchDTO true "merch body" -// @Success 201 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/create [POST] +// @Summary Create new merch +// @Description Create new merch +// @Tags Merch +// @Accept json +// @Param merch body newMerchDTO true "merch body" +// @Success 201 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/create [POST] func (co *controller) create(c *gin.Context) { var newMerch newMerchDTO if err := c.ShouldBindJSON(&newMerch); err != nil { @@ -91,16 +91,16 @@ func (co *controller) getOne(c *gin.Context) {} // getMany godoc // -// @Summary Get all merch -// @Description Get all merch without origins -// @Tags Merch -// @Produce json -// @Success 200 {array} ListResponse -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/list [GET] +// @Summary Get all merch +// @Description Get all merch without origins +// @Tags Merch +// @Produce json +// @Success 200 {array} ListResponse +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/list [GET] func (co *controller) getMany(c *gin.Context) { response, err := co.service.getMany(c, getUserId(c)) if err != nil { @@ -119,18 +119,18 @@ func (co *controller) getMany(c *gin.Context) { // updateMerch godoc // -// @Summary Update merch -// @Description Update merch general info (except extra data) -// @Tags Merch -// @Accept json -// @Param uuid path string true "merch uuid" -// @Param payload body updateMerchDTO true "payload" -// @Produce json -// @Success 200 {object} merchDTO -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/{uuid} [PUT] +// @Summary Update merch +// @Description Update merch general info (except extra data) +// @Tags Merch +// @Accept json +// @Param uuid path string true "merch uuid" +// @Param payload body updateMerchDTO true "payload" +// @Produce json +// @Success 200 {object} merchDTO +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/{uuid} [PUT] func (co *controller) updateMerch(c *gin.Context) { merchUuid := c.Param("id") if err := uuid.Validate(merchUuid); err != nil { @@ -164,18 +164,18 @@ func (co *controller) updateMerch(c *gin.Context) { // updateMerch godoc // -// @Summary Update merch extra data -// @Description Update ONLY merch extra data -// @Tags Merch -// @Accept json -// @Param uuid path string true "merch uuid" -// @Param payload body extraDataDTO true "payload" -// @Produce json -// @Success 200 {object} extraDataDTO -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/extra/{uuid} [PUT] +// @Summary Update merch extra data +// @Description Update ONLY merch extra data +// @Tags Merch +// @Accept json +// @Param uuid path string true "merch uuid" +// @Param payload body extraDataDTO true "payload" +// @Produce json +// @Success 200 {object} extraDataDTO +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/extra/{uuid} [PUT] func (co *controller) updateExtraData(c *gin.Context) { merchUuid := c.Param("id") if err := uuid.Validate(merchUuid); err != nil { @@ -209,16 +209,16 @@ func (co *controller) updateExtraData(c *gin.Context) { // deleteMerch godoc // -// @Summary Delete merch -// @Description Marks merch and all its extra data as deleted by uuid. -// @Tags Merch -// @Accept json -// @Param uuid path string true "merch uuid" -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/{uuid} [DELETE] +// @Summary Delete merch +// @Description Marks merch and all its extra data as deleted by uuid. +// @Tags Merch +// @Accept json +// @Param uuid path string true "merch uuid" +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/{uuid} [DELETE] func (co *controller) deleteMerch(c *gin.Context) { merchUuid := c.Param("id") if err := uuid.Validate(merchUuid); err != nil { @@ -238,16 +238,16 @@ func (co *controller) deleteMerch(c *gin.Context) { // createOrigin godoc // -// @Summary Create new origin -// @Description Create new origin with name -// @Tags Origins -// @Accept json -// @Param origin body newOriginDTO true "origin body" -// @Success 201 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/origins [POST] +// @Summary Create new origin +// @Description Create new origin with name +// @Tags Origins +// @Accept json +// @Param origin body newOriginDTO true "origin body" +// @Success 201 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/origins [POST] func (co *controller) createOrigin(c *gin.Context) { var origin *newOriginDTO @@ -269,16 +269,16 @@ func (co *controller) createOrigin(c *gin.Context) { // getOrigins godoc // -// @Summary Get all origins -// @Description Get all origins -// @Tags Origins -// @Produce json -// @Success 200 {object} originsDTO -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/origins [GET] +// @Summary Get all origins +// @Description Get all origins +// @Tags Origins +// @Produce json +// @Success 200 {object} originsDTO +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/origins [GET] func (co *controller) getOrigins(c *gin.Context) { response, err := co.service.getOrigins(c) if err != nil { @@ -293,16 +293,16 @@ func (co *controller) getOrigins(c *gin.Context) { // deleteOrigin godoc // -// @Summary Delete origin -// @Description Marks origin as deleted by name. -// @Tags Origins -// @Accept json -// @Param origin body deleteOriginDTO true "origin body" -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/origins [DELETE] +// @Summary Delete origin +// @Description Marks origin as deleted by name. +// @Tags Origins +// @Accept json +// @Param origin body deleteOriginDTO true "origin body" +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/origins [DELETE] func (co *controller) deleteOrigin(c *gin.Context) { var origin *deleteOriginDTO @@ -324,16 +324,16 @@ func (co *controller) deleteOrigin(c *gin.Context) { // getChartsPrices godoc // -// @Summary Получить цены мерча за период -// @Description Получить цены мерча за период -// @Tags Merch -// @Produce json -// @Param days query string false "period in days" -// @Success 200 {array} PricesResponse -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /prices [get] +// @Summary Получить цены мерча за период +// @Description Получить цены мерча за период +// @Tags Merch +// @Produce json +// @Param days query string false "period in days" +// @Success 200 {array} PricesResponse +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /prices [get] func (co *controller) getChartsPrices(c *gin.Context) { response, err := co.service.getPrices(c, getUserId(c), getDays(c)) if err != nil { @@ -347,18 +347,18 @@ func (co *controller) getChartsPrices(c *gin.Context) { // getDistinctPrices godoc // -// @Summary Получить перепады цен мерча за период по его merch_uuid -// @Description Получить перепады цен мерча за период по его merch_uuid -// @Tags Merch -// @Produce json -// @Param uuid path string true "merch_uuid" -// @Param days query string false "period in days" -// @Success 200 {object} PricesResponse -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /prices/{uuid} [get] +// @Summary Получить перепады цен мерча за период по его merch_uuid +// @Description Получить перепады цен мерча за период по его merch_uuid +// @Tags Merch +// @Produce json +// @Param uuid path string true "merch_uuid" +// @Param days query string false "period in days" +// @Success 200 {object} PricesResponse +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /prices/{uuid} [get] func (co *controller) getDistinctPrices(c *gin.Context) { merchUuid := c.Param("uuid") if merchUuid == "" { @@ -385,15 +385,15 @@ func (co *controller) getDistinctPrices(c *gin.Context) { // getZeroPrices godoc // -// @Summary Получить нулевые цены -// @Description Получить нулевые цены -// @Tags Merch zero prices -// @Produce json -// @Success 200 {array} ZeroPrice -// @Success 204 -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/zeroprices [get] +// @Summary Получить нулевые цены +// @Description Получить нулевые цены +// @Tags Merch zero prices +// @Produce json +// @Success 200 {array} ZeroPrice +// @Success 204 +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/zeroprices [get] func (co *controller) getZeroPrices(c *gin.Context) { response, err := co.service.getZeroPrices(c, getUserId(c)) if err != nil { @@ -411,17 +411,17 @@ func (co *controller) getZeroPrices(c *gin.Context) { // deleteZeroPrices godoc // -// @Summary Пометить нулевые цены как удаленные -// @Description Пометить нулевые цены как удаленные -// @Tags Merch zero prices -// @Security BearerAuth -// @Accept json -// @Param payload body DeleteZeroPrices true "payload" -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/zeroprices [delete] +// @Summary Пометить нулевые цены как удаленные +// @Description Пометить нулевые цены как удаленные +// @Tags Merch zero prices +// @Security BearerAuth +// @Accept json +// @Param payload body DeleteZeroPrices true "payload" +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/zeroprices [delete] func (co *controller) deleteZeroPrices(c *gin.Context) { var payload []DeleteZeroPrices if err := c.ShouldBindJSON(&payload); err != nil { @@ -446,17 +446,17 @@ func (co *controller) deleteZeroPrices(c *gin.Context) { // deleteZeroPricesPeriod godoc // -// @Summary Пометить нулевые цены как удаленные за указанный период -// @Description Пометить нулевые цены как удаленные за указанный период -// @Tags Merch zero prices -// @Security BearerAuth -// @Param start query string true "start" -// @Param end query string true "end" -// @Success 204 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/zeroprices/period [delete] +// @Summary Пометить нулевые цены как удаленные за указанный период +// @Description Пометить нулевые цены как удаленные за указанный период +// @Tags Merch zero prices +// @Security BearerAuth +// @Param start query string true "start" +// @Param end query string true "end" +// @Success 204 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/zeroprices/period [delete] func (co *controller) deleteZeroPricesPeriod(c *gin.Context) { start, err := co.utils.ParseTime(c.Query("start")) if err != nil { @@ -482,17 +482,17 @@ func (co *controller) deleteZeroPricesPeriod(c *gin.Context) { // createLabel godoc // -// @Summary Создать новую метку для товара -// @Description Создать новую метку для товара -// @Tags Merch labels -// @Security BearerAuth -// @Accept json -// @Param payload body LabelDTO true "payload" -// @Success 200 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels [post] +// @Summary Создать новую метку для товара +// @Description Создать новую метку для товара +// @Tags Merch labels +// @Security BearerAuth +// @Accept json +// @Param payload body LabelDTO true "payload" +// @Success 200 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels [post] func (co *controller) createLabel(c *gin.Context) { var payload LabelDTO if err := c.ShouldBindJSON(&payload); err != nil { @@ -512,16 +512,16 @@ func (co *controller) createLabel(c *gin.Context) { // getLabels godoc // -// @Summary Получить все метки товаров -// @Description Получить все метки товаров -// @Tags Merch labels -// @Security BearerAuth -// @Produce json -// @Success 200 {array} LabelsList -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels [get] +// @Summary Получить все метки товаров +// @Description Получить все метки товаров +// @Tags Merch labels +// @Security BearerAuth +// @Produce json +// @Success 200 {array} LabelsList +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels [get] func (co *controller) getLabels(c *gin.Context) { response, err := co.service.getLabels(c, getUserId(c)) if err != nil { @@ -535,18 +535,18 @@ func (co *controller) getLabels(c *gin.Context) { // updateLabel godoc // -// @Summary Изменить метку -// @Description Изменить метку -// @Tags Merch labels -// @Security BearerAuth -// @Accept json -// @Param uuid path string true "label uuid" -// @Param payload body LabelDTO true "payload" -// @Success 200 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels/{uuid} [put] +// @Summary Изменить метку +// @Description Изменить метку +// @Tags Merch labels +// @Security BearerAuth +// @Accept json +// @Param uuid path string true "label uuid" +// @Param payload body LabelDTO true "payload" +// @Success 200 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels/{uuid} [put] func (co *controller) updateLabel(c *gin.Context) { labelUuid := c.Param("uuid") if labelUuid == "" { @@ -573,16 +573,16 @@ func (co *controller) updateLabel(c *gin.Context) { // deleteLabel godoc // -// @Summary Пометить метку как удаленную -// @Description Пометить метку как удаленную -// @Tags Merch labels -// @Security BearerAuth -// @Param uuid path string true "label uuid" -// @Success 200 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels/{uuid} [delete] +// @Summary Пометить метку как удаленную +// @Description Пометить метку как удаленную +// @Tags Merch labels +// @Security BearerAuth +// @Param uuid path string true "label uuid" +// @Success 200 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels/{uuid} [delete] func (co *controller) deleteLabel(c *gin.Context) { labelUuid := c.Param("uuid") if labelUuid == "" { @@ -602,17 +602,17 @@ func (co *controller) deleteLabel(c *gin.Context) { // attachLabel godoc // -// @Summary Прикрепить метку к товару -// @Description Прикрепить метку к товару -// @Tags Merch labels -// @Security BearerAuth -// @Accept json -// @Param payload body LabelLink true "payload" -// @Success 200 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels/attach [post] +// @Summary Прикрепить метку к товару +// @Description Прикрепить метку к товару +// @Tags Merch labels +// @Security BearerAuth +// @Accept json +// @Param payload body LabelLink true "payload" +// @Success 200 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels/attach [post] func (co *controller) attachLabel(c *gin.Context) { var payload LabelLink if err := c.ShouldBindJSON(&payload); err != nil { @@ -631,17 +631,17 @@ func (co *controller) attachLabel(c *gin.Context) { // detachLabel godoc // -// @Summary Удалить привязку метки к товару -// @Description Удалить привязку метки к товару -// @Tags Merch labels -// @Security BearerAuth -// @Accept json -// @Param payload body LabelLink true "payload" -// @Success 200 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels/detach [post] +// @Summary Удалить привязку метки к товару +// @Description Удалить привязку метки к товару +// @Tags Merch labels +// @Security BearerAuth +// @Accept json +// @Param payload body LabelLink true "payload" +// @Success 200 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels/detach [post] func (co *controller) detachLabel(c *gin.Context) { var payload LabelLink if err := c.ShouldBindJSON(&payload); err != nil { @@ -661,17 +661,17 @@ func (co *controller) detachLabel(c *gin.Context) { // getMerchLabels godoc // -// @Summary Получить метки товара по его uuid -// @Description Получить метки товара по его uuid -// @Tags Merch labels -// @Security BearerAuth -// @Produce json -// @Param uuid path string true "label uuid" -// @Success 200 -// @Failure 400 {object} responses.BadRequest -// @Failure 401 {object} responses.Unauthorized -// @Failure 500 {object} responses.InternalServerError -// @Router /merch/labels/{uuid} [get] +// @Summary Получить метки товара по его uuid +// @Description Получить метки товара по его uuid +// @Tags Merch labels +// @Security BearerAuth +// @Produce json +// @Param uuid path string true "label uuid" +// @Success 200 +// @Failure 400 {object} responses.BadRequest +// @Failure 401 {object} responses.Unauthorized +// @Failure 500 {object} responses.InternalServerError +// @Router /merch/labels/{uuid} [get] func (co *controller) getMerchLabels(c *gin.Context) { merchUuid := c.Param("uuid") if merchUuid == "" {