Compare commits
No commits in common. "main" and "v0.1.7" have entirely different histories.
30 changed files with 261 additions and 4180 deletions
19
Dockerfile
19
Dockerfile
|
|
@ -1,21 +1,34 @@
|
||||||
FROM golang:1.25.1-alpine3.22 AS builder
|
FROM golang:1.25.1-alpine3.22 AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
ca-certificates
|
||||||
|
|
||||||
|
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o main "./cmd"
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o main "./cmd"
|
||||||
|
|
||||||
|
|
||||||
FROM alpine:3.22
|
FROM alpine:3.22
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
tzdata \
|
bash \
|
||||||
ca-certificates
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
tzdata
|
||||||
|
|
||||||
COPY --from=builder /app/main /usr/local/bin/app
|
COPY --from=builder /app/main /usr/local/bin/app
|
||||||
|
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/app
|
RUN chmod +x /usr/local/bin/app
|
||||||
|
RUN adduser -D -s /bin/bash appuser
|
||||||
|
USER appuser
|
||||||
|
|
||||||
ENTRYPOINT ["app"]
|
ENTRYPOINT ["app"]
|
||||||
8
api.env
8
api.env
|
|
@ -8,14 +8,6 @@ APP_ALLOWED_ORIGINS=http://localhost:5173,
|
||||||
GRPC_SERVER_PORT=9050
|
GRPC_SERVER_PORT=9050
|
||||||
GRPC_CLIENT_PORT=9060
|
GRPC_CLIENT_PORT=9060
|
||||||
|
|
||||||
IMAGE_STORAGE_HOST=
|
|
||||||
IMAGE_STORAGE_PORT=
|
|
||||||
|
|
||||||
MEDIA_STORAGE_ENDPOINT=
|
|
||||||
MEDIA_STORAGE_USER=
|
|
||||||
MEDIA_STORAGE_PASSWORD=
|
|
||||||
MEDIA_STORAGE_SECURE=false
|
|
||||||
|
|
||||||
DB_HOST=
|
DB_HOST=
|
||||||
DB_PORT=
|
DB_PORT=
|
||||||
DB_USER=
|
DB_USER=
|
||||||
|
|
|
||||||
18
cmd/main.go
18
cmd/main.go
|
|
@ -9,9 +9,7 @@ import (
|
||||||
"merch-parser-api/internal/api/user"
|
"merch-parser-api/internal/api/user"
|
||||||
"merch-parser-api/internal/app"
|
"merch-parser-api/internal/app"
|
||||||
"merch-parser-api/internal/grpcService"
|
"merch-parser-api/internal/grpcService"
|
||||||
"merch-parser-api/internal/imagesProvider"
|
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
"merch-parser-api/internal/mediaStorage"
|
|
||||||
"merch-parser-api/internal/provider/auth"
|
"merch-parser-api/internal/provider/auth"
|
||||||
"merch-parser-api/internal/provider/token"
|
"merch-parser-api/internal/provider/token"
|
||||||
"merch-parser-api/internal/router"
|
"merch-parser-api/internal/router"
|
||||||
|
|
@ -30,6 +28,7 @@ func main() {
|
||||||
log.Debug("Starting merch-parser-api")
|
log.Debug("Starting merch-parser-api")
|
||||||
//setup config
|
//setup config
|
||||||
c := config.NewConfig()
|
c := config.NewConfig()
|
||||||
|
//c := config.DevConfig()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
//log level
|
//log level
|
||||||
|
|
@ -52,19 +51,6 @@ func main() {
|
||||||
utilsProvider := utils.NewUtils()
|
utilsProvider := utils.NewUtils()
|
||||||
log.Debug("Utils provider initialized")
|
log.Debug("Utils provider initialized")
|
||||||
|
|
||||||
mediaProvider := mediaStorage.NewHandler(mediaStorage.Deps{
|
|
||||||
Endpoint: c.MediaConf.Endpoint,
|
|
||||||
User: c.MediaConf.User,
|
|
||||||
Password: c.MediaConf.Password,
|
|
||||||
Secure: c.MediaConf.Secure,
|
|
||||||
})
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"endpoint": c.MediaConf.Endpoint,
|
|
||||||
"provider": mediaProvider,
|
|
||||||
}).Debug("Media storage | Minio client created")
|
|
||||||
|
|
||||||
imageProvider := imagesProvider.NewClient(c.ImageConf.Host + ":" + c.ImageConf.Port)
|
|
||||||
|
|
||||||
//deps providers
|
//deps providers
|
||||||
routerHandler := router.NewRouter(router.Deps{
|
routerHandler := router.NewRouter(router.Deps{
|
||||||
ApiPrefix: c.AppConf.ApiPrefix,
|
ApiPrefix: c.AppConf.ApiPrefix,
|
||||||
|
|
@ -96,8 +82,6 @@ func main() {
|
||||||
merchModule := merch.NewHandler(merch.Deps{
|
merchModule := merch.NewHandler(merch.Deps{
|
||||||
DB: database,
|
DB: database,
|
||||||
Utils: utilsProvider,
|
Utils: utilsProvider,
|
||||||
//Media: mediaProvider,
|
|
||||||
ImageStorage: imageProvider,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//collect modules
|
//collect modules
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@ package config
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AppConf AppConfig
|
AppConf AppConfig
|
||||||
DBConf DatabaseConfig
|
DBConf DatabaseConfig
|
||||||
JWTConf JWTConfig
|
JWTConf JWTConfig
|
||||||
GrpcConf GrpcConfig
|
GrpcConf GrpcConfig
|
||||||
MediaConf MediaConfig
|
|
||||||
ImageConf ImageStorageConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
|
|
@ -42,18 +40,6 @@ type GrpcConfig struct {
|
||||||
GrpcClientPort string
|
GrpcClientPort string
|
||||||
}
|
}
|
||||||
|
|
||||||
type MediaConfig struct {
|
|
||||||
Endpoint string
|
|
||||||
User string
|
|
||||||
Password string
|
|
||||||
Secure string
|
|
||||||
}
|
|
||||||
|
|
||||||
type ImageStorageConfig struct {
|
|
||||||
Host string
|
|
||||||
Port string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
AppConf: AppConfig{
|
AppConf: AppConfig{
|
||||||
|
|
@ -86,17 +72,5 @@ func NewConfig() *Config {
|
||||||
GrpcServerPort: getEnv("GRPC_SERVER_PORT", ""),
|
GrpcServerPort: getEnv("GRPC_SERVER_PORT", ""),
|
||||||
GrpcClientPort: getEnv("GRPC_CLIENT_PORT", ""),
|
GrpcClientPort: getEnv("GRPC_CLIENT_PORT", ""),
|
||||||
},
|
},
|
||||||
|
|
||||||
MediaConf: MediaConfig{
|
|
||||||
Endpoint: getEnv("MEDIA_STORAGE_ENDPOINT", ""),
|
|
||||||
User: getEnv("MEDIA_STORAGE_USER", ""),
|
|
||||||
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
|
|
||||||
Secure: getEnv("MEDIA_STORAGE_SECURE", ""),
|
|
||||||
},
|
|
||||||
|
|
||||||
ImageConf: ImageStorageConfig{
|
|
||||||
Host: getEnv("IMAGE_STORAGE_HOST", ""),
|
|
||||||
Port: getEnv("IMAGE_STORAGE_PORT", ""),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
801
docs/docs.go
801
docs/docs.go
|
|
@ -68,9 +68,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить все записи мерча",
|
"description": "Получить все записи мерча",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -98,628 +95,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"put": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Обновить информацию про мерч по его uuid в json-е",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch"
|
|
||||||
],
|
|
||||||
"summary": "Обновить информацию про мерч",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "merch_uuid",
|
|
||||||
"name": "body",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.UpdateMerchDTO"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/merch/images/{uuid}": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Получить картинки по merch_uuid и query параметрам",
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch images"
|
|
||||||
],
|
|
||||||
"summary": "Получить картинки по merch_uuid и query параметрам",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "merch_uuid",
|
|
||||||
"name": "uuid",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "image type",
|
|
||||||
"name": "type",
|
|
||||||
"in": "query",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.ImageLink"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на созданные картинки.",
|
|
||||||
"consumes": [
|
|
||||||
"multipart/form-data"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch images"
|
|
||||||
],
|
|
||||||
"summary": "Загрузить картинку по merch_uuid",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "Merch UUID",
|
|
||||||
"name": "uuid",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "file",
|
|
||||||
"description": "Image file",
|
|
||||||
"name": "file",
|
|
||||||
"in": "formData",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/imageStorage.UploadMerchImageResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Удалить (безвозвратно) картинки по merch_uuid",
|
|
||||||
"tags": [
|
|
||||||
"Merch images"
|
|
||||||
],
|
|
||||||
"summary": "Удалить (безвозвратно) картинки по merch_uuid",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "merch_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/labels": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Получить все метки товаров",
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Получить все метки товаров",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/merch.LabelsList"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Создать новую метку для товара",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Создать новую метку для товара",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelDTO"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/merch/labels/attach": {
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Прикрепить метку к товару",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Прикрепить метку к товару",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelLink"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/merch/labels/detach": {
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Удалить привязку метки к товару",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Удалить привязку метки к товару",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelLink"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/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": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Изменить метку",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Изменить метку",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "label uuid",
|
|
||||||
"name": "uuid",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelDTO"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.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/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}": {
|
||||||
|
|
@ -730,9 +105,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить всю информацию про мерч по его uuid",
|
"description": "Получить всю информацию про мерч по его uuid",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -767,6 +139,49 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Обновить информацию про мерч по его uuid в json-е",
|
||||||
|
"tags": [
|
||||||
|
"Merch"
|
||||||
|
],
|
||||||
|
"summary": "Обновить информацию про мерч",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "merch_uuid",
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/merch.MerchDTO"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/merch.MerchDTO"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
|
|
@ -817,9 +232,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить цены мерча за период",
|
"description": "Получить цены мерча за период",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -865,9 +277,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -1211,90 +620,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"imageStorage.UploadMerchImageResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"fullImage": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.DeleteZeroPrices": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.ImageLink": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"etag": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"link": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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": {
|
||||||
"labels": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1314,12 +642,6 @@ 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"
|
||||||
},
|
},
|
||||||
|
|
@ -1384,43 +706,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"merch.UpdateMerchDTO": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"link": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"origin": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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,9 +60,6 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить все записи мерча",
|
"description": "Получить все записи мерча",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -90,628 +87,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"put": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Обновить информацию про мерч по его uuid в json-е",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch"
|
|
||||||
],
|
|
||||||
"summary": "Обновить информацию про мерч",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "merch_uuid",
|
|
||||||
"name": "body",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.UpdateMerchDTO"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/merch/images/{uuid}": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Получить картинки по merch_uuid и query параметрам",
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch images"
|
|
||||||
],
|
|
||||||
"summary": "Получить картинки по merch_uuid и query параметрам",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "merch_uuid",
|
|
||||||
"name": "uuid",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "image type",
|
|
||||||
"name": "type",
|
|
||||||
"in": "query",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.ImageLink"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на созданные картинки.",
|
|
||||||
"consumes": [
|
|
||||||
"multipart/form-data"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch images"
|
|
||||||
],
|
|
||||||
"summary": "Загрузить картинку по merch_uuid",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "Merch UUID",
|
|
||||||
"name": "uuid",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "file",
|
|
||||||
"description": "Image file",
|
|
||||||
"name": "file",
|
|
||||||
"in": "formData",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/imageStorage.UploadMerchImageResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Удалить (безвозвратно) картинки по merch_uuid",
|
|
||||||
"tags": [
|
|
||||||
"Merch images"
|
|
||||||
],
|
|
||||||
"summary": "Удалить (безвозвратно) картинки по merch_uuid",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "merch_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/labels": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Получить все метки товаров",
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Получить все метки товаров",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/merch.LabelsList"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Создать новую метку для товара",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Создать новую метку для товара",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelDTO"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/merch/labels/attach": {
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Прикрепить метку к товару",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Прикрепить метку к товару",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelLink"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/merch/labels/detach": {
|
|
||||||
"post": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Удалить привязку метки к товару",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Удалить привязку метки к товару",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelLink"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.ErrorResponse500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/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": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"BearerAuth": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Изменить метку",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Merch labels"
|
|
||||||
],
|
|
||||||
"summary": "Изменить метку",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "label uuid",
|
|
||||||
"name": "uuid",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "payload",
|
|
||||||
"name": "payload",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/merch.LabelDTO"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK"
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/responses.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/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}": {
|
||||||
|
|
@ -722,9 +97,6 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить всю информацию про мерч по его uuid",
|
"description": "Получить всю информацию про мерч по его uuid",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -759,6 +131,49 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Обновить информацию про мерч по его uuid в json-е",
|
||||||
|
"tags": [
|
||||||
|
"Merch"
|
||||||
|
],
|
||||||
|
"summary": "Обновить информацию про мерч",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "merch_uuid",
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/merch.MerchDTO"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/merch.MerchDTO"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse400"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/responses.ErrorResponse500"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
|
|
@ -809,9 +224,6 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить цены мерча за период",
|
"description": "Получить цены мерча за период",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -857,9 +269,6 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
"description": "Получить перепады цен мерча за период по его merch_uuid",
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -1203,90 +612,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"imageStorage.UploadMerchImageResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"fullImage": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.DeleteZeroPrices": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.ImageLink": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"etag": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"link": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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": {
|
||||||
"labels": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1306,12 +634,6 @@
|
||||||
"merch.MerchDTO": {
|
"merch.MerchDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"labels": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
"merch_uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -1376,43 +698,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"merch.UpdateMerchDTO": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"link": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"merch_uuid": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"origin": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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": {
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,7 @@
|
||||||
basePath: /api/v2
|
basePath: /api/v2
|
||||||
definitions:
|
definitions:
|
||||||
imageStorage.UploadMerchImageResponse:
|
|
||||||
properties:
|
|
||||||
fullImage:
|
|
||||||
type: string
|
|
||||||
thumbnail:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.DeleteZeroPrices:
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
merch_uuid:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.ImageLink:
|
|
||||||
properties:
|
|
||||||
etag:
|
|
||||||
type: string
|
|
||||||
link:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.LabelDTO:
|
|
||||||
properties:
|
|
||||||
bg_color:
|
|
||||||
type: string
|
|
||||||
color:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.LabelLink:
|
|
||||||
properties:
|
|
||||||
label_uuid:
|
|
||||||
type: string
|
|
||||||
merch_uuid:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.LabelsList:
|
|
||||||
properties:
|
|
||||||
bg_color:
|
|
||||||
type: string
|
|
||||||
color:
|
|
||||||
type: string
|
|
||||||
label_uuid:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.ListResponse:
|
merch.ListResponse:
|
||||||
properties:
|
properties:
|
||||||
labels:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
merch_uuid:
|
merch_uuid:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
|
@ -66,10 +14,6 @@ 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:
|
||||||
|
|
@ -111,30 +55,6 @@ definitions:
|
||||||
link:
|
link:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
merch.UpdateMerchDTO:
|
|
||||||
properties:
|
|
||||||
link:
|
|
||||||
type: string
|
|
||||||
merch_uuid:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
origin:
|
|
||||||
type: string
|
|
||||||
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:
|
||||||
|
|
@ -233,8 +153,6 @@ paths:
|
||||||
/merch/:
|
/merch/:
|
||||||
get:
|
get:
|
||||||
description: Получить все записи мерча
|
description: Получить все записи мерча
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -255,33 +173,6 @@ paths:
|
||||||
summary: Получить все записи мерча
|
summary: Получить все записи мерча
|
||||||
tags:
|
tags:
|
||||||
- Merch
|
- Merch
|
||||||
put:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: Обновить информацию про мерч по его uuid в json-е
|
|
||||||
parameters:
|
|
||||||
- description: merch_uuid
|
|
||||||
in: body
|
|
||||||
name: body
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/merch.UpdateMerchDTO'
|
|
||||||
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
|
|
||||||
/merch/{uuid}:
|
/merch/{uuid}:
|
||||||
delete:
|
delete:
|
||||||
description: Пометить мерч как удаленный по его uuid
|
description: Пометить мерч как удаленный по его uuid
|
||||||
|
|
@ -317,8 +208,6 @@ paths:
|
||||||
name: uuid
|
name: uuid
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -337,222 +226,20 @@ paths:
|
||||||
summary: Получить всю информацию про мерч
|
summary: Получить всю информацию про мерч
|
||||||
tags:
|
tags:
|
||||||
- Merch
|
- Merch
|
||||||
/merch/images/{uuid}:
|
|
||||||
delete:
|
|
||||||
description: Удалить (безвозвратно) картинки по merch_uuid
|
|
||||||
parameters:
|
|
||||||
- description: merch_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: Удалить (безвозвратно) картинки по merch_uuid
|
|
||||||
tags:
|
|
||||||
- Merch images
|
|
||||||
get:
|
|
||||||
description: Получить картинки по merch_uuid и query параметрам
|
|
||||||
parameters:
|
|
||||||
- description: merch_uuid
|
|
||||||
in: path
|
|
||||||
name: uuid
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
- description: image type
|
|
||||||
in: query
|
|
||||||
name: type
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/merch.ImageLink'
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse400'
|
|
||||||
"500":
|
|
||||||
description: Internal Server Error
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
summary: Получить картинки по merch_uuid и query параметрам
|
|
||||||
tags:
|
|
||||||
- Merch images
|
|
||||||
post:
|
|
||||||
consumes:
|
|
||||||
- multipart/form-data
|
|
||||||
description: Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на
|
|
||||||
созданные картинки.
|
|
||||||
parameters:
|
|
||||||
- description: Merch UUID
|
|
||||||
in: path
|
|
||||||
name: uuid
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
- description: Image file
|
|
||||||
in: formData
|
|
||||||
name: file
|
|
||||||
required: true
|
|
||||||
type: file
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/imageStorage.UploadMerchImageResponse'
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse400'
|
|
||||||
"500":
|
|
||||||
description: Internal Server Error
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
summary: Загрузить картинку по merch_uuid
|
|
||||||
tags:
|
|
||||||
- Merch images
|
|
||||||
/merch/labels:
|
|
||||||
get:
|
|
||||||
description: Получить все метки товаров
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/merch.LabelsList'
|
|
||||||
type: array
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse400'
|
|
||||||
"500":
|
|
||||||
description: Internal Server Error
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
summary: Получить все метки товаров
|
|
||||||
tags:
|
|
||||||
- Merch labels
|
|
||||||
post:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: Создать новую метку для товара
|
|
||||||
parameters:
|
|
||||||
- description: payload
|
|
||||||
in: body
|
|
||||||
name: payload
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/merch.LabelDTO'
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.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
|
|
||||||
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:
|
description: Обновить информацию про мерч по его uuid в json-е
|
||||||
- application/json
|
|
||||||
description: Изменить метку
|
|
||||||
parameters:
|
parameters:
|
||||||
- description: label uuid
|
- description: merch_uuid
|
||||||
in: path
|
|
||||||
name: uuid
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
- description: payload
|
|
||||||
in: body
|
in: body
|
||||||
name: payload
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/merch.LabelDTO'
|
$ref: '#/definitions/merch.MerchDTO'
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/merch.MerchDTO'
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
|
|
@ -563,147 +250,9 @@ paths:
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
security:
|
security:
|
||||||
- BearerAuth: []
|
- BearerAuth: []
|
||||||
summary: Изменить метку
|
summary: Обновить информацию про мерч
|
||||||
tags:
|
tags:
|
||||||
- Merch labels
|
- Merch
|
||||||
/merch/labels/attach:
|
|
||||||
post:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: Прикрепить метку к товару
|
|
||||||
parameters:
|
|
||||||
- description: payload
|
|
||||||
in: body
|
|
||||||
name: payload
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/merch.LabelLink'
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse400'
|
|
||||||
"500":
|
|
||||||
description: Internal Server Error
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
summary: Прикрепить метку к товару
|
|
||||||
tags:
|
|
||||||
- Merch labels
|
|
||||||
/merch/labels/detach:
|
|
||||||
post:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: Удалить привязку метки к товару
|
|
||||||
parameters:
|
|
||||||
- description: payload
|
|
||||||
in: body
|
|
||||||
name: payload
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/merch.LabelLink'
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse400'
|
|
||||||
"500":
|
|
||||||
description: Internal Server Error
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
summary: Удалить привязку метки к товару
|
|
||||||
tags:
|
|
||||||
- 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: Получить цены мерча за период
|
||||||
|
|
@ -712,8 +261,6 @@ paths:
|
||||||
in: query
|
in: query
|
||||||
name: days
|
name: days
|
||||||
type: string
|
type: string
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -747,8 +294,6 @@ paths:
|
||||||
in: query
|
in: query
|
||||||
name: days
|
name: days
|
||||||
type: string
|
type: string
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
|
||||||
31
go.mod
31
go.mod
|
|
@ -3,18 +3,16 @@ module merch-parser-api
|
||||||
go 1.25.1
|
go 1.25.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/disintegration/imaging v1.6.2
|
|
||||||
github.com/gin-contrib/cors v1.7.6
|
github.com/gin-contrib/cors v1.7.6
|
||||||
github.com/gin-gonic/gin v1.11.0
|
github.com/gin-gonic/gin v1.11.0
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0
|
github.com/golang-jwt/jwt/v5 v5.3.0
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/minio/minio-go/v7 v7.0.95
|
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/swaggo/files v1.0.1
|
github.com/swaggo/files v1.0.1
|
||||||
github.com/swaggo/gin-swagger v1.6.1
|
github.com/swaggo/gin-swagger v1.6.1
|
||||||
github.com/swaggo/swag v1.16.6
|
github.com/swaggo/swag v1.16.6
|
||||||
golang.org/x/crypto v0.43.0
|
golang.org/x/crypto v0.42.0
|
||||||
google.golang.org/grpc v1.76.0
|
google.golang.org/grpc v1.75.1
|
||||||
google.golang.org/protobuf v1.36.10
|
google.golang.org/protobuf v1.36.10
|
||||||
gorm.io/driver/postgres v1.6.0
|
gorm.io/driver/postgres v1.6.0
|
||||||
gorm.io/gorm v1.31.0
|
gorm.io/gorm v1.31.0
|
||||||
|
|
@ -26,10 +24,8 @@ require (
|
||||||
github.com/bytedance/sonic v1.14.1 // indirect
|
github.com/bytedance/sonic v1.14.1 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
||||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/go-ini/ini v1.67.0 // indirect
|
|
||||||
github.com/go-openapi/jsonpointer v0.22.1 // indirect
|
github.com/go-openapi/jsonpointer v0.22.1 // indirect
|
||||||
github.com/go-openapi/jsonreference v0.21.2 // indirect
|
github.com/go-openapi/jsonreference v0.21.2 // indirect
|
||||||
github.com/go-openapi/spec v0.22.0 // indirect
|
github.com/go-openapi/spec v0.22.0 // indirect
|
||||||
|
|
@ -42,7 +38,7 @@ require (
|
||||||
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
|
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.28.0 // indirect
|
github.com/go-playground/validator/v10 v10.27.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/goccy/go-yaml v1.18.0 // indirect
|
github.com/goccy/go-yaml v1.18.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
|
@ -52,32 +48,25 @@ require (
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.18.1 // indirect
|
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/minio/crc64nvme v1.1.1 // indirect
|
|
||||||
github.com/minio/md5-simd v1.1.2 // indirect
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
github.com/philhofer/fwd v1.2.0 // indirect
|
|
||||||
github.com/quic-go/qpack v0.5.1 // indirect
|
github.com/quic-go/qpack v0.5.1 // indirect
|
||||||
github.com/quic-go/quic-go v0.55.0 // indirect
|
github.com/quic-go/quic-go v0.55.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||||
github.com/rs/xid v1.6.0 // indirect
|
|
||||||
github.com/tinylib/msgp v1.4.0 // indirect
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.3.0 // indirect
|
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||||
go.uber.org/mock v0.6.0 // indirect
|
go.uber.org/mock v0.6.0 // indirect
|
||||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||||
golang.org/x/arch v0.22.0 // indirect
|
golang.org/x/arch v0.21.0 // indirect
|
||||||
golang.org/x/image v0.32.0 // indirect
|
golang.org/x/mod v0.28.0 // indirect
|
||||||
golang.org/x/mod v0.29.0 // indirect
|
golang.org/x/net v0.44.0 // indirect
|
||||||
golang.org/x/net v0.46.0 // indirect
|
|
||||||
golang.org/x/sync v0.17.0 // indirect
|
golang.org/x/sync v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.37.0 // indirect
|
golang.org/x/sys v0.36.0 // indirect
|
||||||
golang.org/x/text v0.30.0 // indirect
|
golang.org/x/text v0.29.0 // indirect
|
||||||
golang.org/x/tools v0.38.0 // indirect
|
golang.org/x/tools v0.37.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20251002232023-7c0ddcbb5797 // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
64
go.sum
64
go.sum
|
|
@ -11,10 +11,6 @@ github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gE
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
|
||||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQY=
|
github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQY=
|
||||||
|
|
@ -25,8 +21,6 @@ github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w
|
||||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
||||||
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
||||||
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
|
||||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
|
||||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
|
|
@ -60,8 +54,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
|
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
|
||||||
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
|
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
||||||
|
|
@ -89,9 +83,6 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
|
||||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
|
||||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
|
@ -102,12 +93,6 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI=
|
|
||||||
github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
|
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
|
||||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
|
||||||
github.com/minio/minio-go/v7 v7.0.95 h1:ywOUPg+PebTMTzn9VDsoFJy32ZuARN9zhB+K3IYEvYU=
|
|
||||||
github.com/minio/minio-go/v7 v7.0.95/go.mod h1:wOOX3uxS334vImCNRVyIDdXX9OsXDm89ToynKgqUKlo=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
|
@ -115,8 +100,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
|
|
||||||
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
||||||
|
|
@ -125,8 +108,6 @@ github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9M
|
||||||
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
|
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
|
||||||
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
|
||||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
|
@ -145,8 +126,6 @@ github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs
|
||||||
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
||||||
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||||
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||||
github.com/tinylib/msgp v1.4.0 h1:SYOeDRiydzOw9kSiwdYp9UcBgPFtLU2WDHaJXyHruf8=
|
|
||||||
github.com/tinylib/msgp v1.4.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o=
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||||
|
|
@ -168,24 +147,21 @@ go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
golang.org/x/arch v0.21.0 h1:iTC9o7+wP6cPWpDWkivCvQFGAHDQ59SrSxsLPcnkArw=
|
||||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
golang.org/x/arch v0.21.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
|
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||||
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
|
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
|
||||||
golang.org/x/image v0.32.0 h1:6lZQWq75h7L5IWNk0r+SCpUJ6tUVd3v4ZHnbRKLkUDQ=
|
|
||||||
golang.org/x/image v0.32.0/go.mod h1:/R37rrQmKXtO6tYXAjtDLwQgFLHmhW+V6ayXlxzP2Pc=
|
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
|
||||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||||
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||||
|
|
@ -198,8 +174,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
|
@ -207,20 +183,20 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||||
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
||||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 h1:M1rk8KBnUsBDg1oPGHNCxG4vc1f49epmTO7xscSajMk=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20251002232023-7c0ddcbb5797 h1:CirRxTOwnRWVLKzDNrs0CXAaVozJoR4G9xvdRecrdpk=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20251002232023-7c0ddcbb5797/go.mod h1:HSkG/KdJWusxU1F6CNrwNDjBMgisKxGnc5dAZfT0mjQ=
|
||||||
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
|
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
|
||||||
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
|
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
|
||||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,29 @@
|
||||||
package merch
|
package merch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"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"
|
||||||
"merch-parser-api/pkg/responses"
|
"merch-parser-api/pkg/responses"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type controller struct {
|
type controller struct {
|
||||||
service *service
|
service *service
|
||||||
utils interfaces.Utils
|
utils interfaces.Utils
|
||||||
expires time.Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newController(service *service, utils interfaces.Utils, expires time.Duration) *controller {
|
func newController(service *service, utils interfaces.Utils) *controller {
|
||||||
return &controller{
|
return &controller{
|
||||||
service: service,
|
service: service,
|
||||||
utils: utils,
|
utils: utils,
|
||||||
expires: expires,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -37,26 +34,6 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc, ref
|
||||||
chartsGroup.GET("", h.controller.getChartsPrices)
|
chartsGroup.GET("", h.controller.getChartsPrices)
|
||||||
chartsGroup.GET("/:uuid", h.controller.getDistinctPrices)
|
chartsGroup.GET("/:uuid", h.controller.getDistinctPrices)
|
||||||
|
|
||||||
imagesGroup := merchGroup.Group("/images")
|
|
||||||
imagesGroup.POST("/:uuid", h.controller.uploadMerchImage)
|
|
||||||
imagesGroup.GET("/:uuid", h.controller.getMerchImage)
|
|
||||||
imagesGroup.DELETE("/:uuid", h.controller.deleteMerchImage)
|
|
||||||
|
|
||||||
labelsGroup := merchGroup.Group("/labels", authMW)
|
|
||||||
labelsGroup.POST("", h.controller.createLabel)
|
|
||||||
labelsGroup.GET("", h.controller.getLabels)
|
|
||||||
labelsGroup.PUT("/:uuid", h.controller.updateLabel)
|
|
||||||
labelsGroup.DELETE("/:uuid", h.controller.deleteLabel)
|
|
||||||
labelsGroup.POST("/attach", h.controller.attachLabel)
|
|
||||||
labelsGroup.POST("/detach", h.controller.detachLabel)
|
|
||||||
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 Добавить новый мерч
|
||||||
|
|
@ -98,7 +75,6 @@ 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
|
||||||
|
|
@ -132,7 +108,6 @@ 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
|
||||||
|
|
@ -159,11 +134,10 @@ 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
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
// @Router /merch/ [put]
|
// @Router /merch/ [put]
|
||||||
func (co *controller) updateMerch(c *gin.Context) {
|
func (co *controller) updateMerch(c *gin.Context) {
|
||||||
var payload UpdateMerchDTO
|
var payload UpdateMerchDTO
|
||||||
|
|
@ -185,7 +159,6 @@ 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 Пометить мерч как удаленный
|
||||||
|
|
@ -196,7 +169,6 @@ 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")
|
||||||
|
|
@ -225,16 +197,11 @@ 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", ""))
|
||||||
|
|
||||||
|
|
@ -259,12 +226,11 @@ 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
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
// @Router /prices/{uuid} [get]
|
// @Router /prices/{uuid} [get]
|
||||||
func (co *controller) getDistinctPrices(c *gin.Context) {
|
func (co *controller) getDistinctPrices(c *gin.Context) {
|
||||||
daysQuery := strings.ToLower(c.DefaultQuery("days", ""))
|
daysQuery := strings.ToLower(c.DefaultQuery("days", ""))
|
||||||
|
|
@ -291,506 +257,3 @@ func (co *controller) getDistinctPrices(c *gin.Context) {
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Загрузить картинку по merch_uuid
|
|
||||||
// @Description Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на созданные картинки.
|
|
||||||
// @Tags Merch images
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Accept multipart/form-data
|
|
||||||
// @Produce json
|
|
||||||
// @Param uuid path string true "Merch UUID"
|
|
||||||
// @Param file formData file true "Image file"
|
|
||||||
// @Success 200 {object} imageStorage.UploadMerchImageResponse
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/images/{uuid} [post]
|
|
||||||
func (co *controller) uploadMerchImage(c *gin.Context) {
|
|
||||||
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error("Merch | Failed to get user uuid from context")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
merchUuid := c.Param("uuid")
|
|
||||||
if merchUuid == "" {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
|
||||||
log.Error("Merch | Failed to get single merch")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//Uncomment for MinIO use
|
|
||||||
//imageType := c.PostForm("imageType")
|
|
||||||
//types := map[string]struct{}{"thumbnail": {}, "full": {}, "all": {}}
|
|
||||||
//if _, allowed := types[imageType]; !allowed {
|
|
||||||
// c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "imageType must be one of: thumbnail, full, all"})
|
|
||||||
// log.WithError(err).Error("Merch | imageType must be one of: thumbnail, full, all")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
file, err := c.FormFile("file")
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "file is required"})
|
|
||||||
log.WithError(err).Error("Merch | File is required")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
//Uncomment for MinIO use
|
|
||||||
//err = co.service.uploadMerchImage(ctx, userUuid, merchUuid, imageType, file)
|
|
||||||
response, err := co.service.mtUploadMerchImage(ctx, userUuid, merchUuid, file)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error("Merch | Failed to upload merch image")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary Получить картинки по merch_uuid и query параметрам
|
|
||||||
// @Description Получить картинки по merch_uuid и query параметрам
|
|
||||||
// @Tags Merch images
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Produce json
|
|
||||||
// @Param uuid path string true "merch_uuid"
|
|
||||||
// @Param type query string true "image type"
|
|
||||||
// @Success 200 {object} ImageLink
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/images/{uuid} [get]
|
|
||||||
func (co *controller) getMerchImage(c *gin.Context) {
|
|
||||||
//Uncomment for MinIO use
|
|
||||||
|
|
||||||
//typeQuery := strings.ToLower(c.Query("type"))
|
|
||||||
//if typeQuery == "" {
|
|
||||||
// c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "Image type query param is empty"})
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
//if err != nil {
|
|
||||||
// c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
// log.WithError(err).Error("Merch | Failed to get user uuid from context")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//merchUuid := c.Param("uuid")
|
|
||||||
//if merchUuid == "" {
|
|
||||||
// c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
|
||||||
// log.WithError(err).Error("Merch | Failed to get single merch")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
|
||||||
//defer cancel()
|
|
||||||
//
|
|
||||||
//link, err := co.service.getPublicImageLink(ctx, userUuid, merchUuid, typeQuery)
|
|
||||||
//if err != nil {
|
|
||||||
// c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
// log.WithError(err).Error("Merch | Failed to get merch image")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if link.Link == "" {
|
|
||||||
// log.Debug("Merch | No image")
|
|
||||||
// c.Status(http.StatusNoContent)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//c.JSON(http.StatusOK, link)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary Удалить (безвозвратно) картинки по merch_uuid
|
|
||||||
// @Description Удалить (безвозвратно) картинки по merch_uuid
|
|
||||||
// @Tags Merch images
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Param uuid path string true "merch_uuid"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/images/{uuid} [delete]
|
|
||||||
func (co *controller) deleteMerchImage(c *gin.Context) {
|
|
||||||
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error("Merch | Failed to get user uuid from context")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
merchUuid := c.Param("uuid")
|
|
||||||
if merchUuid == "" {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
|
||||||
log.WithError(err).Error("Merch | Failed to get merch uuid")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
//Uncomment for MinIO use
|
|
||||||
//if err := co.service.deleteMerchImage(ctx, userUuid, merchUuid); err != nil {
|
|
||||||
|
|
||||||
if err := co.service.mtDeleteMerchImage(ctx, userUuid, merchUuid); err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error("Merch | Failed to delete merch image")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.Status(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary Создать новую метку для товара
|
|
||||||
// @Description Создать новую метку для товара
|
|
||||||
// @Tags Merch labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Accept json
|
|
||||||
// @Param payload body LabelDTO true "payload"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels [post]
|
|
||||||
func (co *controller) createLabel(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Create label"
|
|
||||||
|
|
||||||
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 LabelDTO
|
|
||||||
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.createLabel(payload, userUuid); 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 labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Produce json
|
|
||||||
// @Success 200 {array} LabelsList
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels [get]
|
|
||||||
func (co *controller) getLabels(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Get labels"
|
|
||||||
|
|
||||||
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.getLabels(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 labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Accept json
|
|
||||||
// @Param uuid path string true "label uuid"
|
|
||||||
// @Param payload body LabelDTO true "payload"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels/{uuid} [put]
|
|
||||||
func (co *controller) updateLabel(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Update label"
|
|
||||||
|
|
||||||
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
labelUuid := c.Param("uuid")
|
|
||||||
if labelUuid == "" {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "label uuid is empty"})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var payload LabelDTO
|
|
||||||
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.updateLabel(userUuid, labelUuid, 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 labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Param uuid path string true "label uuid"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels/{uuid} [delete]
|
|
||||||
func (co *controller) deleteLabel(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Delete label"
|
|
||||||
|
|
||||||
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
labelUuid := c.Param("uuid")
|
|
||||||
if labelUuid == "" {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "label uuid is empty"})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = co.service.deleteLabel(userUuid, labelUuid); 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 labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Accept json
|
|
||||||
// @Param payload body LabelLink true "payload"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels/attach [post]
|
|
||||||
func (co *controller) attachLabel(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Attach label"
|
|
||||||
|
|
||||||
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 LabelLink
|
|
||||||
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.attachLabel(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 labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Accept json
|
|
||||||
// @Param payload body LabelLink true "payload"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels/detach [post]
|
|
||||||
func (co *controller) detachLabel(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Detach label"
|
|
||||||
|
|
||||||
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 LabelLink
|
|
||||||
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.detachLabel(userUuid, payload); err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.Status(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary Получить метки товара по его uuid
|
|
||||||
// @Description Получить метки товара по его uuid
|
|
||||||
// @Tags Merch labels
|
|
||||||
// @Security BearerAuth
|
|
||||||
// @Produce json
|
|
||||||
// @Param uuid path string true "label uuid"
|
|
||||||
// @Success 200
|
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
|
||||||
// @Router /merch/labels/{uuid} [get]
|
|
||||||
func (co *controller) getMerchLabels(c *gin.Context) {
|
|
||||||
const logMsg = "Merch | Get merch labels"
|
|
||||||
|
|
||||||
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
merchUuid := c.Param("uuid")
|
|
||||||
if merchUuid == "" {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "label uuid is empty"})
|
|
||||||
log.WithError(err).Error(logMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := co.service.getMerchLabels(userUuid, merchUuid)
|
|
||||||
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
|
|
||||||
// @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,7 +1,5 @@
|
||||||
package merch
|
package merch
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
type merchBundle struct {
|
type merchBundle struct {
|
||||||
Merch *Merch
|
Merch *Merch
|
||||||
Surugaya *Surugaya
|
Surugaya *Surugaya
|
||||||
|
|
@ -12,7 +10,6 @@ type MerchDTO struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
OriginSurugaya SurugayaDTO `json:"origin_surugaya"`
|
OriginSurugaya SurugayaDTO `json:"origin_surugaya"`
|
||||||
OriginMandarake MandarakeDTO `json:"origin_mandarake"`
|
OriginMandarake MandarakeDTO `json:"origin_mandarake"`
|
||||||
Labels []string `json:"labels,omitempty" gorm:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SurugayaDTO struct {
|
type SurugayaDTO struct {
|
||||||
|
|
@ -30,9 +27,8 @@ 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 {
|
||||||
|
|
@ -57,39 +53,3 @@ type UpdateMerchDTO struct {
|
||||||
Origin string `json:"origin"`
|
Origin string `json:"origin"`
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageLink struct {
|
|
||||||
Link string `json:"link"`
|
|
||||||
ETag string `json:"etag"`
|
|
||||||
}
|
|
||||||
|
|
||||||
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"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Color string `json:"color,omitempty"`
|
|
||||||
BgColor string `json:"bg_color,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LabelLink struct {
|
|
||||||
MerchUuid string `json:"merch_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"`
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ package merch
|
||||||
import (
|
import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
is "merch-parser-api/proto/imageStorage"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
|
|
@ -16,33 +14,12 @@ type Handler struct {
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
Utils interfaces.Utils
|
Utils interfaces.Utils
|
||||||
//Media interfaces.MediaStorage
|
|
||||||
ImageStorage is.ImageStorageClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandler(deps Deps) *Handler {
|
func NewHandler(deps Deps) *Handler {
|
||||||
packageBucketName := "user-merch-images"
|
|
||||||
expires := time.Minute * 5
|
|
||||||
|
|
||||||
r := NewRepo(deps.DB)
|
r := NewRepo(deps.DB)
|
||||||
s := newService(serviceDeps{
|
s := newService(r)
|
||||||
repo: r,
|
c := newController(s, deps.Utils)
|
||||||
//media: deps.Media,
|
|
||||||
bucketName: packageBucketName,
|
|
||||||
expires: expires,
|
|
||||||
imageStorage: deps.ImageStorage,
|
|
||||||
})
|
|
||||||
c := newController(s, deps.Utils, expires)
|
|
||||||
|
|
||||||
//media := deps.Media
|
|
||||||
//log.WithFields(log.Fields{
|
|
||||||
// "addr": media,
|
|
||||||
//}).Debug("Merch handler constructor | Media provider")
|
|
||||||
//
|
|
||||||
//exists, err := media.CheckBucketExists(packageBucketName)
|
|
||||||
//if err != nil || !exists {
|
|
||||||
// log.WithError(err).Fatal("Merch handler constructor | Failed to ensure bucket exists")
|
|
||||||
//}
|
|
||||||
|
|
||||||
return &Handler{
|
return &Handler{
|
||||||
repo: r,
|
repo: r,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package merch
|
package merch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -18,14 +17,3 @@ func getPeriod(days string) time.Time {
|
||||||
|
|
||||||
return time.Now().UTC().Add(-(time.Duration(daysInt) * time.Hour * 24))
|
return time.Now().UTC().Add(-(time.Duration(daysInt) * time.Hour * 24))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) makeObject(userUuid, merchUuid, imageType string) (string, error) {
|
|
||||||
switch imageType {
|
|
||||||
case "thumbnail":
|
|
||||||
return fmt.Sprintf("%s/merch/%s/thumbnail.jpg", userUuid, merchUuid), nil
|
|
||||||
case "full":
|
|
||||||
return fmt.Sprintf("%s/merch/%s/full.jpg", userUuid, merchUuid), nil
|
|
||||||
default:
|
|
||||||
return "", fmt.Errorf("unknown image type %s", imageType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -44,35 +44,9 @@ 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,omitempty" gorm:"column:updated_at"`
|
UpdatedAt sql.NullTime `json:"updated_at" gorm:"column:updated_at"`
|
||||||
DeletedAt sql.NullTime `json:"deleted_at,omitempty" gorm:"column:deleted_at"`
|
DeletedAt sql.NullTime `json:"deleted_at" 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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Label struct {
|
|
||||||
Id uint `json:"-" gorm:"primary_key"`
|
|
||||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
|
||||||
UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
|
|
||||||
DeletedAt sql.NullTime `json:"deleted_at" gorm:"column:deleted_at"`
|
|
||||||
LabelUuid string `json:"label_uuid" gorm:"column:label_uuid"`
|
|
||||||
UserUuid string `json:"user_uuid" gorm:"column:user_uuid"`
|
|
||||||
Name string `json:"name" gorm:"column:name"`
|
|
||||||
Color string `json:"color" gorm:"column:color"`
|
|
||||||
BgColor string `json:"bg_color" gorm:"column:bg_color"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (Label) TableName() string {
|
|
||||||
return "labels"
|
|
||||||
}
|
|
||||||
|
|
||||||
type CardLabel struct {
|
|
||||||
LabelUuid string `json:"label_uuid"`
|
|
||||||
UserUuid string `json:"user_uuid"`
|
|
||||||
MerchUuid string `json:"merch_uuid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CardLabel) TableName() string {
|
|
||||||
return "card_labels"
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ func NewRepo(db *gorm.DB) *Repo {
|
||||||
type repository interface {
|
type repository interface {
|
||||||
addMerch(bundle merchBundle) error
|
addMerch(bundle merchBundle) 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)
|
||||||
|
|
||||||
|
|
@ -33,27 +31,11 @@ type repository interface {
|
||||||
getAllUserMerch(userUuid string) ([]Merch, error)
|
getAllUserMerch(userUuid string) ([]Merch, error)
|
||||||
|
|
||||||
prices
|
prices
|
||||||
labels
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
|
||||||
createLabel(label Label) error
|
|
||||||
getLabels(userUuid string) ([]Label, error)
|
|
||||||
updateLabel(userUuid, labelUuid string, label map[string]any) error
|
|
||||||
deleteLabel(userUuid, labelUuid string) error
|
|
||||||
attachLabel(label CardLabel) error
|
|
||||||
detachLabel(label CardLabel) error
|
|
||||||
getAttachedLabelsByList(list []string) ([]CardLabel, error)
|
|
||||||
getAttachedLabelsByUuid(userUuid, merchUuid string) ([]CardLabel, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) addMerch(bundle merchBundle) error {
|
func (r *Repo) addMerch(bundle merchBundle) error {
|
||||||
|
|
@ -72,36 +54,6 @@ func (r *Repo) addMerch(bundle merchBundle) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) merchRecordExists(userUuid, merchUuid string) (bool, error) {
|
|
||||||
var exists bool
|
|
||||||
err := r.db.Raw(`
|
|
||||||
SELECT EXISTS (
|
|
||||||
SELECT 1
|
|
||||||
FROM merch
|
|
||||||
WHERE user_uuid = ?
|
|
||||||
AND merch_uuid = ?
|
|
||||||
AND deleted_at IS NULL
|
|
||||||
);`, userUuid, merchUuid).Scan(&exists).Error
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
@ -272,119 +224,3 @@ func (r *Repo) upsertOrigin(model any) error {
|
||||||
DoUpdates: clause.AssignmentColumns([]string{"link"}),
|
DoUpdates: clause.AssignmentColumns([]string{"link"}),
|
||||||
}).Create(model).Error
|
}).Create(model).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) createLabel(label Label) error {
|
|
||||||
return r.db.Model(&Label{}).Create(&label).Error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repo) getLabels(userUuid string) ([]Label, error) {
|
|
||||||
var labelsList []Label
|
|
||||||
|
|
||||||
if err := r.db.
|
|
||||||
Model(&Label{}).
|
|
||||||
Where("user_uuid = ?", userUuid).
|
|
||||||
Where("deleted_at IS NULL").
|
|
||||||
Find(&labelsList).Error; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return labelsList, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repo) updateLabel(userUuid, labelUuid string, label map[string]any) error {
|
|
||||||
return r.db.Model(&Label{}).
|
|
||||||
Where("user_uuid =? AND label_uuid = ?", userUuid, labelUuid).
|
|
||||||
Updates(label).Error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repo) deleteLabel(userUuid, labelUuid string) error {
|
|
||||||
return r.db.Model(&Label{}).
|
|
||||||
Where("user_uuid =? AND label_uuid = ?", userUuid, labelUuid).
|
|
||||||
Update("deleted_at", time.Now().UTC()).Error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repo) attachLabel(label CardLabel) error {
|
|
||||||
return r.db.Model(&CardLabel{}).Create(&label).Error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repo) detachLabel(label CardLabel) error {
|
|
||||||
return r.db.
|
|
||||||
Where("user_uuid = ? AND label_uuid = ? AND merch_uuid = ?", label.UserUuid, label.LabelUuid, label.MerchUuid).
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repo) getAttachedLabelsByUuid(userUuid, merchUuid string) ([]CardLabel, error) {
|
|
||||||
var labelsList []CardLabel
|
|
||||||
|
|
||||||
if err := r.db.Model(&CardLabel{}).Where("user_uuid = ? AND merch_uuid = ?", userUuid, merchUuid).Find(&labelsList).Error; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,22 @@
|
||||||
package merch
|
package merch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"github.com/disintegration/imaging"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"image"
|
|
||||||
"image/jpeg"
|
|
||||||
"io"
|
|
||||||
"merch-parser-api/internal/interfaces"
|
|
||||||
is "merch-parser-api/proto/imageStorage"
|
|
||||||
"mime/multipart"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
repo repository
|
repo repository
|
||||||
media interfaces.MediaStorage
|
|
||||||
bucketName string
|
|
||||||
expires time.Duration
|
|
||||||
imageStorage is.ImageStorageClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceDeps struct {
|
func newService(repo repository) *service {
|
||||||
repo repository
|
|
||||||
media interfaces.MediaStorage
|
|
||||||
bucketName string
|
|
||||||
expires time.Duration
|
|
||||||
imageStorage is.ImageStorageClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func newService(deps serviceDeps) *service {
|
|
||||||
return &service{
|
return &service{
|
||||||
repo: deps.repo,
|
repo: repo,
|
||||||
media: deps.media,
|
|
||||||
bucketName: deps.bucketName,
|
|
||||||
expires: deps.expires,
|
|
||||||
imageStorage: deps.imageStorage,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type uploadImageParams struct {
|
|
||||||
ctx context.Context
|
|
||||||
src io.Reader
|
|
||||||
imageType string
|
|
||||||
object string
|
|
||||||
quality int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) addMerch(payload MerchDTO, userUuid string) error {
|
func (s *service) addMerch(payload MerchDTO, userUuid string) error {
|
||||||
merchUuid := uuid.NewString()
|
merchUuid := uuid.NewString()
|
||||||
|
|
||||||
|
|
@ -101,34 +64,7 @@ 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) {
|
||||||
const logMsg = "Merch service | Get all merch"
|
return s.repo.getAllMerch(userUuid)
|
||||||
|
|
||||||
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 {
|
||||||
|
|
@ -144,13 +80,6 @@ func (s *service) updateMerch(payload UpdateMerchDTO, userUuid string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) deleteMerch(userUuid, merchUuid string) error {
|
func (s *service) deleteMerch(userUuid, merchUuid string) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), s.expires)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
if err := s.deleteMerchImage(ctx, userUuid, merchUuid); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.repo.deleteMerch(userUuid, merchUuid)
|
return s.repo.deleteMerch(userUuid, merchUuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,422 +176,3 @@ func (s *service) getDistinctPrices(userUuid, merchUuid, days string) (PricesRes
|
||||||
Origins: []OriginWithPrices{originSurugaya, originMandarake},
|
Origins: []OriginWithPrices{originSurugaya, originMandarake},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// uploadMerchImage
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage. Use mtUploadMerchImage for merch-tracker images storage.
|
|
||||||
func (s *service) uploadMerchImage(ctx context.Context, userUuid, merchUuid, imageType string, file *multipart.FileHeader) error {
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
rawExt := filepath.Ext(file.Filename)
|
|
||||||
if rawExt == "" {
|
|
||||||
return errors.New("no file extension")
|
|
||||||
}
|
|
||||||
|
|
||||||
ext := strings.ToLower(rawExt[1:])
|
|
||||||
allowedTypes := map[string]struct{}{"jpeg": {}, "jpg": {}, "png": {}, "gif": {}}
|
|
||||||
if _, ok := allowedTypes[ext]; !ok {
|
|
||||||
return errors.New("invalid file type")
|
|
||||||
}
|
|
||||||
|
|
||||||
getSrc := func() (io.ReadCloser, error) {
|
|
||||||
f, err := file.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error("Merch | Failed to open file")
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return f, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
switch imageType {
|
|
||||||
case "thumbnail":
|
|
||||||
src, err := getSrc()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return s._uploadToStorage(uploadImageParams{
|
|
||||||
ctx: ctx,
|
|
||||||
src: src,
|
|
||||||
imageType: "thumbnail",
|
|
||||||
object: fmt.Sprintf("%s/merch/%s/thumbnail.jpg", userUuid, merchUuid),
|
|
||||||
quality: 80,
|
|
||||||
})
|
|
||||||
|
|
||||||
case "full":
|
|
||||||
src, err := getSrc()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return s._uploadToStorage(uploadImageParams{
|
|
||||||
ctx: ctx,
|
|
||||||
src: src,
|
|
||||||
imageType: "full",
|
|
||||||
object: fmt.Sprintf("%s/merch/%s/full.jpg", userUuid, merchUuid),
|
|
||||||
quality: 90,
|
|
||||||
})
|
|
||||||
|
|
||||||
case "all":
|
|
||||||
src, err := getSrc()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = s._uploadToStorage(uploadImageParams{
|
|
||||||
ctx: ctx,
|
|
||||||
src: src,
|
|
||||||
imageType: "thumbnail",
|
|
||||||
object: fmt.Sprintf("%s/merch/%s/thumbnail.jpg", userUuid, merchUuid),
|
|
||||||
quality: 80,
|
|
||||||
}); err != nil {
|
|
||||||
log.WithError(err).Error("Merch | Upload thumbnail and full image")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
src2, err := getSrc()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = s._uploadToStorage(uploadImageParams{
|
|
||||||
ctx: ctx,
|
|
||||||
src: src2,
|
|
||||||
imageType: "full",
|
|
||||||
object: fmt.Sprintf("%s/merch/%s/full.jpg", userUuid, merchUuid),
|
|
||||||
quality: 90,
|
|
||||||
}); err != nil {
|
|
||||||
log.WithError(err).Error("Merch | Upload thumbnail and full image")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return errors.New("invalid file type")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// getPublicImageLink
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage.
|
|
||||||
func (s *service) getPublicImageLink(ctx context.Context, userUuid, merchUuid, imageType string) (ImageLink, error) {
|
|
||||||
object, err := s.makeObject(userUuid, merchUuid, imageType)
|
|
||||||
if err != nil {
|
|
||||||
return ImageLink{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
link, etag, err := s.media.GetPublicLink(ctx, s.bucketName, object)
|
|
||||||
if err != nil {
|
|
||||||
return ImageLink{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return ImageLink{
|
|
||||||
Link: link,
|
|
||||||
ETag: etag,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// getPresignedImageLink
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage.
|
|
||||||
func (s *service) getPresignedImageLink(ctx context.Context, userUuid, merchUuid, imageType string) (ImageLink, error) {
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
return ImageLink{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return ImageLink{}, fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
object, err := s.makeObject(userUuid, merchUuid, imageType)
|
|
||||||
if err != nil {
|
|
||||||
return ImageLink{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
link, err := s.media.GetPresignedLink(ctx, s.bucketName, object, s.expires, nil)
|
|
||||||
if err != nil {
|
|
||||||
return ImageLink{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
etag, err := s.media.GetObjectEtag(ctx, s.bucketName, object)
|
|
||||||
if err != nil {
|
|
||||||
return ImageLink{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return ImageLink{
|
|
||||||
Link: link,
|
|
||||||
ETag: etag,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteMerchImage
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage.
|
|
||||||
func (s *service) deleteMerchImage(ctx context.Context, userUuid, merchUuid string) error {
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
//uncomment for MinIO
|
|
||||||
//if err = s.media.Delete(ctx, s.bucketName, fmt.Sprintf("%s/merch/%s/thumbnail.jpg", userUuid, merchUuid)); err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if err = s.media.Delete(ctx, s.bucketName, fmt.Sprintf("%s/merch/%s/full.jpg", userUuid, merchUuid)); err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) _uploadToStorage(params uploadImageParams) error {
|
|
||||||
img, _, err := image.Decode(params.src)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to decode image: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if params.imageType == "thumbnail" {
|
|
||||||
img = imaging.Resize(img, 300, 300, imaging.Lanczos)
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
if err = jpeg.Encode(&buf, img, &jpeg.Options{Quality: params.quality}); err != nil {
|
|
||||||
return fmt.Errorf("failed to encode full image: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = s.media.Upload(params.ctx, s.bucketName, params.object, &buf, -1)
|
|
||||||
if err != nil {
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"error": err,
|
|
||||||
"img type": params.imageType,
|
|
||||||
}).Error("Merch | Failed to upload file to media storage")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// mtUploadMerchImage
|
|
||||||
// Upload new/rewrite existing image to merch-tracker images storage
|
|
||||||
func (s *service) mtUploadMerchImage(ctx context.Context, userUuid, merchUuid string, file *multipart.FileHeader) (*is.UploadMerchImageResponse, error) {
|
|
||||||
const uploadMerchImage = "Merch service | Upload merch image"
|
|
||||||
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
err = fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err := file.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
data, err := io.ReadAll(f)
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := s.imageStorage.UploadImage(ctx, &is.UploadMerchImageRequest{
|
|
||||||
ImageData: data,
|
|
||||||
UserUuid: userUuid,
|
|
||||||
MerchUuid: merchUuid,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// mtDeleteMerchImage
|
|
||||||
// Delete all merch images for given user and merch uuid-s from merch-tracker images storage
|
|
||||||
func (s *service) mtDeleteMerchImage(ctx context.Context, userUuid, merchUuid string) error {
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
s.imageStorage.DeleteImage(ctx, &is.DeleteImageRequest{
|
|
||||||
UserUuid: userUuid,
|
|
||||||
MerchUuid: merchUuid,
|
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) createLabel(label LabelDTO, userUuid string) error {
|
|
||||||
now := time.Now().UTC()
|
|
||||||
|
|
||||||
if label.Name == "" {
|
|
||||||
return fmt.Errorf("label name is required")
|
|
||||||
}
|
|
||||||
|
|
||||||
newLabel := Label{
|
|
||||||
CreatedAt: now,
|
|
||||||
UpdatedAt: now,
|
|
||||||
DeletedAt: sql.NullTime{Time: time.Time{}, Valid: false},
|
|
||||||
LabelUuid: uuid.NewString(),
|
|
||||||
UserUuid: userUuid,
|
|
||||||
Name: label.Name,
|
|
||||||
Color: label.Color,
|
|
||||||
BgColor: label.BgColor,
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.repo.createLabel(newLabel)
|
|
||||||
}
|
|
||||||
func (s *service) getLabels(userUuid string) ([]LabelsList, error) {
|
|
||||||
stored, err := s.repo.getLabels(userUuid)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response := make([]LabelsList, 0, len(stored))
|
|
||||||
for _, label := range stored {
|
|
||||||
response = append(response, LabelsList{
|
|
||||||
LabelUuid: label.LabelUuid,
|
|
||||||
Name: label.Name,
|
|
||||||
Color: label.Color,
|
|
||||||
BgColor: label.BgColor,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
func (s *service) updateLabel(userUuid, labelUuid string, label LabelDTO) error {
|
|
||||||
updateMap := make(map[string]any, 3)
|
|
||||||
|
|
||||||
if label.Name != "" {
|
|
||||||
updateMap["name"] = label.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
if label.Color != "" {
|
|
||||||
updateMap["color"] = label.Color
|
|
||||||
}
|
|
||||||
|
|
||||||
if label.BgColor != "" {
|
|
||||||
updateMap["bg_color"] = label.BgColor
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.repo.updateLabel(userUuid, labelUuid, updateMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) deleteLabel(userUuid, labelUuid string) error {
|
|
||||||
return s.repo.deleteLabel(userUuid, labelUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) attachLabel(userUuid string, label LabelLink) error {
|
|
||||||
if label.LabelUuid == "" || label.MerchUuid == "" {
|
|
||||||
return fmt.Errorf("both label and merch uuid-s are required")
|
|
||||||
}
|
|
||||||
|
|
||||||
attach := CardLabel{
|
|
||||||
LabelUuid: label.LabelUuid,
|
|
||||||
UserUuid: userUuid,
|
|
||||||
MerchUuid: label.MerchUuid,
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.repo.attachLabel(attach)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) detachLabel(userUuid string, label LabelLink) error {
|
|
||||||
if label.LabelUuid == "" || label.MerchUuid == "" {
|
|
||||||
return fmt.Errorf("both label and merch uuid-s are required")
|
|
||||||
}
|
|
||||||
|
|
||||||
detach := CardLabel{
|
|
||||||
LabelUuid: label.LabelUuid,
|
|
||||||
UserUuid: userUuid,
|
|
||||||
MerchUuid: label.MerchUuid,
|
|
||||||
}
|
|
||||||
return s.repo.detachLabel(detach)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *service) getMerchLabels(userUuid, merchUuid string) ([]string, error) {
|
|
||||||
getLabels, err := s.repo.getAttachedLabelsByUuid(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response := make([]string, 0, len(getLabels))
|
|
||||||
for _, label := range getLabels {
|
|
||||||
response = append(response, label.LabelUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
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.Model(&User{}).Where("uuid = ?", user["uuid"]).Updates(&user).Error
|
return r.db.Where("uuid = ?", user["uuid"]).Updates(&user).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repo) delete(userUuid string) error {
|
func (r *repo) delete(userUuid string) error {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,106 @@
|
||||||
package grpcService
|
package grpcService
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
"io"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
|
"merch-parser-api/internal/shared"
|
||||||
pb "merch-parser-api/proto/taskProcessor"
|
pb "merch-parser-api/proto/taskProcessor"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type repoServer struct {
|
||||||
|
pb.UnimplementedTaskProcessorServer
|
||||||
|
taskProvider interfaces.TaskProvider
|
||||||
|
}
|
||||||
|
|
||||||
func NewGrpcServer(taskProvider interfaces.TaskProvider) *grpc.Server {
|
func NewGrpcServer(taskProvider interfaces.TaskProvider) *grpc.Server {
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
|
|
||||||
repoSrv := &repoServer{
|
repoSrv := &repoServer{
|
||||||
taskProvider: taskProvider,
|
taskProvider: taskProvider,
|
||||||
}
|
}
|
||||||
pb.RegisterTaskProcessorServer(srv, repoSrv)
|
|
||||||
|
|
||||||
|
pb.RegisterTaskProcessorServer(srv, repoSrv)
|
||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *repoServer) RequestTask(_ *emptypb.Empty, stream pb.TaskProcessor_RequestTaskServer) error {
|
||||||
|
tasks, err := r.taskProvider.PrepareTasks()
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Request task error")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, task := range tasks {
|
||||||
|
if err = stream.Send(&pb.Task{
|
||||||
|
MerchUuid: task.MerchUuid,
|
||||||
|
OriginSurugayaLink: task.OriginSurugayaLink,
|
||||||
|
OriginMandarakeLink: task.OriginMandarakeLink,
|
||||||
|
}); err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Stream send error")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *repoServer) SendResult(stream pb.TaskProcessor_SendResultServer) error {
|
||||||
|
saveInterval := time.Second * 2
|
||||||
|
batch := make([]shared.TaskResult, 0)
|
||||||
|
|
||||||
|
ticker := time.NewTicker(saveInterval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
if len(batch) > 0 {
|
||||||
|
err := r.taskProvider.InsertPrices(batch)
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Batch insert")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for {
|
||||||
|
response, err := stream.Recv()
|
||||||
|
if err == io.EOF {
|
||||||
|
log.Debug("gRPC EOF")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Receive")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
entry := shared.TaskResult{
|
||||||
|
MerchUuid: response.MerchUuid,
|
||||||
|
Origin: response.OriginName,
|
||||||
|
Price: response.Price,
|
||||||
|
}
|
||||||
|
|
||||||
|
batch = append(batch, entry)
|
||||||
|
log.WithField("response", entry).Debug("gRPC Server | Receive success")
|
||||||
|
}
|
||||||
|
|
||||||
|
close(done)
|
||||||
|
if len(batch) > 0 {
|
||||||
|
err := r.taskProvider.InsertPrices(batch)
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Last data batch insert")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
package grpcService
|
|
||||||
|
|
||||||
import (
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
"io"
|
|
||||||
"merch-parser-api/internal/interfaces"
|
|
||||||
"merch-parser-api/internal/shared"
|
|
||||||
pb "merch-parser-api/proto/taskProcessor"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type repoServer struct {
|
|
||||||
pb.UnimplementedTaskProcessorServer
|
|
||||||
taskProvider interfaces.TaskProvider
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repoServer) RequestTask(_ *emptypb.Empty, stream pb.TaskProcessor_RequestTaskServer) error {
|
|
||||||
tasks, err := r.taskProvider.PrepareTasks()
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Request task error")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, task := range tasks {
|
|
||||||
if err = stream.Send(&pb.Task{
|
|
||||||
MerchUuid: task.MerchUuid,
|
|
||||||
OriginSurugayaLink: task.OriginSurugayaLink,
|
|
||||||
OriginMandarakeLink: task.OriginMandarakeLink,
|
|
||||||
}); err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Stream send error")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repoServer) SendResult(stream pb.TaskProcessor_SendResultServer) error {
|
|
||||||
saveInterval := time.Second * 2
|
|
||||||
batch := make([]shared.TaskResult, 0)
|
|
||||||
|
|
||||||
ticker := time.NewTicker(saveInterval)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
done := make(chan struct{})
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
if len(batch) > 0 {
|
|
||||||
err := r.taskProvider.InsertPrices(batch)
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Batch insert")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
for {
|
|
||||||
response, err := stream.Recv()
|
|
||||||
if err == io.EOF {
|
|
||||||
log.Debug("gRPC EOF")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Receive")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
entry := shared.TaskResult{
|
|
||||||
MerchUuid: response.MerchUuid,
|
|
||||||
Origin: response.OriginName,
|
|
||||||
Price: response.Price,
|
|
||||||
}
|
|
||||||
|
|
||||||
batch = append(batch, entry)
|
|
||||||
log.WithField("response", entry).Debug("gRPC Server | Receive success")
|
|
||||||
}
|
|
||||||
|
|
||||||
close(done)
|
|
||||||
if len(batch) > 0 {
|
|
||||||
err := r.taskProvider.InsertPrices(batch)
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Last data batch insert")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package imagesProvider
|
|
||||||
|
|
||||||
import (
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
is "merch-parser-api/proto/imageStorage"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Handler struct{}
|
|
||||||
|
|
||||||
func NewClient(address string) is.ImageStorageClient {
|
|
||||||
var opts []grpc.DialOption
|
|
||||||
insec := grpc.WithTransportCredentials(insecure.NewCredentials())
|
|
||||||
opts = append(opts, insec)
|
|
||||||
|
|
||||||
conn, err := grpc.NewClient(address, opts...)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"address": address,
|
|
||||||
}).Debug("gRPC | API client")
|
|
||||||
|
|
||||||
return is.NewImageStorageClient(conn)
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
package interfaces
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
"net/url"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MinIO service replaced by imagesProvider
|
|
||||||
|
|
||||||
type MediaStorage interface {
|
|
||||||
CheckBucketExists(bucketName string) (bool, error)
|
|
||||||
Upload(ctx context.Context, bucket, object string, reader io.Reader, size int64) error
|
|
||||||
GetPublicLink(ctx context.Context, bucket, object string) (string, string, error)
|
|
||||||
GetPresignedLink(ctx context.Context, bucket, object string, expires time.Duration, params url.Values) (string, error)
|
|
||||||
Delete(ctx context.Context, bucket, object string) error
|
|
||||||
GetObjectEtag(ctx context.Context, bucketName, object string) (string, error)
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
import (
|
import "github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Utils interface {
|
type Utils interface {
|
||||||
IsEmail(email string) bool
|
IsEmail(email string) bool
|
||||||
|
|
@ -11,5 +8,4 @@ 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)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
package mediaStorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Handler struct {
|
|
||||||
*Service
|
|
||||||
}
|
|
||||||
|
|
||||||
type Deps struct {
|
|
||||||
Endpoint string
|
|
||||||
User string
|
|
||||||
Password string
|
|
||||||
Secure string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewHandler(deps Deps) *Handler {
|
|
||||||
secureMode := false
|
|
||||||
if deps.Secure == "true" {
|
|
||||||
secureMode = true
|
|
||||||
}
|
|
||||||
|
|
||||||
minioClient, err := minio.New(deps.Endpoint, &minio.Options{
|
|
||||||
Creds: credentials.NewStaticV4(deps.User, deps.Password, ""),
|
|
||||||
Secure: secureMode,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Fatal("Media storage | Failed to create minio client")
|
|
||||||
}
|
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"endpoint": deps.Endpoint,
|
|
||||||
"secure": secureMode,
|
|
||||||
}).Debug("Media storage | Created minio client")
|
|
||||||
|
|
||||||
return &Handler{
|
|
||||||
newService(minioClient, deps.Endpoint, secureMode),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
package mediaStorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"io"
|
|
||||||
"net/url"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
client *minio.Client
|
|
||||||
endpoint string
|
|
||||||
secureMode bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func newService(client *minio.Client, endpoint string, secureMode bool) *Service {
|
|
||||||
return &Service{
|
|
||||||
client: client,
|
|
||||||
endpoint: endpoint,
|
|
||||||
secureMode: secureMode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) CheckBucketExists(bucketName string) (bool, error) {
|
|
||||||
ctx := context.Background()
|
|
||||||
exists, err := s.client.BucketExists(ctx, bucketName)
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Fatal("Media storage | Failed to check bucket existence")
|
|
||||||
return exists, err
|
|
||||||
}
|
|
||||||
log.Infof("Media storage | Bucket %s exists", bucketName)
|
|
||||||
return exists, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Upload(ctx context.Context, bucket, object string, reader io.Reader, size int64) error {
|
|
||||||
_, err := s.client.PutObject(ctx, bucket, object, reader, size, minio.PutObjectOptions{ContentType: "image/jpeg"})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetPublicLink(ctx context.Context, bucket, object string) (string, string, error) {
|
|
||||||
stat, err := s.client.StatObject(ctx, bucket, object, minio.StatObjectOptions{})
|
|
||||||
if err != nil {
|
|
||||||
if err.Error() == minio.ToErrorResponse(err).Error() {
|
|
||||||
return "", "", nil
|
|
||||||
}
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"error": err,
|
|
||||||
"key": bucket + "/" + object,
|
|
||||||
}).Error("Media storage | Failed to get public link")
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
var scheme string
|
|
||||||
if s.secureMode {
|
|
||||||
scheme = "https"
|
|
||||||
} else {
|
|
||||||
scheme = "http"
|
|
||||||
}
|
|
||||||
|
|
||||||
link := fmt.Sprintf("%s://%s/%s/%s", scheme, strings.TrimRight(s.endpoint, "/"), bucket, object)
|
|
||||||
log.WithFields(log.Fields{"link": link}).Debug("Media storage | Get public link")
|
|
||||||
|
|
||||||
return link, stat.ETag, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetPresignedLink(ctx context.Context, bucket, object string, expires time.Duration, params url.Values) (string, error) {
|
|
||||||
presigned, err := s.client.PresignedGetObject(ctx, bucket, object, expires, params)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return presigned.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Delete(ctx context.Context, bucket, object string) error {
|
|
||||||
return s.client.RemoveObject(ctx, bucket, object, minio.RemoveObjectOptions{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetObjectEtag(ctx context.Context, bucketName, object string) (string, error) {
|
|
||||||
info, err := s.client.StatObject(ctx, bucketName, object, minio.StatObjectOptions{})
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return info.ETag, nil
|
|
||||||
}
|
|
||||||
|
|
@ -55,27 +55,4 @@ CREATE TABLE prices(
|
||||||
merch_uuid VARCHAR(36) NOT NULL,
|
merch_uuid VARCHAR(36) NOT NULL,
|
||||||
price INT NULL,
|
price INT NULL,
|
||||||
origin INT
|
origin INT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE labels(
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
||||||
updated_at TIMESTAMP WITH TIME ZONE NULL,
|
|
||||||
deleted_at TIMESTAMP WITH TIME ZONE NULL,
|
|
||||||
user_uuid VARCHAR(36) NOT NULL,
|
|
||||||
label_uuid VARCHAR(36) NOT NULL,
|
|
||||||
name VARCHAR(255),
|
|
||||||
color VARCHAR(32),
|
|
||||||
bg_color VARCHAR(32)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE card_labels (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
user_uuid VARCHAR(36) NOT NULL,
|
|
||||||
label_uuid VARCHAR(36) NOT NULL,
|
|
||||||
merch_uuid VARCHAR(36) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE card_labels
|
|
||||||
ADD CONSTRAINT card_labels_unique_user_label_merch
|
|
||||||
UNIQUE (user_uuid, label_uuid, merch_uuid);
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
syntax="proto3";
|
|
||||||
|
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
|
|
||||||
package imageStorage;
|
|
||||||
option go_package = "imageStorage/pkg/proto/imageStorage";
|
|
||||||
|
|
||||||
message UploadMerchImageRequest{
|
|
||||||
bytes imageData = 1;
|
|
||||||
string userUuid = 2;
|
|
||||||
string merchUuid = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UploadMerchImageResponse {
|
|
||||||
string fullImage = 1;
|
|
||||||
string thumbnail = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteImageRequest {
|
|
||||||
string userUuid = 1;
|
|
||||||
string merchUuid = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
service ImageStorage {
|
|
||||||
rpc UploadImage(UploadMerchImageRequest) returns (UploadMerchImageResponse);
|
|
||||||
rpc DeleteImage(DeleteImageRequest) returns (google.protobuf.Empty);
|
|
||||||
}
|
|
||||||
|
|
@ -1,261 +0,0 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.36.8
|
|
||||||
// protoc v6.32.1
|
|
||||||
// source: imageStorage.proto
|
|
||||||
|
|
||||||
package imageStorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
type UploadMerchImageRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
ImageData []byte `protobuf:"bytes,1,opt,name=imageData,proto3" json:"imageData,omitempty"`
|
|
||||||
UserUuid string `protobuf:"bytes,2,opt,name=userUuid,proto3" json:"userUuid,omitempty"`
|
|
||||||
MerchUuid string `protobuf:"bytes,3,opt,name=merchUuid,proto3" json:"merchUuid,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) Reset() {
|
|
||||||
*x = UploadMerchImageRequest{}
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UploadMerchImageRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[0]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use UploadMerchImageRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*UploadMerchImageRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_imageStorage_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) GetImageData() []byte {
|
|
||||||
if x != nil {
|
|
||||||
return x.ImageData
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) GetUserUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.UserUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) GetMerchUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.MerchUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type UploadMerchImageResponse struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
FullImage string `protobuf:"bytes,1,opt,name=fullImage,proto3" json:"fullImage,omitempty"`
|
|
||||||
Thumbnail string `protobuf:"bytes,2,opt,name=thumbnail,proto3" json:"thumbnail,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) Reset() {
|
|
||||||
*x = UploadMerchImageResponse{}
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UploadMerchImageResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[1]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use UploadMerchImageResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*UploadMerchImageResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_imageStorage_proto_rawDescGZIP(), []int{1}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) GetFullImage() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.FullImage
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) GetThumbnail() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Thumbnail
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteImageRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
UserUuid string `protobuf:"bytes,1,opt,name=userUuid,proto3" json:"userUuid,omitempty"`
|
|
||||||
MerchUuid string `protobuf:"bytes,2,opt,name=merchUuid,proto3" json:"merchUuid,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) Reset() {
|
|
||||||
*x = DeleteImageRequest{}
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DeleteImageRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[2]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DeleteImageRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DeleteImageRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_imageStorage_proto_rawDescGZIP(), []int{2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) GetUserUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.UserUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) GetMerchUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.MerchUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_imageStorage_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
const file_imageStorage_proto_rawDesc = "" +
|
|
||||||
"\n" +
|
|
||||||
"\x12imageStorage.proto\x12\fimageStorage\x1a\x1bgoogle/protobuf/empty.proto\"q\n" +
|
|
||||||
"\x17UploadMerchImageRequest\x12\x1c\n" +
|
|
||||||
"\timageData\x18\x01 \x01(\fR\timageData\x12\x1a\n" +
|
|
||||||
"\buserUuid\x18\x02 \x01(\tR\buserUuid\x12\x1c\n" +
|
|
||||||
"\tmerchUuid\x18\x03 \x01(\tR\tmerchUuid\"V\n" +
|
|
||||||
"\x18UploadMerchImageResponse\x12\x1c\n" +
|
|
||||||
"\tfullImage\x18\x01 \x01(\tR\tfullImage\x12\x1c\n" +
|
|
||||||
"\tthumbnail\x18\x02 \x01(\tR\tthumbnail\"N\n" +
|
|
||||||
"\x12DeleteImageRequest\x12\x1a\n" +
|
|
||||||
"\buserUuid\x18\x01 \x01(\tR\buserUuid\x12\x1c\n" +
|
|
||||||
"\tmerchUuid\x18\x02 \x01(\tR\tmerchUuid2\xb5\x01\n" +
|
|
||||||
"\fImageStorage\x12\\\n" +
|
|
||||||
"\vUploadImage\x12%.imageStorage.UploadMerchImageRequest\x1a&.imageStorage.UploadMerchImageResponse\x12G\n" +
|
|
||||||
"\vDeleteImage\x12 .imageStorage.DeleteImageRequest\x1a\x16.google.protobuf.EmptyB%Z#imageStorage/pkg/proto/imageStorageb\x06proto3"
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_imageStorage_proto_rawDescOnce sync.Once
|
|
||||||
file_imageStorage_proto_rawDescData []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_imageStorage_proto_rawDescGZIP() []byte {
|
|
||||||
file_imageStorage_proto_rawDescOnce.Do(func() {
|
|
||||||
file_imageStorage_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_imageStorage_proto_rawDesc), len(file_imageStorage_proto_rawDesc)))
|
|
||||||
})
|
|
||||||
return file_imageStorage_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_imageStorage_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
|
||||||
var file_imageStorage_proto_goTypes = []any{
|
|
||||||
(*UploadMerchImageRequest)(nil), // 0: imageStorage.UploadMerchImageRequest
|
|
||||||
(*UploadMerchImageResponse)(nil), // 1: imageStorage.UploadMerchImageResponse
|
|
||||||
(*DeleteImageRequest)(nil), // 2: imageStorage.DeleteImageRequest
|
|
||||||
(*emptypb.Empty)(nil), // 3: google.protobuf.Empty
|
|
||||||
}
|
|
||||||
var file_imageStorage_proto_depIdxs = []int32{
|
|
||||||
0, // 0: imageStorage.ImageStorage.UploadImage:input_type -> imageStorage.UploadMerchImageRequest
|
|
||||||
2, // 1: imageStorage.ImageStorage.DeleteImage:input_type -> imageStorage.DeleteImageRequest
|
|
||||||
1, // 2: imageStorage.ImageStorage.UploadImage:output_type -> imageStorage.UploadMerchImageResponse
|
|
||||||
3, // 3: imageStorage.ImageStorage.DeleteImage:output_type -> google.protobuf.Empty
|
|
||||||
2, // [2:4] is the sub-list for method output_type
|
|
||||||
0, // [0:2] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_imageStorage_proto_init() }
|
|
||||||
func file_imageStorage_proto_init() {
|
|
||||||
if File_imageStorage_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_imageStorage_proto_rawDesc), len(file_imageStorage_proto_rawDesc)),
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 3,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 1,
|
|
||||||
},
|
|
||||||
GoTypes: file_imageStorage_proto_goTypes,
|
|
||||||
DependencyIndexes: file_imageStorage_proto_depIdxs,
|
|
||||||
MessageInfos: file_imageStorage_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_imageStorage_proto = out.File
|
|
||||||
file_imageStorage_proto_goTypes = nil
|
|
||||||
file_imageStorage_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
|
||||||
// - protoc v6.32.1
|
|
||||||
// source: imageStorage.proto
|
|
||||||
|
|
||||||
package imageStorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
ImageStorage_UploadImage_FullMethodName = "/imageStorage.ImageStorage/UploadImage"
|
|
||||||
ImageStorage_DeleteImage_FullMethodName = "/imageStorage.ImageStorage/DeleteImage"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ImageStorageClient is the client API for ImageStorage service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
type ImageStorageClient interface {
|
|
||||||
UploadImage(ctx context.Context, in *UploadMerchImageRequest, opts ...grpc.CallOption) (*UploadMerchImageResponse, error)
|
|
||||||
DeleteImage(ctx context.Context, in *DeleteImageRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type imageStorageClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewImageStorageClient(cc grpc.ClientConnInterface) ImageStorageClient {
|
|
||||||
return &imageStorageClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *imageStorageClient) UploadImage(ctx context.Context, in *UploadMerchImageRequest, opts ...grpc.CallOption) (*UploadMerchImageResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(UploadMerchImageResponse)
|
|
||||||
err := c.cc.Invoke(ctx, ImageStorage_UploadImage_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *imageStorageClient) DeleteImage(ctx context.Context, in *DeleteImageRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(emptypb.Empty)
|
|
||||||
err := c.cc.Invoke(ctx, ImageStorage_DeleteImage_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageStorageServer is the server API for ImageStorage service.
|
|
||||||
// All implementations must embed UnimplementedImageStorageServer
|
|
||||||
// for forward compatibility.
|
|
||||||
type ImageStorageServer interface {
|
|
||||||
UploadImage(context.Context, *UploadMerchImageRequest) (*UploadMerchImageResponse, error)
|
|
||||||
DeleteImage(context.Context, *DeleteImageRequest) (*emptypb.Empty, error)
|
|
||||||
mustEmbedUnimplementedImageStorageServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedImageStorageServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedImageStorageServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedImageStorageServer) UploadImage(context.Context, *UploadMerchImageRequest) (*UploadMerchImageResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UploadImage not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedImageStorageServer) DeleteImage(context.Context, *DeleteImageRequest) (*emptypb.Empty, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteImage not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedImageStorageServer) mustEmbedUnimplementedImageStorageServer() {}
|
|
||||||
func (UnimplementedImageStorageServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeImageStorageServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to ImageStorageServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeImageStorageServer interface {
|
|
||||||
mustEmbedUnimplementedImageStorageServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterImageStorageServer(s grpc.ServiceRegistrar, srv ImageStorageServer) {
|
|
||||||
// If the following call pancis, it indicates UnimplementedImageStorageServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&ImageStorage_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _ImageStorage_UploadImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(UploadMerchImageRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ImageStorageServer).UploadImage(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: ImageStorage_UploadImage_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ImageStorageServer).UploadImage(ctx, req.(*UploadMerchImageRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _ImageStorage_DeleteImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(DeleteImageRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ImageStorageServer).DeleteImage(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: ImageStorage_DeleteImage_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ImageStorageServer).DeleteImage(ctx, req.(*DeleteImageRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageStorage_ServiceDesc is the grpc.ServiceDesc for ImageStorage service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var ImageStorage_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "imageStorage.ImageStorage",
|
|
||||||
HandlerType: (*ImageStorageServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "UploadImage",
|
|
||||||
Handler: _ImageStorage_UploadImage_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "DeleteImage",
|
|
||||||
Handler: _ImageStorage_DeleteImage_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "imageStorage.proto",
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue