Skip to content

Commit

Permalink
Merge pull request #36 from isd-sgcu/dev
Browse files Browse the repository at this point in the history
fix: checkin add timestamp, isDupe
  • Loading branch information
bookpanda authored Jul 19, 2024
2 parents 78debda + 62822ae commit caaabea
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/go-playground/validator/v10 v10.22.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.6.0
github.com/isd-sgcu/rpkm67-go-proto v0.4.8
github.com/isd-sgcu/rpkm67-go-proto v0.5.0
github.com/isd-sgcu/rpkm67-model v0.0.7
github.com/joho/godotenv v1.5.1
github.com/prometheus/client_golang v1.19.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/isd-sgcu/rpkm67-go-proto v0.4.8 h1:tU6nCv4A34guBoDwkZvUzzs6z43NBzgLsSbGmX5QRYI=
github.com/isd-sgcu/rpkm67-go-proto v0.4.8/go.mod h1:w+UCeQnJ3wBuJ7Tyf8LiBiPZVb1KlecjMNCB7kBeL7M=
github.com/isd-sgcu/rpkm67-go-proto v0.5.0 h1:FFYIv/Ejs3fP+AWErtx9ONxbzZLr1y1Ttd7j8xHIJ34=
github.com/isd-sgcu/rpkm67-go-proto v0.5.0/go.mod h1:w+UCeQnJ3wBuJ7Tyf8LiBiPZVb1KlecjMNCB7kBeL7M=
github.com/isd-sgcu/rpkm67-model v0.0.7 h1:3b8gf1Ocg+Ky4xocKtCqVCB3rFDg90IgEXRwNmHt0OE=
github.com/isd-sgcu/rpkm67-model v0.0.7/go.mod h1:dxgLSkrFpbQOXsrzqgepZoEOyZUIG2LBGtm5gsuBbVc=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
Expand Down
11 changes: 6 additions & 5 deletions internal/checkin/checkin.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ func (h *handlerImpl) Create(c context.Ctx) {
c.ResponseError(appErr)
return
}
h.log.Info("user found", zap.Any("user", resUser.User))

c.JSON(http.StatusCreated, &dto.CreateCheckInResponse{
CheckIn: &dto.CheckIn{
ID: res.CheckIn.ID,
UserID: res.CheckIn.UserID,
Email: resUser.User.Email,
Event: res.CheckIn.Event,
ID: res.CheckIn.ID,
UserID: res.CheckIn.UserID,
Email: resUser.User.Email,
Event: res.CheckIn.Event,
Timestamp: res.CheckIn.Timestamp,
IsDuplicate: res.CheckIn.IsDuplicate,
},
Firstname: resUser.User.Firstname,
Lastname: resUser.User.Lastname,
Expand Down
10 changes: 6 additions & 4 deletions internal/checkin/checkin.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ func (s *serviceImpl) Create(ctx context.Context, req *dto.CreateCheckInRequest)

return &dto.CreateCheckInResponse{
CheckIn: &dto.CheckIn{
ID: res.CheckIn.Id,
UserID: res.CheckIn.UserId,
Email: res.CheckIn.Email,
Event: res.CheckIn.Event,
ID: res.CheckIn.Id,
UserID: res.CheckIn.UserId,
Email: res.CheckIn.Email,
Event: res.CheckIn.Event,
Timestamp: res.CheckIn.Timestamp,
IsDuplicate: res.CheckIn.IsDuplicate,
},
}, nil
}
Expand Down
10 changes: 6 additions & 4 deletions internal/checkin/checkin.utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (

func ProtoToDto(in *checkinProto.CheckIn) *dto.CheckIn {
return &dto.CheckIn{
ID: in.Id,
UserID: in.UserId,
Email: in.Email,
Event: in.Event,
ID: in.Id,
UserID: in.UserId,
Email: in.Email,
Event: in.Event,
Timestamp: in.Timestamp,
IsDuplicate: in.IsDuplicate,
}
}

Expand Down
10 changes: 6 additions & 4 deletions internal/dto/checkin.dto.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dto

type CheckIn struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Email string `json:"email"`
Event string `json:"event"`
ID string `json:"id"`
UserID string `json:"user_id"`
Email string `json:"email"`
Event string `json:"event"`
Timestamp string `json:"timestamp"`
IsDuplicate bool `json:"is_duplicate"`
}

type CreateCheckInRequest struct {
Expand Down

0 comments on commit caaabea

Please sign in to comment.