1
0
This commit is contained in:
syui 2023-07-01 23:21:48 +09:00
parent 53f275cbb3
commit 93a50de9c5
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
28 changed files with 1240 additions and 201 deletions

View File

@ -2,6 +2,13 @@
d=${0:a:h} d=${0:a:h}
cd $d cd $d
su=4000
go generate ./... go generate ./...
sed -i '' "s/255/$su/g" $d/ent/ogent/oas_parameters_gen.go
sed -i '' "s/255/$su/g" $d/ent/openapi.json
cp -rf $d/ent/ogent/oas_parameters_gen.go $d/tmp/ogent/oas_parameters_gen.go
cp -rf $d/ent/ogent/openapi.json $d/tmp/openapi.json
cp -rf $d/tmp/ogent ent/ cp -rf $d/tmp/ogent ent/
cp -rf $d/tmp/openapi.json ent/ cp -rf $d/tmp/openapi.json ent/

View File

@ -25,6 +25,8 @@ type Card struct {
Skill string `json:"skill,omitempty"` Skill string `json:"skill,omitempty"`
// Status holds the value of the "status" field. // Status holds the value of the "status" field.
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
// Token holds the value of the "token" field.
Token string `json:"-"`
// Cp holds the value of the "cp" field. // Cp holds the value of the "cp" field.
Cp int `json:"cp,omitempty"` Cp int `json:"cp,omitempty"`
// URL holds the value of the "url" field. // URL holds the value of the "url" field.
@ -66,7 +68,7 @@ func (*Card) scanValues(columns []string) ([]any, error) {
switch columns[i] { switch columns[i] {
case card.FieldID, card.FieldCard, card.FieldCp: case card.FieldID, card.FieldCard, card.FieldCp:
values[i] = new(sql.NullInt64) values[i] = new(sql.NullInt64)
case card.FieldPassword, card.FieldSkill, card.FieldStatus, card.FieldURL: case card.FieldPassword, card.FieldSkill, card.FieldStatus, card.FieldToken, card.FieldURL:
values[i] = new(sql.NullString) values[i] = new(sql.NullString)
case card.FieldCreatedAt: case card.FieldCreatedAt:
values[i] = new(sql.NullTime) values[i] = new(sql.NullTime)
@ -117,6 +119,12 @@ func (c *Card) assignValues(columns []string, values []any) error {
} else if value.Valid { } else if value.Valid {
c.Status = value.String c.Status = value.String
} }
case card.FieldToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field token", values[i])
} else if value.Valid {
c.Token = value.String
}
case card.FieldCp: case card.FieldCp:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field cp", values[i]) return fmt.Errorf("unexpected type %T for field cp", values[i])
@ -186,6 +194,8 @@ func (c *Card) String() string {
builder.WriteString("status=") builder.WriteString("status=")
builder.WriteString(c.Status) builder.WriteString(c.Status)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("token=<sensitive>")
builder.WriteString(", ")
builder.WriteString("cp=") builder.WriteString("cp=")
builder.WriteString(fmt.Sprintf("%v", c.Cp)) builder.WriteString(fmt.Sprintf("%v", c.Cp))
builder.WriteString(", ") builder.WriteString(", ")

View File

@ -19,6 +19,8 @@ const (
FieldSkill = "skill" FieldSkill = "skill"
// FieldStatus holds the string denoting the status field in the database. // FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status" FieldStatus = "status"
// FieldToken holds the string denoting the token field in the database.
FieldToken = "token"
// FieldCp holds the string denoting the cp field in the database. // FieldCp holds the string denoting the cp field in the database.
FieldCp = "cp" FieldCp = "cp"
// FieldURL holds the string denoting the url field in the database. // FieldURL holds the string denoting the url field in the database.
@ -45,6 +47,7 @@ var Columns = []string{
FieldCard, FieldCard,
FieldSkill, FieldSkill,
FieldStatus, FieldStatus,
FieldToken,
FieldCp, FieldCp,
FieldURL, FieldURL,
FieldCreatedAt, FieldCreatedAt,

View File

@ -75,6 +75,11 @@ func Status(v string) predicate.Card {
return predicate.Card(sql.FieldEQ(FieldStatus, v)) return predicate.Card(sql.FieldEQ(FieldStatus, v))
} }
// Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
func Token(v string) predicate.Card {
return predicate.Card(sql.FieldEQ(FieldToken, v))
}
// Cp applies equality check predicate on the "cp" field. It's identical to CpEQ. // Cp applies equality check predicate on the "cp" field. It's identical to CpEQ.
func Cp(v int) predicate.Card { func Cp(v int) predicate.Card {
return predicate.Card(sql.FieldEQ(FieldCp, v)) return predicate.Card(sql.FieldEQ(FieldCp, v))
@ -355,6 +360,81 @@ func StatusContainsFold(v string) predicate.Card {
return predicate.Card(sql.FieldContainsFold(FieldStatus, v)) return predicate.Card(sql.FieldContainsFold(FieldStatus, v))
} }
// TokenEQ applies the EQ predicate on the "token" field.
func TokenEQ(v string) predicate.Card {
return predicate.Card(sql.FieldEQ(FieldToken, v))
}
// TokenNEQ applies the NEQ predicate on the "token" field.
func TokenNEQ(v string) predicate.Card {
return predicate.Card(sql.FieldNEQ(FieldToken, v))
}
// TokenIn applies the In predicate on the "token" field.
func TokenIn(vs ...string) predicate.Card {
return predicate.Card(sql.FieldIn(FieldToken, vs...))
}
// TokenNotIn applies the NotIn predicate on the "token" field.
func TokenNotIn(vs ...string) predicate.Card {
return predicate.Card(sql.FieldNotIn(FieldToken, vs...))
}
// TokenGT applies the GT predicate on the "token" field.
func TokenGT(v string) predicate.Card {
return predicate.Card(sql.FieldGT(FieldToken, v))
}
// TokenGTE applies the GTE predicate on the "token" field.
func TokenGTE(v string) predicate.Card {
return predicate.Card(sql.FieldGTE(FieldToken, v))
}
// TokenLT applies the LT predicate on the "token" field.
func TokenLT(v string) predicate.Card {
return predicate.Card(sql.FieldLT(FieldToken, v))
}
// TokenLTE applies the LTE predicate on the "token" field.
func TokenLTE(v string) predicate.Card {
return predicate.Card(sql.FieldLTE(FieldToken, v))
}
// TokenContains applies the Contains predicate on the "token" field.
func TokenContains(v string) predicate.Card {
return predicate.Card(sql.FieldContains(FieldToken, v))
}
// TokenHasPrefix applies the HasPrefix predicate on the "token" field.
func TokenHasPrefix(v string) predicate.Card {
return predicate.Card(sql.FieldHasPrefix(FieldToken, v))
}
// TokenHasSuffix applies the HasSuffix predicate on the "token" field.
func TokenHasSuffix(v string) predicate.Card {
return predicate.Card(sql.FieldHasSuffix(FieldToken, v))
}
// TokenIsNil applies the IsNil predicate on the "token" field.
func TokenIsNil() predicate.Card {
return predicate.Card(sql.FieldIsNull(FieldToken))
}
// TokenNotNil applies the NotNil predicate on the "token" field.
func TokenNotNil() predicate.Card {
return predicate.Card(sql.FieldNotNull(FieldToken))
}
// TokenEqualFold applies the EqualFold predicate on the "token" field.
func TokenEqualFold(v string) predicate.Card {
return predicate.Card(sql.FieldEqualFold(FieldToken, v))
}
// TokenContainsFold applies the ContainsFold predicate on the "token" field.
func TokenContainsFold(v string) predicate.Card {
return predicate.Card(sql.FieldContainsFold(FieldToken, v))
}
// CpEQ applies the EQ predicate on the "cp" field. // CpEQ applies the EQ predicate on the "cp" field.
func CpEQ(v int) predicate.Card { func CpEQ(v int) predicate.Card {
return predicate.Card(sql.FieldEQ(FieldCp, v)) return predicate.Card(sql.FieldEQ(FieldCp, v))

View File

@ -69,6 +69,20 @@ func (cc *CardCreate) SetNillableStatus(s *string) *CardCreate {
return cc return cc
} }
// SetToken sets the "token" field.
func (cc *CardCreate) SetToken(s string) *CardCreate {
cc.mutation.SetToken(s)
return cc
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (cc *CardCreate) SetNillableToken(s *string) *CardCreate {
if s != nil {
cc.SetToken(*s)
}
return cc
}
// SetCp sets the "cp" field. // SetCp sets the "cp" field.
func (cc *CardCreate) SetCp(i int) *CardCreate { func (cc *CardCreate) SetCp(i int) *CardCreate {
cc.mutation.SetCp(i) cc.mutation.SetCp(i)
@ -238,6 +252,10 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
_spec.SetField(card.FieldStatus, field.TypeString, value) _spec.SetField(card.FieldStatus, field.TypeString, value)
_node.Status = value _node.Status = value
} }
if value, ok := cc.mutation.Token(); ok {
_spec.SetField(card.FieldToken, field.TypeString, value)
_node.Token = value
}
if value, ok := cc.mutation.Cp(); ok { if value, ok := cc.mutation.Cp(); ok {
_spec.SetField(card.FieldCp, field.TypeInt, value) _spec.SetField(card.FieldCp, field.TypeInt, value)
_node.Cp = value _node.Cp = value

View File

@ -48,6 +48,73 @@ func (cu *CardUpdate) ClearSkill() *CardUpdate {
return cu return cu
} }
// SetStatus sets the "status" field.
func (cu *CardUpdate) SetStatus(s string) *CardUpdate {
cu.mutation.SetStatus(s)
return cu
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (cu *CardUpdate) SetNillableStatus(s *string) *CardUpdate {
if s != nil {
cu.SetStatus(*s)
}
return cu
}
// ClearStatus clears the value of the "status" field.
func (cu *CardUpdate) ClearStatus() *CardUpdate {
cu.mutation.ClearStatus()
return cu
}
// SetToken sets the "token" field.
func (cu *CardUpdate) SetToken(s string) *CardUpdate {
cu.mutation.SetToken(s)
return cu
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (cu *CardUpdate) SetNillableToken(s *string) *CardUpdate {
if s != nil {
cu.SetToken(*s)
}
return cu
}
// ClearToken clears the value of the "token" field.
func (cu *CardUpdate) ClearToken() *CardUpdate {
cu.mutation.ClearToken()
return cu
}
// SetCp sets the "cp" field.
func (cu *CardUpdate) SetCp(i int) *CardUpdate {
cu.mutation.ResetCp()
cu.mutation.SetCp(i)
return cu
}
// SetNillableCp sets the "cp" field if the given value is not nil.
func (cu *CardUpdate) SetNillableCp(i *int) *CardUpdate {
if i != nil {
cu.SetCp(*i)
}
return cu
}
// AddCp adds i to the "cp" field.
func (cu *CardUpdate) AddCp(i int) *CardUpdate {
cu.mutation.AddCp(i)
return cu
}
// ClearCp clears the value of the "cp" field.
func (cu *CardUpdate) ClearCp() *CardUpdate {
cu.mutation.ClearCp()
return cu
}
// SetOwnerID sets the "owner" edge to the User entity by ID. // SetOwnerID sets the "owner" edge to the User entity by ID.
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate { func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
cu.mutation.SetOwnerID(id) cu.mutation.SetOwnerID(id)
@ -126,9 +193,24 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
if cu.mutation.SkillCleared() { if cu.mutation.SkillCleared() {
_spec.ClearField(card.FieldSkill, field.TypeString) _spec.ClearField(card.FieldSkill, field.TypeString)
} }
if value, ok := cu.mutation.Status(); ok {
_spec.SetField(card.FieldStatus, field.TypeString, value)
}
if cu.mutation.StatusCleared() { if cu.mutation.StatusCleared() {
_spec.ClearField(card.FieldStatus, field.TypeString) _spec.ClearField(card.FieldStatus, field.TypeString)
} }
if value, ok := cu.mutation.Token(); ok {
_spec.SetField(card.FieldToken, field.TypeString, value)
}
if cu.mutation.TokenCleared() {
_spec.ClearField(card.FieldToken, field.TypeString)
}
if value, ok := cu.mutation.Cp(); ok {
_spec.SetField(card.FieldCp, field.TypeInt, value)
}
if value, ok := cu.mutation.AddedCp(); ok {
_spec.AddField(card.FieldCp, field.TypeInt, value)
}
if cu.mutation.CpCleared() { if cu.mutation.CpCleared() {
_spec.ClearField(card.FieldCp, field.TypeInt) _spec.ClearField(card.FieldCp, field.TypeInt)
} }
@ -207,6 +289,73 @@ func (cuo *CardUpdateOne) ClearSkill() *CardUpdateOne {
return cuo return cuo
} }
// SetStatus sets the "status" field.
func (cuo *CardUpdateOne) SetStatus(s string) *CardUpdateOne {
cuo.mutation.SetStatus(s)
return cuo
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableStatus(s *string) *CardUpdateOne {
if s != nil {
cuo.SetStatus(*s)
}
return cuo
}
// ClearStatus clears the value of the "status" field.
func (cuo *CardUpdateOne) ClearStatus() *CardUpdateOne {
cuo.mutation.ClearStatus()
return cuo
}
// SetToken sets the "token" field.
func (cuo *CardUpdateOne) SetToken(s string) *CardUpdateOne {
cuo.mutation.SetToken(s)
return cuo
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableToken(s *string) *CardUpdateOne {
if s != nil {
cuo.SetToken(*s)
}
return cuo
}
// ClearToken clears the value of the "token" field.
func (cuo *CardUpdateOne) ClearToken() *CardUpdateOne {
cuo.mutation.ClearToken()
return cuo
}
// SetCp sets the "cp" field.
func (cuo *CardUpdateOne) SetCp(i int) *CardUpdateOne {
cuo.mutation.ResetCp()
cuo.mutation.SetCp(i)
return cuo
}
// SetNillableCp sets the "cp" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableCp(i *int) *CardUpdateOne {
if i != nil {
cuo.SetCp(*i)
}
return cuo
}
// AddCp adds i to the "cp" field.
func (cuo *CardUpdateOne) AddCp(i int) *CardUpdateOne {
cuo.mutation.AddCp(i)
return cuo
}
// ClearCp clears the value of the "cp" field.
func (cuo *CardUpdateOne) ClearCp() *CardUpdateOne {
cuo.mutation.ClearCp()
return cuo
}
// SetOwnerID sets the "owner" edge to the User entity by ID. // SetOwnerID sets the "owner" edge to the User entity by ID.
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne { func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
cuo.mutation.SetOwnerID(id) cuo.mutation.SetOwnerID(id)
@ -315,9 +464,24 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
if cuo.mutation.SkillCleared() { if cuo.mutation.SkillCleared() {
_spec.ClearField(card.FieldSkill, field.TypeString) _spec.ClearField(card.FieldSkill, field.TypeString)
} }
if value, ok := cuo.mutation.Status(); ok {
_spec.SetField(card.FieldStatus, field.TypeString, value)
}
if cuo.mutation.StatusCleared() { if cuo.mutation.StatusCleared() {
_spec.ClearField(card.FieldStatus, field.TypeString) _spec.ClearField(card.FieldStatus, field.TypeString)
} }
if value, ok := cuo.mutation.Token(); ok {
_spec.SetField(card.FieldToken, field.TypeString, value)
}
if cuo.mutation.TokenCleared() {
_spec.ClearField(card.FieldToken, field.TypeString)
}
if value, ok := cuo.mutation.Cp(); ok {
_spec.SetField(card.FieldCp, field.TypeInt, value)
}
if value, ok := cuo.mutation.AddedCp(); ok {
_spec.AddField(card.FieldCp, field.TypeInt, value)
}
if cuo.mutation.CpCleared() { if cuo.mutation.CpCleared() {
_spec.ClearField(card.FieldCp, field.TypeInt) _spec.ClearField(card.FieldCp, field.TypeInt)
} }

View File

@ -15,6 +15,7 @@ var (
{Name: "card", Type: field.TypeInt, Nullable: true}, {Name: "card", Type: field.TypeInt, Nullable: true},
{Name: "skill", Type: field.TypeString, Nullable: true}, {Name: "skill", Type: field.TypeString, Nullable: true},
{Name: "status", Type: field.TypeString, Nullable: true}, {Name: "status", Type: field.TypeString, Nullable: true},
{Name: "token", Type: field.TypeString, Nullable: true},
{Name: "cp", Type: field.TypeInt, Nullable: true}, {Name: "cp", Type: field.TypeInt, Nullable: true},
{Name: "url", Type: field.TypeString, Nullable: true, Default: "https://card.syui.ai"}, {Name: "url", Type: field.TypeString, Nullable: true, Default: "https://card.syui.ai"},
{Name: "created_at", Type: field.TypeTime, Nullable: true}, {Name: "created_at", Type: field.TypeTime, Nullable: true},
@ -28,7 +29,7 @@ var (
ForeignKeys: []*schema.ForeignKey{ ForeignKeys: []*schema.ForeignKey{
{ {
Symbol: "cards_users_card", Symbol: "cards_users_card",
Columns: []*schema.Column{CardsColumns[8]}, Columns: []*schema.Column{CardsColumns[9]},
RefColumns: []*schema.Column{UsersColumns[0]}, RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.NoAction, OnDelete: schema.NoAction,
}, },
@ -70,6 +71,7 @@ var (
{Name: "like", Type: field.TypeInt, Nullable: true}, {Name: "like", Type: field.TypeInt, Nullable: true},
{Name: "like_rank", Type: field.TypeInt, Nullable: true}, {Name: "like_rank", Type: field.TypeInt, Nullable: true},
{Name: "like_at", Type: field.TypeTime, Nullable: true}, {Name: "like_at", Type: field.TypeTime, Nullable: true},
{Name: "fav", Type: field.TypeInt, Nullable: true},
{Name: "ten", Type: field.TypeBool, Nullable: true}, {Name: "ten", Type: field.TypeBool, Nullable: true},
{Name: "ten_su", Type: field.TypeInt, Nullable: true}, {Name: "ten_su", Type: field.TypeInt, Nullable: true},
{Name: "ten_kai", Type: field.TypeInt, Nullable: true}, {Name: "ten_kai", Type: field.TypeInt, Nullable: true},
@ -79,7 +81,7 @@ var (
{Name: "ten_post", Type: field.TypeString, Nullable: true}, {Name: "ten_post", Type: field.TypeString, Nullable: true},
{Name: "ten_get", Type: field.TypeString, Nullable: true}, {Name: "ten_get", Type: field.TypeString, Nullable: true},
{Name: "ten_at", Type: field.TypeTime, Nullable: true}, {Name: "ten_at", Type: field.TypeTime, Nullable: true},
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230701"}, {Name: "next", Type: field.TypeString, Nullable: true, Default: "20230708"},
{Name: "group_users", Type: field.TypeInt, Nullable: true}, {Name: "group_users", Type: field.TypeInt, Nullable: true},
} }
// UsersTable holds the schema information for the "users" table. // UsersTable holds the schema information for the "users" table.
@ -90,7 +92,7 @@ var (
ForeignKeys: []*schema.ForeignKey{ ForeignKeys: []*schema.ForeignKey{
{ {
Symbol: "users_groups_users", Symbol: "users_groups_users",
Columns: []*schema.Column{UsersColumns[25]}, Columns: []*schema.Column{UsersColumns[26]},
RefColumns: []*schema.Column{GroupsColumns[0]}, RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.SetNull, OnDelete: schema.SetNull,
}, },

View File

@ -42,6 +42,7 @@ type CardMutation struct {
addcard *int addcard *int
skill *string skill *string
status *string status *string
token *string
cp *int cp *int
addcp *int addcp *int
url *string url *string
@ -356,6 +357,55 @@ func (m *CardMutation) ResetStatus() {
delete(m.clearedFields, card.FieldStatus) delete(m.clearedFields, card.FieldStatus)
} }
// SetToken sets the "token" field.
func (m *CardMutation) SetToken(s string) {
m.token = &s
}
// Token returns the value of the "token" field in the mutation.
func (m *CardMutation) Token() (r string, exists bool) {
v := m.token
if v == nil {
return
}
return *v, true
}
// OldToken returns the old "token" field's value of the Card entity.
// If the Card 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 *CardMutation) OldToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldToken: %w", err)
}
return oldValue.Token, nil
}
// ClearToken clears the value of the "token" field.
func (m *CardMutation) ClearToken() {
m.token = nil
m.clearedFields[card.FieldToken] = struct{}{}
}
// TokenCleared returns if the "token" field was cleared in this mutation.
func (m *CardMutation) TokenCleared() bool {
_, ok := m.clearedFields[card.FieldToken]
return ok
}
// ResetToken resets all changes to the "token" field.
func (m *CardMutation) ResetToken() {
m.token = nil
delete(m.clearedFields, card.FieldToken)
}
// SetCp sets the "cp" field. // SetCp sets the "cp" field.
func (m *CardMutation) SetCp(i int) { func (m *CardMutation) SetCp(i int) {
m.cp = &i m.cp = &i
@ -597,7 +647,7 @@ func (m *CardMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call // order to get all numeric fields that were incremented/decremented, call
// AddedFields(). // AddedFields().
func (m *CardMutation) Fields() []string { func (m *CardMutation) Fields() []string {
fields := make([]string, 0, 7) fields := make([]string, 0, 8)
if m.password != nil { if m.password != nil {
fields = append(fields, card.FieldPassword) fields = append(fields, card.FieldPassword)
} }
@ -610,6 +660,9 @@ func (m *CardMutation) Fields() []string {
if m.status != nil { if m.status != nil {
fields = append(fields, card.FieldStatus) fields = append(fields, card.FieldStatus)
} }
if m.token != nil {
fields = append(fields, card.FieldToken)
}
if m.cp != nil { if m.cp != nil {
fields = append(fields, card.FieldCp) fields = append(fields, card.FieldCp)
} }
@ -635,6 +688,8 @@ func (m *CardMutation) Field(name string) (ent.Value, bool) {
return m.Skill() return m.Skill()
case card.FieldStatus: case card.FieldStatus:
return m.Status() return m.Status()
case card.FieldToken:
return m.Token()
case card.FieldCp: case card.FieldCp:
return m.Cp() return m.Cp()
case card.FieldURL: case card.FieldURL:
@ -658,6 +713,8 @@ func (m *CardMutation) OldField(ctx context.Context, name string) (ent.Value, er
return m.OldSkill(ctx) return m.OldSkill(ctx)
case card.FieldStatus: case card.FieldStatus:
return m.OldStatus(ctx) return m.OldStatus(ctx)
case card.FieldToken:
return m.OldToken(ctx)
case card.FieldCp: case card.FieldCp:
return m.OldCp(ctx) return m.OldCp(ctx)
case card.FieldURL: case card.FieldURL:
@ -701,6 +758,13 @@ func (m *CardMutation) SetField(name string, value ent.Value) error {
} }
m.SetStatus(v) m.SetStatus(v)
return nil return nil
case card.FieldToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetToken(v)
return nil
case card.FieldCp: case card.FieldCp:
v, ok := value.(int) v, ok := value.(int)
if !ok { if !ok {
@ -788,6 +852,9 @@ func (m *CardMutation) ClearedFields() []string {
if m.FieldCleared(card.FieldStatus) { if m.FieldCleared(card.FieldStatus) {
fields = append(fields, card.FieldStatus) fields = append(fields, card.FieldStatus)
} }
if m.FieldCleared(card.FieldToken) {
fields = append(fields, card.FieldToken)
}
if m.FieldCleared(card.FieldCp) { if m.FieldCleared(card.FieldCp) {
fields = append(fields, card.FieldCp) fields = append(fields, card.FieldCp)
} }
@ -820,6 +887,9 @@ func (m *CardMutation) ClearField(name string) error {
case card.FieldStatus: case card.FieldStatus:
m.ClearStatus() m.ClearStatus()
return nil return nil
case card.FieldToken:
m.ClearToken()
return nil
case card.FieldCp: case card.FieldCp:
m.ClearCp() m.ClearCp()
return nil return nil
@ -849,6 +919,9 @@ func (m *CardMutation) ResetField(name string) error {
case card.FieldStatus: case card.FieldStatus:
m.ResetStatus() m.ResetStatus()
return nil return nil
case card.FieldToken:
m.ResetToken()
return nil
case card.FieldCp: case card.FieldCp:
m.ResetCp() m.ResetCp()
return nil return nil
@ -1432,6 +1505,8 @@ type UserMutation struct {
like_rank *int like_rank *int
addlike_rank *int addlike_rank *int
like_at *time.Time like_at *time.Time
fav *int
addfav *int
ten *bool ten *bool
ten_su *int ten_su *int
addten_su *int addten_su *int
@ -2275,6 +2350,76 @@ func (m *UserMutation) ResetLikeAt() {
delete(m.clearedFields, user.FieldLikeAt) delete(m.clearedFields, user.FieldLikeAt)
} }
// SetFav sets the "fav" field.
func (m *UserMutation) SetFav(i int) {
m.fav = &i
m.addfav = nil
}
// Fav returns the value of the "fav" field in the mutation.
func (m *UserMutation) Fav() (r int, exists bool) {
v := m.fav
if v == nil {
return
}
return *v, true
}
// OldFav returns the old "fav" 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) OldFav(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldFav is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldFav requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFav: %w", err)
}
return oldValue.Fav, nil
}
// AddFav adds i to the "fav" field.
func (m *UserMutation) AddFav(i int) {
if m.addfav != nil {
*m.addfav += i
} else {
m.addfav = &i
}
}
// AddedFav returns the value that was added to the "fav" field in this mutation.
func (m *UserMutation) AddedFav() (r int, exists bool) {
v := m.addfav
if v == nil {
return
}
return *v, true
}
// ClearFav clears the value of the "fav" field.
func (m *UserMutation) ClearFav() {
m.fav = nil
m.addfav = nil
m.clearedFields[user.FieldFav] = struct{}{}
}
// FavCleared returns if the "fav" field was cleared in this mutation.
func (m *UserMutation) FavCleared() bool {
_, ok := m.clearedFields[user.FieldFav]
return ok
}
// ResetFav resets all changes to the "fav" field.
func (m *UserMutation) ResetFav() {
m.fav = nil
m.addfav = nil
delete(m.clearedFields, user.FieldFav)
}
// SetTen sets the "ten" field. // SetTen sets the "ten" field.
func (m *UserMutation) SetTen(b bool) { func (m *UserMutation) SetTen(b bool) {
m.ten = &b m.ten = &b
@ -2916,7 +3061,7 @@ func (m *UserMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call // order to get all numeric fields that were incremented/decremented, call
// AddedFields(). // AddedFields().
func (m *UserMutation) Fields() []string { func (m *UserMutation) Fields() []string {
fields := make([]string, 0, 24) fields := make([]string, 0, 25)
if m.username != nil { if m.username != nil {
fields = append(fields, user.FieldUsername) fields = append(fields, user.FieldUsername)
} }
@ -2959,6 +3104,9 @@ func (m *UserMutation) Fields() []string {
if m.like_at != nil { if m.like_at != nil {
fields = append(fields, user.FieldLikeAt) fields = append(fields, user.FieldLikeAt)
} }
if m.fav != nil {
fields = append(fields, user.FieldFav)
}
if m.ten != nil { if m.ten != nil {
fields = append(fields, user.FieldTen) fields = append(fields, user.FieldTen)
} }
@ -3025,6 +3173,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
return m.LikeRank() return m.LikeRank()
case user.FieldLikeAt: case user.FieldLikeAt:
return m.LikeAt() return m.LikeAt()
case user.FieldFav:
return m.Fav()
case user.FieldTen: case user.FieldTen:
return m.Ten() return m.Ten()
case user.FieldTenSu: case user.FieldTenSu:
@ -3082,6 +3232,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
return m.OldLikeRank(ctx) return m.OldLikeRank(ctx)
case user.FieldLikeAt: case user.FieldLikeAt:
return m.OldLikeAt(ctx) return m.OldLikeAt(ctx)
case user.FieldFav:
return m.OldFav(ctx)
case user.FieldTen: case user.FieldTen:
return m.OldTen(ctx) return m.OldTen(ctx)
case user.FieldTenSu: case user.FieldTenSu:
@ -3209,6 +3361,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
} }
m.SetLikeAt(v) m.SetLikeAt(v)
return nil return nil
case user.FieldFav:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFav(v)
return nil
case user.FieldTen: case user.FieldTen:
v, ok := value.(bool) v, ok := value.(bool)
if !ok { if !ok {
@ -3296,6 +3455,9 @@ func (m *UserMutation) AddedFields() []string {
if m.addlike_rank != nil { if m.addlike_rank != nil {
fields = append(fields, user.FieldLikeRank) fields = append(fields, user.FieldLikeRank)
} }
if m.addfav != nil {
fields = append(fields, user.FieldFav)
}
if m.addten_su != nil { if m.addten_su != nil {
fields = append(fields, user.FieldTenSu) fields = append(fields, user.FieldTenSu)
} }
@ -3319,6 +3481,8 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedLike() return m.AddedLike()
case user.FieldLikeRank: case user.FieldLikeRank:
return m.AddedLikeRank() return m.AddedLikeRank()
case user.FieldFav:
return m.AddedFav()
case user.FieldTenSu: case user.FieldTenSu:
return m.AddedTenSu() return m.AddedTenSu()
case user.FieldTenKai: case user.FieldTenKai:
@ -3355,6 +3519,13 @@ func (m *UserMutation) AddField(name string, value ent.Value) error {
} }
m.AddLikeRank(v) m.AddLikeRank(v)
return nil return nil
case user.FieldFav:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFav(v)
return nil
case user.FieldTenSu: case user.FieldTenSu:
v, ok := value.(int) v, ok := value.(int)
if !ok { if !ok {
@ -3420,6 +3591,9 @@ func (m *UserMutation) ClearedFields() []string {
if m.FieldCleared(user.FieldLikeAt) { if m.FieldCleared(user.FieldLikeAt) {
fields = append(fields, user.FieldLikeAt) fields = append(fields, user.FieldLikeAt)
} }
if m.FieldCleared(user.FieldFav) {
fields = append(fields, user.FieldFav)
}
if m.FieldCleared(user.FieldTen) { if m.FieldCleared(user.FieldTen) {
fields = append(fields, user.FieldTen) fields = append(fields, user.FieldTen)
} }
@ -3500,6 +3674,9 @@ func (m *UserMutation) ClearField(name string) error {
case user.FieldLikeAt: case user.FieldLikeAt:
m.ClearLikeAt() m.ClearLikeAt()
return nil return nil
case user.FieldFav:
m.ClearFav()
return nil
case user.FieldTen: case user.FieldTen:
m.ClearTen() m.ClearTen()
return nil return nil
@ -3580,6 +3757,9 @@ func (m *UserMutation) ResetField(name string) error {
case user.FieldLikeAt: case user.FieldLikeAt:
m.ResetLikeAt() m.ResetLikeAt()
return nil return nil
case user.FieldFav:
m.ResetFav()
return nil
case user.FieldTen: case user.FieldTen:
m.ResetTen() m.ResetTen()
return nil return nil

View File

@ -497,6 +497,12 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -559,7 +565,7 @@ func (s *CardOwnerRead) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfCardOwnerRead = [23]string{ var jsonFieldsNameOfCardOwnerRead = [24]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
@ -573,16 +579,17 @@ var jsonFieldsNameOfCardOwnerRead = [23]string{
10: "like", 10: "like",
11: "like_rank", 11: "like_rank",
12: "like_at", 12: "like_at",
13: "ten", 13: "fav",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "next",
} }
// Decode decodes CardOwnerRead from json. // Decode decodes CardOwnerRead from json.
@ -728,6 +735,16 @@ func (s *CardOwnerRead) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -1316,6 +1333,12 @@ func (s *CreateCardReq) encodeFields(e *jx.Encoder) {
s.Status.Encode(e) s.Status.Encode(e)
} }
} }
{
if s.Token.Set {
e.FieldStart("token")
s.Token.Encode(e)
}
}
{ {
if s.Cp.Set { if s.Cp.Set {
e.FieldStart("cp") e.FieldStart("cp")
@ -1341,15 +1364,16 @@ func (s *CreateCardReq) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfCreateCardReq = [8]string{ var jsonFieldsNameOfCreateCardReq = [9]string{
0: "password", 0: "password",
1: "card", 1: "card",
2: "skill", 2: "skill",
3: "status", 3: "status",
4: "cp", 4: "token",
5: "url", 5: "cp",
6: "created_at", 6: "url",
7: "owner", 7: "created_at",
8: "owner",
} }
// Decode decodes CreateCardReq from json. // Decode decodes CreateCardReq from json.
@ -1357,7 +1381,7 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode CreateCardReq to nil") return errors.New("invalid: unable to decode CreateCardReq to nil")
} }
var requiredBitSet [1]uint8 var requiredBitSet [2]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) { switch string(k) {
@ -1403,6 +1427,16 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"status\"") return errors.Wrap(err, "decode field \"status\"")
} }
case "token":
if err := func() error {
s.Token.Reset()
if err := s.Token.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"token\"")
}
case "cp": case "cp":
if err := func() error { if err := func() error {
s.Cp.Reset() s.Cp.Reset()
@ -1434,7 +1468,7 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"created_at\"") return errors.Wrap(err, "decode field \"created_at\"")
} }
case "owner": case "owner":
requiredBitSet[0] |= 1 << 7 requiredBitSet[1] |= 1 << 0
if err := func() error { if err := func() error {
v, err := d.Int() v, err := d.Int()
s.Owner = int(v) s.Owner = int(v)
@ -1454,8 +1488,9 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
} }
// Validate required fields. // Validate required fields.
var failures []validate.FieldError var failures []validate.FieldError
for i, mask := range [1]uint8{ for i, mask := range [2]uint8{
0b10000001, 0b00000001,
0b00000001,
} { } {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR. // Mask only required fields and check equality to mask using XOR.
@ -1737,6 +1772,12 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -1809,7 +1850,7 @@ func (s *CreateUserReq) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfCreateUserReq = [25]string{ var jsonFieldsNameOfCreateUserReq = [26]string{
0: "username", 0: "username",
1: "did", 1: "did",
2: "delete", 2: "delete",
@ -1824,17 +1865,18 @@ var jsonFieldsNameOfCreateUserReq = [25]string{
11: "like", 11: "like",
12: "like_rank", 12: "like_rank",
13: "like_at", 13: "like_at",
14: "ten", 14: "fav",
15: "ten_su", 15: "ten",
16: "ten_kai", 16: "ten_su",
17: "aiten", 17: "ten_kai",
18: "ten_card", 18: "aiten",
19: "ten_delete", 19: "ten_card",
20: "ten_post", 20: "ten_delete",
21: "ten_get", 21: "ten_post",
22: "ten_at", 22: "ten_get",
23: "next", 23: "ten_at",
24: "card", 24: "next",
25: "card",
} }
// Decode decodes CreateUserReq from json. // Decode decodes CreateUserReq from json.
@ -1990,6 +2032,16 @@ func (s *CreateUserReq) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -2713,6 +2765,12 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -2775,7 +2833,7 @@ func (s *GroupUsersList) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfGroupUsersList = [23]string{ var jsonFieldsNameOfGroupUsersList = [24]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
@ -2789,16 +2847,17 @@ var jsonFieldsNameOfGroupUsersList = [23]string{
10: "like", 10: "like",
11: "like_rank", 11: "like_rank",
12: "like_at", 12: "like_at",
13: "ten", 13: "fav",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "next",
} }
// Decode decodes GroupUsersList from json. // Decode decodes GroupUsersList from json.
@ -2944,6 +3003,16 @@ func (s *GroupUsersList) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -4043,6 +4112,24 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) {
s.Skill.Encode(e) s.Skill.Encode(e)
} }
} }
{
if s.Status.Set {
e.FieldStart("status")
s.Status.Encode(e)
}
}
{
if s.Token.Set {
e.FieldStart("token")
s.Token.Encode(e)
}
}
{
if s.Cp.Set {
e.FieldStart("cp")
s.Cp.Encode(e)
}
}
{ {
if s.Owner.Set { if s.Owner.Set {
e.FieldStart("owner") e.FieldStart("owner")
@ -4051,9 +4138,12 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUpdateCardReq = [2]string{ var jsonFieldsNameOfUpdateCardReq = [5]string{
0: "skill", 0: "skill",
1: "owner", 1: "status",
2: "token",
3: "cp",
4: "owner",
} }
// Decode decodes UpdateCardReq from json. // Decode decodes UpdateCardReq from json.
@ -4074,6 +4164,36 @@ func (s *UpdateCardReq) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"skill\"") return errors.Wrap(err, "decode field \"skill\"")
} }
case "status":
if err := func() error {
s.Status.Reset()
if err := s.Status.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"status\"")
}
case "token":
if err := func() error {
s.Token.Reset()
if err := s.Token.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"token\"")
}
case "cp":
if err := func() error {
s.Cp.Reset()
if err := s.Cp.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"cp\"")
}
case "owner": case "owner":
if err := func() error { if err := func() error {
s.Owner.Reset() s.Owner.Reset()
@ -4276,6 +4396,12 @@ func (s *UpdateUserReq) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -4348,7 +4474,7 @@ func (s *UpdateUserReq) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUpdateUserReq = [22]string{ var jsonFieldsNameOfUpdateUserReq = [23]string{
0: "did", 0: "did",
1: "delete", 1: "delete",
2: "handle", 2: "handle",
@ -4360,17 +4486,18 @@ var jsonFieldsNameOfUpdateUserReq = [22]string{
8: "like", 8: "like",
9: "like_rank", 9: "like_rank",
10: "like_at", 10: "like_at",
11: "ten", 11: "fav",
12: "ten_su", 12: "ten",
13: "ten_kai", 13: "ten_su",
14: "aiten", 14: "ten_kai",
15: "ten_card", 15: "aiten",
16: "ten_delete", 16: "ten_card",
17: "ten_post", 17: "ten_delete",
18: "ten_get", 18: "ten_post",
19: "ten_at", 19: "ten_get",
20: "next", 20: "ten_at",
21: "card", 21: "next",
22: "card",
} }
// Decode decodes UpdateUserReq from json. // Decode decodes UpdateUserReq from json.
@ -4491,6 +4618,16 @@ func (s *UpdateUserReq) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -4918,6 +5055,12 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -4980,7 +5123,7 @@ func (s *UserCreate) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserCreate = [23]string{ var jsonFieldsNameOfUserCreate = [24]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
@ -4994,16 +5137,17 @@ var jsonFieldsNameOfUserCreate = [23]string{
10: "like", 10: "like",
11: "like_rank", 11: "like_rank",
12: "like_at", 12: "like_at",
13: "ten", 13: "fav",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "next",
} }
// Decode decodes UserCreate from json. // Decode decodes UserCreate from json.
@ -5149,6 +5293,16 @@ func (s *UserCreate) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -5392,6 +5546,12 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -5454,7 +5614,7 @@ func (s *UserList) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserList = [23]string{ var jsonFieldsNameOfUserList = [24]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
@ -5468,16 +5628,17 @@ var jsonFieldsNameOfUserList = [23]string{
10: "like", 10: "like",
11: "like_rank", 11: "like_rank",
12: "like_at", 12: "like_at",
13: "ten", 13: "fav",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "next",
} }
// Decode decodes UserList from json. // Decode decodes UserList from json.
@ -5623,6 +5784,16 @@ func (s *UserList) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -5866,6 +6037,12 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -5928,7 +6105,7 @@ func (s *UserRead) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserRead = [23]string{ var jsonFieldsNameOfUserRead = [24]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
@ -5942,16 +6119,17 @@ var jsonFieldsNameOfUserRead = [23]string{
10: "like", 10: "like",
11: "like_rank", 11: "like_rank",
12: "like_at", 12: "like_at",
13: "ten", 13: "fav",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "next",
} }
// Decode decodes UserRead from json. // Decode decodes UserRead from json.
@ -6097,6 +6275,16 @@ func (s *UserRead) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()
@ -6340,6 +6528,12 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
s.LikeAt.Encode(e, json.EncodeDateTime) s.LikeAt.Encode(e, json.EncodeDateTime)
} }
} }
{
if s.Fav.Set {
e.FieldStart("fav")
s.Fav.Encode(e)
}
}
{ {
if s.Ten.Set { if s.Ten.Set {
e.FieldStart("ten") e.FieldStart("ten")
@ -6402,7 +6596,7 @@ func (s *UserUpdate) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfUserUpdate = [23]string{ var jsonFieldsNameOfUserUpdate = [24]string{
0: "id", 0: "id",
1: "username", 1: "username",
2: "did", 2: "did",
@ -6416,16 +6610,17 @@ var jsonFieldsNameOfUserUpdate = [23]string{
10: "like", 10: "like",
11: "like_rank", 11: "like_rank",
12: "like_at", 12: "like_at",
13: "ten", 13: "fav",
14: "ten_su", 14: "ten",
15: "ten_kai", 15: "ten_su",
16: "aiten", 16: "ten_kai",
17: "ten_card", 17: "aiten",
18: "ten_delete", 18: "ten_card",
19: "ten_post", 19: "ten_delete",
20: "ten_get", 20: "ten_post",
21: "ten_at", 21: "ten_get",
22: "next", 22: "ten_at",
23: "next",
} }
// Decode decodes UserUpdate from json. // Decode decodes UserUpdate from json.
@ -6571,6 +6766,16 @@ func (s *UserUpdate) Decode(d *jx.Decoder) error {
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"like_at\"") return errors.Wrap(err, "decode field \"like_at\"")
} }
case "fav":
if err := func() error {
s.Fav.Reset()
if err := s.Fav.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"fav\"")
}
case "ten": case "ten":
if err := func() error { if err := func() error {
s.Ten.Reset() s.Ten.Reset()

View File

@ -187,6 +187,7 @@ type CardOwnerRead struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -264,6 +265,11 @@ func (s *CardOwnerRead) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *CardOwnerRead) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *CardOwnerRead) GetTen() OptBool { func (s *CardOwnerRead) GetTen() OptBool {
return s.Ten return s.Ten
@ -379,6 +385,11 @@ func (s *CardOwnerRead) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *CardOwnerRead) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *CardOwnerRead) SetTen(val OptBool) { func (s *CardOwnerRead) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -602,6 +613,7 @@ type CreateCardReq struct {
Card OptInt `json:"card"` Card OptInt `json:"card"`
Skill OptString `json:"skill"` Skill OptString `json:"skill"`
Status OptString `json:"status"` Status OptString `json:"status"`
Token OptString `json:"token"`
Cp OptInt `json:"cp"` Cp OptInt `json:"cp"`
URL OptString `json:"url"` URL OptString `json:"url"`
CreatedAt OptDateTime `json:"created_at"` CreatedAt OptDateTime `json:"created_at"`
@ -628,6 +640,11 @@ func (s *CreateCardReq) GetStatus() OptString {
return s.Status return s.Status
} }
// GetToken returns the value of Token.
func (s *CreateCardReq) GetToken() OptString {
return s.Token
}
// GetCp returns the value of Cp. // GetCp returns the value of Cp.
func (s *CreateCardReq) GetCp() OptInt { func (s *CreateCardReq) GetCp() OptInt {
return s.Cp return s.Cp
@ -668,6 +685,11 @@ func (s *CreateCardReq) SetStatus(val OptString) {
s.Status = val s.Status = val
} }
// SetToken sets the value of Token.
func (s *CreateCardReq) SetToken(val OptString) {
s.Token = val
}
// SetCp sets the value of Cp. // SetCp sets the value of Cp.
func (s *CreateCardReq) SetCp(val OptInt) { func (s *CreateCardReq) SetCp(val OptInt) {
s.Cp = val s.Cp = val
@ -739,6 +761,7 @@ type CreateUserReq struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -822,6 +845,11 @@ func (s *CreateUserReq) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *CreateUserReq) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *CreateUserReq) GetTen() OptBool { func (s *CreateUserReq) GetTen() OptBool {
return s.Ten return s.Ten
@ -947,6 +975,11 @@ func (s *CreateUserReq) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *CreateUserReq) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *CreateUserReq) SetTen(val OptBool) { func (s *CreateUserReq) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -1148,6 +1181,7 @@ type GroupUsersList struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -1225,6 +1259,11 @@ func (s *GroupUsersList) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *GroupUsersList) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *GroupUsersList) GetTen() OptBool { func (s *GroupUsersList) GetTen() OptBool {
return s.Ten return s.Ten
@ -1340,6 +1379,11 @@ func (s *GroupUsersList) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *GroupUsersList) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *GroupUsersList) SetTen(val OptBool) { func (s *GroupUsersList) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -1812,8 +1856,11 @@ func (*R500) updateGroupRes() {}
func (*R500) updateUserRes() {} func (*R500) updateUserRes() {}
type UpdateCardReq struct { type UpdateCardReq struct {
Skill OptString `json:"skill"` Skill OptString `json:"skill"`
Owner OptInt `json:"owner"` Status OptString `json:"status"`
Token OptString `json:"token"`
Cp OptInt `json:"cp"`
Owner OptInt `json:"owner"`
} }
// GetSkill returns the value of Skill. // GetSkill returns the value of Skill.
@ -1821,6 +1868,21 @@ func (s *UpdateCardReq) GetSkill() OptString {
return s.Skill return s.Skill
} }
// GetStatus returns the value of Status.
func (s *UpdateCardReq) GetStatus() OptString {
return s.Status
}
// GetToken returns the value of Token.
func (s *UpdateCardReq) GetToken() OptString {
return s.Token
}
// GetCp returns the value of Cp.
func (s *UpdateCardReq) GetCp() OptInt {
return s.Cp
}
// GetOwner returns the value of Owner. // GetOwner returns the value of Owner.
func (s *UpdateCardReq) GetOwner() OptInt { func (s *UpdateCardReq) GetOwner() OptInt {
return s.Owner return s.Owner
@ -1831,6 +1893,21 @@ func (s *UpdateCardReq) SetSkill(val OptString) {
s.Skill = val s.Skill = val
} }
// SetStatus sets the value of Status.
func (s *UpdateCardReq) SetStatus(val OptString) {
s.Status = val
}
// SetToken sets the value of Token.
func (s *UpdateCardReq) SetToken(val OptString) {
s.Token = val
}
// SetCp sets the value of Cp.
func (s *UpdateCardReq) SetCp(val OptInt) {
s.Cp = val
}
// SetOwner sets the value of Owner. // SetOwner sets the value of Owner.
func (s *UpdateCardReq) SetOwner(val OptInt) { func (s *UpdateCardReq) SetOwner(val OptInt) {
s.Owner = val s.Owner = val
@ -1873,6 +1950,7 @@ type UpdateUserReq struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -1941,6 +2019,11 @@ func (s *UpdateUserReq) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *UpdateUserReq) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *UpdateUserReq) GetTen() OptBool { func (s *UpdateUserReq) GetTen() OptBool {
return s.Ten return s.Ten
@ -2051,6 +2134,11 @@ func (s *UpdateUserReq) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *UpdateUserReq) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *UpdateUserReq) SetTen(val OptBool) { func (s *UpdateUserReq) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -2202,6 +2290,7 @@ type UserCreate struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -2279,6 +2368,11 @@ func (s *UserCreate) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *UserCreate) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *UserCreate) GetTen() OptBool { func (s *UserCreate) GetTen() OptBool {
return s.Ten return s.Ten
@ -2394,6 +2488,11 @@ func (s *UserCreate) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *UserCreate) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *UserCreate) SetTen(val OptBool) { func (s *UserCreate) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -2461,6 +2560,7 @@ type UserList struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -2538,6 +2638,11 @@ func (s *UserList) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *UserList) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *UserList) GetTen() OptBool { func (s *UserList) GetTen() OptBool {
return s.Ten return s.Ten
@ -2653,6 +2758,11 @@ func (s *UserList) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *UserList) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *UserList) SetTen(val OptBool) { func (s *UserList) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -2718,6 +2828,7 @@ type UserRead struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -2795,6 +2906,11 @@ func (s *UserRead) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *UserRead) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *UserRead) GetTen() OptBool { func (s *UserRead) GetTen() OptBool {
return s.Ten return s.Ten
@ -2910,6 +3026,11 @@ func (s *UserRead) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *UserRead) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *UserRead) SetTen(val OptBool) { func (s *UserRead) SetTen(val OptBool) {
s.Ten = val s.Ten = val
@ -2977,6 +3098,7 @@ type UserUpdate struct {
Like OptInt `json:"like"` Like OptInt `json:"like"`
LikeRank OptInt `json:"like_rank"` LikeRank OptInt `json:"like_rank"`
LikeAt OptDateTime `json:"like_at"` LikeAt OptDateTime `json:"like_at"`
Fav OptInt `json:"fav"`
Ten OptBool `json:"ten"` Ten OptBool `json:"ten"`
TenSu OptInt `json:"ten_su"` TenSu OptInt `json:"ten_su"`
TenKai OptInt `json:"ten_kai"` TenKai OptInt `json:"ten_kai"`
@ -3054,6 +3176,11 @@ func (s *UserUpdate) GetLikeAt() OptDateTime {
return s.LikeAt return s.LikeAt
} }
// GetFav returns the value of Fav.
func (s *UserUpdate) GetFav() OptInt {
return s.Fav
}
// GetTen returns the value of Ten. // GetTen returns the value of Ten.
func (s *UserUpdate) GetTen() OptBool { func (s *UserUpdate) GetTen() OptBool {
return s.Ten return s.Ten
@ -3169,6 +3296,11 @@ func (s *UserUpdate) SetLikeAt(val OptDateTime) {
s.LikeAt = val s.LikeAt = val
} }
// SetFav sets the value of Fav.
func (s *UserUpdate) SetFav(val OptInt) {
s.Fav = val
}
// SetTen sets the value of Ten. // SetTen sets the value of Ten.
func (s *UserUpdate) SetTen(val OptBool) { func (s *UserUpdate) SetTen(val OptBool) {
s.Ten = val s.Ten = val

View File

@ -125,17 +125,26 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea
// UpdateCard handles PATCH /cards/{id} requests. // UpdateCard handles PATCH /cards/{id} requests.
func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) { func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
b := h.client.Card.UpdateOneID(params.ID) b := h.client.Card.UpdateOneID(params.ID)
if v, ok := req.Token.Get(); ok {
if v == token {
// Add all fields. b.SetToken(v)
if v, ok := req.Skill.Get(); ok { if v, ok := req.Skill.Get(); ok {
b.SetSkill(v) b.SetSkill(v)
} }
// Add all edges. if v, ok := req.Status.Get(); ok {
b.SetStatus(v)
}
if v, ok := req.Token.Get(); ok {
b.SetToken(v)
}
if v, ok := req.Cp.Get(); ok {
b.SetCp(v)
}
if v, ok := req.Owner.Get(); ok { if v, ok := req.Owner.Get(); ok {
b.SetOwnerID(v) b.SetOwnerID(v)
} }
}
}
// Persist to storage. // Persist to storage.
e, err := b.Save(ctx) e, err := b.Save(ctx)
@ -170,7 +179,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
// DeleteCard handles DELETE /cards/{id} requests. // DeleteCard handles DELETE /cards/{id} requests.
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) { func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) err := h.client.Card.DeleteOneID(0).Exec(ctx)
if err != nil { if err != nil {
switch { switch {
case ent.IsNotFound(err): case ent.IsNotFound(err):
@ -478,6 +487,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
b.SetPassword(req.Password) b.SetPassword(req.Password)
if v, ok := req.Fav.Get(); ok {
b.SetFav(v)
}
if v, ok := req.Did.Get(); ok { if v, ok := req.Did.Get(); ok {
b.SetDid(v) b.SetDid(v)
} }
@ -611,6 +623,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
if v == token { if v == token {
b.SetToken(v) b.SetToken(v)
if v, ok := req.Fav.Get(); ok {
b.SetFav(v)
}
if v, ok := req.Did.Get(); ok { if v, ok := req.Did.Get(); ok {
b.SetDid(v) b.SetDid(v)
} }
@ -711,7 +726,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
// DeleteUser handles DELETE /users/{id} requests. // DeleteUser handles DELETE /users/{id} requests.
func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) { func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
err := h.client.User.DeleteOneID(params.ID).Exec(ctx) err := h.client.User.DeleteOneID(0).Exec(ctx)
if err != nil { if err != nil {
switch { switch {
case ent.IsNotFound(err): case ent.IsNotFound(err):

View File

@ -154,6 +154,7 @@ func NewCardOwnerRead(e *ent.User) *CardOwnerRead {
ret.Like = NewOptInt(e.Like) ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank) ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt) ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten) ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu) ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai) ret.TenKai = NewOptInt(e.TenKai)
@ -315,6 +316,7 @@ func NewGroupUsersList(e *ent.User) *GroupUsersList {
ret.Like = NewOptInt(e.Like) ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank) ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt) ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten) ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu) ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai) ret.TenKai = NewOptInt(e.TenKai)
@ -364,6 +366,7 @@ func NewUserCreate(e *ent.User) *UserCreate {
ret.Like = NewOptInt(e.Like) ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank) ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt) ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten) ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu) ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai) ret.TenKai = NewOptInt(e.TenKai)
@ -413,6 +416,7 @@ func NewUserList(e *ent.User) *UserList {
ret.Like = NewOptInt(e.Like) ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank) ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt) ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten) ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu) ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai) ret.TenKai = NewOptInt(e.TenKai)
@ -462,6 +466,7 @@ func NewUserRead(e *ent.User) *UserRead {
ret.Like = NewOptInt(e.Like) ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank) ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt) ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten) ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu) ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai) ret.TenKai = NewOptInt(e.TenKai)
@ -511,6 +516,7 @@ func NewUserUpdate(e *ent.User) *UserUpdate {
ret.Like = NewOptInt(e.Like) ret.Like = NewOptInt(e.Like)
ret.LikeRank = NewOptInt(e.LikeRank) ret.LikeRank = NewOptInt(e.LikeRank)
ret.LikeAt = NewOptDateTime(e.LikeAt) ret.LikeAt = NewOptDateTime(e.LikeAt)
ret.Fav = NewOptInt(e.Fav)
ret.Ten = NewOptBool(e.Ten) ret.Ten = NewOptBool(e.Ten)
ret.TenSu = NewOptInt(e.TenSu) ret.TenSu = NewOptInt(e.TenSu)
ret.TenKai = NewOptInt(e.TenKai) ret.TenKai = NewOptInt(e.TenKai)

View File

@ -30,7 +30,7 @@
"description": "item count to render per page", "description": "item count to render per page",
"schema": { "schema": {
"type": "integer", "type": "integer",
"maximum": 4000, "maximum": 3000,
"minimum": 1 "minimum": 1
} }
} }
@ -372,7 +372,7 @@
"description": "item count to render per page", "description": "item count to render per page",
"schema": { "schema": {
"type": "integer", "type": "integer",
"maximum": 4000, "maximum": 3000,
"minimum": 1 "minimum": 1
} }
} }
@ -698,7 +698,7 @@
"description": "item count to render per page", "description": "item count to render per page",
"schema": { "schema": {
"type": "integer", "type": "integer",
"maximum": 4000, "maximum": 3000,
"minimum": 1 "minimum": 1
} }
} }
@ -754,9 +754,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"token": { "token": {
"type": "string" "type": "string"
}, },
@ -801,9 +798,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -831,6 +825,7 @@
} }
}, },
"required": [ "required": [
"username",
"password" "password"
] ]
} }
@ -966,18 +961,12 @@
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
"username": {
"type": "string"
},
"did": { "did": {
"type": "string" "type": "string"
}, },
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"token": { "token": {
"type": "string" "type": "string"
}, },
@ -1015,9 +1004,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1340,9 +1326,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1381,9 +1364,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1405,7 +1385,8 @@
} }
}, },
"required": [ "required": [
"id" "id",
"username"
] ]
}, },
"Group": { "Group": {
@ -1508,9 +1489,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1549,9 +1527,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1573,7 +1548,8 @@
} }
}, },
"required": [ "required": [
"id" "id",
"username"
] ]
}, },
"User": { "User": {
@ -1591,9 +1567,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"token": { "token": {
"type": "string" "type": "string"
}, },
@ -1638,9 +1611,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1669,6 +1639,7 @@
}, },
"required": [ "required": [
"id", "id",
"username",
"password" "password"
] ]
}, },
@ -1687,9 +1658,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1728,9 +1696,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1752,7 +1717,8 @@
} }
}, },
"required": [ "required": [
"id" "id",
"username"
] ]
}, },
"UserList": { "UserList": {
@ -1770,9 +1736,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1811,9 +1774,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1835,7 +1795,8 @@
} }
}, },
"required": [ "required": [
"id" "id",
"username"
] ]
}, },
"UserRead": { "UserRead": {
@ -1853,9 +1814,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1894,9 +1852,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -1918,7 +1873,8 @@
} }
}, },
"required": [ "required": [
"id" "id",
"username"
] ]
}, },
"UserUpdate": { "UserUpdate": {
@ -1936,9 +1892,6 @@
"delete": { "delete": {
"type": "boolean" "type": "boolean"
}, },
"handle": {
"type": "boolean"
},
"created_at": { "created_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@ -1977,9 +1930,6 @@
"ten_kai": { "ten_kai": {
"type": "integer" "type": "integer"
}, },
"aiten": {
"type": "integer"
},
"ten_card": { "ten_card": {
"type": "string" "type": "string"
}, },
@ -2001,7 +1951,8 @@
} }
}, },
"required": [ "required": [
"id" "id",
"username"
] ]
}, },
"User_CardList": { "User_CardList": {

View File

@ -33,15 +33,15 @@ func init() {
// card.DefaultStatus holds the default value on creation for the status field. // card.DefaultStatus holds the default value on creation for the status field.
card.DefaultStatus = cardDescStatus.Default.(func() string) card.DefaultStatus = cardDescStatus.Default.(func() string)
// cardDescCp is the schema descriptor for cp field. // cardDescCp is the schema descriptor for cp field.
cardDescCp := cardFields[4].Descriptor() cardDescCp := cardFields[5].Descriptor()
// card.DefaultCp holds the default value on creation for the cp field. // card.DefaultCp holds the default value on creation for the cp field.
card.DefaultCp = cardDescCp.Default.(func() int) card.DefaultCp = cardDescCp.Default.(func() int)
// cardDescURL is the schema descriptor for url field. // cardDescURL is the schema descriptor for url field.
cardDescURL := cardFields[5].Descriptor() cardDescURL := cardFields[6].Descriptor()
// card.DefaultURL holds the default value on creation for the url field. // card.DefaultURL holds the default value on creation for the url field.
card.DefaultURL = cardDescURL.Default.(string) card.DefaultURL = cardDescURL.Default.(string)
// cardDescCreatedAt is the schema descriptor for created_at field. // cardDescCreatedAt is the schema descriptor for created_at field.
cardDescCreatedAt := cardFields[6].Descriptor() cardDescCreatedAt := cardFields[7].Descriptor()
// card.DefaultCreatedAt holds the default value on creation for the created_at field. // card.DefaultCreatedAt holds the default value on creation for the created_at field.
card.DefaultCreatedAt = cardDescCreatedAt.Default.(func() time.Time) card.DefaultCreatedAt = cardDescCreatedAt.Default.(func() time.Time)
groupFields := schema.Group{}.Fields() groupFields := schema.Group{}.Fields()
@ -103,11 +103,11 @@ func init() {
// user.DefaultLikeAt holds the default value on creation for the like_at field. // user.DefaultLikeAt holds the default value on creation for the like_at field.
user.DefaultLikeAt = userDescLikeAt.Default.(func() time.Time) user.DefaultLikeAt = userDescLikeAt.Default.(func() time.Time)
// userDescTenAt is the schema descriptor for ten_at field. // userDescTenAt is the schema descriptor for ten_at field.
userDescTenAt := userFields[22].Descriptor() userDescTenAt := userFields[23].Descriptor()
// user.DefaultTenAt holds the default value on creation for the ten_at field. // user.DefaultTenAt holds the default value on creation for the ten_at field.
user.DefaultTenAt = userDescTenAt.Default.(func() time.Time) user.DefaultTenAt = userDescTenAt.Default.(func() time.Time)
// userDescNext is the schema descriptor for next field. // userDescNext is the schema descriptor for next field.
userDescNext := userFields[23].Descriptor() userDescNext := userFields[24].Descriptor()
// user.DefaultNext holds the default value on creation for the next field. // user.DefaultNext holds the default value on creation for the next field.
user.DefaultNext = userDescNext.Default.(string) user.DefaultNext = userDescNext.Default.(string)
} }

View File

@ -80,7 +80,7 @@ func (Card) Fields() []ent.Field {
Optional(), Optional(),
field.String("status"). field.String("status").
Immutable(). //Immutable().
DefaultFunc(func() string { DefaultFunc(func() string {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
var a = rand.Intn(10) var a = rand.Intn(10)
@ -96,8 +96,12 @@ func (Card) Fields() []ent.Field {
}). }).
Optional(), Optional(),
field.String("token").
Optional().
Sensitive(),
field.Int("cp"). field.Int("cp").
Immutable(). //Immutable().
DefaultFunc(func() int { DefaultFunc(func() int {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
var cp = 1 + rand.Intn(100) var cp = 1 + rand.Intn(100)

View File

@ -95,6 +95,9 @@ func (User) Fields() []ent.Field {
return time.Now().In(jst) return time.Now().In(jst)
}), }),
field.Int("fav").
Optional(),
field.Bool("ten"). field.Bool("ten").
Optional(), Optional(),

View File

@ -44,6 +44,8 @@ type User struct {
LikeRank int `json:"like_rank,omitempty"` LikeRank int `json:"like_rank,omitempty"`
// LikeAt holds the value of the "like_at" field. // LikeAt holds the value of the "like_at" field.
LikeAt time.Time `json:"like_at,omitempty"` LikeAt time.Time `json:"like_at,omitempty"`
// Fav holds the value of the "fav" field.
Fav int `json:"fav,omitempty"`
// Ten holds the value of the "ten" field. // Ten holds the value of the "ten" field.
Ten bool `json:"ten,omitempty"` Ten bool `json:"ten,omitempty"`
// TenSu holds the value of the "ten_su" field. // TenSu holds the value of the "ten_su" field.
@ -95,7 +97,7 @@ func (*User) scanValues(columns []string) ([]any, error) {
switch columns[i] { switch columns[i] {
case user.FieldDelete, user.FieldHandle, user.FieldTen: case user.FieldDelete, user.FieldHandle, user.FieldTen:
values[i] = new(sql.NullBool) values[i] = new(sql.NullBool)
case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldTenSu, user.FieldTenKai, user.FieldAiten: case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldFav, user.FieldTenSu, user.FieldTenKai, user.FieldAiten:
values[i] = new(sql.NullInt64) values[i] = new(sql.NullInt64)
case user.FieldUsername, user.FieldDid, user.FieldToken, user.FieldPassword, user.FieldTenCard, user.FieldTenDelete, user.FieldTenPost, user.FieldTenGet, user.FieldNext: case user.FieldUsername, user.FieldDid, user.FieldToken, user.FieldPassword, user.FieldTenCard, user.FieldTenDelete, user.FieldTenPost, user.FieldTenGet, user.FieldNext:
values[i] = new(sql.NullString) values[i] = new(sql.NullString)
@ -208,6 +210,12 @@ func (u *User) assignValues(columns []string, values []any) error {
} else if value.Valid { } else if value.Valid {
u.LikeAt = value.Time u.LikeAt = value.Time
} }
case user.FieldFav:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field fav", values[i])
} else if value.Valid {
u.Fav = int(value.Int64)
}
case user.FieldTen: case user.FieldTen:
if value, ok := values[i].(*sql.NullBool); !ok { if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field ten", values[i]) return fmt.Errorf("unexpected type %T for field ten", values[i])
@ -348,6 +356,9 @@ func (u *User) String() string {
builder.WriteString("like_at=") builder.WriteString("like_at=")
builder.WriteString(u.LikeAt.Format(time.ANSIC)) builder.WriteString(u.LikeAt.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("fav=")
builder.WriteString(fmt.Sprintf("%v", u.Fav))
builder.WriteString(", ")
builder.WriteString("ten=") builder.WriteString("ten=")
builder.WriteString(fmt.Sprintf("%v", u.Ten)) builder.WriteString(fmt.Sprintf("%v", u.Ten))
builder.WriteString(", ") builder.WriteString(", ")

View File

@ -39,6 +39,8 @@ const (
FieldLikeRank = "like_rank" FieldLikeRank = "like_rank"
// FieldLikeAt holds the string denoting the like_at field in the database. // FieldLikeAt holds the string denoting the like_at field in the database.
FieldLikeAt = "like_at" FieldLikeAt = "like_at"
// FieldFav holds the string denoting the fav field in the database.
FieldFav = "fav"
// FieldTen holds the string denoting the ten field in the database. // FieldTen holds the string denoting the ten field in the database.
FieldTen = "ten" FieldTen = "ten"
// FieldTenSu holds the string denoting the ten_su field in the database. // FieldTenSu holds the string denoting the ten_su field in the database.
@ -89,6 +91,7 @@ var Columns = []string{
FieldLike, FieldLike,
FieldLikeRank, FieldLikeRank,
FieldLikeAt, FieldLikeAt,
FieldFav,
FieldTen, FieldTen,
FieldTenSu, FieldTenSu,
FieldTenKai, FieldTenKai,

View File

@ -125,6 +125,11 @@ func LikeAt(v time.Time) predicate.User {
return predicate.User(sql.FieldEQ(FieldLikeAt, v)) return predicate.User(sql.FieldEQ(FieldLikeAt, v))
} }
// Fav applies equality check predicate on the "fav" field. It's identical to FavEQ.
func Fav(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldFav, v))
}
// Ten applies equality check predicate on the "ten" field. It's identical to TenEQ. // Ten applies equality check predicate on the "ten" field. It's identical to TenEQ.
func Ten(v bool) predicate.User { func Ten(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldTen, v)) return predicate.User(sql.FieldEQ(FieldTen, v))
@ -895,6 +900,56 @@ func LikeAtNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldLikeAt)) return predicate.User(sql.FieldNotNull(FieldLikeAt))
} }
// FavEQ applies the EQ predicate on the "fav" field.
func FavEQ(v int) predicate.User {
return predicate.User(sql.FieldEQ(FieldFav, v))
}
// FavNEQ applies the NEQ predicate on the "fav" field.
func FavNEQ(v int) predicate.User {
return predicate.User(sql.FieldNEQ(FieldFav, v))
}
// FavIn applies the In predicate on the "fav" field.
func FavIn(vs ...int) predicate.User {
return predicate.User(sql.FieldIn(FieldFav, vs...))
}
// FavNotIn applies the NotIn predicate on the "fav" field.
func FavNotIn(vs ...int) predicate.User {
return predicate.User(sql.FieldNotIn(FieldFav, vs...))
}
// FavGT applies the GT predicate on the "fav" field.
func FavGT(v int) predicate.User {
return predicate.User(sql.FieldGT(FieldFav, v))
}
// FavGTE applies the GTE predicate on the "fav" field.
func FavGTE(v int) predicate.User {
return predicate.User(sql.FieldGTE(FieldFav, v))
}
// FavLT applies the LT predicate on the "fav" field.
func FavLT(v int) predicate.User {
return predicate.User(sql.FieldLT(FieldFav, v))
}
// FavLTE applies the LTE predicate on the "fav" field.
func FavLTE(v int) predicate.User {
return predicate.User(sql.FieldLTE(FieldFav, v))
}
// FavIsNil applies the IsNil predicate on the "fav" field.
func FavIsNil() predicate.User {
return predicate.User(sql.FieldIsNull(FieldFav))
}
// FavNotNil applies the NotNil predicate on the "fav" field.
func FavNotNil() predicate.User {
return predicate.User(sql.FieldNotNull(FieldFav))
}
// TenEQ applies the EQ predicate on the "ten" field. // TenEQ applies the EQ predicate on the "ten" field.
func TenEQ(v bool) predicate.User { func TenEQ(v bool) predicate.User {
return predicate.User(sql.FieldEQ(FieldTen, v)) return predicate.User(sql.FieldEQ(FieldTen, v))

View File

@ -201,6 +201,20 @@ func (uc *UserCreate) SetNillableLikeAt(t *time.Time) *UserCreate {
return uc return uc
} }
// SetFav sets the "fav" field.
func (uc *UserCreate) SetFav(i int) *UserCreate {
uc.mutation.SetFav(i)
return uc
}
// SetNillableFav sets the "fav" field if the given value is not nil.
func (uc *UserCreate) SetNillableFav(i *int) *UserCreate {
if i != nil {
uc.SetFav(*i)
}
return uc
}
// SetTen sets the "ten" field. // SetTen sets the "ten" field.
func (uc *UserCreate) SetTen(b bool) *UserCreate { func (uc *UserCreate) SetTen(b bool) *UserCreate {
uc.mutation.SetTen(b) uc.mutation.SetTen(b)
@ -529,6 +543,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
_spec.SetField(user.FieldLikeAt, field.TypeTime, value) _spec.SetField(user.FieldLikeAt, field.TypeTime, value)
_node.LikeAt = value _node.LikeAt = value
} }
if value, ok := uc.mutation.Fav(); ok {
_spec.SetField(user.FieldFav, field.TypeInt, value)
_node.Fav = value
}
if value, ok := uc.mutation.Ten(); ok { if value, ok := uc.mutation.Ten(); ok {
_spec.SetField(user.FieldTen, field.TypeBool, value) _spec.SetField(user.FieldTen, field.TypeBool, value)
_node.Ten = value _node.Ten = value

View File

@ -270,6 +270,33 @@ func (uu *UserUpdate) ClearLikeAt() *UserUpdate {
return uu return uu
} }
// SetFav sets the "fav" field.
func (uu *UserUpdate) SetFav(i int) *UserUpdate {
uu.mutation.ResetFav()
uu.mutation.SetFav(i)
return uu
}
// SetNillableFav sets the "fav" field if the given value is not nil.
func (uu *UserUpdate) SetNillableFav(i *int) *UserUpdate {
if i != nil {
uu.SetFav(*i)
}
return uu
}
// AddFav adds i to the "fav" field.
func (uu *UserUpdate) AddFav(i int) *UserUpdate {
uu.mutation.AddFav(i)
return uu
}
// ClearFav clears the value of the "fav" field.
func (uu *UserUpdate) ClearFav() *UserUpdate {
uu.mutation.ClearFav()
return uu
}
// SetTen sets the "ten" field. // SetTen sets the "ten" field.
func (uu *UserUpdate) SetTen(b bool) *UserUpdate { func (uu *UserUpdate) SetTen(b bool) *UserUpdate {
uu.mutation.SetTen(b) uu.mutation.SetTen(b)
@ -646,6 +673,15 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
if uu.mutation.LikeAtCleared() { if uu.mutation.LikeAtCleared() {
_spec.ClearField(user.FieldLikeAt, field.TypeTime) _spec.ClearField(user.FieldLikeAt, field.TypeTime)
} }
if value, ok := uu.mutation.Fav(); ok {
_spec.SetField(user.FieldFav, field.TypeInt, value)
}
if value, ok := uu.mutation.AddedFav(); ok {
_spec.AddField(user.FieldFav, field.TypeInt, value)
}
if uu.mutation.FavCleared() {
_spec.ClearField(user.FieldFav, field.TypeInt)
}
if value, ok := uu.mutation.Ten(); ok { if value, ok := uu.mutation.Ten(); ok {
_spec.SetField(user.FieldTen, field.TypeBool, value) _spec.SetField(user.FieldTen, field.TypeBool, value)
} }
@ -1021,6 +1057,33 @@ func (uuo *UserUpdateOne) ClearLikeAt() *UserUpdateOne {
return uuo return uuo
} }
// SetFav sets the "fav" field.
func (uuo *UserUpdateOne) SetFav(i int) *UserUpdateOne {
uuo.mutation.ResetFav()
uuo.mutation.SetFav(i)
return uuo
}
// SetNillableFav sets the "fav" field if the given value is not nil.
func (uuo *UserUpdateOne) SetNillableFav(i *int) *UserUpdateOne {
if i != nil {
uuo.SetFav(*i)
}
return uuo
}
// AddFav adds i to the "fav" field.
func (uuo *UserUpdateOne) AddFav(i int) *UserUpdateOne {
uuo.mutation.AddFav(i)
return uuo
}
// ClearFav clears the value of the "fav" field.
func (uuo *UserUpdateOne) ClearFav() *UserUpdateOne {
uuo.mutation.ClearFav()
return uuo
}
// SetTen sets the "ten" field. // SetTen sets the "ten" field.
func (uuo *UserUpdateOne) SetTen(b bool) *UserUpdateOne { func (uuo *UserUpdateOne) SetTen(b bool) *UserUpdateOne {
uuo.mutation.SetTen(b) uuo.mutation.SetTen(b)
@ -1427,6 +1490,15 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
if uuo.mutation.LikeAtCleared() { if uuo.mutation.LikeAtCleared() {
_spec.ClearField(user.FieldLikeAt, field.TypeTime) _spec.ClearField(user.FieldLikeAt, field.TypeTime)
} }
if value, ok := uuo.mutation.Fav(); ok {
_spec.SetField(user.FieldFav, field.TypeInt, value)
}
if value, ok := uuo.mutation.AddedFav(); ok {
_spec.AddField(user.FieldFav, field.TypeInt, value)
}
if uuo.mutation.FavCleared() {
_spec.ClearField(user.FieldFav, field.TypeInt)
}
if value, ok := uuo.mutation.Ten(); ok { if value, ok := uuo.mutation.Ten(); ok {
_spec.SetField(user.FieldTen, field.TypeBool, value) _spec.SetField(user.FieldTen, field.TypeBool, value)
} }

View File

@ -77,3 +77,18 @@ func (h *OgentHandler) UpdateUsers(ctx context.Context, req UpdateUsersReq, para
- https://github.com/go-kratos/beer-shop/tree/main/app/catalog/service/internal/data/ent - https://github.com/go-kratos/beer-shop/tree/main/app/catalog/service/internal/data/ent
### update
```sh
$ curl --dump-header - 'https://api.syui.ai/users' -H 'Origin: https://card.syui.ai'|less
```
> ent/ogent/oas_response_encoders_gen.go
```go
func encodeCreateGroupResponse(response CreateGroupRes, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
switch response := response.(type) {
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
```

View File

@ -13,6 +13,8 @@ if [ -z "$3" ];then
exit exit
fi fi
echo username card cp
read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id` id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=$2 card=$2
cp=$3 cp=$3

29
tmp/card_fav_first.zsh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/zsh
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
card_status=first
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
data=`curl -sL "https://api.syui.ai/users?itemsPerPage=2555"`
fav=`echo $data|jq ".[]|select(.fav != 0)|.fav"`
id=`echo $data|jq ".[]|select(.fav != 0)|.id"`
n=`echo $fav|wc -l`
echo $n
for ((i=1;i<=$n;i++))
do
cid=`echo $fav|awk "NR==$i"`
uid=`echo $id|awk "NR==$i"`
#check
u_data=`curl -sL "https://api.syui.ai/users/$uid/card?itemsPerPage=2555"|jq -r ".[]|select(.status == \"first\")"`
if [ -z "$u_data" ];then
echo no $uid $cid
curl -X PATCH -H "Content-Type: application/json" -d "{\"status\":\"$card_status\",\"token\":\"$token\"}" $host/cards/$cid
fi
done

32
tmp/card_fav_second.zsh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/zsh
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
card_status=second
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
data=`curl -sL "https://api.syui.ai/users?itemsPerPage=2555"`
fav=`echo $data|jq ".[]|select(.fav != 0)|.fav"`
id=`echo $data|jq ".[]|select(.fav != 0)|.id"`
n=`echo $fav|wc -l`
echo $n
for ((i=1;i<=$n;i++))
do
cid=`echo $fav|awk "NR==$i"`
uid=`echo $id|awk "NR==$i"`
#check
u_data=`curl -sL "https://api.syui.ai/users/$uid/card?itemsPerPage=2555"|jq -r ".[]|select(.status == \"second\" or \"second\")"`
if [ -z "$u_data" ];then
d_data=`curl -sL $host/cards/$cid|jq -r "select(.status == \"first\")"`
echo $d_data
if [ -z "$d_data" ];then
curl -X PATCH -H "Content-Type: application/json" -d "{\"status\":\"$card_status\",\"token\":\"$token\"}" $host/cards/$cid
fi
fi
done

View File

@ -22,7 +22,7 @@ if [ -n "$1" ];then
if [ "ai" = "$1" ] || [ "yui" = "$1" ];then if [ "ai" = "$1" ] || [ "yui" = "$1" ];then
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7, \"like\":0,\"aiten\":1000}" -s $host/users/$id curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7, \"like\":0,\"aiten\":1000}" -s $host/users/$id
else else
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 0, \"luck_at\": \"$updated_at_n\", \"ten\":false, \"ten_at\": \"$updated_at_n\",\"token\": \"$token\",\"ten_kai\" : 0, \"aiten\":0}" -s $host/users/$id curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"luck_at\": \"$updated_at_n\", \"ten_at\": \"$updated_at_n\",\"token\": \"$token\"}" -s $host/users/$id
fi fi
exit exit
fi fi

View File

@ -1,13 +1,14 @@
#!/bin/zsh #!/bin/zsh
username=yui
id=381
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
alias date="/opt/homebrew/bin/gdate" alias date="/opt/homebrew/bin/gdate"
;; ;;
esac esac
username=syui
id=1
host=https://api.syui.ai host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token` token=`cat ~/.config/atr/api_card.json|jq -r .token`
pass=`cat ~/.config/atr/api_card.json|jq -r .password` pass=`cat ~/.config/atr/api_card.json|jq -r .password`
@ -16,6 +17,12 @@ data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"` nd=`date +"%Y%m%d"`
nd=20230101 nd=20230101
title=card_patch
echo $title
card_id=1
curl -X PATCH -H "Content-Type: application/json" -d "{\"cp\":1,\"token\":\"$token\"}" $host/cards/$card_id
read
## users ## users
curl -sL "$host/users?itemsPerPage=2550"|jq . curl -sL "$host/users?itemsPerPage=2550"|jq .
read read

View File

@ -125,17 +125,26 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea
// UpdateCard handles PATCH /cards/{id} requests. // UpdateCard handles PATCH /cards/{id} requests.
func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) { func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
b := h.client.Card.UpdateOneID(params.ID) b := h.client.Card.UpdateOneID(params.ID)
if v, ok := req.Token.Get(); ok {
if v == token {
// Add all fields. b.SetToken(v)
if v, ok := req.Skill.Get(); ok { if v, ok := req.Skill.Get(); ok {
b.SetSkill(v) b.SetSkill(v)
} }
// Add all edges. if v, ok := req.Status.Get(); ok {
b.SetStatus(v)
}
if v, ok := req.Token.Get(); ok {
b.SetToken(v)
}
if v, ok := req.Cp.Get(); ok {
b.SetCp(v)
}
if v, ok := req.Owner.Get(); ok { if v, ok := req.Owner.Get(); ok {
b.SetOwnerID(v) b.SetOwnerID(v)
} }
}
}
// Persist to storage. // Persist to storage.
e, err := b.Save(ctx) e, err := b.Save(ctx)
@ -170,7 +179,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
// DeleteCard handles DELETE /cards/{id} requests. // DeleteCard handles DELETE /cards/{id} requests.
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) { func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) err := h.client.Card.DeleteOneID(0).Exec(ctx)
if err != nil { if err != nil {
switch { switch {
case ent.IsNotFound(err): case ent.IsNotFound(err):
@ -478,6 +487,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
b.SetPassword(req.Password) b.SetPassword(req.Password)
if v, ok := req.Fav.Get(); ok {
b.SetFav(v)
}
if v, ok := req.Did.Get(); ok { if v, ok := req.Did.Get(); ok {
b.SetDid(v) b.SetDid(v)
} }
@ -611,6 +623,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
if v == token { if v == token {
b.SetToken(v) b.SetToken(v)
if v, ok := req.Fav.Get(); ok {
b.SetFav(v)
}
if v, ok := req.Did.Get(); ok { if v, ok := req.Did.Get(); ok {
b.SetDid(v) b.SetDid(v)
} }
@ -711,7 +726,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
// DeleteUser handles DELETE /users/{id} requests. // DeleteUser handles DELETE /users/{id} requests.
func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) { func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
err := h.client.User.DeleteOneID(params.ID).Exec(ctx) err := h.client.User.DeleteOneID(0).Exec(ctx)
if err != nil { if err != nil {
switch { switch {
case ent.IsNotFound(err): case ent.IsNotFound(err):