You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/field"
|
|
mixins2 "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/schema/mixins"
|
|
"git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/mixins"
|
|
"git.noahlan.cn/noahlan/ntool/nrandom"
|
|
)
|
|
|
|
type OauthProvider struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (OauthProvider) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.String("name").Unique().Comment("The provider's name | 提供商名称"),
|
|
field.String("client_id").Comment("The client id | 客户端 id"),
|
|
field.String("client_secret").Comment("The client secret | 客户端密钥"),
|
|
field.String("redirect_url").Default("").Comment("The redirect url | 跳转地址"),
|
|
field.String("scopes").Default("").Comment("The scopes | 权限范围"),
|
|
field.String("auth_url").Default("").Comment("The auth url of the provider | 认证地址"),
|
|
field.String("token_url").Default("").Comment("The token url of the provider | 获取 Token 地址"),
|
|
field.String("info_url").Default("").Comment("The URL to request user information by token | 用户信息请求地址"),
|
|
field.Text("description").Default("").Comment("The description of the provider | 提供商描述"),
|
|
field.Bool("system").
|
|
Default(false).
|
|
Comment("The system internal oauth provider | 系统内置提供商"),
|
|
field.Bool("init").
|
|
Default(false).
|
|
Comment("The oauth provider init status | 提供商初始化状态"),
|
|
}
|
|
}
|
|
|
|
func (OauthProvider) Mixin() []ent.Mixin {
|
|
return []ent.Mixin{
|
|
mixins.NewDistributedIDMixin(func() int64 { return nrandom.SnowflakeId() }),
|
|
mixins.TimeMixin{},
|
|
mixins2.SoftDeleteMixin{},
|
|
}
|
|
}
|
|
|
|
func (OauthProvider) Edges() []ent.Edge {
|
|
return nil
|
|
}
|
|
|
|
func (OauthProvider) Indexes() []ent.Index {
|
|
return nil
|
|
}
|
|
|
|
func (OauthProvider) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.WithComments(true),
|
|
entsql.Annotation{Table: "sys_oauth_provider"},
|
|
schema.Comment("OAuth提供商"),
|
|
}
|
|
}
|