1
0

add handle

This commit is contained in:
syui 2023-06-21 10:17:52 +09:00
parent 9d1f0f73c1
commit e9516ac4cd
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
18 changed files with 663 additions and 176 deletions

View File

@ -59,6 +59,7 @@ var (
{Name: "username", Type: field.TypeString, Unique: true, Size: 100}, {Name: "username", Type: field.TypeString, Unique: true, Size: 100},
{Name: "did", Type: field.TypeString, Nullable: true}, {Name: "did", Type: field.TypeString, Nullable: true},
{Name: "delete", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "delete", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "handle", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "token", Type: field.TypeString, Nullable: true}, {Name: "token", Type: field.TypeString, Nullable: true},
{Name: "password", Type: field.TypeString}, {Name: "password", Type: field.TypeString},
{Name: "created_at", Type: field.TypeTime, Nullable: true}, {Name: "created_at", Type: field.TypeTime, Nullable: true},
@ -78,7 +79,7 @@ var (
{Name: "ten_post", Type: field.TypeString, Nullable: true}, {Name: "ten_post", Type: field.TypeString, Nullable: true},
{Name: "ten_get", Type: field.TypeString, Nullable: true}, {Name: "ten_get", Type: field.TypeString, Nullable: true},
{Name: "ten_at", Type: field.TypeTime, Nullable: true}, {Name: "ten_at", Type: field.TypeTime, Nullable: true},
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230613"}, {Name: "next", Type: field.TypeString, Nullable: true, Default: "20230621"},
{Name: "group_users", Type: field.TypeInt, Nullable: true}, {Name: "group_users", Type: field.TypeInt, Nullable: true},
} }
// UsersTable holds the schema information for the "users" table. // UsersTable holds the schema information for the "users" table.
@ -89,7 +90,7 @@ var (
ForeignKeys: []*schema.ForeignKey{ ForeignKeys: []*schema.ForeignKey{
{ {
Symbol: "users_groups_users", Symbol: "users_groups_users",
Columns: []*schema.Column{UsersColumns[24]}, Columns: []*schema.Column{UsersColumns[25]},
RefColumns: []*schema.Column{GroupsColumns[0]}, RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.SetNull, OnDelete: schema.SetNull,
}, },

View File

@ -1418,6 +1418,7 @@ type UserMutation struct {
username *string username *string
did *string did *string
delete *bool delete *bool
handle *bool
token *string token *string
password *string password *string
created_at *time.Time created_at *time.Time
@ -1685,6 +1686,55 @@ func (m *UserMutation) ResetDelete() {
delete(m.clearedFields, user.FieldDelete) delete(m.clearedFields, user.FieldDelete)
} }
// SetHandle sets the "handle" field.
func (m *UserMutation) SetHandle(b bool) {
m.handle = &b
}
// Handle returns the value of the "handle" field in the mutation.
func (m *UserMutation) Handle() (r bool, exists bool) {
v := m.handle
if v == nil {
return
}
return *v, true
}
// OldHandle returns the old "handle" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldHandle(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHandle is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHandle requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHandle: %w", err)
}
return oldValue.Handle, nil
}
// ClearHandle clears the value of the "handle" field.
func (m *UserMutation) ClearHandle() {
m.handle = nil
m.clearedFields[user.FieldHandle] = struct{}{}
}
// HandleCleared returns if the "handle" field was cleared in this mutation.
func (m *UserMutation) HandleCleared() bool {
_, ok := m.clearedFields[user.FieldHandle]
return ok
}
// ResetHandle resets all changes to the "handle" field.
func (m *UserMutation) ResetHandle() {
m.handle = nil
delete(m.clearedFields, user.FieldHandle)
}
// SetToken sets the "token" field. // SetToken sets the "token" field.
func (m *UserMutation) SetToken(s string) { func (m *UserMutation) SetToken(s string) {
m.token = &s m.token = &s
@ -2866,7 +2916,7 @@ func (m *UserMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call // order to get all numeric fields that were incremented/decremented, call
// AddedFields(). // AddedFields().
func (m *UserMutation) Fields() []string { func (m *UserMutation) Fields() []string {
fields := make([]string, 0, 23) fields := make([]string, 0, 24)
if m.username != nil { if m.username != nil {
fields = append(fields, user.FieldUsername) fields = append(fields, user.FieldUsername)
} }
@ -2876,6 +2926,9 @@ func (m *UserMutation) Fields() []string {
if m.delete != nil { if m.delete != nil {
fields = append(fields, user.FieldDelete) fields = append(fields, user.FieldDelete)
} }
if m.handle != nil {
fields = append(fields, user.FieldHandle)
}
if m.token != nil { if m.token != nil {
fields = append(fields, user.FieldToken) fields = append(fields, user.FieldToken)
} }
@ -2950,6 +3003,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
return m.Did() return m.Did()
case user.FieldDelete: case user.FieldDelete:
return m.Delete() return m.Delete()
case user.FieldHandle:
return m.Handle()
case user.FieldToken: case user.FieldToken:
return m.Token() return m.Token()
case user.FieldPassword: case user.FieldPassword:
@ -3005,6 +3060,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
return m.OldDid(ctx) return m.OldDid(ctx)
case user.FieldDelete: case user.FieldDelete:
return m.OldDelete(ctx) return m.OldDelete(ctx)
case user.FieldHandle:
return m.OldHandle(ctx)
case user.FieldToken: case user.FieldToken:
return m.OldToken(ctx) return m.OldToken(ctx)
case user.FieldPassword: case user.FieldPassword:
@ -3075,6 +3132,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
} }
m.SetDelete(v) m.SetDelete(v)
return nil return nil
case user.FieldHandle:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHandle(v)
return nil
case user.FieldToken: case user.FieldToken:
v, ok := value.(string) v, ok := value.(string)
if !ok { if !ok {
@ -3326,6 +3390,9 @@ func (m *UserMutation) ClearedFields() []string {
if m.FieldCleared(user.FieldDelete) { if m.FieldCleared(user.FieldDelete) {
fields = append(fields, user.FieldDelete) fields = append(fields, user.FieldDelete)
} }
if m.FieldCleared(user.FieldHandle) {
fields = append(fields, user.FieldHandle)
}
if m.FieldCleared(user.FieldToken) { if m.FieldCleared(user.FieldToken) {
fields = append(fields, user.FieldToken) fields = append(fields, user.FieldToken)
} }
@ -3403,6 +3470,9 @@ func (m *UserMutation) ClearField(name string) error {
case user.FieldDelete: case user.FieldDelete:
m.ClearDelete() m.ClearDelete()
return nil return nil
case user.FieldHandle:
m.ClearHandle()
return nil
case user.FieldToken: case user.FieldToken:
m.ClearToken() m.ClearToken()
return nil return nil
@ -3477,6 +3547,9 @@ func (m *UserMutation) ResetField(name string) error {
case user.FieldDelete: case user.FieldDelete:
m.ResetDelete() m.ResetDelete()
return nil return nil
case user.FieldHandle:
m.ResetHandle()
return nil
case user.FieldToken: case user.FieldToken:
m.ResetToken() m.ResetToken()
return nil return nil

View File

@ -443,6 +443,12 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.CreatedAt.Set { if s.CreatedAt.Set {
e.FieldStart("created_at") e.FieldStart("created_at")
@ -553,29 +559,30 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfCardOwnerRead = [22]string{ var jsonFieldsNameOfCardOwnerRead = [23]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
3: "delete", 3: "delete",
4: "created_at", 4: "handle",
5: "updated_at", 5: "created_at",
6: "raid_at", 6: "updated_at",
7: "luck", 7: "raid_at",
8: "luck_at", 8: "luck",
9: "like", 9: "luck_at",
10: "like_rank", 10: "like",
11: "like_at", 11: "like_rank",
12: "ten", 12: "like_at",
13: "ten_su", 13: "ten",
14: "ten_kai", 14: "ten_su",
15: "aiten", 15: "ten_kai",
16: "ten_card", 16: "aiten",
17: "ten_delete", 17: "ten_card",
18: "ten_post", 18: "ten_delete",
19: "ten_get", 19: "ten_post",
20: "ten_at", 20: "ten_get",
21: "next", 21: "ten_at",
22: "next",
} }
// Decode decodes CardOwnerRead from json. // Decode decodes CardOwnerRead from json.
@ -631,6 +638,16 @@ func (s *CardOwnerRead) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "created_at": case "created_at":
if err := func() error { if err := func() error {
s.CreatedAt.Reset() s.CreatedAt.Reset()
@ -1655,6 +1672,12 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.Token.Set { if s.Token.Set {
e.FieldStart("token") e.FieldStart("token")
@ -1786,31 +1809,32 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfCreateUserReq = [24]string{ var jsonFieldsNameOfCreateUserReq = [25]string{
0: "username", 0: "username",
1: "did", 1: "did",
2: "delete", 2: "delete",
3: "token", 3: "handle",
4: "password", 4: "token",
5: "created_at", 5: "password",
6: "updated_at", 6: "created_at",
7: "raid_at", 7: "updated_at",
8: "luck", 8: "raid_at",
9: "luck_at", 9: "luck",
10: "like", 10: "luck_at",
11: "like_rank", 11: "like",
12: "like_at", 12: "like_rank",
13: "ten", 13: "like_at",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "card", 23: "next",
24: "card",
} }
// Decode decodes CreateUserReq from json. // Decode decodes CreateUserReq from json.
@ -1818,7 +1842,7 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode CreateUserReq to nil") return errors.New("invalid: unable to decode CreateUserReq to nil")
} }
var requiredBitSet [3]uint8 var requiredBitSet [4]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) { switch string(k) {
@ -1854,6 +1878,16 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "token": case "token":
if err := func() error { if err := func() error {
s.Token.Reset() s.Token.Reset()
@ -1865,7 +1899,7 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"token\"") return errors.Wrap(err, "decode field \"token\"")
} }
case "password": case "password":
requiredBitSet[0] |= 1 << 4 requiredBitSet[0] |= 1 << 5
if err := func() error { if err := func() error {
v, err := d.Str() v, err := d.Str()
s.Password = string(v) s.Password = string(v)
@ -2084,8 +2118,9 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
} }
// Validate required fields. // Validate required fields.
var failures []validate.FieldError var failures []validate.FieldError
for i, mask := range [3]uint8{ for i, mask := range [4]uint8{
0b00010001, 0b00100001,
0b00000000,
0b00000000, 0b00000000,
0b00000000, 0b00000000,
} { } {
@ -2624,6 +2659,12 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.CreatedAt.Set { if s.CreatedAt.Set {
e.FieldStart("created_at") e.FieldStart("created_at")
@ -2734,29 +2775,30 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfGroupUsersList = [22]string{ var jsonFieldsNameOfGroupUsersList = [23]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
3: "delete", 3: "delete",
4: "created_at", 4: "handle",
5: "updated_at", 5: "created_at",
6: "raid_at", 6: "updated_at",
7: "luck", 7: "raid_at",
8: "luck_at", 8: "luck",
9: "like", 9: "luck_at",
10: "like_rank", 10: "like",
11: "like_at", 11: "like_rank",
12: "ten", 12: "like_at",
13: "ten_su", 13: "ten",
14: "ten_kai", 14: "ten_su",
15: "aiten", 15: "ten_kai",
16: "ten_card", 16: "aiten",
17: "ten_delete", 17: "ten_card",
18: "ten_post", 18: "ten_delete",
19: "ten_get", 19: "ten_post",
20: "ten_at", 20: "ten_get",
21: "next", 21: "ten_at",
22: "next",
} }
// Decode decodes GroupUsersList from json. // Decode decodes GroupUsersList from json.
@ -2812,6 +2854,16 @@ func (s *GroupUsersList) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "created_at": case "created_at":
if err := func() error { if err := func() error {
s.CreatedAt.Reset() s.CreatedAt.Reset()
@ -4170,6 +4222,12 @@ func (s *UpdateUserReq) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.Token.Set { if s.Token.Set {
e.FieldStart("token") e.FieldStart("token")
@ -4290,28 +4348,29 @@ func (s *UpdateUserReq) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUpdateUserReq = [21]string{ var jsonFieldsNameOfUpdateUserReq = [22]string{
0: "did", 0: "did",
1: "delete", 1: "delete",
2: "token", 2: "handle",
3: "updated_at", 3: "token",
4: "raid_at", 4: "updated_at",
5: "luck", 5: "raid_at",
6: "luck_at", 6: "luck",
7: "like", 7: "luck_at",
8: "like_rank", 8: "like",
9: "like_at", 9: "like_rank",
10: "ten", 10: "like_at",
11: "ten_su", 11: "ten",
12: "ten_kai", 12: "ten_su",
13: "aiten", 13: "ten_kai",
14: "ten_card", 14: "aiten",
15: "ten_delete", 15: "ten_card",
16: "ten_post", 16: "ten_delete",
17: "ten_get", 17: "ten_post",
18: "ten_at", 18: "ten_get",
19: "next", 19: "ten_at",
20: "card", 20: "next",
21: "card",
} }
// Decode decodes UpdateUserReq from json. // Decode decodes UpdateUserReq from json.
@ -4342,6 +4401,16 @@ func (s *UpdateUserReq) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "token": case "token":
if err := func() error { if err := func() error {
s.Token.Reset() s.Token.Reset()
@ -4795,6 +4864,12 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.CreatedAt.Set { if s.CreatedAt.Set {
e.FieldStart("created_at") e.FieldStart("created_at")
@ -4905,29 +4980,30 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserCreate = [22]string{ var jsonFieldsNameOfUserCreate = [23]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
3: "delete", 3: "delete",
4: "created_at", 4: "handle",
5: "updated_at", 5: "created_at",
6: "raid_at", 6: "updated_at",
7: "luck", 7: "raid_at",
8: "luck_at", 8: "luck",
9: "like", 9: "luck_at",
10: "like_rank", 10: "like",
11: "like_at", 11: "like_rank",
12: "ten", 12: "like_at",
13: "ten_su", 13: "ten",
14: "ten_kai", 14: "ten_su",
15: "aiten", 15: "ten_kai",
16: "ten_card", 16: "aiten",
17: "ten_delete", 17: "ten_card",
18: "ten_post", 18: "ten_delete",
19: "ten_get", 19: "ten_post",
20: "ten_at", 20: "ten_get",
21: "next", 21: "ten_at",
22: "next",
} }
// Decode decodes UserCreate from json. // Decode decodes UserCreate from json.
@ -4983,6 +5059,16 @@ func (s *UserCreate) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "created_at": case "created_at":
if err := func() error { if err := func() error {
s.CreatedAt.Reset() s.CreatedAt.Reset()
@ -5252,6 +5338,12 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.CreatedAt.Set { if s.CreatedAt.Set {
e.FieldStart("created_at") e.FieldStart("created_at")
@ -5362,29 +5454,30 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserList = [22]string{ var jsonFieldsNameOfUserList = [23]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
3: "delete", 3: "delete",
4: "created_at", 4: "handle",
5: "updated_at", 5: "created_at",
6: "raid_at", 6: "updated_at",
7: "luck", 7: "raid_at",
8: "luck_at", 8: "luck",
9: "like", 9: "luck_at",
10: "like_rank", 10: "like",
11: "like_at", 11: "like_rank",
12: "ten", 12: "like_at",
13: "ten_su", 13: "ten",
14: "ten_kai", 14: "ten_su",
15: "aiten", 15: "ten_kai",
16: "ten_card", 16: "aiten",
17: "ten_delete", 17: "ten_card",
18: "ten_post", 18: "ten_delete",
19: "ten_get", 19: "ten_post",
20: "ten_at", 20: "ten_get",
21: "next", 21: "ten_at",
22: "next",
} }
// Decode decodes UserList from json. // Decode decodes UserList from json.
@ -5440,6 +5533,16 @@ func (s *UserList) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "created_at": case "created_at":
if err := func() error { if err := func() error {
s.CreatedAt.Reset() s.CreatedAt.Reset()
@ -5709,6 +5812,12 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.CreatedAt.Set { if s.CreatedAt.Set {
e.FieldStart("created_at") e.FieldStart("created_at")
@ -5819,29 +5928,30 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserRead = [22]string{ var jsonFieldsNameOfUserRead = [23]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
3: "delete", 3: "delete",
4: "created_at", 4: "handle",
5: "updated_at", 5: "created_at",
6: "raid_at", 6: "updated_at",
7: "luck", 7: "raid_at",
8: "luck_at", 8: "luck",
9: "like", 9: "luck_at",
10: "like_rank", 10: "like",
11: "like_at", 11: "like_rank",
12: "ten", 12: "like_at",
13: "ten_su", 13: "ten",
14: "ten_kai", 14: "ten_su",
15: "aiten", 15: "ten_kai",
16: "ten_card", 16: "aiten",
17: "ten_delete", 17: "ten_card",
18: "ten_post", 18: "ten_delete",
19: "ten_get", 19: "ten_post",
20: "ten_at", 20: "ten_get",
21: "next", 21: "ten_at",
22: "next",
} }
// Decode decodes UserRead from json. // Decode decodes UserRead from json.
@ -5897,6 +6007,16 @@ func (s *UserRead) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "created_at": case "created_at":
if err := func() error { if err := func() error {
s.CreatedAt.Reset() s.CreatedAt.Reset()
@ -6166,6 +6286,12 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
s.Delete.Encode(e) s.Delete.Encode(e)
} }
} }
{
if s.Handle.Set {
e.FieldStart("handle")
s.Handle.Encode(e)
}
}
{ {
if s.CreatedAt.Set { if s.CreatedAt.Set {
e.FieldStart("created_at") e.FieldStart("created_at")
@ -6276,29 +6402,30 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserUpdate = [22]string{ var jsonFieldsNameOfUserUpdate = [23]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
3: "delete", 3: "delete",
4: "created_at", 4: "handle",
5: "updated_at", 5: "created_at",
6: "raid_at", 6: "updated_at",
7: "luck", 7: "raid_at",
8: "luck_at", 8: "luck",
9: "like", 9: "luck_at",
10: "like_rank", 10: "like",
11: "like_at", 11: "like_rank",
12: "ten", 12: "like_at",
13: "ten_su", 13: "ten",
14: "ten_kai", 14: "ten_su",
15: "aiten", 15: "ten_kai",
16: "ten_card", 16: "aiten",
17: "ten_delete", 17: "ten_card",
18: "ten_post", 18: "ten_delete",
19: "ten_get", 19: "ten_post",
20: "ten_at", 20: "ten_get",
21: "next", 21: "ten_at",
22: "next",
} }
// Decode decodes UserUpdate from json. // Decode decodes UserUpdate from json.
@ -6354,6 +6481,16 @@ func (s *UserUpdate) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"delete\"") return errors.Wrap(err, "decode field \"delete\"")
} }
case "handle":
if err := func() error {
s.Handle.Reset()
if err := s.Handle.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"handle\"")
}
case "created_at": case "created_at":
if err := func() error { if err := func() error {
s.CreatedAt.Reset() s.CreatedAt.Reset()

View File

@ -178,6 +178,7 @@ type CardOwnerRead struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -218,6 +219,11 @@ func (s *CardOwnerRead) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *CardOwnerRead) GetHandle() OptBool {
return s.Handle
}
// GetCreatedAt returns the value of CreatedAt. // GetCreatedAt returns the value of CreatedAt.
func (s *CardOwnerRead) GetCreatedAt() OptDateTime { func (s *CardOwnerRead) GetCreatedAt() OptDateTime {
return s.CreatedAt return s.CreatedAt
@ -328,6 +334,11 @@ func (s *CardOwnerRead) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *CardOwnerRead) SetHandle(val OptBool) {
s.Handle = val
}
// SetCreatedAt sets the value of CreatedAt. // SetCreatedAt sets the value of CreatedAt.
func (s *CardOwnerRead) SetCreatedAt(val OptDateTime) { func (s *CardOwnerRead) SetCreatedAt(val OptDateTime) {
s.CreatedAt = val s.CreatedAt = val
@ -717,6 +728,7 @@ type CreateUserReq struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
Token OptString `json:"token"` Token OptString `json:"token"`
Password string `json:"password"` Password string `json:"password"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
@ -755,6 +767,11 @@ func (s *CreateUserReq) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *CreateUserReq) GetHandle() OptBool {
return s.Handle
}
// GetToken returns the value of Token. // GetToken returns the value of Token.
func (s *CreateUserReq) GetToken() OptString { func (s *CreateUserReq) GetToken() OptString {
return s.Token return s.Token
@ -875,6 +892,11 @@ func (s *CreateUserReq) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *CreateUserReq) SetHandle(val OptBool) {
s.Handle = val
}
// SetToken sets the value of Token. // SetToken sets the value of Token.
func (s *CreateUserReq) SetToken(val OptString) { func (s *CreateUserReq) SetToken(val OptString) {
s.Token = val s.Token = val
@ -1117,6 +1139,7 @@ type GroupUsersList struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -1157,6 +1180,11 @@ func (s *GroupUsersList) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *GroupUsersList) GetHandle() OptBool {
return s.Handle
}
// GetCreatedAt returns the value of CreatedAt. // GetCreatedAt returns the value of CreatedAt.
func (s *GroupUsersList) GetCreatedAt() OptDateTime { func (s *GroupUsersList) GetCreatedAt() OptDateTime {
return s.CreatedAt return s.CreatedAt
@ -1267,6 +1295,11 @@ func (s *GroupUsersList) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *GroupUsersList) SetHandle(val OptBool) {
s.Handle = val
}
// SetCreatedAt sets the value of CreatedAt. // SetCreatedAt sets the value of CreatedAt.
func (s *GroupUsersList) SetCreatedAt(val OptDateTime) { func (s *GroupUsersList) SetCreatedAt(val OptDateTime) {
s.CreatedAt = val s.CreatedAt = val
@ -1831,6 +1864,7 @@ func (s *UpdateGroupReq) SetUsers(val []int) {
type UpdateUserReq struct { type UpdateUserReq struct {
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
Token OptString `json:"token"` Token OptString `json:"token"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -1862,6 +1896,11 @@ func (s *UpdateUserReq) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *UpdateUserReq) GetHandle() OptBool {
return s.Handle
}
// GetToken returns the value of Token. // GetToken returns the value of Token.
func (s *UpdateUserReq) GetToken() OptString { func (s *UpdateUserReq) GetToken() OptString {
return s.Token return s.Token
@ -1967,6 +2006,11 @@ func (s *UpdateUserReq) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *UpdateUserReq) SetHandle(val OptBool) {
s.Handle = val
}
// SetToken sets the value of Token. // SetToken sets the value of Token.
func (s *UpdateUserReq) SetToken(val OptString) { func (s *UpdateUserReq) SetToken(val OptString) {
s.Token = val s.Token = val
@ -2149,6 +2193,7 @@ type UserCreate struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -2189,6 +2234,11 @@ func (s *UserCreate) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *UserCreate) GetHandle() OptBool {
return s.Handle
}
// GetCreatedAt returns the value of CreatedAt. // GetCreatedAt returns the value of CreatedAt.
func (s *UserCreate) GetCreatedAt() OptDateTime { func (s *UserCreate) GetCreatedAt() OptDateTime {
return s.CreatedAt return s.CreatedAt
@ -2299,6 +2349,11 @@ func (s *UserCreate) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *UserCreate) SetHandle(val OptBool) {
s.Handle = val
}
// SetCreatedAt sets the value of CreatedAt. // SetCreatedAt sets the value of CreatedAt.
func (s *UserCreate) SetCreatedAt(val OptDateTime) { func (s *UserCreate) SetCreatedAt(val OptDateTime) {
s.CreatedAt = val s.CreatedAt = val
@ -2397,6 +2452,7 @@ type UserList struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -2437,6 +2493,11 @@ func (s *UserList) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *UserList) GetHandle() OptBool {
return s.Handle
}
// GetCreatedAt returns the value of CreatedAt. // GetCreatedAt returns the value of CreatedAt.
func (s *UserList) GetCreatedAt() OptDateTime { func (s *UserList) GetCreatedAt() OptDateTime {
return s.CreatedAt return s.CreatedAt
@ -2547,6 +2608,11 @@ func (s *UserList) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *UserList) SetHandle(val OptBool) {
s.Handle = val
}
// SetCreatedAt sets the value of CreatedAt. // SetCreatedAt sets the value of CreatedAt.
func (s *UserList) SetCreatedAt(val OptDateTime) { func (s *UserList) SetCreatedAt(val OptDateTime) {
s.CreatedAt = val s.CreatedAt = val
@ -2643,6 +2709,7 @@ type UserRead struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -2683,6 +2750,11 @@ func (s *UserRead) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *UserRead) GetHandle() OptBool {
return s.Handle
}
// GetCreatedAt returns the value of CreatedAt. // GetCreatedAt returns the value of CreatedAt.
func (s *UserRead) GetCreatedAt() OptDateTime { func (s *UserRead) GetCreatedAt() OptDateTime {
return s.CreatedAt return s.CreatedAt
@ -2793,6 +2865,11 @@ func (s *UserRead) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *UserRead) SetHandle(val OptBool) {
s.Handle = val
}
// SetCreatedAt sets the value of CreatedAt. // SetCreatedAt sets the value of CreatedAt.
func (s *UserRead) SetCreatedAt(val OptDateTime) { func (s *UserRead) SetCreatedAt(val OptDateTime) {
s.CreatedAt = val s.CreatedAt = val
@ -2891,6 +2968,7 @@ type UserUpdate struct {
Username string `json:"username"` Username string `json:"username"`
Did OptString `json:"did"` Did OptString `json:"did"`
Delete OptBool `json:"delete"` Delete OptBool `json:"delete"`
Handle OptBool `json:"handle"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
UpdatedAt OptDateTime `json:"updated_at"` UpdatedAt OptDateTime `json:"updated_at"`
RaidAt OptDateTime `json:"raid_at"` RaidAt OptDateTime `json:"raid_at"`
@ -2931,6 +3009,11 @@ func (s *UserUpdate) GetDelete() OptBool {
return s.Delete return s.Delete
} }
// GetHandle returns the value of Handle.
func (s *UserUpdate) GetHandle() OptBool {
return s.Handle
}
// GetCreatedAt returns the value of CreatedAt. // GetCreatedAt returns the value of CreatedAt.
func (s *UserUpdate) GetCreatedAt() OptDateTime { func (s *UserUpdate) GetCreatedAt() OptDateTime {
return s.CreatedAt return s.CreatedAt
@ -3041,6 +3124,11 @@ func (s *UserUpdate) SetDelete(val OptBool) {
s.Delete = val s.Delete = val
} }
// SetHandle sets the value of Handle.
func (s *UserUpdate) SetHandle(val OptBool) {
s.Handle = val
}
// SetCreatedAt sets the value of CreatedAt. // SetCreatedAt sets the value of CreatedAt.
func (s *UserUpdate) SetCreatedAt(val OptDateTime) { func (s *UserUpdate) SetCreatedAt(val OptDateTime) {
s.CreatedAt = val s.CreatedAt = val

View File

@ -484,6 +484,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
if v, ok := req.Delete.Get(); ok { if v, ok := req.Delete.Get(); ok {
b.SetDelete(v) b.SetDelete(v)
} }
if v, ok := req.Handle.Get(); ok {
b.SetHandle(v)
}
if v, ok := req.Token.Get(); ok { if v, ok := req.Token.Get(); ok {
b.SetToken(v) b.SetToken(v)
} }
@ -614,7 +617,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
if v, ok := req.Delete.Get(); ok { if v, ok := req.Delete.Get(); ok {
b.SetDelete(v) b.SetDelete(v)
} }
if v, ok := req.Handle.Get(); ok {
b.SetHandle(v)
}
if v, ok := req.UpdatedAt.Get(); ok { if v, ok := req.UpdatedAt.Get(); ok {
b.SetUpdatedAt(v) b.SetUpdatedAt(v)
} }

View File

@ -145,6 +145,7 @@ func NewCardOwnerRead(e *ent.User) *CardOwnerRead {
ret.Username = e.Username ret.Username = e.Username
ret.Did = NewOptString(e.Did) ret.Did = NewOptString(e.Did)
ret.Delete = NewOptBool(e.Delete) ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt) ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt) ret.RaidAt = NewOptDateTime(e.RaidAt)
@ -305,6 +306,7 @@ func NewGroupUsersList(e *ent.User) *GroupUsersList {
ret.Username = e.Username ret.Username = e.Username
ret.Did = NewOptString(e.Did) ret.Did = NewOptString(e.Did)
ret.Delete = NewOptBool(e.Delete) ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt) ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt) ret.RaidAt = NewOptDateTime(e.RaidAt)
@ -353,6 +355,7 @@ func NewUserCreate(e *ent.User) *UserCreate {
ret.Username = e.Username ret.Username = e.Username
ret.Did = NewOptString(e.Did) ret.Did = NewOptString(e.Did)
ret.Delete = NewOptBool(e.Delete) ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt) ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt) ret.RaidAt = NewOptDateTime(e.RaidAt)
@ -401,6 +404,7 @@ func NewUserList(e *ent.User) *UserList {
ret.Username = e.Username ret.Username = e.Username
ret.Did = NewOptString(e.Did) ret.Did = NewOptString(e.Did)
ret.Delete = NewOptBool(e.Delete) ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt) ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt) ret.RaidAt = NewOptDateTime(e.RaidAt)
@ -449,6 +453,7 @@ func NewUserRead(e *ent.User) *UserRead {
ret.Username = e.Username ret.Username = e.Username
ret.Did = NewOptString(e.Did) ret.Did = NewOptString(e.Did)
ret.Delete = NewOptBool(e.Delete) ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt) ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt) ret.RaidAt = NewOptDateTime(e.RaidAt)
@ -497,6 +502,7 @@ func NewUserUpdate(e *ent.User) *UserUpdate {
ret.Username = e.Username ret.Username = e.Username
ret.Did = NewOptString(e.Did) ret.Did = NewOptString(e.Did)
ret.Delete = NewOptBool(e.Delete) ret.Delete = NewOptBool(e.Delete)
ret.Handle = NewOptBool(e.Handle)
ret.CreatedAt = NewOptDateTime(e.CreatedAt) ret.CreatedAt = NewOptDateTime(e.CreatedAt)
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt) ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
ret.RaidAt = NewOptDateTime(e.RaidAt) ret.RaidAt = NewOptDateTime(e.RaidAt)

View File

@ -754,6 +754,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"token": { "token": {
"type": "string" "type": "string"
}, },
@ -970,6 +973,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"token": { "token": {
"type": "string" "type": "string"
}, },
@ -1332,6 +1338,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1498,6 +1507,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1579,6 +1591,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"token": { "token": {
"type": "string" "type": "string"
}, },
@ -1673,6 +1688,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1754,6 +1772,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1835,6 +1856,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1916,6 +1940,9 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"

View File

@ -74,36 +74,40 @@ func init() {
userDescDelete := userFields[2].Descriptor() userDescDelete := userFields[2].Descriptor()
// user.DefaultDelete holds the default value on creation for the delete field. // user.DefaultDelete holds the default value on creation for the delete field.
user.DefaultDelete = userDescDelete.Default.(bool) user.DefaultDelete = userDescDelete.Default.(bool)
// userDescHandle is the schema descriptor for handle field.
userDescHandle := userFields[3].Descriptor()
// user.DefaultHandle holds the default value on creation for the handle field.
user.DefaultHandle = userDescHandle.Default.(bool)
// userDescPassword is the schema descriptor for password field. // userDescPassword is the schema descriptor for password field.
userDescPassword := userFields[4].Descriptor() userDescPassword := userFields[5].Descriptor()
// user.PasswordValidator is a validator for the "password" field. It is called by the builders before save. // user.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
user.PasswordValidator = userDescPassword.Validators[0].(func(string) error) user.PasswordValidator = userDescPassword.Validators[0].(func(string) error)
// userDescCreatedAt is the schema descriptor for created_at field. // userDescCreatedAt is the schema descriptor for created_at field.
userDescCreatedAt := userFields[5].Descriptor() userDescCreatedAt := userFields[6].Descriptor()
// user.DefaultCreatedAt holds the default value on creation for the created_at field. // user.DefaultCreatedAt holds the default value on creation for the created_at field.
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time) user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
// userDescUpdatedAt is the schema descriptor for updated_at field. // userDescUpdatedAt is the schema descriptor for updated_at field.
userDescUpdatedAt := userFields[6].Descriptor() userDescUpdatedAt := userFields[7].Descriptor()
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field. // user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time) user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
// userDescRaidAt is the schema descriptor for raid_at field. // userDescRaidAt is the schema descriptor for raid_at field.
userDescRaidAt := userFields[7].Descriptor() userDescRaidAt := userFields[8].Descriptor()
// user.DefaultRaidAt holds the default value on creation for the raid_at field. // user.DefaultRaidAt holds the default value on creation for the raid_at field.
user.DefaultRaidAt = userDescRaidAt.Default.(func() time.Time) user.DefaultRaidAt = userDescRaidAt.Default.(func() time.Time)
// userDescLuckAt is the schema descriptor for luck_at field. // userDescLuckAt is the schema descriptor for luck_at field.
userDescLuckAt := userFields[9].Descriptor() userDescLuckAt := userFields[10].Descriptor()
// user.DefaultLuckAt holds the default value on creation for the luck_at field. // user.DefaultLuckAt holds the default value on creation for the luck_at field.
user.DefaultLuckAt = userDescLuckAt.Default.(func() time.Time) user.DefaultLuckAt = userDescLuckAt.Default.(func() time.Time)
// userDescLikeAt is the schema descriptor for like_at field. // userDescLikeAt is the schema descriptor for like_at field.
userDescLikeAt := userFields[12].Descriptor() userDescLikeAt := userFields[13].Descriptor()
// user.DefaultLikeAt holds the default value on creation for the like_at field. // user.DefaultLikeAt holds the default value on creation for the like_at field.
user.DefaultLikeAt = userDescLikeAt.Default.(func() time.Time) user.DefaultLikeAt = userDescLikeAt.Default.(func() time.Time)
// userDescTenAt is the schema descriptor for ten_at field. // userDescTenAt is the schema descriptor for ten_at field.
userDescTenAt := userFields[21].Descriptor() userDescTenAt := userFields[22].Descriptor()
// user.DefaultTenAt holds the default value on creation for the ten_at field. // user.DefaultTenAt holds the default value on creation for the ten_at field.
user.DefaultTenAt = userDescTenAt.Default.(func() time.Time) user.DefaultTenAt = userDescTenAt.Default.(func() time.Time)
// userDescNext is the schema descriptor for next field. // userDescNext is the schema descriptor for next field.
userDescNext := userFields[22].Descriptor() userDescNext := userFields[23].Descriptor()
// user.DefaultNext holds the default value on creation for the next field. // user.DefaultNext holds the default value on creation for the next field.
user.DefaultNext = userDescNext.Default.(string) user.DefaultNext = userDescNext.Default.(string)
} }

View File

@ -42,6 +42,10 @@ func (User) Fields() []ent.Field {
Default(false). Default(false).
Optional(), Optional(),
field.Bool("handle").
Default(false).
Optional(),
field.String("token"). field.String("token").
Optional(). Optional().
Sensitive(), Sensitive(),

View File

@ -22,6 +22,8 @@ type User struct {
Did string `json:"did,omitempty"` Did string `json:"did,omitempty"`
// Delete holds the value of the "delete" field. // Delete holds the value of the "delete" field.
Delete bool `json:"delete,omitempty"` Delete bool `json:"delete,omitempty"`
// Handle holds the value of the "handle" field.
Handle bool `json:"handle,omitempty"`
// Token holds the value of the "token" field. // Token holds the value of the "token" field.
Token string `json:"-"` Token string `json:"-"`
// Password holds the value of the "password" field. // Password holds the value of the "password" field.
@ -91,7 +93,7 @@ func (*User) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns)) values := make([]any, len(columns))
for i := range columns { for i := range columns {
switch columns[i] { switch columns[i] {
case user.FieldDelete, user.FieldTen: case user.FieldDelete, user.FieldHandle, user.FieldTen:
values[i] = new(sql.NullBool) values[i] = new(sql.NullBool)
case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldTenSu, user.FieldTenKai, user.FieldAiten: case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldTenSu, user.FieldTenKai, user.FieldAiten:
values[i] = new(sql.NullInt64) values[i] = new(sql.NullInt64)
@ -140,6 +142,12 @@ func (u *User) assignValues(columns []string, values []any) error {
} else if value.Valid { } else if value.Valid {
u.Delete = value.Bool u.Delete = value.Bool
} }
case user.FieldHandle:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field handle", values[i])
} else if value.Valid {
u.Handle = value.Bool
}
case user.FieldToken: case user.FieldToken:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field token", values[i]) return fmt.Errorf("unexpected type %T for field token", values[i])
@ -309,6 +317,9 @@ func (u *User) String() string {
builder.WriteString("delete=") builder.WriteString("delete=")
builder.WriteString(fmt.Sprintf("%v", u.Delete)) builder.WriteString(fmt.Sprintf("%v", u.Delete))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("handle=")
builder.WriteString(fmt.Sprintf("%v", u.Handle))
builder.WriteString(", ")
builder.WriteString("token=<sensitive>") builder.WriteString("token=<sensitive>")
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("password=<sensitive>") builder.WriteString("password=<sensitive>")

View File

@ -17,6 +17,8 @@ const (
FieldDid = "did" FieldDid = "did"
// FieldDelete holds the string denoting the delete field in the database. // FieldDelete holds the string denoting the delete field in the database.
FieldDelete = "delete" FieldDelete = "delete"
// FieldHandle holds the string denoting the handle field in the database.
FieldHandle = "handle"
// FieldToken holds the string denoting the token field in the database. // FieldToken holds the string denoting the token field in the database.
FieldToken = "token" FieldToken = "token"
// FieldPassword holds the string denoting the password field in the database. // FieldPassword holds the string denoting the password field in the database.
@ -76,6 +78,7 @@ var Columns = []string{
FieldUsername, FieldUsername,
FieldDid, FieldDid,
FieldDelete, FieldDelete,
FieldHandle,
FieldToken, FieldToken,
FieldPassword, FieldPassword,
FieldCreatedAt, FieldCreatedAt,
@ -124,6 +127,8 @@ var (
UsernameValidator func(string) error UsernameValidator func(string) error
// DefaultDelete holds the default value on creation for the "delete" field. // DefaultDelete holds the default value on creation for the "delete" field.
DefaultDelete bool DefaultDelete bool
// DefaultHandle holds the default value on creation for the "handle" field.
DefaultHandle bool
// PasswordValidator is a validator for the "password" field. It is called by the builders before save. // PasswordValidator is a validator for the "password" field. It is called by the builders before save.
PasswordValidator func(string) error PasswordValidator func(string) error
// DefaultCreatedAt holds the default value on creation for the "created_at" field. // DefaultCreatedAt holds the default value on creation for the "created_at" field.

View File

@ -70,6 +70,11 @@ func Delete(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldDelete, v)) return predicate.User(sql.FieldEQ(FieldDelete, v))
} }
// Handle applies equality check predicate on the "handle" field. It's identical to HandleEQ.
func Handle(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldHandle, v))
}
// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. // Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
func Token(v string) predicate.User { func Token(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldToken, v)) return predicate.User(sql.FieldEQ(FieldToken, v))
@ -330,6 +335,26 @@ func DeleteNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldDelete)) return predicate.User(sql.FieldNotNull(FieldDelete))
} }
// HandleEQ applies the EQ predicate on the "handle" field.
func HandleEQ(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldHandle, v))
}
// HandleNEQ applies the NEQ predicate on the "handle" field.
func HandleNEQ(v bool) predicate.User {
return predicate.User(sql.FieldNEQ(FieldHandle, v))
}
// HandleIsNil applies the IsNil predicate on the "handle" field.
func HandleIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldHandle))
}
// HandleNotNil applies the NotNil predicate on the "handle" field.
func HandleNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldHandle))
}
// TokenEQ applies the EQ predicate on the "token" field. // TokenEQ applies the EQ predicate on the "token" field.
func TokenEQ(v string) predicate.User { func TokenEQ(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldToken, v)) return predicate.User(sql.FieldEQ(FieldToken, v))

View File

@ -55,6 +55,20 @@ func (uc *UserCreate) SetNillableDelete(b *bool) *UserCreate {
return uc return uc
} }
// SetHandle sets the "handle" field.
func (uc *UserCreate) SetHandle(b bool) *UserCreate {
uc.mutation.SetHandle(b)
return uc
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (uc *UserCreate) SetNillableHandle(b *bool) *UserCreate {
if b != nil {
uc.SetHandle(*b)
}
return uc
}
// SetToken sets the "token" field. // SetToken sets the "token" field.
func (uc *UserCreate) SetToken(s string) *UserCreate { func (uc *UserCreate) SetToken(s string) *UserCreate {
uc.mutation.SetToken(s) uc.mutation.SetToken(s)
@ -381,6 +395,10 @@ func (uc *UserCreate) defaults() {
v := user.DefaultDelete v := user.DefaultDelete
uc.mutation.SetDelete(v) uc.mutation.SetDelete(v)
} }
if _, ok := uc.mutation.Handle(); !ok {
v := user.DefaultHandle
uc.mutation.SetHandle(v)
}
if _, ok := uc.mutation.CreatedAt(); !ok { if _, ok := uc.mutation.CreatedAt(); !ok {
v := user.DefaultCreatedAt() v := user.DefaultCreatedAt()
uc.mutation.SetCreatedAt(v) uc.mutation.SetCreatedAt(v)
@ -467,6 +485,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
_spec.SetField(user.FieldDelete, field.TypeBool, value) _spec.SetField(user.FieldDelete, field.TypeBool, value)
_node.Delete = value _node.Delete = value
} }
if value, ok := uc.mutation.Handle(); ok {
_spec.SetField(user.FieldHandle, field.TypeBool, value)
_node.Handle = value
}
if value, ok := uc.mutation.Token(); ok { if value, ok := uc.mutation.Token(); ok {
_spec.SetField(user.FieldToken, field.TypeString, value) _spec.SetField(user.FieldToken, field.TypeString, value)
_node.Token = value _node.Token = value

View File

@ -69,6 +69,26 @@ func (uu *UserUpdate) ClearDelete() *UserUpdate {
return uu return uu
} }
// SetHandle sets the "handle" field.
func (uu *UserUpdate) SetHandle(b bool) *UserUpdate {
uu.mutation.SetHandle(b)
return uu
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (uu *UserUpdate) SetNillableHandle(b *bool) *UserUpdate {
if b != nil {
uu.SetHandle(*b)
}
return uu
}
// ClearHandle clears the value of the "handle" field.
func (uu *UserUpdate) ClearHandle() *UserUpdate {
uu.mutation.ClearHandle()
return uu
}
// SetToken sets the "token" field. // SetToken sets the "token" field.
func (uu *UserUpdate) SetToken(s string) *UserUpdate { func (uu *UserUpdate) SetToken(s string) *UserUpdate {
uu.mutation.SetToken(s) uu.mutation.SetToken(s)
@ -560,6 +580,12 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
if uu.mutation.DeleteCleared() { if uu.mutation.DeleteCleared() {
_spec.ClearField(user.FieldDelete, field.TypeBool) _spec.ClearField(user.FieldDelete, field.TypeBool)
} }
if value, ok := uu.mutation.Handle(); ok {
_spec.SetField(user.FieldHandle, field.TypeBool, value)
}
if uu.mutation.HandleCleared() {
_spec.ClearField(user.FieldHandle, field.TypeBool)
}
if value, ok := uu.mutation.Token(); ok { if value, ok := uu.mutation.Token(); ok {
_spec.SetField(user.FieldToken, field.TypeString, value) _spec.SetField(user.FieldToken, field.TypeString, value)
} }
@ -794,6 +820,26 @@ func (uuo *UserUpdateOne) ClearDelete() *UserUpdateOne {
return uuo return uuo
} }
// SetHandle sets the "handle" field.
func (uuo *UserUpdateOne) SetHandle(b bool) *UserUpdateOne {
uuo.mutation.SetHandle(b)
return uuo
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (uuo *UserUpdateOne) SetNillableHandle(b *bool) *UserUpdateOne {
if b != nil {
uuo.SetHandle(*b)
}
return uuo
}
// ClearHandle clears the value of the "handle" field.
func (uuo *UserUpdateOne) ClearHandle() *UserUpdateOne {
uuo.mutation.ClearHandle()
return uuo
}
// SetToken sets the "token" field. // SetToken sets the "token" field.
func (uuo *UserUpdateOne) SetToken(s string) *UserUpdateOne { func (uuo *UserUpdateOne) SetToken(s string) *UserUpdateOne {
uuo.mutation.SetToken(s) uuo.mutation.SetToken(s)
@ -1315,6 +1361,12 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
if uuo.mutation.DeleteCleared() { if uuo.mutation.DeleteCleared() {
_spec.ClearField(user.FieldDelete, field.TypeBool) _spec.ClearField(user.FieldDelete, field.TypeBool)
} }
if value, ok := uuo.mutation.Handle(); ok {
_spec.SetField(user.FieldHandle, field.TypeBool, value)
}
if uuo.mutation.HandleCleared() {
_spec.ClearField(user.FieldHandle, field.TypeBool)
}
if value, ok := uuo.mutation.Token(); ok { if value, ok := uuo.mutation.Token(); ok {
_spec.SetField(user.FieldToken, field.TypeString, value) _spec.SetField(user.FieldToken, field.TypeString, value)
} }

View File

@ -20,9 +20,9 @@ n=$((n - 1))
if [ -n "$1" ];then if [ -n "$1" ];then
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id` id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
if [ "ai" = "$1" ] || [ "yui" = "$1" ];then if [ "ai" = "$1" ] || [ "yui" = "$1" ];then
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7, \"like\":0}" -s $host/users/$id curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7, \"like\":0,\"aiten\":1000}" -s $host/users/$id
else else
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 0, \"luck_at\": \"$now_at\", \"ten\":false,\"ten_at\": \"$updated_at_n\",\"token\": \"$token\",\"ten_kai\" : 0}" -s $host/users/$id curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 0, \"luck_at\": \"$updated_at_n\", \"ten\":false, \"ten_at\": \"$updated_at_n\",\"token\": \"$token\",\"ten_kai\" : 0, \"aiten\":0}" -s $host/users/$id
fi fi
exit exit
fi fi

View File

@ -34,6 +34,7 @@ curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\"}" -s $ho
echo "\ntest token (yes token)" echo "\ntest token (yes token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id
read
## delete ## delete
echo "\ntest delete" echo "\ntest delete"
data=`curl -sL https://api.syui.ai/users/$id/card` data=`curl -sL https://api.syui.ai/users/$id/card`

View File

@ -484,6 +484,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
if v, ok := req.Delete.Get(); ok { if v, ok := req.Delete.Get(); ok {
b.SetDelete(v) b.SetDelete(v)
} }
if v, ok := req.Handle.Get(); ok {
b.SetHandle(v)
}
if v, ok := req.Token.Get(); ok { if v, ok := req.Token.Get(); ok {
b.SetToken(v) b.SetToken(v)
} }
@ -614,7 +617,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
if v, ok := req.Delete.Get(); ok { if v, ok := req.Delete.Get(); ok {
b.SetDelete(v) b.SetDelete(v)
} }
if v, ok := req.Handle.Get(); ok {
b.SetHandle(v)
}
if v, ok := req.UpdatedAt.Get(); ok { if v, ok := req.UpdatedAt.Get(); ok {
b.SetUpdatedAt(v) b.SetUpdatedAt(v)
} }

21
tmp/user_did.zsh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/zsh
username=$1
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
host_users="$host/users?itemsPerPage=255"
data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"`
nd=20230101
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
echo username did
read
curl -X PATCH -H "Content-Type: application/json" -d "{\"did\":\"$2\",\"token\":\"$token\"}" -s $host/users/$id