Compare commits
4 commits
9895b86666
...
8ac753f632
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ac753f632 | ||
|
|
565e019a67 | ||
|
|
f7ec1bce1e | ||
|
|
844561ef70 |
9 changed files with 845 additions and 36 deletions
290
docs/docs.go
290
docs/docs.go
|
|
@ -279,6 +279,254 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/merch/labels": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Получить все метки товаров",
|
||||||
|
"tags": [
|
||||||
|
"Merch labels"
|
||||||
|
],
|
||||||
|
"summary": "Получить все метки товаров",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/merch.LabelsList"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Создать новую метку для товара",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/labels/attach": {
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Прикрепить метку к товару",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/labels/detach": {
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Удалить привязку метки к товару",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/labels/{uuid}": {
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Изменить метку",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/merch/{uuid}": {
|
"/merch/{uuid}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -781,6 +1029,48 @@ 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": {
|
"merch.ListResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,254 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/merch/labels": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Получить все метки товаров",
|
||||||
|
"tags": [
|
||||||
|
"Merch labels"
|
||||||
|
],
|
||||||
|
"summary": "Получить все метки товаров",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/merch.LabelsList"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Создать новую метку для товара",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/labels/attach": {
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Прикрепить метку к товару",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/labels/detach": {
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Удалить привязку метки к товару",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/labels/{uuid}": {
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Изменить метку",
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/merch/{uuid}": {
|
"/merch/{uuid}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -773,6 +1021,48 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"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": {
|
"merch.ListResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,33 @@ definitions:
|
||||||
link:
|
link:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
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:
|
merch.ListResponse:
|
||||||
properties:
|
properties:
|
||||||
merch_uuid:
|
merch_uuid:
|
||||||
|
|
@ -368,6 +395,161 @@ paths:
|
||||||
summary: Загрузить картинку по merch_uuid
|
summary: Загрузить картинку по merch_uuid
|
||||||
tags:
|
tags:
|
||||||
- Merch images
|
- Merch images
|
||||||
|
/merch/labels:
|
||||||
|
get:
|
||||||
|
description: Получить все метки товаров
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/merch.LabelsList'
|
||||||
|
type: array
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Получить все метки товаров
|
||||||
|
tags:
|
||||||
|
- Merch labels
|
||||||
|
post:
|
||||||
|
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.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
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.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Пометить метку как удаленную
|
||||||
|
tags:
|
||||||
|
- Merch labels
|
||||||
|
put:
|
||||||
|
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.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Изменить метку
|
||||||
|
tags:
|
||||||
|
- Merch labels
|
||||||
|
/merch/labels/attach:
|
||||||
|
post:
|
||||||
|
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.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Прикрепить метку к товару
|
||||||
|
tags:
|
||||||
|
- Merch labels
|
||||||
|
/merch/labels/detach:
|
||||||
|
post:
|
||||||
|
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.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Удалить привязку метки к товару
|
||||||
|
tags:
|
||||||
|
- Merch labels
|
||||||
/prices:
|
/prices:
|
||||||
get:
|
get:
|
||||||
description: Получить цены мерча за период
|
description: Получить цены мерча за период
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package merch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
|
|
@ -45,8 +44,8 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, ref
|
||||||
imagesGroup.DELETE("/:uuid", h.controller.deleteMerchImage)
|
imagesGroup.DELETE("/:uuid", h.controller.deleteMerchImage)
|
||||||
|
|
||||||
labelsGroup := merchGroup.Group("/labels")
|
labelsGroup := merchGroup.Group("/labels")
|
||||||
labelsGroup.POST("/", h.controller.createLabel)
|
labelsGroup.POST("", h.controller.createLabel)
|
||||||
labelsGroup.GET("/", h.controller.getLabels)
|
labelsGroup.GET("", h.controller.getLabels)
|
||||||
labelsGroup.PUT("/:uuid", h.controller.updateLabel)
|
labelsGroup.PUT("/:uuid", h.controller.updateLabel)
|
||||||
labelsGroup.DELETE("/:uuid", h.controller.deleteLabel)
|
labelsGroup.DELETE("/:uuid", h.controller.deleteLabel)
|
||||||
labelsGroup.POST("/attach", h.controller.attachLabel)
|
labelsGroup.POST("/attach", h.controller.attachLabel)
|
||||||
|
|
@ -464,7 +463,7 @@ func (co *controller) createLabel(c *gin.Context) {
|
||||||
// @Description Получить все метки товаров
|
// @Description Получить все метки товаров
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Success 200 {array} LabelDTO
|
// @Success 200 {array} LabelsList
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
// @Router /merch/labels [get]
|
// @Router /merch/labels [get]
|
||||||
|
|
@ -522,14 +521,7 @@ func (co *controller) updateLabel(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if labelUuid != payload.LabelUuid {
|
if err = co.service.updateLabel(userUuid, labelUuid, payload); err != nil {
|
||||||
err = errors.New("label uuid is different")
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = co.service.updateLabel(userUuid, payload); err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
log.WithError(err).Error(logMsg)
|
log.WithError(err).Error(logMsg)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ type SingleMerchResponse struct {
|
||||||
type ListResponse struct {
|
type ListResponse struct {
|
||||||
MerchUuid string `json:"merch_uuid"`
|
MerchUuid string `json:"merch_uuid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Labels []string `json:"labels,omitempty" gorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PriceEntry struct {
|
type PriceEntry struct {
|
||||||
|
|
@ -60,10 +61,16 @@ type ImageLink struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type LabelDTO struct {
|
type LabelDTO struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Color string `json:"color,omitempty"`
|
||||||
|
BgColor string `json:"bg_color,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LabelsList struct {
|
||||||
LabelUuid string `json:"label_uuid"`
|
LabelUuid string `json:"label_uuid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color,omitempty"`
|
||||||
BgColor string `json:"bg_color"`
|
BgColor string `json:"bg_color,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LabelLink struct {
|
type LabelLink struct {
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,16 @@ type Label struct {
|
||||||
BgColor string `json:"bg_color" gorm:"column:bg_color"`
|
BgColor string `json:"bg_color" gorm:"column:bg_color"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (Label) TableName() string {
|
||||||
|
return "labels"
|
||||||
|
}
|
||||||
|
|
||||||
type CardLabel struct {
|
type CardLabel struct {
|
||||||
LabelUuid string `json:"label_uuid"`
|
LabelUuid string `json:"label_uuid"`
|
||||||
UserUuid string `json:"user_uuid"`
|
UserUuid string `json:"user_uuid"`
|
||||||
MerchUuid string `json:"merch_uuid"`
|
MerchUuid string `json:"merch_uuid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (CardLabel) TableName() string {
|
||||||
|
return "card_labels"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,11 @@ type prices interface {
|
||||||
type labels interface {
|
type labels interface {
|
||||||
createLabel(label Label) error
|
createLabel(label Label) error
|
||||||
getLabels(userUuid string) ([]Label, error)
|
getLabels(userUuid string) ([]Label, error)
|
||||||
updateLabel(userUuid, labelUuid string, label map[string]string) error
|
updateLabel(userUuid, labelUuid string, label map[string]any) error
|
||||||
deleteLabel(userUuid, labelUuid string) error
|
deleteLabel(userUuid, labelUuid string) error
|
||||||
attachLabel(label CardLabel) error
|
attachLabel(label CardLabel) error
|
||||||
detachLabel(label CardLabel) error
|
detachLabel(label CardLabel) error
|
||||||
|
getAttachedLabelsByList(list []string) ([]CardLabel, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) addMerch(bundle merchBundle) error {
|
func (r *Repo) addMerch(bundle merchBundle) error {
|
||||||
|
|
@ -251,22 +252,24 @@ func (r *Repo) upsertOrigin(model any) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) createLabel(label Label) error {
|
func (r *Repo) createLabel(label Label) error {
|
||||||
return r.db.Model(&Label{}).Create(label).Error
|
return r.db.Model(&Label{}).Create(&label).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) getLabels(userUuid string) ([]Label, error) {
|
func (r *Repo) getLabels(userUuid string) ([]Label, error) {
|
||||||
var labels []Label
|
var labelsList []Label
|
||||||
|
|
||||||
if err := r.db.
|
if err := r.db.
|
||||||
|
Model(&Label{}).
|
||||||
Where("user_uuid = ?", userUuid).
|
Where("user_uuid = ?", userUuid).
|
||||||
Where("deleted_at IS NULL").
|
Where("deleted_at IS NULL").
|
||||||
Find(labels).Error; err != nil {
|
Find(&labelsList).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return labels, nil
|
return labelsList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) updateLabel(userUuid, labelUuid string, label map[string]string) error {
|
func (r *Repo) updateLabel(userUuid, labelUuid string, label map[string]any) error {
|
||||||
return r.db.Model(&Label{}).
|
return r.db.Model(&Label{}).
|
||||||
Where("user_uuid =? AND label_uuid = ?", userUuid, labelUuid).
|
Where("user_uuid =? AND label_uuid = ?", userUuid, labelUuid).
|
||||||
Updates(label).Error
|
Updates(label).Error
|
||||||
|
|
@ -284,6 +287,16 @@ func (r *Repo) attachLabel(label CardLabel) error {
|
||||||
|
|
||||||
func (r *Repo) detachLabel(label CardLabel) error {
|
func (r *Repo) detachLabel(label CardLabel) error {
|
||||||
return r.db.
|
return r.db.
|
||||||
Where("userUuid = ? AND label_uuid = ? AND merch_uuid = ?", label.UserUuid, label.LabelUuid, label.MerchUuid).
|
Where("user_uuid = ? AND label_uuid = ? AND merch_uuid = ?", label.UserUuid, label.LabelUuid, label.MerchUuid).
|
||||||
Delete(&CardLabel{}).Error
|
Delete(&CardLabel{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Repo) getAttachedLabelsByList(list []string) ([]CardLabel, error) {
|
||||||
|
var labelsList []CardLabel
|
||||||
|
|
||||||
|
if err := r.db.Model(&CardLabel{}).Where("merch_uuid IN ?", list).Find(&labelsList).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labelsList, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,34 @@ func (s *service) getSingleMerch(userUuid, merchUuid string) (MerchDTO, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) getAllMerch(userUuid string) ([]ListResponse, error) {
|
func (s *service) getAllMerch(userUuid string) ([]ListResponse, error) {
|
||||||
return s.repo.getAllMerch(userUuid)
|
const logMsg = "Merch service | Get all merch"
|
||||||
|
|
||||||
|
allMerch, err := s.repo.getAllMerch(userUuid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ids := make([]string, 0, len(allMerch))
|
||||||
|
for _, m := range allMerch {
|
||||||
|
ids = append(ids, m.MerchUuid)
|
||||||
|
}
|
||||||
|
|
||||||
|
cardLabels, err := s.repo.getAttachedLabelsByList(ids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
log.WithField("content", cardLabels).Debug(logMsg)
|
||||||
|
|
||||||
|
clMap := make(map[string][]string)
|
||||||
|
for _, cl := range cardLabels {
|
||||||
|
clMap[cl.MerchUuid] = append(clMap[cl.MerchUuid], cl.LabelUuid)
|
||||||
|
}
|
||||||
|
|
||||||
|
for item := range allMerch {
|
||||||
|
allMerch[item].Labels = clMap[allMerch[item].MerchUuid]
|
||||||
|
}
|
||||||
|
|
||||||
|
return allMerch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) updateMerch(payload UpdateMerchDTO, userUuid string) error {
|
func (s *service) updateMerch(payload UpdateMerchDTO, userUuid string) error {
|
||||||
|
|
@ -504,15 +531,15 @@ func (s *service) createLabel(label LabelDTO, userUuid string) error {
|
||||||
|
|
||||||
return s.repo.createLabel(newLabel)
|
return s.repo.createLabel(newLabel)
|
||||||
}
|
}
|
||||||
func (s *service) getLabels(userUuid string) ([]LabelDTO, error) {
|
func (s *service) getLabels(userUuid string) ([]LabelsList, error) {
|
||||||
stored, err := s.repo.getLabels(userUuid)
|
stored, err := s.repo.getLabels(userUuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
response := make([]LabelDTO, 0, len(stored))
|
response := make([]LabelsList, 0, len(stored))
|
||||||
for _, label := range stored {
|
for _, label := range stored {
|
||||||
response = append(response, LabelDTO{
|
response = append(response, LabelsList{
|
||||||
LabelUuid: label.LabelUuid,
|
LabelUuid: label.LabelUuid,
|
||||||
Name: label.Name,
|
Name: label.Name,
|
||||||
Color: label.Color,
|
Color: label.Color,
|
||||||
|
|
@ -522,8 +549,8 @@ func (s *service) getLabels(userUuid string) ([]LabelDTO, error) {
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
func (s *service) updateLabel(userUuid string, label LabelDTO) error {
|
func (s *service) updateLabel(userUuid, labelUuid string, label LabelDTO) error {
|
||||||
updateMap := make(map[string]string, 3)
|
updateMap := make(map[string]any, 3)
|
||||||
|
|
||||||
if label.Name != "" {
|
if label.Name != "" {
|
||||||
updateMap["name"] = label.Name
|
updateMap["name"] = label.Name
|
||||||
|
|
@ -537,7 +564,7 @@ func (s *service) updateLabel(userUuid string, label LabelDTO) error {
|
||||||
updateMap["bgcolor"] = label.BgColor
|
updateMap["bgcolor"] = label.BgColor
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.repo.updateLabel(userUuid, label.LabelUuid, updateMap)
|
return s.repo.updateLabel(userUuid, labelUuid, updateMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) deleteLabel(userUuid, labelUuid string) error {
|
func (s *service) deleteLabel(userUuid, labelUuid string) error {
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ CREATE TABLE labels(
|
||||||
bg_color VARCHAR(32)
|
bg_color VARCHAR(32)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE card_label (
|
CREATE TABLE card_labels (
|
||||||
user_uuid VARCHAR(36) NOT NULL,
|
user_uuid VARCHAR(36) NOT NULL,
|
||||||
label_uuid VARCHAR(36) NOT NULL,
|
label_uuid VARCHAR(36) NOT NULL,
|
||||||
merch_uuid VARCHAR(36) NOT NULL
|
merch_uuid VARCHAR(36) NOT NULL
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue