Skip to content

Commit

Permalink
fix: add UpdateSOSPost return time
Browse files Browse the repository at this point in the history
  • Loading branch information
barabobBOB committed May 1, 2024
1 parent 49c720d commit baa72a3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions internal/postgres/sos_post_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,12 @@ func FindSOSPostByID(ctx context.Context, tx *database.Tx, id int) (*sospost.SOS
} else {
sosPost.Media = media.ViewListForSOSPost{}
}
if err := json.Unmarshal(conditionsData, &sosPost.Conditions); err != nil {
return nil, pnd.FromPostgresError(err)
if len(conditionsData) > 0 {
if err := json.Unmarshal(conditionsData, &sosPost.Conditions); err != nil {
return nil, pnd.FromPostgresError(err)
}
} else {
sosPost.Conditions = soscondition.ViewListForSOSPost{}
}

return &sosPost, nil
Expand Down Expand Up @@ -488,7 +492,10 @@ func UpdateSOSPost(
care_type,
carer_gender,
reward_type,
thumbnail_id
thumbnail_id,
created_at,
updated_at
`

if err := tx.QueryRowContext(ctx, query,
Expand All @@ -498,7 +505,7 @@ func UpdateSOSPost(
request.CareType,
request.CarerGender,
request.RewardType,
request.ImageIDs[0],
setThumbnailID(request.ImageIDs),
request.ID,
).Scan(
&sosPost.ID,
Expand All @@ -510,6 +517,8 @@ func UpdateSOSPost(
&sosPost.CarerGender,
&sosPost.RewardType,
&sosPost.ThumbnailID,
&sosPost.CreatedAt,
&sosPost.UpdatedAt,
); err != nil {
return nil, pnd.FromPostgresError(err)
}
Expand Down

0 comments on commit baa72a3

Please sign in to comment.