Compare commits
No commits in common. "fe54b6182257d8cc96aa5aff0cf14b17b4299189" and "96611825bc0b1511eb4257bc4a9dee846793f613" have entirely different histories.
fe54b61822
...
96611825bc
3 changed files with 16 additions and 55 deletions
|
|
@ -90,12 +90,10 @@ func (s Server) GetImage(ctx context.Context, id int64) (oapi.Image, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return oapi_image, fmt.Errorf("query GetImageByID: %v", err)
|
return oapi_image, fmt.Errorf("query GetImageByID: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//can cast and dont use brain cause all this fiels required
|
//can cast and dont use brain cause all this fiels required
|
||||||
oapi_image.Id = &sqlc_image.ID
|
oapi_image.Id = &sqlc_image.ID
|
||||||
oapi_image.ImagePath = &sqlc_image.ImagePath
|
oapi_image.ImagePath = &sqlc_image.ImagePath
|
||||||
storageTypeStr := string(sqlc_image.StorageType) // или fmt.Sprint(...), если int
|
oapi_image.StorageType = (*string)(&sqlc_image.StorageType)
|
||||||
oapi_image.StorageType = &storageTypeStr
|
|
||||||
|
|
||||||
return oapi_image, nil
|
return oapi_image, nil
|
||||||
}
|
}
|
||||||
|
|
@ -152,28 +150,22 @@ func (s Server) mapTitle(ctx context.Context, title sqlc.Title) (oapi.Title, err
|
||||||
return oapi_title, fmt.Errorf("GetStudio: %v", err)
|
return oapi_title, fmt.Errorf("GetStudio: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if title.ReleaseSeason != nil {
|
oapi_title = oapi.Title{
|
||||||
rs := oapi.ReleaseSeason(*title.ReleaseSeason)
|
|
||||||
oapi_title.ReleaseSeason = &rs
|
Id: title.ID,
|
||||||
} else {
|
Poster: &oapi_image,
|
||||||
oapi_title.ReleaseSeason = nil
|
Rating: title.Rating,
|
||||||
|
RatingCount: title.RatingCount,
|
||||||
|
ReleaseSeason: (*oapi.ReleaseSeason)(title.ReleaseSeason),
|
||||||
|
ReleaseYear: title.ReleaseYear,
|
||||||
|
Studio: &oapi_studio,
|
||||||
|
Tags: oapi_tag_names,
|
||||||
|
TitleNames: title_names,
|
||||||
|
TitleStatus: (*oapi.TitleStatus)(&title.TitleStatus),
|
||||||
|
EpisodesAired: title.EpisodesAired,
|
||||||
|
EpisodesAll: title.EpisodesAll,
|
||||||
|
EpisodesLen: &episodes_lens,
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := oapi.TitleStatus(title.TitleStatus)
|
|
||||||
oapi_title.TitleStatus = &ts
|
|
||||||
|
|
||||||
oapi_title.Id = title.ID
|
|
||||||
oapi_title.Poster = &oapi_image
|
|
||||||
oapi_title.Rating = title.Rating
|
|
||||||
oapi_title.RatingCount = title.RatingCount
|
|
||||||
oapi_title.ReleaseYear = title.ReleaseYear
|
|
||||||
oapi_title.Studio = &oapi_studio
|
|
||||||
oapi_title.Tags = oapi_tag_names
|
|
||||||
oapi_title.TitleNames = title_names
|
|
||||||
oapi_title.EpisodesAired = title.EpisodesAired
|
|
||||||
oapi_title.EpisodesAll = title.EpisodesAll
|
|
||||||
oapi_title.EpisodesLen = &episodes_lens
|
|
||||||
|
|
||||||
return oapi_title, nil
|
return oapi_title, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,6 @@ CREATE TABLE images (
|
||||||
image_path text UNIQUE NOT NULL
|
image_path text UNIQUE NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE reviews (
|
|
||||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
||||||
data text NOT NULL,
|
|
||||||
rating int CHECK (rating >= 0 AND rating <= 10),
|
|
||||||
illust_id bigint REFERENCES images (id),
|
|
||||||
user_id bigint REFERENCES users (id),
|
|
||||||
title_id bigint REFERENCES titles (id),
|
|
||||||
created_at timestamptz DEFAULT NOW()
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE review_images (
|
|
||||||
PRIMARY KEY (review_id, image_id),
|
|
||||||
review_id bigint NOT NULL REFERENCES reviews(id) ON DELETE CASCADE,
|
|
||||||
image_id bigint NOT NULL REFERENCES images(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
avatar_id bigint REFERENCES images (id),
|
avatar_id bigint REFERENCES images (id),
|
||||||
|
|
|
||||||
|
|
@ -208,21 +208,6 @@ type Provider struct {
|
||||||
Credentials []byte `json:"credentials"`
|
Credentials []byte `json:"credentials"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Review struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Data string `json:"data"`
|
|
||||||
Rating *int32 `json:"rating"`
|
|
||||||
IllustID *int64 `json:"illust_id"`
|
|
||||||
UserID *int64 `json:"user_id"`
|
|
||||||
TitleID *int64 `json:"title_id"`
|
|
||||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReviewImage struct {
|
|
||||||
ReviewID int64 `json:"review_id"`
|
|
||||||
ImageID int64 `json:"image_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Signal struct {
|
type Signal struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TitleID *int64 `json:"title_id"`
|
TitleID *int64 `json:"title_id"`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue