update userAvatar
This commit is contained in:
parent
3c4eab8977
commit
c33715bdd5
|
@ -65,7 +65,7 @@ func (s Service) HasPermission(userID, permission string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateUserAvatar ...
|
// UpdateUserAvatar ...
|
||||||
func (s Service) UpdateUserAvatar(userID, avatar string) error {
|
func (s Service) UpdateUserAvatar(userID string, avatar interface{}) error {
|
||||||
return user.UpdateAvatar(userID, avatar)
|
return user.UpdateAvatar(userID, avatar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ type DBUser struct {
|
||||||
Status string `bson:"status"`
|
Status string `bson:"status"`
|
||||||
RoleID primitive.ObjectID `bson:"roleId"`
|
RoleID primitive.ObjectID `bson:"roleId"`
|
||||||
RequireToChangePassword bool `bson:"requireToChangePassword"`
|
RequireToChangePassword bool `bson:"requireToChangePassword"`
|
||||||
Avatar string `bson:"avatar"`
|
Avatar interface{} `bson:"avatar"`
|
||||||
Deleted bool `bson:"deleted"`
|
Deleted bool `bson:"deleted"`
|
||||||
Other interface{} `bson:"other"` // object
|
Other interface{} `bson:"other"` // object
|
||||||
CreatedAt time.Time `bson:"createdAt"`
|
CreatedAt time.Time `bson:"createdAt"`
|
||||||
|
|
|
@ -16,6 +16,7 @@ type UserCreateOptions struct {
|
||||||
RoleID string
|
RoleID string
|
||||||
RequireToChangePassword bool
|
RequireToChangePassword bool
|
||||||
Other interface{}
|
Other interface{}
|
||||||
|
Avatar interface{} // if not, pass default file object
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserUpdateOptions ...
|
// UserUpdateOptions ...
|
||||||
|
|
|
@ -13,6 +13,7 @@ type User struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Role RoleShort `json:"role"`
|
Role RoleShort `json:"role"`
|
||||||
Other interface{} `json:"other"`
|
Other interface{} `json:"other"`
|
||||||
|
Avatar interface{} `json:"avatar"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ func newUser(payload model.UserCreateOptions) model.DBUser {
|
||||||
Status: payload.Status,
|
Status: payload.Status,
|
||||||
RoleID: roleID,
|
RoleID: roleID,
|
||||||
Other: payload.Other,
|
Other: payload.Other,
|
||||||
|
Avatar: payload.Avatar,
|
||||||
CreatedAt: timeNow,
|
CreatedAt: timeNow,
|
||||||
UpdatedAt: timeNow,
|
UpdatedAt: timeNow,
|
||||||
}
|
}
|
||||||
|
@ -177,6 +178,7 @@ func getResponse(ctx context.Context, user model.DBUser) model.User {
|
||||||
Level: roleRaw.Level,
|
Level: roleRaw.Level,
|
||||||
IsAdmin: roleRaw.IsAdmin,
|
IsAdmin: roleRaw.IsAdmin,
|
||||||
},
|
},
|
||||||
|
Avatar: user.Avatar,
|
||||||
Other: user.Other,
|
Other: user.Other,
|
||||||
CreatedAt: user.CreatedAt,
|
CreatedAt: user.CreatedAt,
|
||||||
UpdatedAt: user.UpdatedAt,
|
UpdatedAt: user.UpdatedAt,
|
||||||
|
@ -443,12 +445,12 @@ func checkUserHasPermissionFromCache(roleID primitive.ObjectID, permission strin
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAvatar ...
|
// UpdateAvatar ...
|
||||||
func UpdateAvatar(userID string, avatar string) error {
|
func UpdateAvatar(userID string, avatar interface{}) error {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
)
|
)
|
||||||
|
|
||||||
if avatar == "" {
|
if avatar == nil {
|
||||||
return errors.New("no avatar data")
|
return errors.New("no avatar data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue