Skip to content

Commit

Permalink
Merge pull request #51 from openhacku-team-a/milestone-cond-fix-0316
Browse files Browse the repository at this point in the history
🐛 (handler/milestone)use UserID from middleware in update
  • Loading branch information
Shion1305 authored Mar 16, 2024
2 parents 492cd15 + 5a6e735 commit 3f9ad4c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions svc/pkg/handler/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"a-project-backend/gen/gModel"
"a-project-backend/gen/gQuery"
"a-project-backend/svc/pkg/domain/model/pkg_time"
"a-project-backend/svc/pkg/middleware"
"io"

"github.com/google/uuid"
Expand Down Expand Up @@ -53,7 +54,7 @@ func (m MileStone) PostMileStone() gin.HandlerFunc {
}
target := gModel.Milestone{
MilestoneID: uuid.New().String(),
UserID: milestoneCreateRequest.Milestone.UserId,
UserID: c.Param(middleware.AuthorizedUserIDField),
Title: milestoneCreateRequest.Milestone.Title,
Content: milestoneCreateRequest.Milestone.Content,
ImageHash: "",
Expand Down Expand Up @@ -104,7 +105,10 @@ func (m MileStone) UpdateMileStone() gin.HandlerFunc {
c.AbortWithStatusJSON(500, gin.H{"error": err.Error()})
}

_, err = m.q.Milestone.WithContext(c).Where(m.q.Milestone.MilestoneID.Eq(milestoneUpdateRequest.Milestone.MilestoneId)).Updates(
_, err = m.q.Milestone.WithContext(c).
Where(m.q.Milestone.MilestoneID.Eq(milestoneUpdateRequest.Milestone.MilestoneId),
m.q.Milestone.UserID.Eq(c.Param(middleware.AuthorizedUserIDField)),
).Updates(
map[string]interface{}{
"title": milestoneUpdateRequest.Milestone.Title,
"content": milestoneUpdateRequest.Milestone.Content,
Expand Down

0 comments on commit 3f9ad4c

Please sign in to comment.