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