Merge branch 'dev-ars' into dev
This commit is contained in:
commit
fe54b61822
3 changed files with 55 additions and 16 deletions
|
|
@ -90,10 +90,12 @@ func (s Server) GetImage(ctx context.Context, id int64) (oapi.Image, error) {
|
|||
if err != nil {
|
||||
return oapi_image, fmt.Errorf("query GetImageByID: %v", err)
|
||||
}
|
||||
|
||||
//can cast and dont use brain cause all this fiels required
|
||||
oapi_image.Id = &sqlc_image.ID
|
||||
oapi_image.ImagePath = &sqlc_image.ImagePath
|
||||
oapi_image.StorageType = (*string)(&sqlc_image.StorageType)
|
||||
storageTypeStr := string(sqlc_image.StorageType) // или fmt.Sprint(...), если int
|
||||
oapi_image.StorageType = &storageTypeStr
|
||||
|
||||
return oapi_image, nil
|
||||
}
|
||||
|
|
@ -150,22 +152,28 @@ func (s Server) mapTitle(ctx context.Context, title sqlc.Title) (oapi.Title, err
|
|||
return oapi_title, fmt.Errorf("GetStudio: %v", err)
|
||||
}
|
||||
|
||||
oapi_title = oapi.Title{
|
||||
|
||||
Id: title.ID,
|
||||
Poster: &oapi_image,
|
||||
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,
|
||||
if title.ReleaseSeason != nil {
|
||||
rs := oapi.ReleaseSeason(*title.ReleaseSeason)
|
||||
oapi_title.ReleaseSeason = &rs
|
||||
} else {
|
||||
oapi_title.ReleaseSeason = nil
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,22 @@ CREATE TABLE images (
|
|||
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 (
|
||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
avatar_id bigint REFERENCES images (id),
|
||||
|
|
|
|||
|
|
@ -208,6 +208,21 @@ type Provider struct {
|
|||
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 {
|
||||
ID int64 `json:"id"`
|
||||
TitleID *int64 `json:"title_id"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue