🎉 init

This commit is contained in:
landaiqing
2024-11-12 17:00:16 +08:00
commit 97ca3fc7b0
80 changed files with 26877 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRule holds the schema definition for the ScaAuthPermissionRule entity.
type ScaAuthPermissionRule struct {
ent.Schema
}
// Fields of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20) unsigned",
}).
Unique(),
field.String("ptype").
MaxLen(100).
Nillable(),
field.String("v0").
MaxLen(100).
Nillable(),
field.String("v1").
MaxLen(100).
Nillable(),
field.String("v2").
MaxLen(100).
Optional().
Nillable(),
field.String("v3").
MaxLen(100).
Optional().
Nillable(),
field.String("v4").
MaxLen(100).
Optional().
Nillable(),
field.String("v5").
MaxLen(100).
Optional().
Nillable(),
}
}
// Edges of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Edges() []ent.Edge {
return []ent.Edge{
edge.From("sca_auth_role", ScaAuthRole.Type).
Ref("sca_auth_permission_rule").
Unique(),
}
}

View File

@@ -0,0 +1,55 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// ScaAuthRole holds the schema definition for the ScaAuthRole entity.
type ScaAuthRole struct {
ent.Schema
}
// Fields of the ScaAuthRole.
func (ScaAuthRole) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("主键ID"),
field.String("role_name").
MaxLen(32).
Comment("角色名称"),
field.String("role_key").
MaxLen(64).
Comment("角色关键字"),
field.Time("created_at").
Default(time.Now).
Immutable().
Comment("创建时间"),
field.Time("update_at").
Default(time.Now).UpdateDefault(time.Now).
Comment("更新时间"),
field.Int("deleted").
Default(0).
Comment("是否删除 0 未删除 1已删除"),
}
}
// Edges of the ScaAuthRole.
func (ScaAuthRole) Edges() []ent.Edge {
return []ent.Edge{
edge.To("sca_auth_permission_rule", ScaAuthPermissionRule.Type),
}
}
// Indexes of the ScaAuthRole.
func (ScaAuthRole) Indexes() []ent.Index {
return nil
}

View File

@@ -0,0 +1,115 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ScaAuthUser holds the schema definition for the ScaAuthUser entity.
type ScaAuthUser struct {
ent.Schema
}
// Fields of the ScaAuthUser.
func (ScaAuthUser) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("自增ID"),
field.String("uid").
MaxLen(20).
Unique().
Comment("唯一ID"),
field.String("username").
MaxLen(32).
Optional().
Comment("用户名"),
field.String("nickname").
MaxLen(32).
Optional().
Comment("昵称"),
field.String("email").
MaxLen(32).
Optional().
Comment("邮箱"),
field.String("phone").
MaxLen(32).
Optional().
Comment("电话"),
field.String("password").
MaxLen(64).
Optional().
Sensitive().
Comment("密码"),
field.String("gender").
MaxLen(32).
Optional().
Comment("性别"),
field.String("avatar").
Optional().
Comment("头像"),
field.Int8("status").
Default(0).
Optional().
Comment("状态 0 正常 1 封禁"),
field.String("introduce").
MaxLen(255).
Optional().
Comment("介绍"),
field.Time("created_at").
Default(time.Now).
Immutable().
Comment("创建时间"),
field.Time("update_at").
Default(time.Now).UpdateDefault(time.Now).
Nillable().
Optional().
Comment("更新时间"),
field.Int8("deleted").
Default(0).
Comment("是否删除 0 未删除 1 已删除"),
field.String("blog").
MaxLen(30).
Nillable().
Optional().
Comment("博客"),
field.String("location").
MaxLen(50).
Nillable().
Optional().
Comment("地址"),
field.String("company").
MaxLen(50).
Nillable().
Optional().
Comment("公司"),
}
}
// Edges of the ScaAuthUser.
func (ScaAuthUser) Edges() []ent.Edge {
return []ent.Edge{
edge.To("sca_auth_user_social", ScaAuthUserSocial.Type),
edge.To("sca_auth_user_device", ScaAuthUserDevice.Type),
}
}
// Indexes of the ScaAuthUser.
func (ScaAuthUser) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id").
Unique(),
index.Fields("uid").
Unique(),
index.Fields("phone").
Unique(),
}
}

View File

@@ -0,0 +1,94 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ScaAuthUserDevice holds the schema definition for the ScaAuthUserDevice entity.
type ScaAuthUserDevice struct {
ent.Schema
}
// Fields of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("主键ID"),
field.String("user_id").
MaxLen(20).
Comment("用户ID"),
field.String("ip").
MaxLen(20).
Comment("登录IP"),
field.String("location").
MaxLen(20).
Comment("地址"),
field.String("agent").
MaxLen(255).
Comment("设备信息"),
field.Time("created_at").
Default(time.Now).
Optional().
Immutable().
Comment("创建时间"),
field.Time("update_at").
Default(time.Now).UpdateDefault(time.Now).
Nillable().
Comment("更新时间"),
field.Int("deleted").
Default(0).
Comment("是否删除"),
field.String("browser").
MaxLen(20).
Comment("浏览器"),
field.String("operating_system").
MaxLen(20).
Comment("操作系统"),
field.String("browser_version").
MaxLen(20).
Comment("浏览器版本"),
field.Int("mobile").
Comment("是否为手机 0否1是"),
field.Int("bot").
Comment("是否为bot 0否1是"),
field.String("mozilla").
MaxLen(10).
Comment("火狐版本"),
field.String("platform").
MaxLen(20).
Comment("平台"),
field.String("engine_name").
MaxLen(20).
Comment("引擎名称"),
field.String("engine_version").
MaxLen(20).
Comment("引擎版本"),
}
}
// Edges of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Edges() []ent.Edge {
return []ent.Edge{
edge.From("sca_auth_user", ScaAuthUser.Type).
Ref("sca_auth_user_device").
Unique(),
}
}
// Indexes of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id").
Unique(),
}
}

View File

@@ -0,0 +1,69 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ScaAuthUserSocial holds the schema definition for the ScaAuthUserSocial entity.
type ScaAuthUserSocial struct {
ent.Schema
}
// Fields of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("主键ID"),
field.String("user_id").
MaxLen(20).
Comment("用户ID"),
field.String("open_id").
MaxLen(50).
Comment("第三方用户的 open id"),
field.String("source").
MaxLen(10).
Comment("第三方用户来源"),
field.Int("status").
Default(0).
Comment("状态 0正常 1 封禁"),
field.Time("created_at").
Default(time.Now).
Immutable().
Comment("创建时间"),
field.Time("update_at").
Default(time.Now).UpdateDefault(time.Now).
Optional().
Nillable().
Comment("更新时间"),
field.Int("deleted").
Default(0).
Comment("是否删除"),
}
}
// Edges of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Edges() []ent.Edge {
return []ent.Edge{
edge.From("sca_auth_user", ScaAuthUser.Type).
Ref("sca_auth_user_social").
Unique(),
}
}
// Indexes of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id", "user_id", "open_id").
Unique(),
}
}