1
0
api/ent/schema/user.go

253 lines
3.8 KiB
Go
Raw Normal View History

2022-08-31 07:49:08 +00:00
package schema
import (
"time"
//"regexp"
//"math/rand"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
//"entgo.io/ent/schema/mixin"
)
var jst,err = time.LoadLocation("Asia/Tokyo")
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
func Nextime() (tt string){
2024-02-05 22:21:38 +00:00
//t := time.Now().In(jst)
//t := time.Now().Add(time.Hour * 24 * 1).In(jst)
t := time.Now().AddDate(0, 0, -1).In(jst)
2022-08-31 07:49:08 +00:00
tt = t.Format("20060102")
return
}
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("username").
NotEmpty().
Immutable().
2023-04-13 07:50:11 +00:00
MaxLen(100).
2022-08-31 07:49:08 +00:00
//Match(regexp.MustCompile("[a-z]+$")).
Unique(),
2023-04-13 07:50:11 +00:00
field.String("did").
2023-05-01 14:00:17 +00:00
Optional(),
2023-07-20 14:18:17 +00:00
field.Bool("member").
Default(false).
Optional(),
field.Bool("book").
Default(false).
Optional(),
field.Bool("manga").
Default(false).
Optional(),
field.Bool("badge").
Default(false).
Optional(),
2023-07-10 03:43:09 +00:00
field.Bool("bsky").
Default(false).
Optional(),
field.Bool("mastodon").
Default(true).
Optional(),
2023-05-01 14:00:17 +00:00
field.Bool("delete").
Default(false).
Optional(),
2023-04-13 07:50:11 +00:00
2023-06-21 01:17:52 +00:00
field.Bool("handle").
Default(false).
Optional(),
2023-04-18 12:18:38 +00:00
field.String("token").
Optional().
Sensitive(),
2023-04-05 06:05:14 +00:00
field.String("password").
NotEmpty().
Immutable().
Sensitive(),
2022-08-31 07:49:08 +00:00
field.Time("created_at").
Immutable().
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
field.Time("updated_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2023-05-24 09:36:44 +00:00
field.Time("raid_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2023-09-10 08:53:30 +00:00
field.Time("server_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2023-07-23 14:40:24 +00:00
field.Time("egg_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2023-05-24 09:36:44 +00:00
field.Int("luck").
Optional(),
field.Time("luck_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
field.Int("like").
Optional(),
field.Int("like_rank").
Optional(),
field.Time("like_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2023-07-01 14:21:48 +00:00
field.Int("fav").
Optional(),
2023-05-24 09:36:44 +00:00
field.Bool("ten").
Optional(),
field.Int("ten_su").
Optional(),
field.Int("ten_kai").
Optional(),
field.Int("aiten").
Optional(),
field.String("ten_card").
Optional(),
field.String("ten_delete").
Optional(),
field.String("ten_post").
Optional(),
field.String("ten_get").
Optional(),
field.Time("ten_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2022-08-31 07:49:08 +00:00
field.String("next").
Default(Nextime()).
Optional(),
2023-09-10 08:53:30 +00:00
field.Int("room").
Optional(),
2023-11-03 02:24:42 +00:00
field.Bool("model").
Optional(),
field.Time("model_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
field.Int("model_attack").
Optional(),
field.Int("model_limit").
Optional(),
field.Int("model_skill").
Optional(),
field.Int("model_mode").
Optional(),
field.Int("model_critical").
Optional(),
field.Int("model_critical_d").
Optional(),
field.Bool("game").
Default(false).
Optional(),
field.Bool("game_test").
Default(false).
Optional(),
field.Bool("game_end").
Default(false).
Optional(),
field.Bool("game_account").
Default(false).
Optional(),
field.Int("game_lv").
Optional(),
2024-02-21 19:08:34 +00:00
field.Int("coin").
Optional(),
field.Bool("coin_open").
Default(false).
Optional(),
field.Time("coin_at").
Optional().
Default(func() time.Time {
return time.Now().In(jst)
}),
2022-08-31 07:49:08 +00:00
}
}
// Indexes of the User.
func (User) Indexes() []ent.Index {
return []ent.Index{
index.Fields("username").Unique(),
}
}
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("card", Card.Type),
2024-02-03 06:48:28 +00:00
edge.To("ue", Ue.Type),
2024-04-02 09:57:04 +00:00
edge.To("ma", Ma.Type),
2022-08-31 07:49:08 +00:00
//Unique(),
}
}
2024-02-03 06:48:28 +00:00