@@ -25,9 +25,9 @@ import (
|
|||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Router /user/info/{user_id} [get]
|
// @Router /user/info/{user_id} [get]
|
||||||
func (self *UserHandler) Other(c *gin.Context) {
|
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 {
|
if err != nil {
|
||||||
errorCode := new(exception.Builder).
|
errorCode := new(exception.Builder).
|
||||||
SetStatus(exception.StatusServer).
|
SetStatus(exception.StatusServer).
|
||||||
@@ -42,11 +42,50 @@ func (self *UserHandler) Other(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfoPayload := &service_user.UserInfoPayload{
|
userIdFromHeaderOrig, ok := c.Get("user_id")
|
||||||
Context: c,
|
if !ok {
|
||||||
UserId: userId,
|
errorCode := new(exception.Builder).
|
||||||
IsOther: true,
|
SetStatus(exception.StatusUser).
|
||||||
Data: nil,
|
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)
|
result := self.svc.GetUserInfo(UserInfoPayload)
|
||||||
|
|||||||
@@ -34,3 +34,5 @@ event:
|
|||||||
record_not_found: "00001"
|
record_not_found: "00001"
|
||||||
list:
|
list:
|
||||||
database_failed: "00001"
|
database_failed: "00001"
|
||||||
|
join:
|
||||||
|
event_invalid: "00001"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"nixcn-cms/data"
|
"nixcn-cms/data"
|
||||||
"nixcn-cms/internal/exception"
|
"nixcn-cms/internal/exception"
|
||||||
"nixcn-cms/service/shared"
|
"nixcn-cms/service/shared"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
@@ -29,6 +30,7 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
attendenceData := new(data.Attendance)
|
attendenceData := new(data.Attendance)
|
||||||
|
eventData := new(data.Event)
|
||||||
|
|
||||||
eventId, err := uuid.Parse(payload.Data.EventId)
|
eventId, err := uuid.Parse(payload.Data.EventId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -51,6 +53,26 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
return
|
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)
|
userId, err := uuid.Parse(payload.Data.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exception := new(exception.Builder).
|
exception := new(exception.Builder).
|
||||||
|
|||||||
Reference in New Issue
Block a user