@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user