Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f2b0470b1 | ||
|
|
4c59ab3f58 | ||
|
|
f9eac067be | ||
|
|
d997d8bfa4 | ||
|
|
a338fd03b2 | ||
|
|
aeb5cb819b | ||
|
|
7fa79d770a | ||
|
|
2728051fde | ||
|
|
a0e21db5a0 | ||
|
|
93ce93770d | ||
|
|
88fcbfe1a5 |
12 changed files with 952 additions and 11 deletions
247
docs/docs.go
247
docs/docs.go
|
|
@ -68,6 +68,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить все записи мерча",
|
"description": "Получить все записи мерча",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -103,6 +106,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Обновить информацию про мерч по его uuid в json-е",
|
"description": "Обновить информацию про мерч по его uuid в json-е",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -145,6 +151,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить картинки по merch_uuid и query параметрам",
|
"description": "Получить картинки по merch_uuid и query параметрам",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch images"
|
"Merch images"
|
||||||
],
|
],
|
||||||
|
|
@ -287,6 +296,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить все метки товаров",
|
"description": "Получить все метки товаров",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -322,6 +334,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Создать новую метку для товара",
|
"description": "Создать новую метку для товара",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -364,6 +379,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Прикрепить метку к товару",
|
"description": "Прикрепить метку к товару",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -406,6 +424,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Удалить привязку метки к товару",
|
"description": "Удалить привязку метки к товару",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -441,6 +462,47 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/merch/labels/{uuid}": {
|
"/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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"put": {
|
"put": {
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
|
|
@ -448,6 +510,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Изменить метку",
|
"description": "Изменить метку",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -527,6 +592,136 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/merch/zeroprices": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Получить нулевые цены",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Merch zero prices"
|
||||||
|
],
|
||||||
|
"summary": "Получить нулевые цены",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/merch.ZeroPrice"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Пометить нулевые цены как удаленные",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Merch zero prices"
|
||||||
|
],
|
||||||
|
"summary": "Пометить нулевые цены как удаленные",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "payload",
|
||||||
|
"name": "payload",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/merch.DeleteZeroPrices"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK"
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/zeroprices/period": {
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Пометить нулевые цены как удаленные за указанный период",
|
||||||
|
"tags": [
|
||||||
|
"Merch zero prices"
|
||||||
|
],
|
||||||
|
"summary": "Пометить нулевые цены как удаленные за указанный период",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "start",
|
||||||
|
"name": "start",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "end",
|
||||||
|
"name": "end",
|
||||||
|
"in": "query",
|
||||||
|
"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": [
|
||||||
|
|
@ -535,6 +730,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить всю информацию про мерч по его uuid",
|
"description": "Получить всю информацию про мерч по его uuid",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -619,6 +817,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить цены мерча за период",
|
"description": "Получить цены мерча за период",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -664,6 +865,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -1018,6 +1222,17 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"merch.DeleteZeroPrices": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"merch_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"merch.ImageLink": {
|
"merch.ImageLink": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -1074,6 +1289,12 @@ const docTemplate = `{
|
||||||
"merch.ListResponse": {
|
"merch.ListResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"labels": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1093,6 +1314,12 @@ const docTemplate = `{
|
||||||
"merch.MerchDTO": {
|
"merch.MerchDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"labels": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1174,6 +1401,26 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"merch.ZeroPrice": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"created_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"merch_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"responses.ErrorResponse400": {
|
"responses.ErrorResponse400": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить все записи мерча",
|
"description": "Получить все записи мерча",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -95,6 +98,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Обновить информацию про мерч по его uuid в json-е",
|
"description": "Обновить информацию про мерч по его uuid в json-е",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -137,6 +143,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить картинки по merch_uuid и query параметрам",
|
"description": "Получить картинки по merch_uuid и query параметрам",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch images"
|
"Merch images"
|
||||||
],
|
],
|
||||||
|
|
@ -279,6 +288,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить все метки товаров",
|
"description": "Получить все метки товаров",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -314,6 +326,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Создать новую метку для товара",
|
"description": "Создать новую метку для товара",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -356,6 +371,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Прикрепить метку к товару",
|
"description": "Прикрепить метку к товару",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -398,6 +416,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Удалить привязку метки к товару",
|
"description": "Удалить привязку метки к товару",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -433,6 +454,47 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/merch/labels/{uuid}": {
|
"/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.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"put": {
|
"put": {
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
|
|
@ -440,6 +502,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Изменить метку",
|
"description": "Изменить метку",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch labels"
|
"Merch labels"
|
||||||
],
|
],
|
||||||
|
|
@ -519,6 +584,136 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/merch/zeroprices": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Получить нулевые цены",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Merch zero prices"
|
||||||
|
],
|
||||||
|
"summary": "Получить нулевые цены",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/merch.ZeroPrice"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Пометить нулевые цены как удаленные",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Merch zero prices"
|
||||||
|
],
|
||||||
|
"summary": "Пометить нулевые цены как удаленные",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "payload",
|
||||||
|
"name": "payload",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/merch.DeleteZeroPrices"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK"
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/merch/zeroprices/period": {
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Пометить нулевые цены как удаленные за указанный период",
|
||||||
|
"tags": [
|
||||||
|
"Merch zero prices"
|
||||||
|
],
|
||||||
|
"summary": "Пометить нулевые цены как удаленные за указанный период",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "start",
|
||||||
|
"name": "start",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "end",
|
||||||
|
"name": "end",
|
||||||
|
"in": "query",
|
||||||
|
"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": [
|
||||||
|
|
@ -527,6 +722,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить всю информацию про мерч по его uuid",
|
"description": "Получить всю информацию про мерч по его uuid",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -611,6 +809,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить цены мерча за период",
|
"description": "Получить цены мерча за период",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -656,6 +857,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -1010,6 +1214,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"merch.DeleteZeroPrices": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"merch_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"merch.ImageLink": {
|
"merch.ImageLink": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -1066,6 +1281,12 @@
|
||||||
"merch.ListResponse": {
|
"merch.ListResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"labels": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1085,6 +1306,12 @@
|
||||||
"merch.MerchDTO": {
|
"merch.MerchDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"labels": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1166,6 +1393,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"merch.ZeroPrice": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"created_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"merch_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"responses.ErrorResponse400": {
|
"responses.ErrorResponse400": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ definitions:
|
||||||
thumbnail:
|
thumbnail:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
merch.DeleteZeroPrices:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
merch_uuid:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
merch.ImageLink:
|
merch.ImageLink:
|
||||||
properties:
|
properties:
|
||||||
etag:
|
etag:
|
||||||
|
|
@ -43,6 +50,10 @@ definitions:
|
||||||
type: object
|
type: object
|
||||||
merch.ListResponse:
|
merch.ListResponse:
|
||||||
properties:
|
properties:
|
||||||
|
labels:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
merch_uuid:
|
merch_uuid:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
|
@ -55,6 +66,10 @@ definitions:
|
||||||
type: object
|
type: object
|
||||||
merch.MerchDTO:
|
merch.MerchDTO:
|
||||||
properties:
|
properties:
|
||||||
|
labels:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
merch_uuid:
|
merch_uuid:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
|
@ -107,6 +122,19 @@ definitions:
|
||||||
origin:
|
origin:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
merch.ZeroPrice:
|
||||||
|
properties:
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
merch_uuid:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
origin:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
responses.ErrorResponse400:
|
responses.ErrorResponse400:
|
||||||
properties:
|
properties:
|
||||||
error:
|
error:
|
||||||
|
|
@ -205,6 +233,8 @@ paths:
|
||||||
/merch/:
|
/merch/:
|
||||||
get:
|
get:
|
||||||
description: Получить все записи мерча
|
description: Получить все записи мерча
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -226,6 +256,8 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Merch
|
- Merch
|
||||||
put:
|
put:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
description: Обновить информацию про мерч по его uuid в json-е
|
description: Обновить информацию про мерч по его uuid в json-е
|
||||||
parameters:
|
parameters:
|
||||||
- description: merch_uuid
|
- description: merch_uuid
|
||||||
|
|
@ -285,6 +317,8 @@ paths:
|
||||||
name: uuid
|
name: uuid
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -341,6 +375,8 @@ paths:
|
||||||
name: type
|
name: type
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -398,6 +434,8 @@ paths:
|
||||||
/merch/labels:
|
/merch/labels:
|
||||||
get:
|
get:
|
||||||
description: Получить все метки товаров
|
description: Получить все метки товаров
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -419,6 +457,8 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Merch labels
|
- Merch labels
|
||||||
post:
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
description: Создать новую метку для товара
|
description: Создать новую метку для товара
|
||||||
parameters:
|
parameters:
|
||||||
- description: payload
|
- description: payload
|
||||||
|
|
@ -468,7 +508,35 @@ paths:
|
||||||
summary: Пометить метку как удаленную
|
summary: Пометить метку как удаленную
|
||||||
tags:
|
tags:
|
||||||
- Merch labels
|
- 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.ErrorResponse400'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Получить метки товара по его uuid
|
||||||
|
tags:
|
||||||
|
- Merch labels
|
||||||
put:
|
put:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
description: Изменить метку
|
description: Изменить метку
|
||||||
parameters:
|
parameters:
|
||||||
- description: label uuid
|
- description: label uuid
|
||||||
|
|
@ -500,6 +568,8 @@ paths:
|
||||||
- Merch labels
|
- Merch labels
|
||||||
/merch/labels/attach:
|
/merch/labels/attach:
|
||||||
post:
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
description: Прикрепить метку к товару
|
description: Прикрепить метку к товару
|
||||||
parameters:
|
parameters:
|
||||||
- description: payload
|
- description: payload
|
||||||
|
|
@ -526,6 +596,8 @@ paths:
|
||||||
- Merch labels
|
- Merch labels
|
||||||
/merch/labels/detach:
|
/merch/labels/detach:
|
||||||
post:
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
description: Удалить привязку метки к товару
|
description: Удалить привязку метки к товару
|
||||||
parameters:
|
parameters:
|
||||||
- description: payload
|
- description: payload
|
||||||
|
|
@ -550,6 +622,88 @@ paths:
|
||||||
summary: Удалить привязку метки к товару
|
summary: Удалить привязку метки к товару
|
||||||
tags:
|
tags:
|
||||||
- Merch labels
|
- Merch labels
|
||||||
|
/merch/zeroprices:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Пометить нулевые цены как удаленные
|
||||||
|
parameters:
|
||||||
|
- description: payload
|
||||||
|
in: body
|
||||||
|
name: payload
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/merch.DeleteZeroPrices'
|
||||||
|
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 zero prices
|
||||||
|
get:
|
||||||
|
description: Получить нулевые цены
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/merch.ZeroPrice'
|
||||||
|
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 zero prices
|
||||||
|
/merch/zeroprices/period:
|
||||||
|
delete:
|
||||||
|
description: Пометить нулевые цены как удаленные за указанный период
|
||||||
|
parameters:
|
||||||
|
- description: start
|
||||||
|
in: query
|
||||||
|
name: start
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- description: end
|
||||||
|
in: query
|
||||||
|
name: end
|
||||||
|
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 zero prices
|
||||||
/prices:
|
/prices:
|
||||||
get:
|
get:
|
||||||
description: Получить цены мерча за период
|
description: Получить цены мерча за период
|
||||||
|
|
@ -558,6 +712,8 @@ paths:
|
||||||
in: query
|
in: query
|
||||||
name: days
|
name: days
|
||||||
type: string
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -591,6 +747,8 @@ paths:
|
||||||
in: query
|
in: query
|
||||||
name: days
|
name: days
|
||||||
type: string
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ func newController(service *service, utils interfaces.Utils, expires time.Durati
|
||||||
|
|
||||||
func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, refreshMW gin.HandlerFunc) {
|
func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, refreshMW gin.HandlerFunc) {
|
||||||
merchGroup := r.Group("/merch", authMW)
|
merchGroup := r.Group("/merch", authMW)
|
||||||
|
|
||||||
merchGroup.POST("/", h.controller.addMerch)
|
merchGroup.POST("/", h.controller.addMerch)
|
||||||
merchGroup.GET("/:uuid", h.controller.getSingleMerch)
|
merchGroup.GET("/:uuid", h.controller.getSingleMerch)
|
||||||
merchGroup.GET("/", h.controller.getAllMerch)
|
merchGroup.GET("/", h.controller.getAllMerch)
|
||||||
|
|
@ -51,6 +50,13 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, ref
|
||||||
labelsGroup.POST("/attach", h.controller.attachLabel)
|
labelsGroup.POST("/attach", h.controller.attachLabel)
|
||||||
labelsGroup.POST("/detach", h.controller.detachLabel)
|
labelsGroup.POST("/detach", h.controller.detachLabel)
|
||||||
labelsGroup.GET("/:uuid", h.controller.getMerchLabels)
|
labelsGroup.GET("/:uuid", h.controller.getMerchLabels)
|
||||||
|
|
||||||
|
zeroPricesGroup := merchGroup.Group("/zeroprices", authMW)
|
||||||
|
zeroPricesGroup.GET("", h.controller.getZeroPrices)
|
||||||
|
zeroPricesGroup.DELETE("", h.controller.deleteZeroPrices)
|
||||||
|
|
||||||
|
zeroPricesGroup.DELETE("/period", h.controller.deleteZeroPricesPeriod)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Добавить новый мерч
|
// @Summary Добавить новый мерч
|
||||||
|
|
@ -92,6 +98,7 @@ func (co *controller) addMerch(c *gin.Context) {
|
||||||
// @Description Получить всю информацию про мерч по его uuid
|
// @Description Получить всю информацию про мерч по его uuid
|
||||||
// @Tags Merch
|
// @Tags Merch
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Param uuid path string true "merch_uuid"
|
// @Param uuid path string true "merch_uuid"
|
||||||
// @Success 200 {object} MerchDTO
|
// @Success 200 {object} MerchDTO
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
|
@ -125,6 +132,7 @@ func (co *controller) getSingleMerch(c *gin.Context) {
|
||||||
// @Description Получить все записи мерча
|
// @Description Получить все записи мерча
|
||||||
// @Tags Merch
|
// @Tags Merch
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Success 200 {array} ListResponse
|
// @Success 200 {array} ListResponse
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
|
@ -151,6 +159,7 @@ func (co *controller) getAllMerch(c *gin.Context) {
|
||||||
// @Description Обновить информацию про мерч по его uuid в json-е
|
// @Description Обновить информацию про мерч по его uuid в json-е
|
||||||
// @Tags Merch
|
// @Tags Merch
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Accept json
|
||||||
// @Param body body UpdateMerchDTO true "merch_uuid"
|
// @Param body body UpdateMerchDTO true "merch_uuid"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
|
@ -176,6 +185,7 @@ func (co *controller) updateMerch(c *gin.Context) {
|
||||||
log.WithError(err).Error("Merch | Failed to get single merch")
|
log.WithError(err).Error("Merch | Failed to get single merch")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
c.Status(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Пометить мерч как удаленный
|
// @Summary Пометить мерч как удаленный
|
||||||
|
|
@ -186,6 +196,7 @@ func (co *controller) updateMerch(c *gin.Context) {
|
||||||
// @Success 200 {object} MerchDTO
|
// @Success 200 {object} MerchDTO
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
//
|
||||||
// @Router /merch/{uuid} [delete]
|
// @Router /merch/{uuid} [delete]
|
||||||
func (co *controller) deleteMerch(c *gin.Context) {
|
func (co *controller) deleteMerch(c *gin.Context) {
|
||||||
merchUuid := c.Param("uuid")
|
merchUuid := c.Param("uuid")
|
||||||
|
|
@ -214,11 +225,16 @@ func (co *controller) deleteMerch(c *gin.Context) {
|
||||||
// @Description Получить цены мерча за период
|
// @Description Получить цены мерча за период
|
||||||
// @Tags Merch
|
// @Tags Merch
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Param days query string false "period in days"
|
// @Param days query string false "period in days"
|
||||||
// @Success 200 {array} PricesResponse
|
// @Success 200 {array} PricesResponse
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
// @Router /prices [get]
|
// @Router /prices [get]
|
||||||
|
//
|
||||||
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
// @Router /prices [get]
|
||||||
func (co *controller) getChartsPrices(c *gin.Context) {
|
func (co *controller) getChartsPrices(c *gin.Context) {
|
||||||
daysQuery := strings.ToLower(c.DefaultQuery("days", ""))
|
daysQuery := strings.ToLower(c.DefaultQuery("days", ""))
|
||||||
|
|
||||||
|
|
@ -243,6 +259,7 @@ func (co *controller) getChartsPrices(c *gin.Context) {
|
||||||
// @Description Получить перепады цен мерча за период по его merch_uuid
|
// @Description Получить перепады цен мерча за период по его merch_uuid
|
||||||
// @Tags Merch
|
// @Tags Merch
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Param uuid path string true "merch_uuid"
|
// @Param uuid path string true "merch_uuid"
|
||||||
// @Param days query string false "period in days"
|
// @Param days query string false "period in days"
|
||||||
// @Success 200 {object} PricesResponse
|
// @Success 200 {object} PricesResponse
|
||||||
|
|
@ -330,7 +347,6 @@ func (co *controller) uploadMerchImage(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//c.Status(http.StatusOK)
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,6 +354,7 @@ func (co *controller) uploadMerchImage(c *gin.Context) {
|
||||||
// @Description Получить картинки по merch_uuid и query параметрам
|
// @Description Получить картинки по merch_uuid и query параметрам
|
||||||
// @Tags Merch images
|
// @Tags Merch images
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Param uuid path string true "merch_uuid"
|
// @Param uuid path string true "merch_uuid"
|
||||||
// @Param type query string true "image type"
|
// @Param type query string true "image type"
|
||||||
// @Success 200 {object} ImageLink
|
// @Success 200 {object} ImageLink
|
||||||
|
|
@ -384,7 +401,6 @@ func (co *controller) getMerchImage(c *gin.Context) {
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//c.JSON(http.StatusOK, link)
|
//c.JSON(http.StatusOK, link)
|
||||||
c.JSON(http.StatusNotImplemented, gin.H{"msg": "Method deprecated. Request images from image storage."})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Удалить (безвозвратно) картинки по merch_uuid
|
// @Summary Удалить (безвозвратно) картинки по merch_uuid
|
||||||
|
|
@ -429,6 +445,7 @@ func (co *controller) deleteMerchImage(c *gin.Context) {
|
||||||
// @Description Создать новую метку для товара
|
// @Description Создать новую метку для товара
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Accept json
|
||||||
// @Param payload body LabelDTO true "payload"
|
// @Param payload body LabelDTO true "payload"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
|
@ -464,6 +481,7 @@ func (co *controller) createLabel(c *gin.Context) {
|
||||||
// @Description Получить все метки товаров
|
// @Description Получить все метки товаров
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Success 200 {array} LabelsList
|
// @Success 200 {array} LabelsList
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
|
@ -492,6 +510,7 @@ func (co *controller) getLabels(c *gin.Context) {
|
||||||
// @Description Изменить метку
|
// @Description Изменить метку
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Accept json
|
||||||
// @Param uuid path string true "label uuid"
|
// @Param uuid path string true "label uuid"
|
||||||
// @Param payload body LabelDTO true "payload"
|
// @Param payload body LabelDTO true "payload"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
|
|
@ -568,6 +587,7 @@ func (co *controller) deleteLabel(c *gin.Context) {
|
||||||
// @Description Прикрепить метку к товару
|
// @Description Прикрепить метку к товару
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Accept json
|
||||||
// @Param payload body LabelLink true "payload"
|
// @Param payload body LabelLink true "payload"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
|
@ -602,6 +622,7 @@ func (co *controller) attachLabel(c *gin.Context) {
|
||||||
// @Description Удалить привязку метки к товару
|
// @Description Удалить привязку метки к товару
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Accept json
|
||||||
// @Param payload body LabelLink true "payload"
|
// @Param payload body LabelLink true "payload"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
|
@ -636,6 +657,7 @@ func (co *controller) detachLabel(c *gin.Context) {
|
||||||
// @Description Получить метки товара по его uuid
|
// @Description Получить метки товара по его uuid
|
||||||
// @Tags Merch labels
|
// @Tags Merch labels
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
// @Param uuid path string true "label uuid"
|
// @Param uuid path string true "label uuid"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
|
@ -666,3 +688,109 @@ func (co *controller) getMerchLabels(c *gin.Context) {
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary Получить нулевые цены
|
||||||
|
// @Description Получить нулевые цены
|
||||||
|
// @Tags Merch zero prices
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {array} ZeroPrice
|
||||||
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
// @Router /merch/zeroprices [get]
|
||||||
|
func (co *controller) getZeroPrices(c *gin.Context) {
|
||||||
|
const logMsg = "Merch | Get zero prices"
|
||||||
|
|
||||||
|
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := co.service.getZeroPrices(userUuid)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary Пометить нулевые цены как удаленные
|
||||||
|
// @Description Пометить нулевые цены как удаленные
|
||||||
|
// @Tags Merch zero prices
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Accept json
|
||||||
|
// @Param payload body DeleteZeroPrices true "payload"
|
||||||
|
// @Success 200
|
||||||
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
// @Router /merch/zeroprices [delete]
|
||||||
|
func (co *controller) deleteZeroPrices(c *gin.Context) {
|
||||||
|
const logMsg = "Merch | Delete zero prices"
|
||||||
|
|
||||||
|
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var payload []DeleteZeroPrices
|
||||||
|
if err = c.ShouldBindJSON(&payload); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = co.service.deleteZeroPrices(userUuid, payload); err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Status(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary Пометить нулевые цены как удаленные за указанный период
|
||||||
|
// @Description Пометить нулевые цены как удаленные за указанный период
|
||||||
|
// @Tags Merch zero prices
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Param start query string true "start"
|
||||||
|
// @Param end query string true "end"
|
||||||
|
// @Success 200
|
||||||
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
// @Router /merch/zeroprices/period [delete]
|
||||||
|
func (co *controller) deleteZeroPricesPeriod(c *gin.Context) {
|
||||||
|
const logMsg = "Merch | Delete zero prices period"
|
||||||
|
|
||||||
|
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
start, err := co.utils.ParseTime(c.Query("start"))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
end, err := co.utils.ParseTime(c.Query("end"))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = co.service.deleteZeroPricesPeriod(userUuid, start, end); err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
|
log.WithError(err).Error(logMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Status(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package merch
|
package merch
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type merchBundle struct {
|
type merchBundle struct {
|
||||||
Merch *Merch
|
Merch *Merch
|
||||||
Surugaya *Surugaya
|
Surugaya *Surugaya
|
||||||
|
|
@ -78,3 +80,16 @@ type LabelLink struct {
|
||||||
MerchUuid string `json:"merch_uuid"`
|
MerchUuid string `json:"merch_uuid"`
|
||||||
LabelUuid string `json:"label_uuid"`
|
LabelUuid string `json:"label_uuid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ZeroPrice struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
MerchUuid string `json:"merch_uuid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Origin Origin `json:"origin"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteZeroPrices struct {
|
||||||
|
Id uint `json:"id"`
|
||||||
|
MerchUuid string `json:"merch_uuid"`
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ func (Mandarake) TableName() string {
|
||||||
type Price struct {
|
type Price struct {
|
||||||
Id uint `json:"id" gorm:"primary_key"`
|
Id uint `json:"id" gorm:"primary_key"`
|
||||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||||
UpdatedAt sql.NullTime `json:"updated_at" gorm:"column:updated_at"`
|
UpdatedAt sql.NullTime `json:"updated_at,omitempty" gorm:"column:updated_at"`
|
||||||
DeletedAt sql.NullTime `json:"deleted_at" gorm:"column:deleted_at"`
|
DeletedAt sql.NullTime `json:"deleted_at,omitempty" gorm:"column:deleted_at"`
|
||||||
MerchUuid string `json:"merch_uuid" gorm:"column:merch_uuid"`
|
MerchUuid string `json:"merch_uuid" gorm:"column:merch_uuid"`
|
||||||
Price int `json:"price" gorm:"column:price"`
|
Price int `json:"price" gorm:"column:price"`
|
||||||
Origin Origin `json:"origin" gorm:"column:origin;type:integer"`
|
Origin Origin `json:"origin" gorm:"column:origin;type:integer"`
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ type repository interface {
|
||||||
addMerch(bundle merchBundle) error
|
addMerch(bundle merchBundle) error
|
||||||
|
|
||||||
merchRecordExists(userUuid, merchUuid string) (bool, error)
|
merchRecordExists(userUuid, merchUuid string) (bool, error)
|
||||||
|
userOwnsMerchUuids(userUuid string, merchUuids []string) ([]Merch, error)
|
||||||
getSingleMerch(userUuid, merchUuid string) (merchBundle, error)
|
getSingleMerch(userUuid, merchUuid string) (merchBundle, error)
|
||||||
getAllMerch(userUuid string) ([]ListResponse, error)
|
getAllMerch(userUuid string) ([]ListResponse, error)
|
||||||
|
|
||||||
|
|
@ -38,6 +39,10 @@ type repository interface {
|
||||||
type prices interface {
|
type prices interface {
|
||||||
getPricesWithDays(userUuid string, period time.Time) ([]Price, error)
|
getPricesWithDays(userUuid string, period time.Time) ([]Price, error)
|
||||||
getDistinctPrices(userUuid, merchUuid string, period time.Time) (prices []Price, err error)
|
getDistinctPrices(userUuid, merchUuid string, period time.Time) (prices []Price, err error)
|
||||||
|
|
||||||
|
getZeroPrices(userUuid string) ([]ZeroPrice, error)
|
||||||
|
deleteZeroPrices(list []DeleteZeroPrices) error
|
||||||
|
deleteZeroPricesPeriod(userUuid string, start, end time.Time) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type labels interface {
|
type labels interface {
|
||||||
|
|
@ -81,6 +86,22 @@ func (r *Repo) merchRecordExists(userUuid, merchUuid string) (bool, error) {
|
||||||
return exists, err
|
return exists, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Repo) userOwnsMerchUuids(userUuid string, merchUuids []string) ([]Merch, error) {
|
||||||
|
var ownsUuids []Merch
|
||||||
|
err := r.db.Model(&Merch{}).
|
||||||
|
Select("merch_uuid").
|
||||||
|
Where("user_uuid = ?", userUuid).
|
||||||
|
Where("merch_uuid IN (?)", merchUuids).
|
||||||
|
Where("deleted_at IS NULL").
|
||||||
|
Find(&ownsUuids).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ownsUuids, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Repo) getSingleMerch(userUuid, merchUuid string) (merchBundle, error) {
|
func (r *Repo) getSingleMerch(userUuid, merchUuid string) (merchBundle, error) {
|
||||||
var merch Merch
|
var merch Merch
|
||||||
if err := r.db.
|
if err := r.db.
|
||||||
|
|
@ -311,3 +332,59 @@ func (r *Repo) getAttachedLabelsByUuid(userUuid, merchUuid string) ([]CardLabel,
|
||||||
|
|
||||||
return labelsList, nil
|
return labelsList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Repo) getZeroPrices(userUuid string) ([]ZeroPrice, error) {
|
||||||
|
var priceList []ZeroPrice
|
||||||
|
if err := r.db.Raw(`
|
||||||
|
WITH price_with_neighbors AS (
|
||||||
|
SELECT
|
||||||
|
p.id, p.created_at, p.merch_uuid, p.price, p.origin, m.name,
|
||||||
|
LAG(price) OVER (PARTITION BY p.merch_uuid, p.origin ORDER BY p.created_at, p.id) AS prev_price,
|
||||||
|
LEAD(price) OVER (PARTITION BY p.merch_uuid, p.origin ORDER BY p.created_at, p.id) AS next_price
|
||||||
|
FROM prices AS p
|
||||||
|
JOIN merch as m ON m.merch_uuid = p.merch_uuid
|
||||||
|
WHERE p.deleted_at IS NULL
|
||||||
|
AND m.deleted_at IS NULL
|
||||||
|
AND m.user_uuid = ?)
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
id, created_at, merch_uuid, origin, name
|
||||||
|
FROM price_with_neighbors
|
||||||
|
WHERE
|
||||||
|
price = 0
|
||||||
|
AND prev_price IS NOT NULL
|
||||||
|
AND prev_price > 0
|
||||||
|
AND next_price IS NOT NULL
|
||||||
|
AND next_price > 0;
|
||||||
|
`, userUuid).Scan(&priceList).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return priceList, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Repo) deleteZeroPrices(list []DeleteZeroPrices) error {
|
||||||
|
for _, item := range list {
|
||||||
|
if err := r.db.Model(&Price{}).
|
||||||
|
Where("id = ? AND merch_uuid = ?", item.Id, item.MerchUuid).
|
||||||
|
Update("deleted_at", time.Now().UTC()).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Repo) deleteZeroPricesPeriod(userUuid string, start, end time.Time) error {
|
||||||
|
if err := r.db.Exec(`
|
||||||
|
UPDATE prices
|
||||||
|
SET deleted_at = ?
|
||||||
|
FROM merch
|
||||||
|
WHERE prices.merch_uuid = merch.merch_uuid
|
||||||
|
AND merch.user_uuid = ?
|
||||||
|
AND prices.price = 0
|
||||||
|
AND prices.deleted_at IS NULL
|
||||||
|
AND prices.created_at BETWEEN ? AND ?;
|
||||||
|
`, time.Now().UTC(), userUuid, start, end).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -612,3 +612,57 @@ func (s *service) getMerchLabels(userUuid, merchUuid string) ([]string, error) {
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *service) getZeroPrices(userUuid string) ([]ZeroPrice, error) {
|
||||||
|
return s.repo.getZeroPrices(userUuid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) deleteZeroPrices(userUuid string, list []DeleteZeroPrices) error {
|
||||||
|
const delMsg = "Merch - service | Delete zero prices"
|
||||||
|
if len(list) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ids := make([]string, 0, len(list))
|
||||||
|
for _, item := range list {
|
||||||
|
ids = append(ids, item.MerchUuid)
|
||||||
|
}
|
||||||
|
|
||||||
|
uniqueMap := make(map[string]struct{}, len(list))
|
||||||
|
uniqueIds := make([]string, 0, len(list))
|
||||||
|
for _, id := range ids {
|
||||||
|
if _, ok := uniqueMap[id]; !ok {
|
||||||
|
uniqueMap[id] = struct{}{}
|
||||||
|
uniqueIds = append(uniqueIds, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.WithField("uuid count", len(uniqueIds)).Debug(delMsg)
|
||||||
|
|
||||||
|
owns, err := s.repo.userOwnsMerchUuids(userUuid, uniqueIds)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(owns) < 1 {
|
||||||
|
return errors.New("wrong ids")
|
||||||
|
}
|
||||||
|
|
||||||
|
ownsMap := make(map[string]struct{}, len(owns))
|
||||||
|
for _, own := range owns {
|
||||||
|
ownsMap[own.MerchUuid] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
toDelete := make([]DeleteZeroPrices, 0, len(owns))
|
||||||
|
for _, item := range list {
|
||||||
|
if _, ok := ownsMap[item.MerchUuid]; ok {
|
||||||
|
toDelete = append(toDelete, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.repo.deleteZeroPrices(toDelete)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) deleteZeroPricesPeriod(userUuid string, start, end time.Time) error {
|
||||||
|
return s.repo.deleteZeroPricesPeriod(userUuid, start, end)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ func newController(service *service, utils interfaces.Utils) *controller {
|
||||||
func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, refreshMW gin.HandlerFunc) {
|
func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, refreshMW gin.HandlerFunc) {
|
||||||
userGroup := r.Group("/user")
|
userGroup := r.Group("/user")
|
||||||
|
|
||||||
userGroup.POST("/", h.controller.register)
|
userGroup.POST("", h.controller.register)
|
||||||
userGroup.GET("/", authMW, h.controller.get)
|
userGroup.GET("", authMW, h.controller.get)
|
||||||
userGroup.PUT("/", authMW, h.controller.update)
|
userGroup.PUT("", authMW, h.controller.update)
|
||||||
userGroup.DELETE("/", authMW, h.controller.delete)
|
userGroup.DELETE("", authMW, h.controller.delete)
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
h.controller.authPath = fmt.Sprintf("%s/user/auth", h.apiPrefix)
|
h.controller.authPath = fmt.Sprintf("%s/user/auth", h.apiPrefix)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func (r *repo) getByUuid(userUuid string) (user User, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repo) update(user map[string]any) error {
|
func (r *repo) update(user map[string]any) error {
|
||||||
return r.db.Where("uuid = ?", user["uuid"]).Updates(&user).Error
|
return r.db.Model(&User{}).Where("uuid = ?", user["uuid"]).Updates(&user).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repo) delete(userUuid string) error {
|
func (r *repo) delete(userUuid string) error {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Utils interface {
|
type Utils interface {
|
||||||
IsEmail(email string) bool
|
IsEmail(email string) bool
|
||||||
|
|
@ -8,4 +11,5 @@ type Utils interface {
|
||||||
GetRefreshUuidFromContext(c *gin.Context) (string, error)
|
GetRefreshUuidFromContext(c *gin.Context) (string, error)
|
||||||
HashPassword(password string) (string, error)
|
HashPassword(password string) (string, error)
|
||||||
ComparePasswords(hashedPassword string, plainPassword string) error
|
ComparePasswords(hashedPassword string, plainPassword string) error
|
||||||
|
ParseTime(t string) (time.Time, error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
pkg/utils/time.go
Normal file
11
pkg/utils/time.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func (u *Utils) ParseTime(t string) (time.Time, error) {
|
||||||
|
timeStr, err := time.Parse(time.RFC3339, t)
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
return timeStr, nil
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue