add(system): repository BindAvatar()
This commit is contained in:
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
@@ -25,6 +26,8 @@ type (
|
||||
Create(mod *types.User) (*types.User, error)
|
||||
Update(mod *types.User) (*types.User, error)
|
||||
|
||||
BindAvatar(user *types.User, avatar io.Reader) (*types.User, error)
|
||||
|
||||
SuspendByID(id uint64) error
|
||||
UnsuspendByID(id uint64) error
|
||||
DeleteByID(id uint64) error
|
||||
@@ -166,6 +169,15 @@ func (r *user) Update(mod *types.User) (*types.User, error) {
|
||||
return mod, r.db().Replace(r.users, mod)
|
||||
}
|
||||
|
||||
func (r *user) BindAvatar(user *types.User, avatar io.Reader) (*types.User, error) {
|
||||
if user.Meta == nil {
|
||||
user.Meta = new(types.UserMeta)
|
||||
}
|
||||
// @todo: IMPORTANT: implement avatar uploading
|
||||
user.Meta.Avatar = ""
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (r *user) SuspendByID(id uint64) error {
|
||||
return r.updateColumnByID(r.users, "suspend_at", time.Now(), id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user