Avatar

This commit is contained in:
2024-02-01 00:14:25 +08:00
parent d4e437624a
commit afa55c2112
6 changed files with 121 additions and 30 deletions

View File

@ -2,6 +2,8 @@ package models
import (
"github.com/samber/lo"
"github.com/spf13/viper"
"path/filepath"
"time"
"gorm.io/datatypes"
@ -19,6 +21,7 @@ type Account struct {
Name string `json:"name" gorm:"uniqueIndex"`
Nick string `json:"nick"`
Avatar string `json:"avatar"`
State AccountState `json:"state"`
Profile AccountProfile `json:"profile"`
Sessions []AuthSession `json:"sessions"`
@ -39,6 +42,11 @@ func (v Account) GetPrimaryEmail() AccountContact {
return val
}
func (v Account) GetAvatarPath() string {
basepath := viper.GetString("content")
return filepath.Join(basepath, v.Avatar)
}
type AccountContactType = int8
const (