feat:
This commit is contained in:
parent
b400f22844
commit
cbbc2c179d
3 changed files with 74 additions and 66 deletions
|
|
@ -103,33 +103,23 @@ func (s Server) GetUsersUserIdTitles(ctx context.Context, request oapi.GetUsersU
|
|||
return oapi.GetUsersUserIdTitles400Response{}, err
|
||||
}
|
||||
|
||||
// Forward bool `json:"forward"`
|
||||
// SortBy string `json:"sort_by"`
|
||||
// CursorYear *int32 `json:"cursor_year"`
|
||||
// CursorID *int64 `json:"cursor_id"`
|
||||
// CursorRating *float64 `json:"cursor_rating"`
|
||||
// Word *string `json:"word"`
|
||||
// Ongoing string `json:"ongoing"`
|
||||
// Planned string `json:"planned"`
|
||||
// Dropped string `json:"dropped"`
|
||||
// InProgress string `json:"in-progress"`
|
||||
// Finished string `json:"finished"`
|
||||
// Rate *int32 `json:"rate"`
|
||||
// Rating *float64 `json:"rating"`
|
||||
// ReleaseYear *int32 `json:"release_year"`
|
||||
// ReleaseSeason *ReleaseSeasonT `json:"release_season"`
|
||||
// Limit *int32 `json:"limit"`
|
||||
params := sqlc.SearchTitlesParams{
|
||||
Word: word,
|
||||
Ongoing: status.ongoing,
|
||||
Finished: status.finished,
|
||||
Planned: status.planned,
|
||||
Rating: request.Params.Rating,
|
||||
ReleaseYear: request.Params.ReleaseYear,
|
||||
ReleaseSeason: season,
|
||||
Forward: true,
|
||||
SortBy: "id",
|
||||
Limit: request.Params.Limit,
|
||||
params := sqlc.SearchUserTitlesParams{
|
||||
Forward: true,
|
||||
SortBy: "id",
|
||||
// CursorYear :
|
||||
// CursorID *int64 `json:"cursor_id"`
|
||||
// CursorRating *float64 `json:"cursor_rating"`
|
||||
// Word *string `json:"word"`
|
||||
// Ongoing string `json:"ongoing"`
|
||||
// Planned string `json:"planned"`
|
||||
// Dropped string `json:"dropped"`
|
||||
// InProgress string `json:"in-progress"`
|
||||
// Finished string `json:"finished"`
|
||||
// Rate *int32 `json:"rate"`
|
||||
// Rating *float64 `json:"rating"`
|
||||
// ReleaseYear *int32 `json:"release_year"`
|
||||
// ReleaseSeason *ReleaseSeasonT `json:"release_season"`
|
||||
// Limit *int32 `json:"limit"`
|
||||
}
|
||||
|
||||
if request.Params.SortForward != nil {
|
||||
|
|
@ -141,32 +131,42 @@ func (s Server) GetUsersUserIdTitles(ctx context.Context, request oapi.GetUsersU
|
|||
err := ParseCursorInto(string(*request.Params.Sort), string(*request.Params.Cursor), ¶ms)
|
||||
if err != nil {
|
||||
log.Errorf("%v", err)
|
||||
return oapi.GetTitles400Response{}, nil
|
||||
return oapi.GetUsersUserIdTitles400Response{}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_sqlc_title := sqlc.SearchTitlesRow{
|
||||
ID: sqlc_title.ID,
|
||||
StudioID: sqlc_title.StudioID,
|
||||
PosterID: sqlc_title.PosterID,
|
||||
TitleStatus: sqlc_title.TitleStatus,
|
||||
Rating: sqlc_title.Rating,
|
||||
RatingCount: sqlc_title.RatingCount,
|
||||
ReleaseYear: sqlc_title.ReleaseYear,
|
||||
ReleaseSeason: sqlc_title.ReleaseSeason,
|
||||
Season: sqlc_title.Season,
|
||||
EpisodesAired: sqlc_title.EpisodesAired,
|
||||
EpisodesAll: sqlc_title.EpisodesAll,
|
||||
EpisodesLen: sqlc_title.EpisodesLen,
|
||||
TitleStorageType: sqlc_title.TitleStorageType,
|
||||
TitleImagePath: sqlc_title.TitleImagePath,
|
||||
TagNames: sqlc_title.TitleNames,
|
||||
StudioName: sqlc_title.StudioName,
|
||||
StudioIllustID: sqlc_title.StudioIllustID,
|
||||
StudioDesc: sqlc_title.StudioDesc,
|
||||
StudioStorageType: sqlc_title.StudioStorageType,
|
||||
StudioImagePath: sqlc_title.StudioImagePath,
|
||||
// param = nil means it will not be used
|
||||
titles, err := s.db.SearchUserTitles(ctx, params)
|
||||
if err != nil {
|
||||
log.Errorf("%v", err)
|
||||
return oapi.GetUsersUserIdTitles500Response{}, nil
|
||||
}
|
||||
if len(titles) == 0 {
|
||||
return oapi.GetUsersUserIdTitles204Response{}, nil
|
||||
}
|
||||
for _, title := range titles {
|
||||
_sqlc_title := sqlc.SearchTitlesRow{
|
||||
ID: sqlc_title.ID,
|
||||
StudioID: sqlc_title.StudioID,
|
||||
PosterID: sqlc_title.PosterID,
|
||||
TitleStatus: sqlc_title.TitleStatus,
|
||||
Rating: sqlc_title.Rating,
|
||||
RatingCount: sqlc_title.RatingCount,
|
||||
ReleaseYear: sqlc_title.ReleaseYear,
|
||||
ReleaseSeason: sqlc_title.ReleaseSeason,
|
||||
Season: sqlc_title.Season,
|
||||
EpisodesAired: sqlc_title.EpisodesAired,
|
||||
EpisodesAll: sqlc_title.EpisodesAll,
|
||||
EpisodesLen: sqlc_title.EpisodesLen,
|
||||
TitleStorageType: sqlc_title.TitleStorageType,
|
||||
TitleImagePath: sqlc_title.TitleImagePath,
|
||||
TagNames: sqlc_title.TitleNames,
|
||||
StudioName: sqlc_title.StudioName,
|
||||
StudioIllustID: sqlc_title.StudioIllustID,
|
||||
StudioDesc: sqlc_title.StudioDesc,
|
||||
StudioStorageType: sqlc_title.StudioStorageType,
|
||||
StudioImagePath: sqlc_title.StudioImagePath,
|
||||
}
|
||||
}
|
||||
|
||||
return oapi.GetUsersUserIdTitles200JSONResponse(userTitles), nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue