Add service_kyc
All checks were successful
Client CMS Check Build (NixCN CMS) TeamCity build finished
Backend Check Build (NixCN CMS) TeamCity build finished

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-02-01 13:15:17 +08:00
parent a2eb882398
commit 0ac96ab3e6
23 changed files with 1831 additions and 89 deletions

View File

@@ -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")