fix: type cast fixed
This commit is contained in:
parent
d1937fcbd7
commit
b42fb34903
6 changed files with 84 additions and 65 deletions
|
|
@ -42,7 +42,7 @@ func (s Server) mapTitle(ctx context.Context, title sqlc.GetTitleByIDRow) (oapi.
|
|||
return oapi.Title{}, fmt.Errorf("unmarshal TitleNames: %v", err)
|
||||
}
|
||||
|
||||
if title.EpisodesLen != nil && len(title.EpisodesLen) > 0 {
|
||||
if len(title.EpisodesLen) > 0 {
|
||||
episodes_lens := make(map[string]float64, 0)
|
||||
err = json.Unmarshal(title.EpisodesLen, &episodes_lens)
|
||||
if err != nil {
|
||||
|
|
@ -99,3 +99,23 @@ func parseInt64(s string) (int32, error) {
|
|||
i, err := strconv.ParseInt(s, 10, 64)
|
||||
return int32(i), err
|
||||
}
|
||||
|
||||
func TitleStatus2Sqlc(s *[]oapi.TitleStatus) ([]sqlc.TitleStatusT, error) {
|
||||
var sqlc_status []sqlc.TitleStatusT
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
for _, t := range *s {
|
||||
switch t {
|
||||
case oapi.TitleStatusFinished:
|
||||
sqlc_status = append(sqlc_status, sqlc.TitleStatusTFinished)
|
||||
case oapi.TitleStatusOngoing:
|
||||
sqlc_status = append(sqlc_status, sqlc.TitleStatusTOngoing)
|
||||
case oapi.TitleStatusPlanned:
|
||||
sqlc_status = append(sqlc_status, sqlc.TitleStatusTPlanned)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected tittle status: %s", t)
|
||||
}
|
||||
}
|
||||
return sqlc_status, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue