fix: some api bug

This commit is contained in:
wwweww
2026-03-31 22:12:06 +08:00
parent c5ff4f0216
commit e7970ac25f
219 changed files with 16195 additions and 2126 deletions
@@ -0,0 +1,26 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
)
// UserFollows holds the schema definition for the UserFollows entity.
type UserFollows struct {
ent.Schema
}
// Fields of the UserFollows.
func (UserFollows) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").Immutable().Unique(),
field.Int64("follower_id"),
field.Int64("followee_id"),
field.Time("created_at").Immutable(),
}
}
// Edges of the UserFollows.
func (UserFollows) Edges() []ent.Edge {
return nil
}
@@ -0,0 +1,31 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/field"
)
// UserPreferences holds the schema definition for the UserPreferences entity.
type UserPreferences struct {
ent.Schema
}
// Fields of the UserPreferences.
func (UserPreferences) Fields() []ent.Field {
return []ent.Field{
field.Int64("user_id"),
field.Bool("notification_order").Default(true),
field.Bool("notification_community").Default(true),
field.Bool("notification_system").Default(true),
field.String("theme").Default("light"),
field.String("language").Default("zh-CN"),
field.Time("updated_at").Default(time.Now),
}
}
// Edges of the UserPreferences.
func (UserPreferences) Edges() []ent.Edge {
return nil
}
+11 -7
View File
@@ -1,9 +1,11 @@
package schema
import (
"juwan-backend/pkg/types"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/field"
)
@@ -26,16 +28,18 @@ func (Users) Fields() []ent.Field {
field.String("password_hash"),
field.String("email").Unique(),
field.String("phone").Unique(),
field.String("nickname"),
field.String("avatar"),
field.String("bio"),
field.String("current_role"),
field.Strings("verified_roles"),
field.JSON("verificationStatus", VerificationStatusStruct{}),
field.String("nickname").Default(""),
field.String("avatar").Default(""),
field.String("bio").Default(""),
field.String("current_role").Default("consumer").NotEmpty(),
//field.Strings("verified_roles").Default([]string{"consumer"}),
field.JSON("verificationStatus", VerificationStatusStruct{}).Optional(),
field.Bool("is_admin").Default(false),
field.Time("created_at").Default(time.Now),
field.Time("updated_at").Default(time.Now),
field.Time("deleted_at"),
field.Time("deleted_at").Optional(),
field.Other("verified_roles", types.TextArray{}).
SchemaType(map[string]string{dialect.Postgres: "text[]"}).Optional(),
}
}