feat: query for usertitles written
This commit is contained in:
parent
ba68b5ee04
commit
32566fe7a2
8 changed files with 497 additions and 250 deletions
|
|
@ -158,78 +158,6 @@ func (s Server) GetStudio(ctx context.Context, id int64) (*oapi.Studio, error) {
|
|||
return &oapi_studio, nil
|
||||
}
|
||||
|
||||
func (s Server) mapTitle(ctx context.Context, title sqlc.SearchTitlesRow) (oapi.Title, error) {
|
||||
|
||||
// var oapi_title oapi.Title
|
||||
|
||||
title_names := make(map[string][]string, 0)
|
||||
err := json.Unmarshal(title.TitleNames, &title_names)
|
||||
if err != nil {
|
||||
return oapi.Title{}, fmt.Errorf("unmarshal TitleNames: %v", err)
|
||||
}
|
||||
|
||||
episodes_lens := make(map[string]float64, 0)
|
||||
err = json.Unmarshal(title.EpisodesLen, &episodes_lens)
|
||||
if err != nil {
|
||||
return oapi.Title{}, fmt.Errorf("unmarshal EpisodesLen: %v", err)
|
||||
}
|
||||
|
||||
oapi_tag_names := make(oapi.Tags, 0)
|
||||
err = json.Unmarshal(title.TagNames, &oapi_tag_names)
|
||||
if err != nil {
|
||||
return oapi.Title{}, fmt.Errorf("unmarshalling title_tag: %v", err)
|
||||
}
|
||||
|
||||
var oapi_studio oapi.Studio
|
||||
|
||||
oapi_studio.Id = title.StudioID
|
||||
if title.StudioName != nil {
|
||||
oapi_studio.Name = *title.StudioName
|
||||
}
|
||||
oapi_studio.Description = title.StudioDesc
|
||||
if title.StudioIllustID != nil {
|
||||
oapi_studio.Poster.Id = title.StudioIllustID
|
||||
oapi_studio.Poster.ImagePath = title.StudioImagePath
|
||||
oapi_studio.Poster.StorageType = &title.StudioStorageType
|
||||
}
|
||||
|
||||
var oapi_image oapi.Image
|
||||
|
||||
if title.PosterID != nil {
|
||||
oapi_image.Id = title.PosterID
|
||||
oapi_image.ImagePath = title.TitleImagePath
|
||||
oapi_image.StorageType = &title.TitleStorageType
|
||||
}
|
||||
|
||||
var release_season oapi.ReleaseSeason
|
||||
if title.ReleaseSeason != nil {
|
||||
release_season = oapi.ReleaseSeason(*title.ReleaseSeason)
|
||||
}
|
||||
|
||||
oapi_status, err := TitleStatus2oapi(&title.TitleStatus)
|
||||
if err != nil {
|
||||
return oapi.Title{}, fmt.Errorf("TitleStatus2oapi: %v", err)
|
||||
}
|
||||
oapi_title := oapi.Title{
|
||||
EpisodesAired: title.EpisodesAired,
|
||||
EpisodesAll: title.EpisodesAired,
|
||||
EpisodesLen: &episodes_lens,
|
||||
Id: title.ID,
|
||||
Poster: &oapi_image,
|
||||
Rating: title.Rating,
|
||||
RatingCount: title.RatingCount,
|
||||
ReleaseSeason: &release_season,
|
||||
ReleaseYear: title.ReleaseYear,
|
||||
Studio: &oapi_studio,
|
||||
Tags: oapi_tag_names,
|
||||
TitleNames: title_names,
|
||||
TitleStatus: oapi_status,
|
||||
// AdditionalProperties:
|
||||
}
|
||||
|
||||
return oapi_title, nil
|
||||
}
|
||||
|
||||
func (s Server) GetTitlesTitleId(ctx context.Context, request oapi.GetTitlesTitleIdRequestObject) (oapi.GetTitlesTitleIdResponseObject, error) {
|
||||
var oapi_title oapi.Title
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue