Add name field to user auth entries
This commit is contained in:
parent
1e59c661c7
commit
4c8ebaeab8
2 changed files with 6 additions and 1 deletions
|
@ -30,6 +30,7 @@ func newUserAuthMethod(db *gorm.DB, opts ...gen.DOOption) userAuthMethod {
|
||||||
_userAuthMethod.UserId = field.NewString(tableName, "user_id")
|
_userAuthMethod.UserId = field.NewString(tableName, "user_id")
|
||||||
_userAuthMethod.AuthMethod = field.NewField(tableName, "auth_method")
|
_userAuthMethod.AuthMethod = field.NewField(tableName, "auth_method")
|
||||||
_userAuthMethod.Token = field.NewBytes(tableName, "token")
|
_userAuthMethod.Token = field.NewBytes(tableName, "token")
|
||||||
|
_userAuthMethod.Name = field.NewString(tableName, "name")
|
||||||
_userAuthMethod.User = userAuthMethodBelongsToUser{
|
_userAuthMethod.User = userAuthMethodBelongsToUser{
|
||||||
db: db.Session(&gorm.Session{}),
|
db: db.Session(&gorm.Session{}),
|
||||||
|
|
||||||
|
@ -184,6 +185,7 @@ type userAuthMethod struct {
|
||||||
UserId field.String
|
UserId field.String
|
||||||
AuthMethod field.Field
|
AuthMethod field.Field
|
||||||
Token field.Bytes
|
Token field.Bytes
|
||||||
|
Name field.String
|
||||||
User userAuthMethodBelongsToUser
|
User userAuthMethodBelongsToUser
|
||||||
|
|
||||||
fieldMap map[string]field.Expr
|
fieldMap map[string]field.Expr
|
||||||
|
@ -205,6 +207,7 @@ func (u *userAuthMethod) updateTableName(table string) *userAuthMethod {
|
||||||
u.UserId = field.NewString(table, "user_id")
|
u.UserId = field.NewString(table, "user_id")
|
||||||
u.AuthMethod = field.NewField(table, "auth_method")
|
u.AuthMethod = field.NewField(table, "auth_method")
|
||||||
u.Token = field.NewBytes(table, "token")
|
u.Token = field.NewBytes(table, "token")
|
||||||
|
u.Name = field.NewString(table, "name")
|
||||||
|
|
||||||
u.fillFieldMap()
|
u.fillFieldMap()
|
||||||
|
|
||||||
|
@ -221,11 +224,12 @@ func (u *userAuthMethod) GetFieldByName(fieldName string) (field.OrderExpr, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userAuthMethod) fillFieldMap() {
|
func (u *userAuthMethod) fillFieldMap() {
|
||||||
u.fieldMap = make(map[string]field.Expr, 5)
|
u.fieldMap = make(map[string]field.Expr, 6)
|
||||||
u.fieldMap["id"] = u.ID
|
u.fieldMap["id"] = u.ID
|
||||||
u.fieldMap["user_id"] = u.UserId
|
u.fieldMap["user_id"] = u.UserId
|
||||||
u.fieldMap["auth_method"] = u.AuthMethod
|
u.fieldMap["auth_method"] = u.AuthMethod
|
||||||
u.fieldMap["token"] = u.Token
|
u.fieldMap["token"] = u.Token
|
||||||
|
u.fieldMap["name"] = u.Name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,5 @@ type UserAuthMethod struct {
|
||||||
UserId string
|
UserId string
|
||||||
AuthMethod AuthenticationMethodType `gorm:"type:auth_method_type"`
|
AuthMethod AuthenticationMethodType `gorm:"type:auth_method_type"`
|
||||||
Token []byte
|
Token []byte
|
||||||
|
Name string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue