add i18n support

This commit is contained in:
landaiqing
2024-11-12 22:59:39 +08:00
parent 97ca3fc7b0
commit ae743ba8a6
62 changed files with 4468 additions and 2797 deletions

View File

@@ -0,0 +1,31 @@
package mixin
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/mixin"
)
type DefaultMixin struct {
mixin.Schema
}
func (DefaultMixin) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Immutable().
Default(time.Now).
Comment("创建时间"),
field.Time("updated_at").
Default(time.Now).
Comment("更新时间").
UpdateDefault(time.Now),
field.Int8("deleted").
Default(0).
Max(1).
Optional().
Comment("是否删除 0 未删除 1 已删除"),
}
}

View File

@@ -3,6 +3,8 @@ package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
@@ -44,7 +46,9 @@ func (ScaAuthPermissionRule) Fields() []ent.Field {
field.String("v5").
MaxLen(100).
Optional().
Nillable(),
Nillable().Annotations(
entsql.WithComments(true),
),
}
}
@@ -56,3 +60,14 @@ func (ScaAuthPermissionRule) Edges() []ent.Edge {
Unique(),
}
}
// Annotations of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("角色权限规则表"),
entsql.Annotation{
Table: "sca_auth_permission_rule",
},
}
}

View File

@@ -1,12 +1,14 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthRole holds the schema definition for the ScaAuthRole entity.
@@ -14,6 +16,12 @@ type ScaAuthRole struct {
ent.Schema
}
func (ScaAuthRole) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthRole.
func (ScaAuthRole) Fields() []ent.Field {
return []ent.Field{
@@ -28,17 +36,10 @@ func (ScaAuthRole) Fields() []ent.Field {
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已删除"),
Comment("角色关键字").
Annotations(
entsql.WithComments(true),
),
}
}
@@ -53,3 +54,14 @@ func (ScaAuthRole) Edges() []ent.Edge {
func (ScaAuthRole) Indexes() []ent.Index {
return nil
}
// Annotations of the ScaAuthRole.
func (ScaAuthRole) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("角色表"),
entsql.Annotation{
Table: "sca_auth_role",
},
}
}

View File

@@ -1,13 +1,15 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthUser holds the schema definition for the ScaAuthUser entity.
@@ -15,6 +17,12 @@ type ScaAuthUser struct {
ent.Schema
}
func (ScaAuthUser) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthUser.
func (ScaAuthUser) Fields() []ent.Field {
return []ent.Field{
@@ -64,18 +72,6 @@ func (ScaAuthUser) Fields() []ent.Field {
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().
@@ -90,7 +86,10 @@ func (ScaAuthUser) Fields() []ent.Field {
MaxLen(50).
Nillable().
Optional().
Comment("公司"),
Comment("公司").
Annotations(
entsql.WithComments(true),
),
}
}
@@ -113,3 +112,14 @@ func (ScaAuthUser) Indexes() []ent.Index {
Unique(),
}
}
// Annotations of the ScaAuthUser.
func (ScaAuthUser) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("用户表"),
entsql.Annotation{
Table: "sca_auth_user",
},
}
}

View File

@@ -1,13 +1,15 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthUserDevice holds the schema definition for the ScaAuthUserDevice entity.
@@ -15,6 +17,12 @@ type ScaAuthUserDevice struct {
ent.Schema
}
func (ScaAuthUserDevice) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Fields() []ent.Field {
return []ent.Field{
@@ -36,18 +44,6 @@ func (ScaAuthUserDevice) Fields() []ent.Field {
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("浏览器"),
@@ -72,7 +68,9 @@ func (ScaAuthUserDevice) Fields() []ent.Field {
Comment("引擎名称"),
field.String("engine_version").
MaxLen(20).
Comment("引擎版本"),
Comment("引擎版本").Annotations(
entsql.WithComments(true),
),
}
}
@@ -92,3 +90,14 @@ func (ScaAuthUserDevice) Indexes() []ent.Index {
Unique(),
}
}
// Annotations of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("用户设备表"),
entsql.Annotation{
Table: "sca_auth_user_device",
},
}
}

View File

@@ -1,13 +1,15 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthUserSocial holds the schema definition for the ScaAuthUserSocial entity.
@@ -15,6 +17,12 @@ type ScaAuthUserSocial struct {
ent.Schema
}
func (ScaAuthUserSocial) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Fields() []ent.Field {
return []ent.Field{
@@ -35,19 +43,9 @@ func (ScaAuthUserSocial) Fields() []ent.Field {
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("是否删除"),
Comment("状态 0正常 1 封禁").Annotations(
entsql.WithComments(true),
),
}
}
@@ -63,7 +61,22 @@ func (ScaAuthUserSocial) Edges() []ent.Edge {
// Indexes of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id", "user_id", "open_id").
index.Fields("id").
Unique(),
index.Fields("user_id").
Unique(),
index.Fields("open_id").
Unique(),
}
}
// Annotations of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("用户第三方登录信息"),
entsql.Annotation{
Table: "sca_auth_user_social",
},
}
}