test delete
This commit is contained in:
parent
a0ac2438ed
commit
2883ab052c
@ -57,11 +57,12 @@ var (
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 100},
|
||||
{Name: "did", Type: field.TypeString, Nullable: true},
|
||||
{Name: "delete", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230428"},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230503"},
|
||||
{Name: "group_users", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
@ -72,7 +73,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_groups_users",
|
||||
Columns: []*schema.Column{UsersColumns[8]},
|
||||
Columns: []*schema.Column{UsersColumns[9]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
@ -1344,6 +1344,7 @@ type UserMutation struct {
|
||||
id *int
|
||||
username *string
|
||||
did *string
|
||||
delete *bool
|
||||
token *string
|
||||
password *string
|
||||
created_at *time.Time
|
||||
@ -1541,6 +1542,55 @@ func (m *UserMutation) ResetDid() {
|
||||
delete(m.clearedFields, user.FieldDid)
|
||||
}
|
||||
|
||||
// SetDelete sets the "delete" field.
|
||||
func (m *UserMutation) SetDelete(b bool) {
|
||||
m.delete = &b
|
||||
}
|
||||
|
||||
// Delete returns the value of the "delete" field in the mutation.
|
||||
func (m *UserMutation) Delete() (r bool, exists bool) {
|
||||
v := m.delete
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldDelete returns the old "delete" 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) OldDelete(ctx context.Context) (v bool, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldDelete is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldDelete requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldDelete: %w", err)
|
||||
}
|
||||
return oldValue.Delete, nil
|
||||
}
|
||||
|
||||
// ClearDelete clears the value of the "delete" field.
|
||||
func (m *UserMutation) ClearDelete() {
|
||||
m.delete = nil
|
||||
m.clearedFields[user.FieldDelete] = struct{}{}
|
||||
}
|
||||
|
||||
// DeleteCleared returns if the "delete" field was cleared in this mutation.
|
||||
func (m *UserMutation) DeleteCleared() bool {
|
||||
_, ok := m.clearedFields[user.FieldDelete]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetDelete resets all changes to the "delete" field.
|
||||
func (m *UserMutation) ResetDelete() {
|
||||
m.delete = nil
|
||||
delete(m.clearedFields, user.FieldDelete)
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (m *UserMutation) SetToken(s string) {
|
||||
m.token = &s
|
||||
@ -1861,13 +1911,16 @@ func (m *UserMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *UserMutation) Fields() []string {
|
||||
fields := make([]string, 0, 7)
|
||||
fields := make([]string, 0, 8)
|
||||
if m.username != nil {
|
||||
fields = append(fields, user.FieldUsername)
|
||||
}
|
||||
if m.did != nil {
|
||||
fields = append(fields, user.FieldDid)
|
||||
}
|
||||
if m.delete != nil {
|
||||
fields = append(fields, user.FieldDelete)
|
||||
}
|
||||
if m.token != nil {
|
||||
fields = append(fields, user.FieldToken)
|
||||
}
|
||||
@ -1895,6 +1948,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.Username()
|
||||
case user.FieldDid:
|
||||
return m.Did()
|
||||
case user.FieldDelete:
|
||||
return m.Delete()
|
||||
case user.FieldToken:
|
||||
return m.Token()
|
||||
case user.FieldPassword:
|
||||
@ -1918,6 +1973,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
|
||||
return m.OldUsername(ctx)
|
||||
case user.FieldDid:
|
||||
return m.OldDid(ctx)
|
||||
case user.FieldDelete:
|
||||
return m.OldDelete(ctx)
|
||||
case user.FieldToken:
|
||||
return m.OldToken(ctx)
|
||||
case user.FieldPassword:
|
||||
@ -1951,6 +2008,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetDid(v)
|
||||
return nil
|
||||
case user.FieldDelete:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetDelete(v)
|
||||
return nil
|
||||
case user.FieldToken:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@ -2019,6 +2083,9 @@ func (m *UserMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(user.FieldDid) {
|
||||
fields = append(fields, user.FieldDid)
|
||||
}
|
||||
if m.FieldCleared(user.FieldDelete) {
|
||||
fields = append(fields, user.FieldDelete)
|
||||
}
|
||||
if m.FieldCleared(user.FieldToken) {
|
||||
fields = append(fields, user.FieldToken)
|
||||
}
|
||||
@ -2048,6 +2115,9 @@ func (m *UserMutation) ClearField(name string) error {
|
||||
case user.FieldDid:
|
||||
m.ClearDid()
|
||||
return nil
|
||||
case user.FieldDelete:
|
||||
m.ClearDelete()
|
||||
return nil
|
||||
case user.FieldToken:
|
||||
m.ClearToken()
|
||||
return nil
|
||||
@ -2074,6 +2144,9 @@ func (m *UserMutation) ResetField(name string) error {
|
||||
case user.FieldDid:
|
||||
m.ResetDid()
|
||||
return nil
|
||||
case user.FieldDelete:
|
||||
m.ResetDelete()
|
||||
return nil
|
||||
case user.FieldToken:
|
||||
m.ResetToken()
|
||||
return nil
|
||||
|
@ -403,6 +403,12 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -423,13 +429,14 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfCardOwnerRead = [6]string{
|
||||
var jsonFieldsNameOfCardOwnerRead = [7]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
3: "delete",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
}
|
||||
|
||||
// Decode decodes CardOwnerRead from json.
|
||||
@ -475,6 +482,16 @@ func (s *CardOwnerRead) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -1290,6 +1307,12 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Token.Set {
|
||||
e.FieldStart("token")
|
||||
@ -1331,15 +1354,16 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfCreateUserReq = [8]string{
|
||||
var jsonFieldsNameOfCreateUserReq = [9]string{
|
||||
0: "username",
|
||||
1: "did",
|
||||
2: "token",
|
||||
3: "password",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
7: "card",
|
||||
2: "delete",
|
||||
3: "token",
|
||||
4: "password",
|
||||
5: "created_at",
|
||||
6: "updated_at",
|
||||
7: "next",
|
||||
8: "card",
|
||||
}
|
||||
|
||||
// Decode decodes CreateUserReq from json.
|
||||
@ -1347,7 +1371,7 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode CreateUserReq to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
var requiredBitSet [2]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
@ -1373,6 +1397,16 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "token":
|
||||
if err := func() error {
|
||||
s.Token.Reset()
|
||||
@ -1384,7 +1418,7 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"token\"")
|
||||
}
|
||||
case "password":
|
||||
requiredBitSet[0] |= 1 << 3
|
||||
requiredBitSet[0] |= 1 << 4
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.Password = string(v)
|
||||
@ -1453,8 +1487,9 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
|
||||
}
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00001001,
|
||||
for i, mask := range [2]uint8{
|
||||
0b00010001,
|
||||
0b00000000,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
@ -1985,6 +2020,12 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -2005,13 +2046,14 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfGroupUsersList = [6]string{
|
||||
var jsonFieldsNameOfGroupUsersList = [7]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
3: "delete",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
}
|
||||
|
||||
// Decode decodes GroupUsersList from json.
|
||||
@ -2057,6 +2099,16 @@ func (s *GroupUsersList) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -2393,6 +2445,41 @@ func (s *ListUserOKApplicationJSON) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes bool as json.
|
||||
func (o OptBool) Encode(e *jx.Encoder) {
|
||||
if !o.Set {
|
||||
return
|
||||
}
|
||||
e.Bool(bool(o.Value))
|
||||
}
|
||||
|
||||
// Decode decodes bool from json.
|
||||
func (o *OptBool) Decode(d *jx.Decoder) error {
|
||||
if o == nil {
|
||||
return errors.New("invalid: unable to decode OptBool to nil")
|
||||
}
|
||||
o.Set = true
|
||||
v, err := d.Bool()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.Value = bool(v)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements stdjson.Marshaler.
|
||||
func (s OptBool) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *OptBool) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes time.Time as json.
|
||||
func (o OptDateTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time)) {
|
||||
if !o.Set {
|
||||
@ -3199,6 +3286,18 @@ func (s *UpdateUserReq) Encode(e *jx.Encoder) {
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *UpdateUserReq) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Token.Set {
|
||||
e.FieldStart("token")
|
||||
@ -3229,11 +3328,13 @@ func (s *UpdateUserReq) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUpdateUserReq = [4]string{
|
||||
0: "token",
|
||||
1: "updated_at",
|
||||
2: "next",
|
||||
3: "card",
|
||||
var jsonFieldsNameOfUpdateUserReq = [6]string{
|
||||
0: "did",
|
||||
1: "delete",
|
||||
2: "token",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
5: "card",
|
||||
}
|
||||
|
||||
// Decode decodes UpdateUserReq from json.
|
||||
@ -3244,6 +3345,26 @@ func (s *UpdateUserReq) Decode(d *jx.Decoder) error {
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "did":
|
||||
if err := func() error {
|
||||
s.Did.Reset()
|
||||
if err := s.Did.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "token":
|
||||
if err := func() error {
|
||||
s.Token.Reset()
|
||||
@ -3524,6 +3645,12 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3544,13 +3671,14 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserCreate = [6]string{
|
||||
var jsonFieldsNameOfUserCreate = [7]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
3: "delete",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserCreate from json.
|
||||
@ -3596,6 +3724,16 @@ func (s *UserCreate) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -3707,6 +3845,12 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3727,13 +3871,14 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserList = [6]string{
|
||||
var jsonFieldsNameOfUserList = [7]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
3: "delete",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserList from json.
|
||||
@ -3779,6 +3924,16 @@ func (s *UserList) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -3890,6 +4045,12 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3910,13 +4071,14 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserRead = [6]string{
|
||||
var jsonFieldsNameOfUserRead = [7]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
3: "delete",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserRead from json.
|
||||
@ -3962,6 +4124,16 @@ func (s *UserRead) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -4073,6 +4245,12 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Delete.Set {
|
||||
e.FieldStart("delete")
|
||||
s.Delete.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -4093,13 +4271,14 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserUpdate = [6]string{
|
||||
var jsonFieldsNameOfUserUpdate = [7]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
3: "delete",
|
||||
4: "created_at",
|
||||
5: "updated_at",
|
||||
6: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserUpdate from json.
|
||||
@ -4145,6 +4324,16 @@ func (s *UserUpdate) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"did\"")
|
||||
}
|
||||
case "delete":
|
||||
if err := func() error {
|
||||
s.Delete.Reset()
|
||||
if err := s.Delete.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"delete\"")
|
||||
}
|
||||
case "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
|
@ -459,7 +459,7 @@ func decodeListCardParams(args [0]string, r *http.Request) (params ListCardParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 3000,
|
||||
Max: 3500,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -624,7 +624,7 @@ func decodeListGroupParams(args [0]string, r *http.Request) (params ListGroupPar
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 3000,
|
||||
Max: 3500,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -956,7 +956,7 @@ func decodeListUserParams(args [0]string, r *http.Request) (params ListUserParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 3000,
|
||||
Max: 3500,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
|
@ -155,6 +155,7 @@ type CardOwnerRead struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -175,6 +176,11 @@ func (s *CardOwnerRead) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *CardOwnerRead) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *CardOwnerRead) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -205,6 +211,11 @@ func (s *CardOwnerRead) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *CardOwnerRead) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *CardOwnerRead) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -485,6 +496,7 @@ func (s *CreateGroupReq) SetUsers(val []int) {
|
||||
type CreateUserReq struct {
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
Token OptString `json:"token"`
|
||||
Password string `json:"password"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
@ -503,6 +515,11 @@ func (s *CreateUserReq) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *CreateUserReq) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetToken returns the value of Token.
|
||||
func (s *CreateUserReq) GetToken() OptString {
|
||||
return s.Token
|
||||
@ -543,6 +560,11 @@ func (s *CreateUserReq) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *CreateUserReq) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetToken sets the value of Token.
|
||||
func (s *CreateUserReq) SetToken(val OptString) {
|
||||
s.Token = val
|
||||
@ -709,6 +731,7 @@ type GroupUsersList struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -729,6 +752,11 @@ func (s *GroupUsersList) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *GroupUsersList) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *GroupUsersList) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -759,6 +787,11 @@ func (s *GroupUsersList) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *GroupUsersList) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *GroupUsersList) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -794,6 +827,52 @@ type ListUserOKApplicationJSON []UserList
|
||||
|
||||
func (*ListUserOKApplicationJSON) listUserRes() {}
|
||||
|
||||
// NewOptBool returns new OptBool with value set to v.
|
||||
func NewOptBool(v bool) OptBool {
|
||||
return OptBool{
|
||||
Value: v,
|
||||
Set: true,
|
||||
}
|
||||
}
|
||||
|
||||
// OptBool is optional bool.
|
||||
type OptBool struct {
|
||||
Value bool
|
||||
Set bool
|
||||
}
|
||||
|
||||
// IsSet returns true if OptBool was set.
|
||||
func (o OptBool) IsSet() bool { return o.Set }
|
||||
|
||||
// Reset unsets value.
|
||||
func (o *OptBool) Reset() {
|
||||
var v bool
|
||||
o.Value = v
|
||||
o.Set = false
|
||||
}
|
||||
|
||||
// SetTo sets value to v.
|
||||
func (o *OptBool) SetTo(v bool) {
|
||||
o.Set = true
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// Get returns value and boolean that denotes whether value was set.
|
||||
func (o OptBool) Get() (v bool, ok bool) {
|
||||
if !o.Set {
|
||||
return v, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// Or returns value if set, or given parameter if does not.
|
||||
func (o OptBool) Or(d bool) bool {
|
||||
if v, ok := o.Get(); ok {
|
||||
return v
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// NewOptDateTime returns new OptDateTime with value set to v.
|
||||
func NewOptDateTime(v time.Time) OptDateTime {
|
||||
return OptDateTime{
|
||||
@ -1189,12 +1268,24 @@ func (s *UpdateGroupReq) SetUsers(val []int) {
|
||||
}
|
||||
|
||||
type UpdateUserReq struct {
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
Token OptString `json:"token"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
Card []int `json:"card"`
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *UpdateUserReq) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *UpdateUserReq) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetToken returns the value of Token.
|
||||
func (s *UpdateUserReq) GetToken() OptString {
|
||||
return s.Token
|
||||
@ -1215,6 +1306,16 @@ func (s *UpdateUserReq) GetCard() []int {
|
||||
return s.Card
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *UpdateUserReq) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *UpdateUserReq) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetToken sets the value of Token.
|
||||
func (s *UpdateUserReq) SetToken(val OptString) {
|
||||
s.Token = val
|
||||
@ -1310,6 +1411,7 @@ type UserCreate struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1330,6 +1432,11 @@ func (s *UserCreate) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *UserCreate) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserCreate) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1360,6 +1467,11 @@ func (s *UserCreate) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *UserCreate) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserCreate) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1382,6 +1494,7 @@ type UserList struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1402,6 +1515,11 @@ func (s *UserList) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *UserList) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserList) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1432,6 +1550,11 @@ func (s *UserList) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *UserList) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserList) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1452,6 +1575,7 @@ type UserRead struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1472,6 +1596,11 @@ func (s *UserRead) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *UserRead) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserRead) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1502,6 +1631,11 @@ func (s *UserRead) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *UserRead) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserRead) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1524,6 +1658,7 @@ type UserUpdate struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Delete OptBool `json:"delete"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1544,6 +1679,11 @@ func (s *UserUpdate) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetDelete returns the value of Delete.
|
||||
func (s *UserUpdate) GetDelete() OptBool {
|
||||
return s.Delete
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserUpdate) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1574,6 +1714,11 @@ func (s *UserUpdate) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetDelete sets the value of Delete.
|
||||
func (s *UserUpdate) SetDelete(val OptBool) {
|
||||
s.Delete = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserUpdate) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
|
@ -160,6 +160,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -543,6 +544,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
// Add all fields.
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ func NewCardOwnerRead(e *ent.User) *CardOwnerRead {
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -284,6 +285,7 @@ func NewGroupUsersList(e *ent.User) *GroupUsersList {
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -316,6 +318,7 @@ func NewUserCreate(e *ent.User) *UserCreate {
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -348,6 +351,7 @@ func NewUserList(e *ent.User) *UserList {
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -380,6 +384,7 @@ func NewUserRead(e *ent.User) *UserRead {
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -412,6 +417,7 @@ func NewUserUpdate(e *ent.User) *UserUpdate {
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
|
@ -30,7 +30,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 3000,
|
||||
"maximum": 3500,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -366,7 +366,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 3000,
|
||||
"maximum": 3500,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -692,7 +692,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 3000,
|
||||
"maximum": 3500,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -745,6 +745,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -906,6 +909,12 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -1201,6 +1210,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1315,6 +1327,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1344,6 +1359,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -1386,6 +1404,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1415,6 +1436,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1444,6 +1468,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1473,6 +1500,9 @@
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
|
@ -66,20 +66,24 @@ func init() {
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// userDescDelete is the schema descriptor for delete field.
|
||||
userDescDelete := userFields[2].Descriptor()
|
||||
// user.DefaultDelete holds the default value on creation for the delete field.
|
||||
user.DefaultDelete = userDescDelete.Default.(bool)
|
||||
// userDescPassword is the schema descriptor for password field.
|
||||
userDescPassword := userFields[3].Descriptor()
|
||||
userDescPassword := userFields[4].Descriptor()
|
||||
// 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)
|
||||
// userDescCreatedAt is the schema descriptor for created_at field.
|
||||
userDescCreatedAt := userFields[4].Descriptor()
|
||||
userDescCreatedAt := userFields[5].Descriptor()
|
||||
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
|
||||
// userDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
userDescUpdatedAt := userFields[5].Descriptor()
|
||||
userDescUpdatedAt := userFields[6].Descriptor()
|
||||
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
|
||||
// userDescNext is the schema descriptor for next field.
|
||||
userDescNext := userFields[6].Descriptor()
|
||||
userDescNext := userFields[7].Descriptor()
|
||||
// user.DefaultNext holds the default value on creation for the next field.
|
||||
user.DefaultNext = userDescNext.Default.(string)
|
||||
}
|
||||
|
@ -41,19 +41,23 @@ func (Card) Fields() []ent.Field {
|
||||
card = 2
|
||||
}
|
||||
|
||||
if card == 17 {
|
||||
card = 2
|
||||
}
|
||||
|
||||
// 2023/04/09 premium card id:15
|
||||
if card == 15 {
|
||||
card = 3
|
||||
}
|
||||
|
||||
// 2023/04/13 premium card id:16
|
||||
if card == 16 {
|
||||
card = 4
|
||||
}
|
||||
|
||||
if card == 17 {
|
||||
card = 5
|
||||
}
|
||||
|
||||
if card == 18 {
|
||||
card = 6
|
||||
}
|
||||
|
||||
return card
|
||||
}).
|
||||
Optional(),
|
||||
|
@ -36,8 +36,11 @@ func (User) Fields() []ent.Field {
|
||||
Unique(),
|
||||
|
||||
field.String("did").
|
||||
Optional().
|
||||
Immutable(),
|
||||
Optional(),
|
||||
|
||||
field.Bool("delete").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
|
13
ent/user.go
13
ent/user.go
@ -20,6 +20,8 @@ type User struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
// Did holds the value of the "did" field.
|
||||
Did string `json:"did,omitempty"`
|
||||
// Delete holds the value of the "delete" field.
|
||||
Delete bool `json:"delete,omitempty"`
|
||||
// Token holds the value of the "token" field.
|
||||
Token string `json:"-"`
|
||||
// Password holds the value of the "password" field.
|
||||
@ -59,6 +61,8 @@ func (*User) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case user.FieldDelete:
|
||||
values[i] = new(sql.NullBool)
|
||||
case user.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case user.FieldUsername, user.FieldDid, user.FieldToken, user.FieldPassword, user.FieldNext:
|
||||
@ -100,6 +104,12 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.Did = value.String
|
||||
}
|
||||
case user.FieldDelete:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field delete", values[i])
|
||||
} else if value.Valid {
|
||||
u.Delete = value.Bool
|
||||
}
|
||||
case user.FieldToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
@ -176,6 +186,9 @@ func (u *User) String() string {
|
||||
builder.WriteString("did=")
|
||||
builder.WriteString(u.Did)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("delete=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Delete))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
|
@ -15,6 +15,8 @@ const (
|
||||
FieldUsername = "username"
|
||||
// FieldDid holds the string denoting the did field in the database.
|
||||
FieldDid = "did"
|
||||
// FieldDelete holds the string denoting the delete field in the database.
|
||||
FieldDelete = "delete"
|
||||
// FieldToken holds the string denoting the token field in the database.
|
||||
FieldToken = "token"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
@ -43,6 +45,7 @@ var Columns = []string{
|
||||
FieldID,
|
||||
FieldUsername,
|
||||
FieldDid,
|
||||
FieldDelete,
|
||||
FieldToken,
|
||||
FieldPassword,
|
||||
FieldCreatedAt,
|
||||
@ -74,6 +77,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
|
||||
UsernameValidator func(string) error
|
||||
// DefaultDelete holds the default value on creation for the "delete" field.
|
||||
DefaultDelete bool
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
|
@ -65,6 +65,11 @@ func Did(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// Delete applies equality check predicate on the "delete" field. It's identical to DeleteEQ.
|
||||
func Delete(v bool) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldDelete, v))
|
||||
}
|
||||
|
||||
// Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
|
||||
func Token(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldToken, v))
|
||||
@ -230,6 +235,26 @@ func DidContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldDid, v))
|
||||
}
|
||||
|
||||
// DeleteEQ applies the EQ predicate on the "delete" field.
|
||||
func DeleteEQ(v bool) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldDelete, v))
|
||||
}
|
||||
|
||||
// DeleteNEQ applies the NEQ predicate on the "delete" field.
|
||||
func DeleteNEQ(v bool) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldDelete, v))
|
||||
}
|
||||
|
||||
// DeleteIsNil applies the IsNil predicate on the "delete" field.
|
||||
func DeleteIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldDelete))
|
||||
}
|
||||
|
||||
// DeleteNotNil applies the NotNil predicate on the "delete" field.
|
||||
func DeleteNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldDelete))
|
||||
}
|
||||
|
||||
// TokenEQ applies the EQ predicate on the "token" field.
|
||||
func TokenEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldToken, v))
|
||||
|
@ -41,6 +41,20 @@ func (uc *UserCreate) SetNillableDid(s *string) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetDelete sets the "delete" field.
|
||||
func (uc *UserCreate) SetDelete(b bool) *UserCreate {
|
||||
uc.mutation.SetDelete(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableDelete sets the "delete" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableDelete(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetDelete(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (uc *UserCreate) SetToken(s string) *UserCreate {
|
||||
uc.mutation.SetToken(s)
|
||||
@ -153,6 +167,10 @@ func (uc *UserCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UserCreate) defaults() {
|
||||
if _, ok := uc.mutation.Delete(); !ok {
|
||||
v := user.DefaultDelete
|
||||
uc.mutation.SetDelete(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
v := user.DefaultCreatedAt()
|
||||
uc.mutation.SetCreatedAt(v)
|
||||
@ -219,6 +237,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldDid, field.TypeString, value)
|
||||
_node.Did = value
|
||||
}
|
||||
if value, ok := uc.mutation.Delete(); ok {
|
||||
_spec.SetField(user.FieldDelete, field.TypeBool, value)
|
||||
_node.Delete = value
|
||||
}
|
||||
if value, ok := uc.mutation.Token(); ok {
|
||||
_spec.SetField(user.FieldToken, field.TypeString, value)
|
||||
_node.Token = value
|
||||
|
@ -29,6 +29,46 @@ func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
|
||||
return uu
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (uu *UserUpdate) SetDid(s string) *UserUpdate {
|
||||
uu.mutation.SetDid(s)
|
||||
return uu
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (uu *UserUpdate) SetNillableDid(s *string) *UserUpdate {
|
||||
if s != nil {
|
||||
uu.SetDid(*s)
|
||||
}
|
||||
return uu
|
||||
}
|
||||
|
||||
// ClearDid clears the value of the "did" field.
|
||||
func (uu *UserUpdate) ClearDid() *UserUpdate {
|
||||
uu.mutation.ClearDid()
|
||||
return uu
|
||||
}
|
||||
|
||||
// SetDelete sets the "delete" field.
|
||||
func (uu *UserUpdate) SetDelete(b bool) *UserUpdate {
|
||||
uu.mutation.SetDelete(b)
|
||||
return uu
|
||||
}
|
||||
|
||||
// SetNillableDelete sets the "delete" field if the given value is not nil.
|
||||
func (uu *UserUpdate) SetNillableDelete(b *bool) *UserUpdate {
|
||||
if b != nil {
|
||||
uu.SetDelete(*b)
|
||||
}
|
||||
return uu
|
||||
}
|
||||
|
||||
// ClearDelete clears the value of the "delete" field.
|
||||
func (uu *UserUpdate) ClearDelete() *UserUpdate {
|
||||
uu.mutation.ClearDelete()
|
||||
return uu
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (uu *UserUpdate) SetToken(s string) *UserUpdate {
|
||||
uu.mutation.SetToken(s)
|
||||
@ -166,9 +206,18 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := uu.mutation.Did(); ok {
|
||||
_spec.SetField(user.FieldDid, field.TypeString, value)
|
||||
}
|
||||
if uu.mutation.DidCleared() {
|
||||
_spec.ClearField(user.FieldDid, field.TypeString)
|
||||
}
|
||||
if value, ok := uu.mutation.Delete(); ok {
|
||||
_spec.SetField(user.FieldDelete, field.TypeBool, value)
|
||||
}
|
||||
if uu.mutation.DeleteCleared() {
|
||||
_spec.ClearField(user.FieldDelete, field.TypeBool)
|
||||
}
|
||||
if value, ok := uu.mutation.Token(); ok {
|
||||
_spec.SetField(user.FieldToken, field.TypeString, value)
|
||||
}
|
||||
@ -255,6 +304,46 @@ type UserUpdateOne struct {
|
||||
mutation *UserMutation
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (uuo *UserUpdateOne) SetDid(s string) *UserUpdateOne {
|
||||
uuo.mutation.SetDid(s)
|
||||
return uuo
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (uuo *UserUpdateOne) SetNillableDid(s *string) *UserUpdateOne {
|
||||
if s != nil {
|
||||
uuo.SetDid(*s)
|
||||
}
|
||||
return uuo
|
||||
}
|
||||
|
||||
// ClearDid clears the value of the "did" field.
|
||||
func (uuo *UserUpdateOne) ClearDid() *UserUpdateOne {
|
||||
uuo.mutation.ClearDid()
|
||||
return uuo
|
||||
}
|
||||
|
||||
// SetDelete sets the "delete" field.
|
||||
func (uuo *UserUpdateOne) SetDelete(b bool) *UserUpdateOne {
|
||||
uuo.mutation.SetDelete(b)
|
||||
return uuo
|
||||
}
|
||||
|
||||
// SetNillableDelete sets the "delete" field if the given value is not nil.
|
||||
func (uuo *UserUpdateOne) SetNillableDelete(b *bool) *UserUpdateOne {
|
||||
if b != nil {
|
||||
uuo.SetDelete(*b)
|
||||
}
|
||||
return uuo
|
||||
}
|
||||
|
||||
// ClearDelete clears the value of the "delete" field.
|
||||
func (uuo *UserUpdateOne) ClearDelete() *UserUpdateOne {
|
||||
uuo.mutation.ClearDelete()
|
||||
return uuo
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (uuo *UserUpdateOne) SetToken(s string) *UserUpdateOne {
|
||||
uuo.mutation.SetToken(s)
|
||||
@ -422,9 +511,18 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := uuo.mutation.Did(); ok {
|
||||
_spec.SetField(user.FieldDid, field.TypeString, value)
|
||||
}
|
||||
if uuo.mutation.DidCleared() {
|
||||
_spec.ClearField(user.FieldDid, field.TypeString)
|
||||
}
|
||||
if value, ok := uuo.mutation.Delete(); ok {
|
||||
_spec.SetField(user.FieldDelete, field.TypeBool, value)
|
||||
}
|
||||
if uuo.mutation.DeleteCleared() {
|
||||
_spec.ClearField(user.FieldDelete, field.TypeBool)
|
||||
}
|
||||
if value, ok := uuo.mutation.Token(); ok {
|
||||
_spec.SetField(user.FieldToken, field.TypeString, value)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/zsh
|
||||
echo old_id old_did new_name
|
||||
echo old_id new_id
|
||||
host=https://api.syui.ai
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
if [ -z "$1" ];then
|
||||
@ -8,17 +8,11 @@ fi
|
||||
if [ -z "$2" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$4" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
data=`curl -sL "$host/users/$id/card?itemsPerPage=2550"`
|
||||
echo $data
|
||||
id_n=$4
|
||||
id_n=$2
|
||||
echo $id_n
|
||||
read
|
||||
|
||||
@ -32,4 +26,3 @@ do
|
||||
cp=`echo $data|jq -r ".[$i].cp"`
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id_n,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" -sL $host/cards
|
||||
done
|
||||
|
||||
|
12
tmp/card_account_delete.zsh
Executable file
12
tmp/card_account_delete.zsh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/zsh
|
||||
echo id
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .pass`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":true,\"token\":\"$token\"}" -s $host/users/$id
|
||||
|
27
tmp/card_account_select_delete.zsh
Executable file
27
tmp/card_account_select_delete.zsh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/zsh
|
||||
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
d=${0:a:h}
|
||||
f=$d/t.txt
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f $f ];then
|
||||
echo $f
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
n=`cat $f|wc -l`
|
||||
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
card=`cat $d/t.txt|awk "NR==$i"`
|
||||
echo $card
|
||||
read
|
||||
curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$id\"}" https://api.syui.ai/cards/$card
|
||||
done
|
||||
|
||||
rm $d/t.txt
|
20
tmp/card_did_change.zsh
Executable file
20
tmp/card_did_change.zsh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/zsh
|
||||
echo id
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
echo $token
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .pass`
|
||||
if [ -z "$1" ];then
|
||||
echo 1 : id
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
echo 2 : did
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
did=$2
|
||||
|
||||
id=$1
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"did\":\"$did\",\"token\":\"$token\"}" -s $host/users/$id
|
@ -459,7 +459,7 @@ func decodeListCardParams(args [0]string, r *http.Request) (params ListCardParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 3000,
|
||||
Max: 3500,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -624,7 +624,7 @@ func decodeListGroupParams(args [0]string, r *http.Request) (params ListGroupPar
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 3000,
|
||||
Max: 3500,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -956,7 +956,7 @@ func decodeListUserParams(args [0]string, r *http.Request) (params ListUserParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 3000,
|
||||
Max: 3500,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
|
@ -160,6 +160,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -543,6 +544,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
// Add all fields.
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user