@@ -25,9 +25,9 @@ import (
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /user/info/{user_id} [get]
|
||||
func (self *UserHandler) Other(c *gin.Context) {
|
||||
userIdOrig := c.Param("user_id")
|
||||
userIdFromUrlOrig := c.Param("user_id")
|
||||
|
||||
userId, err := uuid.Parse(userIdOrig)
|
||||
userIdFromUrl, err := uuid.Parse(userIdFromUrlOrig)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
@@ -42,11 +42,50 @@ func (self *UserHandler) Other(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
UserInfoPayload := &service_user.UserInfoPayload{
|
||||
Context: c,
|
||||
UserId: userId,
|
||||
IsOther: true,
|
||||
Data: nil,
|
||||
userIdFromHeaderOrig, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceInfo).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorMissingUserId).
|
||||
Throw(c).
|
||||
String()
|
||||
utils.HttpResponse(c, 403, errorCode)
|
||||
return
|
||||
}
|
||||
|
||||
userIdFromHeader, err := uuid.Parse(userIdFromHeaderOrig.(string))
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceInfo).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUuidParseFailed).
|
||||
SetError(err).
|
||||
Throw(c).
|
||||
String()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
return
|
||||
}
|
||||
|
||||
var UserInfoPayload = &service_user.UserInfoPayload{}
|
||||
if userIdFromUrl == userIdFromHeader {
|
||||
UserInfoPayload = &service_user.UserInfoPayload{
|
||||
Context: c,
|
||||
UserId: userIdFromHeader,
|
||||
IsOther: false,
|
||||
Data: nil,
|
||||
}
|
||||
} else if userIdFromUrl != userIdFromHeader {
|
||||
UserInfoPayload = &service_user.UserInfoPayload{
|
||||
Context: c,
|
||||
UserId: userIdFromHeader,
|
||||
IsOther: true,
|
||||
Data: nil,
|
||||
}
|
||||
}
|
||||
|
||||
result := self.svc.GetUserInfo(UserInfoPayload)
|
||||
|
||||
@@ -34,3 +34,5 @@ event:
|
||||
record_not_found: "00001"
|
||||
list:
|
||||
database_failed: "00001"
|
||||
join:
|
||||
event_invalid: "00001"
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"nixcn-cms/data"
|
||||
"nixcn-cms/internal/exception"
|
||||
"nixcn-cms/service/shared"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -29,6 +30,7 @@ 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 {
|
||||
@@ -51,6 +53,26 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
userId, err := uuid.Parse(payload.Data.UserId)
|
||||
if err != nil {
|
||||
exception := new(exception.Builder).
|
||||
|
||||
Reference in New Issue
Block a user