test did
This commit is contained in:
parent
ab66b9efc0
commit
d72f710aaa
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,3 +5,5 @@ t
|
||||
#*.zsh
|
||||
tmp/card_limit.zsh
|
||||
tmp/card_day.zsh
|
||||
tmp/card_delete.zsh
|
||||
memo.md
|
||||
|
@ -55,11 +55,12 @@ var (
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 30},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 100},
|
||||
{Name: "did", 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: "20230410"},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230414"},
|
||||
{Name: "group_users", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
@ -70,7 +71,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_groups_users",
|
||||
Columns: []*schema.Column{UsersColumns[6]},
|
||||
Columns: []*schema.Column{UsersColumns[7]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
@ -1343,6 +1343,7 @@ type UserMutation struct {
|
||||
typ string
|
||||
id *int
|
||||
username *string
|
||||
did *string
|
||||
password *string
|
||||
created_at *time.Time
|
||||
updated_at *time.Time
|
||||
@ -1490,6 +1491,55 @@ func (m *UserMutation) ResetUsername() {
|
||||
m.username = nil
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (m *UserMutation) SetDid(s string) {
|
||||
m.did = &s
|
||||
}
|
||||
|
||||
// Did returns the value of the "did" field in the mutation.
|
||||
func (m *UserMutation) Did() (r string, exists bool) {
|
||||
v := m.did
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldDid returns the old "did" 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) OldDid(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldDid is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldDid requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldDid: %w", err)
|
||||
}
|
||||
return oldValue.Did, nil
|
||||
}
|
||||
|
||||
// ClearDid clears the value of the "did" field.
|
||||
func (m *UserMutation) ClearDid() {
|
||||
m.did = nil
|
||||
m.clearedFields[user.FieldDid] = struct{}{}
|
||||
}
|
||||
|
||||
// DidCleared returns if the "did" field was cleared in this mutation.
|
||||
func (m *UserMutation) DidCleared() bool {
|
||||
_, ok := m.clearedFields[user.FieldDid]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetDid resets all changes to the "did" field.
|
||||
func (m *UserMutation) ResetDid() {
|
||||
m.did = nil
|
||||
delete(m.clearedFields, user.FieldDid)
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (m *UserMutation) SetPassword(s string) {
|
||||
m.password = &s
|
||||
@ -1761,10 +1811,13 @@ 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, 5)
|
||||
fields := make([]string, 0, 6)
|
||||
if m.username != nil {
|
||||
fields = append(fields, user.FieldUsername)
|
||||
}
|
||||
if m.did != nil {
|
||||
fields = append(fields, user.FieldDid)
|
||||
}
|
||||
if m.password != nil {
|
||||
fields = append(fields, user.FieldPassword)
|
||||
}
|
||||
@ -1787,6 +1840,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case user.FieldUsername:
|
||||
return m.Username()
|
||||
case user.FieldDid:
|
||||
return m.Did()
|
||||
case user.FieldPassword:
|
||||
return m.Password()
|
||||
case user.FieldCreatedAt:
|
||||
@ -1806,6 +1861,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
|
||||
switch name {
|
||||
case user.FieldUsername:
|
||||
return m.OldUsername(ctx)
|
||||
case user.FieldDid:
|
||||
return m.OldDid(ctx)
|
||||
case user.FieldPassword:
|
||||
return m.OldPassword(ctx)
|
||||
case user.FieldCreatedAt:
|
||||
@ -1830,6 +1887,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetUsername(v)
|
||||
return nil
|
||||
case user.FieldDid:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetDid(v)
|
||||
return nil
|
||||
case user.FieldPassword:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@ -1888,6 +1952,9 @@ func (m *UserMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *UserMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(user.FieldDid) {
|
||||
fields = append(fields, user.FieldDid)
|
||||
}
|
||||
if m.FieldCleared(user.FieldCreatedAt) {
|
||||
fields = append(fields, user.FieldCreatedAt)
|
||||
}
|
||||
@ -1911,6 +1978,9 @@ func (m *UserMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *UserMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case user.FieldDid:
|
||||
m.ClearDid()
|
||||
return nil
|
||||
case user.FieldCreatedAt:
|
||||
m.ClearCreatedAt()
|
||||
return nil
|
||||
@ -1931,6 +2001,9 @@ func (m *UserMutation) ResetField(name string) error {
|
||||
case user.FieldUsername:
|
||||
m.ResetUsername()
|
||||
return nil
|
||||
case user.FieldDid:
|
||||
m.ResetDid()
|
||||
return nil
|
||||
case user.FieldPassword:
|
||||
m.ResetPassword()
|
||||
return nil
|
||||
|
@ -397,6 +397,12 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -417,12 +423,13 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfCardOwnerRead = [5]string{
|
||||
var jsonFieldsNameOfCardOwnerRead = [6]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
}
|
||||
|
||||
// Decode decodes CardOwnerRead from json.
|
||||
@ -458,6 +465,16 @@ func (s *CardOwnerRead) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -1267,6 +1284,12 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
|
||||
e.FieldStart("password")
|
||||
@ -1302,13 +1325,14 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfCreateUserReq = [6]string{
|
||||
var jsonFieldsNameOfCreateUserReq = [7]string{
|
||||
0: "username",
|
||||
1: "password",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
5: "card",
|
||||
1: "did",
|
||||
2: "password",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
6: "card",
|
||||
}
|
||||
|
||||
// Decode decodes CreateUserReq from json.
|
||||
@ -1332,8 +1356,18 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "password":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
requiredBitSet[0] |= 1 << 2
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.Password = string(v)
|
||||
@ -1403,7 +1437,7 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00000011,
|
||||
0b00000101,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
@ -1928,6 +1962,12 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -1948,12 +1988,13 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfGroupUsersList = [5]string{
|
||||
var jsonFieldsNameOfGroupUsersList = [6]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
}
|
||||
|
||||
// Decode decodes GroupUsersList from json.
|
||||
@ -1989,6 +2030,16 @@ func (s *GroupUsersList) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -3433,6 +3484,12 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3453,12 +3510,13 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserCreate = [5]string{
|
||||
var jsonFieldsNameOfUserCreate = [6]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserCreate from json.
|
||||
@ -3494,6 +3552,16 @@ func (s *UserCreate) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -3599,6 +3667,12 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3619,12 +3693,13 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserList = [5]string{
|
||||
var jsonFieldsNameOfUserList = [6]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserList from json.
|
||||
@ -3660,6 +3735,16 @@ func (s *UserList) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -3765,6 +3850,12 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3785,12 +3876,13 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserRead = [5]string{
|
||||
var jsonFieldsNameOfUserRead = [6]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserRead from json.
|
||||
@ -3826,6 +3918,16 @@ func (s *UserRead) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
@ -3931,6 +4033,12 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("username")
|
||||
e.Str(s.Username)
|
||||
}
|
||||
{
|
||||
if s.Did.Set {
|
||||
e.FieldStart("did")
|
||||
s.Did.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.CreatedAt.Set {
|
||||
e.FieldStart("created_at")
|
||||
@ -3951,12 +4059,13 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUserUpdate = [5]string{
|
||||
var jsonFieldsNameOfUserUpdate = [6]string{
|
||||
0: "id",
|
||||
1: "username",
|
||||
2: "created_at",
|
||||
3: "updated_at",
|
||||
4: "next",
|
||||
2: "did",
|
||||
3: "created_at",
|
||||
4: "updated_at",
|
||||
5: "next",
|
||||
}
|
||||
|
||||
// Decode decodes UserUpdate from json.
|
||||
@ -3992,6 +4101,16 @@ func (s *UserUpdate) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"username\"")
|
||||
}
|
||||
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 "created_at":
|
||||
if err := func() error {
|
||||
s.CreatedAt.Reset()
|
||||
|
@ -154,6 +154,7 @@ func (s *CardList) SetCreatedAt(val OptDateTime) {
|
||||
type CardOwnerRead struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -169,6 +170,11 @@ func (s *CardOwnerRead) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *CardOwnerRead) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *CardOwnerRead) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -194,6 +200,11 @@ func (s *CardOwnerRead) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *CardOwnerRead) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *CardOwnerRead) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -473,6 +484,7 @@ func (s *CreateGroupReq) SetUsers(val []int) {
|
||||
|
||||
type CreateUserReq struct {
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
Password string `json:"password"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
@ -485,6 +497,11 @@ func (s *CreateUserReq) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *CreateUserReq) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetPassword returns the value of Password.
|
||||
func (s *CreateUserReq) GetPassword() string {
|
||||
return s.Password
|
||||
@ -515,6 +532,11 @@ func (s *CreateUserReq) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *CreateUserReq) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetPassword sets the value of Password.
|
||||
func (s *CreateUserReq) SetPassword(val string) {
|
||||
s.Password = val
|
||||
@ -675,6 +697,7 @@ func (*GroupUpdate) updateGroupRes() {}
|
||||
type GroupUsersList struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -690,6 +713,11 @@ func (s *GroupUsersList) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *GroupUsersList) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *GroupUsersList) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -715,6 +743,11 @@ func (s *GroupUsersList) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *GroupUsersList) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *GroupUsersList) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1254,6 +1287,7 @@ func (s *UserCardList) SetCreatedAt(val OptDateTime) {
|
||||
type UserCreate struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1269,6 +1303,11 @@ func (s *UserCreate) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *UserCreate) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserCreate) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1294,6 +1333,11 @@ func (s *UserCreate) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *UserCreate) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserCreate) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1315,6 +1359,7 @@ func (*UserCreate) createUserRes() {}
|
||||
type UserList struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1330,6 +1375,11 @@ func (s *UserList) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *UserList) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserList) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1355,6 +1405,11 @@ func (s *UserList) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *UserList) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserList) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1374,6 +1429,7 @@ func (s *UserList) SetNext(val OptString) {
|
||||
type UserRead struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1389,6 +1445,11 @@ func (s *UserRead) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *UserRead) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserRead) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1414,6 +1475,11 @@ func (s *UserRead) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *UserRead) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserRead) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
@ -1435,6 +1501,7 @@ func (*UserRead) readUserRes() {}
|
||||
type UserUpdate struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Did OptString `json:"did"`
|
||||
CreatedAt OptDateTime `json:"created_at"`
|
||||
UpdatedAt OptDateTime `json:"updated_at"`
|
||||
Next OptString `json:"next"`
|
||||
@ -1450,6 +1517,11 @@ func (s *UserUpdate) GetUsername() string {
|
||||
return s.Username
|
||||
}
|
||||
|
||||
// GetDid returns the value of Did.
|
||||
func (s *UserUpdate) GetDid() OptString {
|
||||
return s.Did
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *UserUpdate) GetCreatedAt() OptDateTime {
|
||||
return s.CreatedAt
|
||||
@ -1475,6 +1547,11 @@ func (s *UserUpdate) SetUsername(val string) {
|
||||
s.Username = val
|
||||
}
|
||||
|
||||
// SetDid sets the value of Did.
|
||||
func (s *UserUpdate) SetDid(val OptString) {
|
||||
s.Did = val
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *UserUpdate) SetCreatedAt(val OptDateTime) {
|
||||
s.CreatedAt = val
|
||||
|
@ -459,7 +459,11 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
|
@ -139,6 +139,7 @@ func NewCardOwnerRead(e *ent.User) *CardOwnerRead {
|
||||
var ret CardOwnerRead
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -282,6 +283,7 @@ func NewGroupUsersList(e *ent.User) *GroupUsersList {
|
||||
var ret GroupUsersList
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -313,6 +315,7 @@ func NewUserCreate(e *ent.User) *UserCreate {
|
||||
var ret UserCreate
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -344,6 +347,7 @@ func NewUserList(e *ent.User) *UserList {
|
||||
var ret UserList
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -375,6 +379,7 @@ func NewUserRead(e *ent.User) *UserRead {
|
||||
var ret UserRead
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
@ -406,6 +411,7 @@ func NewUserUpdate(e *ent.User) *UserUpdate {
|
||||
var ret UserUpdate
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
|
@ -742,6 +742,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -1189,6 +1192,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1300,6 +1306,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1326,6 +1335,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -1362,6 +1374,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1388,6 +1403,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1414,6 +1432,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@ -1440,6 +1461,9 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
|
@ -67,19 +67,19 @@ func init() {
|
||||
}
|
||||
}()
|
||||
// userDescPassword is the schema descriptor for password field.
|
||||
userDescPassword := userFields[1].Descriptor()
|
||||
userDescPassword := userFields[2].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[2].Descriptor()
|
||||
userDescCreatedAt := userFields[3].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[3].Descriptor()
|
||||
userDescUpdatedAt := userFields[4].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[4].Descriptor()
|
||||
userDescNext := userFields[5].Descriptor()
|
||||
// user.DefaultNext holds the default value on creation for the next field.
|
||||
user.DefaultNext = userDescNext.Default.(string)
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ func (Card) Fields() []ent.Field {
|
||||
if card == 15 {
|
||||
card = 1
|
||||
}
|
||||
|
||||
// 2023/04/13 premium card id:16
|
||||
if card == 16 {
|
||||
card = 1
|
||||
}
|
||||
return card
|
||||
}).
|
||||
Optional(),
|
||||
|
@ -31,19 +31,19 @@ func (User) Fields() []ent.Field {
|
||||
field.String("username").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
MaxLen(30).
|
||||
MaxLen(100).
|
||||
//Match(regexp.MustCompile("[a-z]+$")).
|
||||
Unique(),
|
||||
|
||||
field.String("did").
|
||||
Optional().
|
||||
Immutable(),
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
//field.Bool("limit").
|
||||
//Optional().
|
||||
//Default(false),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Optional().
|
||||
|
13
ent/user.go
13
ent/user.go
@ -18,6 +18,8 @@ type User struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
// Username holds the value of the "username" field.
|
||||
Username string `json:"username,omitempty"`
|
||||
// Did holds the value of the "did" field.
|
||||
Did string `json:"did,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
@ -57,7 +59,7 @@ func (*User) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case user.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case user.FieldUsername, user.FieldPassword, user.FieldNext:
|
||||
case user.FieldUsername, user.FieldDid, user.FieldPassword, user.FieldNext:
|
||||
values[i] = new(sql.NullString)
|
||||
case user.FieldCreatedAt, user.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
@ -90,6 +92,12 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.Username = value.String
|
||||
}
|
||||
case user.FieldDid:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field did", values[i])
|
||||
} else if value.Valid {
|
||||
u.Did = value.String
|
||||
}
|
||||
case user.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
@ -157,6 +165,9 @@ func (u *User) String() string {
|
||||
builder.WriteString("username=")
|
||||
builder.WriteString(u.Username)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("did=")
|
||||
builder.WriteString(u.Did)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
|
@ -13,6 +13,8 @@ const (
|
||||
FieldID = "id"
|
||||
// FieldUsername holds the string denoting the username field in the database.
|
||||
FieldUsername = "username"
|
||||
// FieldDid holds the string denoting the did field in the database.
|
||||
FieldDid = "did"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
@ -38,6 +40,7 @@ const (
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldUsername,
|
||||
FieldDid,
|
||||
FieldPassword,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
|
@ -60,6 +60,11 @@ func Username(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldUsername, v))
|
||||
}
|
||||
|
||||
// Did applies equality check predicate on the "did" field. It's identical to DidEQ.
|
||||
func Did(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
|
||||
func Password(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPassword, v))
|
||||
@ -145,6 +150,81 @@ func UsernameContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldUsername, v))
|
||||
}
|
||||
|
||||
// DidEQ applies the EQ predicate on the "did" field.
|
||||
func DidEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidNEQ applies the NEQ predicate on the "did" field.
|
||||
func DidNEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidIn applies the In predicate on the "did" field.
|
||||
func DidIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldDid, vs...))
|
||||
}
|
||||
|
||||
// DidNotIn applies the NotIn predicate on the "did" field.
|
||||
func DidNotIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldDid, vs...))
|
||||
}
|
||||
|
||||
// DidGT applies the GT predicate on the "did" field.
|
||||
func DidGT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidGTE applies the GTE predicate on the "did" field.
|
||||
func DidGTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidLT applies the LT predicate on the "did" field.
|
||||
func DidLT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidLTE applies the LTE predicate on the "did" field.
|
||||
func DidLTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidContains applies the Contains predicate on the "did" field.
|
||||
func DidContains(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContains(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidHasPrefix applies the HasPrefix predicate on the "did" field.
|
||||
func DidHasPrefix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasPrefix(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidHasSuffix applies the HasSuffix predicate on the "did" field.
|
||||
func DidHasSuffix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasSuffix(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidIsNil applies the IsNil predicate on the "did" field.
|
||||
func DidIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldDid))
|
||||
}
|
||||
|
||||
// DidNotNil applies the NotNil predicate on the "did" field.
|
||||
func DidNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldDid))
|
||||
}
|
||||
|
||||
// DidEqualFold applies the EqualFold predicate on the "did" field.
|
||||
func DidEqualFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEqualFold(FieldDid, v))
|
||||
}
|
||||
|
||||
// DidContainsFold applies the ContainsFold predicate on the "did" field.
|
||||
func DidContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldDid, v))
|
||||
}
|
||||
|
||||
// PasswordEQ applies the EQ predicate on the "password" field.
|
||||
func PasswordEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPassword, v))
|
||||
|
@ -27,6 +27,20 @@ func (uc *UserCreate) SetUsername(s string) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (uc *UserCreate) SetDid(s string) *UserCreate {
|
||||
uc.mutation.SetDid(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableDid(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetDid(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (uc *UserCreate) SetPassword(s string) *UserCreate {
|
||||
uc.mutation.SetPassword(s)
|
||||
@ -187,6 +201,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||
_node.Username = value
|
||||
}
|
||||
if value, ok := uc.mutation.Did(); ok {
|
||||
_spec.SetField(user.FieldDid, field.TypeString, value)
|
||||
_node.Did = value
|
||||
}
|
||||
if value, ok := uc.mutation.Password(); ok {
|
||||
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
|
@ -146,6 +146,9 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if uu.mutation.DidCleared() {
|
||||
_spec.ClearField(user.FieldDid, field.TypeString)
|
||||
}
|
||||
if uu.mutation.CreatedAtCleared() {
|
||||
_spec.ClearField(user.FieldCreatedAt, field.TypeTime)
|
||||
}
|
||||
@ -373,6 +376,9 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
||||
}
|
||||
}
|
||||
}
|
||||
if uuo.mutation.DidCleared() {
|
||||
_spec.ClearField(user.FieldDid, field.TypeString)
|
||||
}
|
||||
if uuo.mutation.CreatedAtCleared() {
|
||||
_spec.ClearField(user.FieldCreatedAt, field.TypeTime)
|
||||
}
|
||||
|
3
main.go
3
main.go
@ -52,8 +52,7 @@ func (h handler) DrawDone(ctx context.Context, params ogent.DrawDoneParams) erro
|
||||
func main() {
|
||||
// Create ent client.
|
||||
client, err := ent.Open(dialect.SQLite, "file:/data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data/ent.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:/data/ent.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
3
run.zsh
Executable file
3
run.zsh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
d=${0:a:h}
|
||||
PASS=`cat token.json|jq -r .password` go run -mod=mod main.go
|
@ -7,15 +7,32 @@ host_users="$host/users?itemsPerPage=255"
|
||||
d=${0:a:h}
|
||||
dd=${0:a:h:h}
|
||||
pass=`cat $dd/token.json|jq -r .password`
|
||||
host_at=bsky.social
|
||||
|
||||
if [ -f $d/user.json ] && [ "$1" = "-s" ];then
|
||||
rm $d/user.json
|
||||
fi
|
||||
function did() {
|
||||
unset did
|
||||
url="https://$host_at/xrpc/com.atproto.repo.listRecords?repo=${name}.${host_at}&collection=app.bsky.actor.profile"
|
||||
if [ "`curl -sL $url| jq -r .error`" = "null" ];then
|
||||
t=`curl -sL $url | jq -r ".records|.[]|.uri"|cut -d / -f 3`
|
||||
did=$t
|
||||
else
|
||||
#did=`curl -sL "search.bsky.social/search/posts?q=$name" | jq -r ".[0].user.did"`
|
||||
did="null"
|
||||
fi
|
||||
echo "{\"name\":\"$name\",\"did\":\"$did\"}," >> $d/user.json
|
||||
}
|
||||
|
||||
function l_users() {
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"$name\",\"password\":\"$pass\"}" $api/users
|
||||
sleep 1
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"$name\",\"password\":\"$pass\",\"did\":\"$did\"}" $api/users
|
||||
#sleep 1
|
||||
}
|
||||
|
||||
function l_cards() {
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" $api/cards
|
||||
sleep 1
|
||||
#sleep 1
|
||||
}
|
||||
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
@ -26,7 +43,17 @@ do
|
||||
|
||||
name=`echo $data|jq ".[$i]"|jq -r .username`
|
||||
id=`echo $data|jq ".[$i]"|jq -r .id`
|
||||
echo "{\"username\":\"$name\"} localhost:8080/users"
|
||||
if [ "$1" = "-s" ];then
|
||||
did
|
||||
else
|
||||
did=`cat $d/user.json|jq -r ".[]|select(.name == \"$name\")|.did"`
|
||||
fi
|
||||
echo "{\"username\":\"$name\", \"password\":\"$pass\",\"did\":\"$did\"} localhost:8080/users"
|
||||
#if [ "$did" = "null" ];then
|
||||
# echo "{\"username\":\"$name\", \"password\":\"$pass\",\"did\":\"$did\"} localhost:8080/users"
|
||||
#else
|
||||
# echo "{\"username\":\"$name\", \"password\":\"$pass\"} localhost:8080/users"
|
||||
#fi
|
||||
if [ "$1" = "-a" ];then
|
||||
l_users
|
||||
fi
|
||||
@ -35,15 +62,16 @@ do
|
||||
nn=`echo $data_card|jq length`
|
||||
nn=$((nn - 1))
|
||||
|
||||
if [ "$1" != "-s" ];then
|
||||
for ((ii=0;ii<=$nn;ii++))
|
||||
do
|
||||
card=`echo $data_card|jq -r ".[$ii].card"`
|
||||
s=`echo $data_card|jq -r ".[$ii].status"`
|
||||
cp=`echo $data_card|jq -r ".[$ii].cp"`
|
||||
echo "{\"owner\":$id,\"card\":\"$card\",\"status\":\"$s\",\"cp\":\"$cp\"} localhost:8080/cards"
|
||||
echo "{\"owner\":$id,\"card\":\"$card\",\"status\":\"$s\",\"cp\":\"$cp\", \"password\":\"$pass\"} localhost:8080/cards"
|
||||
if [ "$1" = "-a" ];then
|
||||
l_cards
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -459,7 +459,11 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user