From 62822ae4951d018c9b51f59c80947eee7dddea48 Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Fri, 19 Jul 2024 21:51:38 +0700 Subject: [PATCH] fix: checkin add timestamp, isDupe --- go.mod | 2 +- go.sum | 2 ++ internal/checkin/checkin.handler.go | 11 ++++++----- internal/checkin/checkin.service.go | 10 ++++++---- internal/checkin/checkin.utils.go | 10 ++++++---- internal/dto/checkin.dto.go | 10 ++++++---- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index d716b28..00c88d4 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 3e4b128..397409e 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/checkin/checkin.handler.go b/internal/checkin/checkin.handler.go index e3c9bfb..15a9796 100644 --- a/internal/checkin/checkin.handler.go +++ b/internal/checkin/checkin.handler.go @@ -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, diff --git a/internal/checkin/checkin.service.go b/internal/checkin/checkin.service.go index aecd9f5..1284ff6 100644 --- a/internal/checkin/checkin.service.go +++ b/internal/checkin/checkin.service.go @@ -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 } diff --git a/internal/checkin/checkin.utils.go b/internal/checkin/checkin.utils.go index 208bd21..0fa8ab5 100644 --- a/internal/checkin/checkin.utils.go +++ b/internal/checkin/checkin.utils.go @@ -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, } } diff --git a/internal/dto/checkin.dto.go b/internal/dto/checkin.dto.go index ca6fa7e..e74fbe4 100644 --- a/internal/dto/checkin.dto.go +++ b/internal/dto/checkin.dto.go @@ -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 {