From 4c7d03cddc2d24ccf231d2cc2f31330f291a9e4f Mon Sep 17 00:00:00 2001 From: Iron_Felix Date: Tue, 25 Nov 2025 03:20:39 +0300 Subject: [PATCH] feat: --- api/_build/openapi.yaml | 4 ++++ api/api.gen.go | 17 ++++++++++++++--- api/schemas/Image.yaml | 2 +- api/schemas/enums/StorageType.yaml | 5 +++++ modules/backend/handlers/users.go | 2 +- modules/backend/queries.sql | 2 +- sql/sqlc.yaml | 2 ++ 7 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 api/schemas/enums/StorageType.yaml diff --git a/api/_build/openapi.yaml b/api/_build/openapi.yaml index aa96593..d2f231d 100644 --- a/api/_build/openapi.yaml +++ b/api/_build/openapi.yaml @@ -412,6 +412,10 @@ components: format: int64 storage_type: type: string + description: Image storage type + enum: + - s3 + - local image_path: type: string TitleStatus: diff --git a/api/api.gen.go b/api/api.gen.go index b092742..5e0ddb5 100644 --- a/api/api.gen.go +++ b/api/api.gen.go @@ -16,6 +16,12 @@ import ( openapi_types "github.com/oapi-codegen/runtime/types" ) +// Defines values for ImageStorageType. +const ( + Local ImageStorageType = "local" + S3 ImageStorageType = "s3" +) + // Defines values for ReleaseSeason. const ( Fall ReleaseSeason = "fall" @@ -55,11 +61,16 @@ type CursorObj struct { // Image defines model for Image. type Image struct { - Id *int64 `json:"id,omitempty"` - ImagePath *string `json:"image_path,omitempty"` - StorageType *string `json:"storage_type,omitempty"` + Id *int64 `json:"id,omitempty"` + ImagePath *string `json:"image_path,omitempty"` + + // StorageType Image storage type + StorageType *ImageStorageType `json:"storage_type,omitempty"` } +// ImageStorageType Image storage type +type ImageStorageType string + // ReleaseSeason Title release season type ReleaseSeason string diff --git a/api/schemas/Image.yaml b/api/schemas/Image.yaml index 4ae3cb7..3fb520b 100644 --- a/api/schemas/Image.yaml +++ b/api/schemas/Image.yaml @@ -5,6 +5,6 @@ properties: type: integer format: int64 storage_type: - type: string + $ref: './enums/StorageType.yaml' image_path: type: string diff --git a/api/schemas/enums/StorageType.yaml b/api/schemas/enums/StorageType.yaml new file mode 100644 index 0000000..1984a87 --- /dev/null +++ b/api/schemas/enums/StorageType.yaml @@ -0,0 +1,5 @@ +type: string +description: Image storage type +enum: + - s3 + - local \ No newline at end of file diff --git a/modules/backend/handlers/users.go b/modules/backend/handlers/users.go index 23fda62..9204eb9 100644 --- a/modules/backend/handlers/users.go +++ b/modules/backend/handlers/users.go @@ -141,7 +141,7 @@ func UserTitleStatus2Sqlc1(s *oapi.UserTitleStatus) (*sqlc.UsertitleStatusT, err case oapi.UserTitleStatusPlanned: sqlc_status = sqlc.UsertitleStatusTPlanned default: - return nil, fmt.Errorf("unexpected tittle status: %s", s) + return nil, fmt.Errorf("unexpected tittle status: %s", *s) } return &sqlc_status, nil diff --git a/modules/backend/queries.sql b/modules/backend/queries.sql index 450e0a7..b9e05c1 100644 --- a/modules/backend/queries.sql +++ b/modules/backend/queries.sql @@ -334,7 +334,7 @@ WHERE sqlc.narg('usertitle_statuses')::usertitle_status_t[] IS NULL OR array_length(sqlc.narg('usertitle_statuses')::usertitle_status_t[], 1) IS NULL OR array_length(sqlc.narg('usertitle_statuses')::usertitle_status_t[], 1) = 0 - OR t.title_status = ANY(sqlc.narg('usertitle_statuses')::usertitle_status_t[]) + OR u.status = ANY(sqlc.narg('usertitle_statuses')::usertitle_status_t[]) ) AND (sqlc.narg('rate')::int IS NULL OR u.rate >= sqlc.narg('rate')::int) AND (sqlc.narg('rating')::float IS NULL OR t.rating >= sqlc.narg('rating')::float) diff --git a/sql/sqlc.yaml b/sql/sqlc.yaml index 3338c35..f26cf92 100644 --- a/sql/sqlc.yaml +++ b/sql/sqlc.yaml @@ -14,6 +14,8 @@ sql: emit_pointers_for_null_types: true emit_empty_slices: true #slices returned by :many queries will be empty instead of nil overrides: + - column: "titles.title_storage_type" + go_type: "*string" - db_type: "jsonb" go_type: "encoding/json.RawMessage" - db_type: "uuid"