@@ -12,6 +12,7 @@ import (
|
||||
|
||||
type EventJoinData struct {
|
||||
EventId string `json:"event_id"`
|
||||
KycId string `json:"kyc_id"`
|
||||
UserId string `json:"user_id" swaggerignore:"true"`
|
||||
Role string `json:"role" swaggerignore:"true"`
|
||||
State string `json:"state" swaggerignore:"true"`
|
||||
@@ -30,7 +31,6 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
var err error
|
||||
|
||||
attendenceData := new(data.Attendance)
|
||||
eventData := new(data.Event)
|
||||
|
||||
eventId, err := uuid.Parse(payload.Data.EventId)
|
||||
if err != nil {
|
||||
@@ -53,19 +53,41 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
return
|
||||
}
|
||||
|
||||
if !eventData.EndTime.Before(time.Now()) {
|
||||
eventData, err := new(data.Event).GetEventById(payload.Context, eventId)
|
||||
|
||||
if err != nil {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceEvent).
|
||||
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.EventJoinEventInvalid).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorDatabase).
|
||||
SetError(err).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 403,
|
||||
HttpCode: 500,
|
||||
Exception: exception,
|
||||
},
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if eventData.EnableKYC == true && payload.Data.KycId == "" {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceEvent).
|
||||
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
SetError(nil).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 400,
|
||||
Exception: exception,
|
||||
},
|
||||
}
|
||||
@@ -94,8 +116,94 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
return
|
||||
}
|
||||
|
||||
attendenceData.SetEventId(eventId)
|
||||
if eventData.EnableKYC == true && payload.Data.KycId != "" {
|
||||
kycId, err := uuid.Parse(payload.Data.KycId)
|
||||
if err != nil {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceEvent).
|
||||
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUuidParseFailed).
|
||||
SetError(err).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 400,
|
||||
Exception: exception,
|
||||
},
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
kycData, err := new(data.Kyc).GetByKycId(payload.Context, &kycId)
|
||||
if err != nil {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceEvent).
|
||||
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorDatabase).
|
||||
SetError(err).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 500,
|
||||
Exception: exception,
|
||||
},
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if kycData.UserId != userId {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceEvent).
|
||||
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
SetError(err).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 400,
|
||||
Exception: exception,
|
||||
},
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
attendenceData.SetKycId(kycData.KycId)
|
||||
}
|
||||
|
||||
if !eventData.EndTime.Before(time.Now()) {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceEvent).
|
||||
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.EventJoinEventInvalid).
|
||||
SetError(err).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &EventJoinResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 403,
|
||||
Exception: exception,
|
||||
},
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
attendenceData.SetUserId(userId)
|
||||
attendenceData.SetEventId(eventId)
|
||||
attendenceData.SetRole("notmal")
|
||||
attendenceData.SetState("success")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user