Compare commits
22 Commits
main
...
dc01c83e9d
Author | SHA1 | Date | |
---|---|---|---|
dc01c83e9d
|
|||
c3bd20d90b
|
|||
93a50de9c5
|
|||
53f275cbb3
|
|||
e9516ac4cd
|
|||
9d1f0f73c1
|
|||
baeca96d10
|
|||
33944caab7
|
|||
2883ab052c
|
|||
a0ac2438ed
|
|||
d4ee96b1dc
|
|||
41b6201a10
|
|||
c892ba3d8f
|
|||
d72f710aaa
|
|||
ab66b9efc0
|
|||
311f1ae71a
|
|||
007499e104
|
|||
e454d97086
|
|||
175ab09869
|
|||
e025b48fb4
|
|||
1d65e1194b
|
|||
9573dc895f
|
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,2 +1,9 @@
|
||||
t
|
||||
.env
|
||||
*.json
|
||||
*.sqlite
|
||||
#*.zsh
|
||||
tmp/card_limit.zsh
|
||||
tmp/card_day.zsh
|
||||
tmp/card_delete.zsh
|
||||
memo.md
|
||||
|
11
build.zsh
Executable file
11
build.zsh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/zsh
|
||||
|
||||
d=${0:a:h}
|
||||
cd $d
|
||||
su=4000
|
||||
|
||||
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/tmp/ogent ent/
|
33
ent/card.go
33
ent/card.go
@@ -17,10 +17,16 @@ type Card struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// Card holds the value of the "card" field.
|
||||
Card int `json:"card,omitempty"`
|
||||
// Skill holds the value of the "skill" field.
|
||||
Skill string `json:"skill,omitempty"`
|
||||
// Status holds the value of the "status" field.
|
||||
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 int `json:"cp,omitempty"`
|
||||
// URL holds the value of the "url" field.
|
||||
@@ -62,7 +68,7 @@ func (*Card) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case card.FieldID, card.FieldCard, card.FieldCp:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case card.FieldStatus, card.FieldURL:
|
||||
case card.FieldPassword, card.FieldSkill, card.FieldStatus, card.FieldToken, card.FieldURL:
|
||||
values[i] = new(sql.NullString)
|
||||
case card.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
@@ -89,18 +95,36 @@ func (c *Card) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
c.ID = int(value.Int64)
|
||||
case card.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
c.Password = value.String
|
||||
}
|
||||
case card.FieldCard:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field card", values[i])
|
||||
} else if value.Valid {
|
||||
c.Card = int(value.Int64)
|
||||
}
|
||||
case card.FieldSkill:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field skill", values[i])
|
||||
} else if value.Valid {
|
||||
c.Skill = value.String
|
||||
}
|
||||
case card.FieldStatus:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||
} else if value.Valid {
|
||||
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:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cp", values[i])
|
||||
@@ -159,12 +183,19 @@ func (c *Card) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Card(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", c.ID))
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("card=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.Card))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("skill=")
|
||||
builder.WriteString(c.Skill)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(c.Status)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cp=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.Cp))
|
||||
builder.WriteString(", ")
|
||||
|
@@ -11,10 +11,16 @@ const (
|
||||
Label = "card"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldCard holds the string denoting the card field in the database.
|
||||
FieldCard = "card"
|
||||
// FieldSkill holds the string denoting the skill field in the database.
|
||||
FieldSkill = "skill"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
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 = "cp"
|
||||
// FieldURL holds the string denoting the url field in the database.
|
||||
@@ -37,8 +43,11 @@ const (
|
||||
// Columns holds all SQL columns for card fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldPassword,
|
||||
FieldCard,
|
||||
FieldSkill,
|
||||
FieldStatus,
|
||||
FieldToken,
|
||||
FieldCp,
|
||||
FieldURL,
|
||||
FieldCreatedAt,
|
||||
@@ -66,8 +75,12 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
|
||||
var (
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultCard holds the default value on creation for the "card" field.
|
||||
DefaultCard func() int
|
||||
// DefaultSkill holds the default value on creation for the "skill" field.
|
||||
DefaultSkill func() string
|
||||
// DefaultStatus holds the default value on creation for the "status" field.
|
||||
DefaultStatus func() string
|
||||
// DefaultCp holds the default value on creation for the "cp" field.
|
||||
|
@@ -55,16 +55,31 @@ func IDLTE(id int) predicate.Card {
|
||||
return predicate.Card(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
|
||||
func Password(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// Card applies equality check predicate on the "card" field. It's identical to CardEQ.
|
||||
func Card(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCard, v))
|
||||
}
|
||||
|
||||
// Skill applies equality check predicate on the "skill" field. It's identical to SkillEQ.
|
||||
func Skill(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldSkill, v))
|
||||
}
|
||||
|
||||
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
|
||||
func Status(v string) predicate.Card {
|
||||
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.
|
||||
func Cp(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCp, v))
|
||||
@@ -80,6 +95,71 @@ func CreatedAt(v time.Time) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// PasswordEQ applies the EQ predicate on the "password" field.
|
||||
func PasswordEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordNEQ applies the NEQ predicate on the "password" field.
|
||||
func PasswordNEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldNEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordIn applies the In predicate on the "password" field.
|
||||
func PasswordIn(vs ...string) predicate.Card {
|
||||
return predicate.Card(sql.FieldIn(FieldPassword, vs...))
|
||||
}
|
||||
|
||||
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
||||
func PasswordNotIn(vs ...string) predicate.Card {
|
||||
return predicate.Card(sql.FieldNotIn(FieldPassword, vs...))
|
||||
}
|
||||
|
||||
// PasswordGT applies the GT predicate on the "password" field.
|
||||
func PasswordGT(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldGT(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordGTE applies the GTE predicate on the "password" field.
|
||||
func PasswordGTE(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldGTE(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordLT applies the LT predicate on the "password" field.
|
||||
func PasswordLT(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldLT(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordLTE applies the LTE predicate on the "password" field.
|
||||
func PasswordLTE(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldLTE(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordContains applies the Contains predicate on the "password" field.
|
||||
func PasswordContains(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContains(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
|
||||
func PasswordHasPrefix(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldHasPrefix(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
|
||||
func PasswordHasSuffix(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldHasSuffix(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
|
||||
func PasswordEqualFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEqualFold(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
|
||||
func PasswordContainsFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContainsFold(FieldPassword, v))
|
||||
}
|
||||
|
||||
// CardEQ applies the EQ predicate on the "card" field.
|
||||
func CardEQ(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCard, v))
|
||||
@@ -130,6 +210,81 @@ func CardNotNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldNotNull(FieldCard))
|
||||
}
|
||||
|
||||
// SkillEQ applies the EQ predicate on the "skill" field.
|
||||
func SkillEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillNEQ applies the NEQ predicate on the "skill" field.
|
||||
func SkillNEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldNEQ(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillIn applies the In predicate on the "skill" field.
|
||||
func SkillIn(vs ...string) predicate.Card {
|
||||
return predicate.Card(sql.FieldIn(FieldSkill, vs...))
|
||||
}
|
||||
|
||||
// SkillNotIn applies the NotIn predicate on the "skill" field.
|
||||
func SkillNotIn(vs ...string) predicate.Card {
|
||||
return predicate.Card(sql.FieldNotIn(FieldSkill, vs...))
|
||||
}
|
||||
|
||||
// SkillGT applies the GT predicate on the "skill" field.
|
||||
func SkillGT(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldGT(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillGTE applies the GTE predicate on the "skill" field.
|
||||
func SkillGTE(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldGTE(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillLT applies the LT predicate on the "skill" field.
|
||||
func SkillLT(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldLT(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillLTE applies the LTE predicate on the "skill" field.
|
||||
func SkillLTE(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldLTE(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillContains applies the Contains predicate on the "skill" field.
|
||||
func SkillContains(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContains(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillHasPrefix applies the HasPrefix predicate on the "skill" field.
|
||||
func SkillHasPrefix(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldHasPrefix(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillHasSuffix applies the HasSuffix predicate on the "skill" field.
|
||||
func SkillHasSuffix(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldHasSuffix(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillIsNil applies the IsNil predicate on the "skill" field.
|
||||
func SkillIsNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldIsNull(FieldSkill))
|
||||
}
|
||||
|
||||
// SkillNotNil applies the NotNil predicate on the "skill" field.
|
||||
func SkillNotNil() predicate.Card {
|
||||
return predicate.Card(sql.FieldNotNull(FieldSkill))
|
||||
}
|
||||
|
||||
// SkillEqualFold applies the EqualFold predicate on the "skill" field.
|
||||
func SkillEqualFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEqualFold(FieldSkill, v))
|
||||
}
|
||||
|
||||
// SkillContainsFold applies the ContainsFold predicate on the "skill" field.
|
||||
func SkillContainsFold(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldContainsFold(FieldSkill, v))
|
||||
}
|
||||
|
||||
// StatusEQ applies the EQ predicate on the "status" field.
|
||||
func StatusEQ(v string) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldStatus, v))
|
||||
@@ -205,6 +360,81 @@ func StatusContainsFold(v string) predicate.Card {
|
||||
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.
|
||||
func CpEQ(v int) predicate.Card {
|
||||
return predicate.Card(sql.FieldEQ(FieldCp, v))
|
||||
|
@@ -21,6 +21,12 @@ type CardCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (cc *CardCreate) SetPassword(s string) *CardCreate {
|
||||
cc.mutation.SetPassword(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetCard sets the "card" field.
|
||||
func (cc *CardCreate) SetCard(i int) *CardCreate {
|
||||
cc.mutation.SetCard(i)
|
||||
@@ -35,6 +41,20 @@ func (cc *CardCreate) SetNillableCard(i *int) *CardCreate {
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetSkill sets the "skill" field.
|
||||
func (cc *CardCreate) SetSkill(s string) *CardCreate {
|
||||
cc.mutation.SetSkill(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetNillableSkill sets the "skill" field if the given value is not nil.
|
||||
func (cc *CardCreate) SetNillableSkill(s *string) *CardCreate {
|
||||
if s != nil {
|
||||
cc.SetSkill(*s)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cc *CardCreate) SetStatus(s string) *CardCreate {
|
||||
cc.mutation.SetStatus(s)
|
||||
@@ -49,6 +69,20 @@ func (cc *CardCreate) SetNillableStatus(s *string) *CardCreate {
|
||||
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.
|
||||
func (cc *CardCreate) SetCp(i int) *CardCreate {
|
||||
cc.mutation.SetCp(i)
|
||||
@@ -141,6 +175,10 @@ func (cc *CardCreate) defaults() {
|
||||
v := card.DefaultCard()
|
||||
cc.mutation.SetCard(v)
|
||||
}
|
||||
if _, ok := cc.mutation.Skill(); !ok {
|
||||
v := card.DefaultSkill()
|
||||
cc.mutation.SetSkill(v)
|
||||
}
|
||||
if _, ok := cc.mutation.Status(); !ok {
|
||||
v := card.DefaultStatus()
|
||||
cc.mutation.SetStatus(v)
|
||||
@@ -161,6 +199,14 @@ func (cc *CardCreate) defaults() {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cc *CardCreate) check() error {
|
||||
if _, ok := cc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Card.password"`)}
|
||||
}
|
||||
if v, ok := cc.mutation.Password(); ok {
|
||||
if err := card.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Card.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cc.mutation.OwnerID(); !ok {
|
||||
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Card.owner"`)}
|
||||
}
|
||||
@@ -190,14 +236,26 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
|
||||
_node = &Card{config: cc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(card.Table, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := cc.mutation.Password(); ok {
|
||||
_spec.SetField(card.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := cc.mutation.Card(); ok {
|
||||
_spec.SetField(card.FieldCard, field.TypeInt, value)
|
||||
_node.Card = value
|
||||
}
|
||||
if value, ok := cc.mutation.Skill(); ok {
|
||||
_spec.SetField(card.FieldSkill, field.TypeString, value)
|
||||
_node.Skill = value
|
||||
}
|
||||
if value, ok := cc.mutation.Status(); ok {
|
||||
_spec.SetField(card.FieldStatus, field.TypeString, 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 {
|
||||
_spec.SetField(card.FieldCp, field.TypeInt, value)
|
||||
_node.Cp = value
|
||||
@@ -218,10 +276,7 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
|
||||
Columns: []string{card.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
@@ -298,12 +298,12 @@ func (cq *CardQuery) WithOwner(opts ...func(*UserQuery)) *CardQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Card int `json:"card,omitempty"`
|
||||
// Password string `json:"password,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Card.Query().
|
||||
// GroupBy(card.FieldCard).
|
||||
// GroupBy(card.FieldPassword).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (cq *CardQuery) GroupBy(field string, fields ...string) *CardGroupBy {
|
||||
@@ -321,11 +321,11 @@ func (cq *CardQuery) GroupBy(field string, fields ...string) *CardGroupBy {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Card int `json:"card,omitempty"`
|
||||
// Password string `json:"password,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Card.Query().
|
||||
// Select(card.FieldCard).
|
||||
// Select(card.FieldPassword).
|
||||
// Scan(ctx, &v)
|
||||
func (cq *CardQuery) Select(fields ...string) *CardSelect {
|
||||
cq.ctx.Fields = append(cq.ctx.Fields, fields...)
|
||||
|
@@ -28,6 +28,93 @@ func (cu *CardUpdate) Where(ps ...predicate.Card) *CardUpdate {
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetSkill sets the "skill" field.
|
||||
func (cu *CardUpdate) SetSkill(s string) *CardUpdate {
|
||||
cu.mutation.SetSkill(s)
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetNillableSkill sets the "skill" field if the given value is not nil.
|
||||
func (cu *CardUpdate) SetNillableSkill(s *string) *CardUpdate {
|
||||
if s != nil {
|
||||
cu.SetSkill(*s)
|
||||
}
|
||||
return cu
|
||||
}
|
||||
|
||||
// ClearSkill clears the value of the "skill" field.
|
||||
func (cu *CardUpdate) ClearSkill() *CardUpdate {
|
||||
cu.mutation.ClearSkill()
|
||||
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.
|
||||
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
|
||||
cu.mutation.SetOwnerID(id)
|
||||
@@ -100,9 +187,30 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if cu.mutation.CardCleared() {
|
||||
_spec.ClearField(card.FieldCard, field.TypeInt)
|
||||
}
|
||||
if value, ok := cu.mutation.Skill(); ok {
|
||||
_spec.SetField(card.FieldSkill, field.TypeString, value)
|
||||
}
|
||||
if cu.mutation.SkillCleared() {
|
||||
_spec.ClearField(card.FieldSkill, field.TypeString)
|
||||
}
|
||||
if value, ok := cu.mutation.Status(); ok {
|
||||
_spec.SetField(card.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if cu.mutation.StatusCleared() {
|
||||
_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() {
|
||||
_spec.ClearField(card.FieldCp, field.TypeInt)
|
||||
}
|
||||
@@ -120,10 +228,7 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Columns: []string{card.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
@@ -136,10 +241,7 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Columns: []string{card.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -167,6 +269,93 @@ type CardUpdateOne struct {
|
||||
mutation *CardMutation
|
||||
}
|
||||
|
||||
// SetSkill sets the "skill" field.
|
||||
func (cuo *CardUpdateOne) SetSkill(s string) *CardUpdateOne {
|
||||
cuo.mutation.SetSkill(s)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetNillableSkill sets the "skill" field if the given value is not nil.
|
||||
func (cuo *CardUpdateOne) SetNillableSkill(s *string) *CardUpdateOne {
|
||||
if s != nil {
|
||||
cuo.SetSkill(*s)
|
||||
}
|
||||
return cuo
|
||||
}
|
||||
|
||||
// ClearSkill clears the value of the "skill" field.
|
||||
func (cuo *CardUpdateOne) ClearSkill() *CardUpdateOne {
|
||||
cuo.mutation.ClearSkill()
|
||||
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.
|
||||
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
|
||||
cuo.mutation.SetOwnerID(id)
|
||||
@@ -269,9 +458,30 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
|
||||
if cuo.mutation.CardCleared() {
|
||||
_spec.ClearField(card.FieldCard, field.TypeInt)
|
||||
}
|
||||
if value, ok := cuo.mutation.Skill(); ok {
|
||||
_spec.SetField(card.FieldSkill, field.TypeString, value)
|
||||
}
|
||||
if cuo.mutation.SkillCleared() {
|
||||
_spec.ClearField(card.FieldSkill, field.TypeString)
|
||||
}
|
||||
if value, ok := cuo.mutation.Status(); ok {
|
||||
_spec.SetField(card.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if cuo.mutation.StatusCleared() {
|
||||
_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() {
|
||||
_spec.ClearField(card.FieldCp, field.TypeInt)
|
||||
}
|
||||
@@ -289,10 +499,7 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
|
||||
Columns: []string{card.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
@@ -305,10 +512,7 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
|
||||
Columns: []string{card.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
@@ -509,7 +509,7 @@ func withHooks[V Value, M any, PM interface {
|
||||
return exec(ctx)
|
||||
}
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutationT, ok := m.(PM)
|
||||
mutationT, ok := any(m).(PM)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
|
12
ent/group.go
12
ent/group.go
@@ -17,6 +17,8 @@ type Group struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the GroupQuery when eager-loading is set.
|
||||
Edges GroupEdges `json:"edges"`
|
||||
@@ -47,7 +49,7 @@ func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case group.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case group.FieldName:
|
||||
case group.FieldName, group.FieldPassword:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type Group", columns[i])
|
||||
@@ -76,6 +78,12 @@ func (gr *Group) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
gr.Name = value.String
|
||||
}
|
||||
case group.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
gr.Password = value.String
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -111,6 +119,8 @@ func (gr *Group) String() string {
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", gr.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(gr.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
@@ -9,6 +9,8 @@ const (
|
||||
FieldID = "id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// EdgeUsers holds the string denoting the users edge name in mutations.
|
||||
EdgeUsers = "users"
|
||||
// Table holds the table name of the group in the database.
|
||||
@@ -26,6 +28,7 @@ const (
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldPassword,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -37,3 +40,8 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
)
|
||||
|
@@ -59,6 +59,11 @@ func Name(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
|
||||
func Password(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldName, v))
|
||||
@@ -124,6 +129,71 @@ func NameContainsFold(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// PasswordEQ applies the EQ predicate on the "password" field.
|
||||
func PasswordEQ(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordNEQ applies the NEQ predicate on the "password" field.
|
||||
func PasswordNEQ(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldNEQ(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordIn applies the In predicate on the "password" field.
|
||||
func PasswordIn(vs ...string) predicate.Group {
|
||||
return predicate.Group(sql.FieldIn(FieldPassword, vs...))
|
||||
}
|
||||
|
||||
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
||||
func PasswordNotIn(vs ...string) predicate.Group {
|
||||
return predicate.Group(sql.FieldNotIn(FieldPassword, vs...))
|
||||
}
|
||||
|
||||
// PasswordGT applies the GT predicate on the "password" field.
|
||||
func PasswordGT(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldGT(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordGTE applies the GTE predicate on the "password" field.
|
||||
func PasswordGTE(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldGTE(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordLT applies the LT predicate on the "password" field.
|
||||
func PasswordLT(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldLT(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordLTE applies the LTE predicate on the "password" field.
|
||||
func PasswordLTE(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldLTE(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordContains applies the Contains predicate on the "password" field.
|
||||
func PasswordContains(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldContains(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
|
||||
func PasswordHasPrefix(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldHasPrefix(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
|
||||
func PasswordHasSuffix(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldHasSuffix(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
|
||||
func PasswordEqualFold(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldEqualFold(FieldPassword, v))
|
||||
}
|
||||
|
||||
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
|
||||
func PasswordContainsFold(v string) predicate.Group {
|
||||
return predicate.Group(sql.FieldContainsFold(FieldPassword, v))
|
||||
}
|
||||
|
||||
// HasUsers applies the HasEdge predicate on the "users" edge.
|
||||
func HasUsers() predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
|
@@ -26,6 +26,12 @@ func (gc *GroupCreate) SetName(s string) *GroupCreate {
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (gc *GroupCreate) SetPassword(s string) *GroupCreate {
|
||||
gc.mutation.SetPassword(s)
|
||||
return gc
|
||||
}
|
||||
|
||||
// AddUserIDs adds the "users" edge to the User entity by IDs.
|
||||
func (gc *GroupCreate) AddUserIDs(ids ...int) *GroupCreate {
|
||||
gc.mutation.AddUserIDs(ids...)
|
||||
@@ -78,6 +84,14 @@ func (gc *GroupCreate) check() error {
|
||||
if _, ok := gc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Group.name"`)}
|
||||
}
|
||||
if _, ok := gc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Group.password"`)}
|
||||
}
|
||||
if v, ok := gc.mutation.Password(); ok {
|
||||
if err := group.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Group.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -108,6 +122,10 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(group.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := gc.mutation.Password(); ok {
|
||||
_spec.SetField(group.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if nodes := gc.mutation.UsersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -116,10 +134,7 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
@@ -122,10 +122,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
@@ -138,10 +135,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -157,10 +151,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -312,10 +303,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
@@ -328,10 +316,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -347,10 +332,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
|
||||
Columns: []string{group.UsersColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
12
ent/migrate/migrations/20230405104340_migration_name.sql
Normal file
12
ent/migrate/migrations/20230405104340_migration_name.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Create "cards" table
|
||||
CREATE TABLE `cards` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `password` text NOT NULL, `card` integer NULL, `status` text NULL, `cp` integer NULL, `url` text NULL DEFAULT 'https://card.syui.ai', `created_at` datetime NULL, `user_card` integer NOT NULL, CONSTRAINT `cards_users_card` FOREIGN KEY (`user_card`) REFERENCES `users` (`id`) ON DELETE NO ACTION);
|
||||
-- Create "groups" table
|
||||
CREATE TABLE `groups` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` text NOT NULL, `password` text NOT NULL);
|
||||
-- Create index "group_name" to table: "groups"
|
||||
CREATE UNIQUE INDEX `group_name` ON `groups` (`name`);
|
||||
-- Create "users" table
|
||||
CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `username` text NOT NULL, `password` text NOT NULL, `created_at` datetime NULL, `updated_at` datetime NULL, `next` text NULL DEFAULT '20230405', `group_users` integer NULL, CONSTRAINT `users_groups_users` FOREIGN KEY (`group_users`) REFERENCES `groups` (`id`) ON DELETE SET NULL);
|
||||
-- Create index "users_username_key" to table: "users"
|
||||
CREATE UNIQUE INDEX `users_username_key` ON `users` (`username`);
|
||||
-- Create index "user_username" to table: "users"
|
||||
CREATE UNIQUE INDEX `user_username` ON `users` (`username`);
|
2
ent/migrate/migrations/atlas.sum
Normal file
2
ent/migrate/migrations/atlas.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
h1:GU79ffcSbQHeq4BLGuuAdObBOt0WLTcsQx+AucxEqkA=
|
||||
20230405104340_migration_name.sql h1:vlsZT8ob1qpLmBAGPqNBBG/iFact7wy1pb27tAavvRU=
|
@@ -11,8 +11,11 @@ var (
|
||||
// CardsColumns holds the columns for the "cards" table.
|
||||
CardsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "card", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "skill", 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: "url", Type: field.TypeString, Nullable: true, Default: "https://card.syui.ai"},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
@@ -26,7 +29,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cards_users_card",
|
||||
Columns: []*schema.Column{CardsColumns[6]},
|
||||
Columns: []*schema.Column{CardsColumns[9]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
@@ -36,6 +39,7 @@ var (
|
||||
GroupsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
@@ -53,10 +57,33 @@ var (
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 30},
|
||||
{Name: "username", Type: field.TypeString, Unique: true, Size: 100},
|
||||
{Name: "did", Type: field.TypeString, Nullable: true},
|
||||
{Name: "bsky", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "mastodon", Type: field.TypeBool, Nullable: true, Default: true},
|
||||
{Name: "delete", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "handle", Type: field.TypeBool, Nullable: true, Default: false},
|
||||
{Name: "token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "created_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230404"},
|
||||
{Name: "raid_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "luck", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "luck_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "like", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "like_rank", Type: field.TypeInt, 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_su", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "ten_kai", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "aiten", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "ten_card", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_delete", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_post", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_get", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230710"},
|
||||
{Name: "group_users", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
@@ -67,7 +94,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "users_groups_users",
|
||||
Columns: []*schema.Column{UsersColumns[5]},
|
||||
Columns: []*schema.Column{UsersColumns[28]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
2163
ent/mutation.go
2163
ent/mutation.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -459,7 +459,7 @@ func decodeListCardParams(args [0]string, r *http.Request) (params ListCardParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 4000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@@ -624,7 +624,7 @@ func decodeListGroupParams(args [0]string, r *http.Request) (params ListGroupPar
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 4000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@@ -956,7 +956,7 @@ func decodeListUserParams(args [0]string, r *http.Request) (params ListUserParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 4000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
|
@@ -374,6 +374,7 @@ func encodeDrawStartResponse(response *DrawStartNoContent, w http.ResponseWriter
|
||||
}
|
||||
|
||||
func encodeListCardResponse(response ListCardRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
case *ListCardOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -575,6 +576,7 @@ func encodeListGroupUsersResponse(response ListGroupUsersRes, w http.ResponseWri
|
||||
}
|
||||
|
||||
func encodeListUserResponse(response ListUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
case *ListUserOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -642,6 +644,7 @@ func encodeListUserResponse(response ListUserRes, w http.ResponseWriter, span tr
|
||||
}
|
||||
|
||||
func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
case *ListUserCardOKApplicationJSON:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -709,6 +712,7 @@ func encodeListUserCardResponse(response ListUserCardRes, w http.ResponseWriter,
|
||||
}
|
||||
|
||||
func encodeReadCardResponse(response ReadCardRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
case *CardRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -776,6 +780,7 @@ func encodeReadCardResponse(response ReadCardRes, w http.ResponseWriter, span tr
|
||||
}
|
||||
|
||||
func encodeReadCardOwnerResponse(response ReadCardOwnerRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
case *CardOwnerRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -910,6 +915,7 @@ func encodeReadGroupResponse(response ReadGroupRes, w http.ResponseWriter, span
|
||||
}
|
||||
|
||||
func encodeReadUserResponse(response ReadUserRes, w http.ResponseWriter, span trace.Span) error {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "https://card.syui.ai")
|
||||
switch response := response.(type) {
|
||||
case *UserRead:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -12,8 +12,13 @@ import (
|
||||
"t/ent/user"
|
||||
|
||||
"github.com/go-faster/jx"
|
||||
"os"
|
||||
)
|
||||
|
||||
// origin-config
|
||||
var password = os.Getenv("PASS")
|
||||
var token = os.Getenv("TOKEN")
|
||||
|
||||
// OgentHandler implements the ogen generated Handler interface and uses Ent as data layer.
|
||||
type OgentHandler struct {
|
||||
client *ent.Client
|
||||
@@ -33,9 +38,13 @@ func rawError(err error) jx.Raw {
|
||||
func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (CreateCardRes, error) {
|
||||
b := h.client.Card.Create()
|
||||
// Add all fields.
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
@@ -49,7 +58,13 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// origin-config
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@@ -110,11 +125,27 @@ func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (Rea
|
||||
// UpdateCard handles PATCH /cards/{id} requests.
|
||||
func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
|
||||
b := h.client.Card.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
// Add all edges.
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
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 {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@@ -148,7 +179,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@@ -239,7 +270,8 @@ func (h *OgentHandler) ReadCardOwner(ctx context.Context, params ReadCardOwnerPa
|
||||
func (h *OgentHandler) CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) {
|
||||
b := h.client.Group.Create()
|
||||
// Add all fields.
|
||||
b.SetName(req.Name)
|
||||
b.SetName("")
|
||||
b.SetPassword(req.Password)
|
||||
// Add all edges.
|
||||
b.AddUserIDs(req.Users...)
|
||||
// Persist to storage.
|
||||
@@ -301,7 +333,7 @@ func (h *OgentHandler) ReadGroup(ctx context.Context, params ReadGroupParams) (R
|
||||
|
||||
// UpdateGroup handles PATCH /groups/{id} requests.
|
||||
func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) {
|
||||
b := h.client.Group.UpdateOneID(params.ID)
|
||||
b := h.client.Group.UpdateOneID(0)
|
||||
// Add all fields.
|
||||
if v, ok := req.Name.Get(); ok {
|
||||
b.SetName(v)
|
||||
@@ -343,7 +375,7 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par
|
||||
|
||||
// DeleteGroup handles DELETE /groups/{id} requests.
|
||||
func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
|
||||
err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Group.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@@ -443,14 +475,91 @@ func (h *OgentHandler) ListGroupUsers(ctx context.Context, params ListGroupUsers
|
||||
// CreateUser handles POST /users requests.
|
||||
func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) {
|
||||
b := h.client.User.Create()
|
||||
|
||||
// Add all fields.
|
||||
//b.SetUsername(req.Username)
|
||||
//origin-config
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
if v, ok := req.Handle.Get(); ok {
|
||||
b.SetHandle(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.LuckAt.Get(); ok {
|
||||
b.SetLuckAt(v)
|
||||
}
|
||||
if v, ok := req.Like.Get(); ok {
|
||||
b.SetLike(v)
|
||||
}
|
||||
if v, ok := req.LikeRank.Get(); ok {
|
||||
b.SetLikeRank(v)
|
||||
}
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
if v, ok := req.TenSu.Get(); ok {
|
||||
b.SetTenSu(v)
|
||||
}
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
if v, ok := req.TenDelete.Get(); ok {
|
||||
b.SetTenDelete(v)
|
||||
}
|
||||
if v, ok := req.TenPost.Get(); ok {
|
||||
b.SetTenPost(v)
|
||||
}
|
||||
if v, ok := req.TenGet.Get(); ok {
|
||||
b.SetTenGet(v)
|
||||
}
|
||||
if v, ok := req.TenAt.Get(); ok {
|
||||
b.SetTenAt(v)
|
||||
}
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
@@ -516,10 +625,77 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea
|
||||
// UpdateUser handles PATCH /users/{id} requests.
|
||||
func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
|
||||
b := h.client.User.UpdateOneID(params.ID)
|
||||
// Add all fields.
|
||||
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
if v, ok := req.Handle.Get(); ok {
|
||||
b.SetHandle(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
}
|
||||
if v, ok := req.LuckAt.Get(); ok {
|
||||
b.SetLuckAt(v)
|
||||
}
|
||||
if v, ok := req.Like.Get(); ok {
|
||||
b.SetLike(v)
|
||||
}
|
||||
if v, ok := req.LikeRank.Get(); ok {
|
||||
b.SetLikeRank(v)
|
||||
}
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
if v, ok := req.TenSu.Get(); ok {
|
||||
b.SetTenSu(v)
|
||||
}
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
if v, ok := req.TenDelete.Get(); ok {
|
||||
b.SetTenDelete(v)
|
||||
}
|
||||
if v, ok := req.TenPost.Get(); ok {
|
||||
b.SetTenPost(v)
|
||||
}
|
||||
if v, ok := req.TenGet.Get(); ok {
|
||||
b.SetTenGet(v)
|
||||
}
|
||||
if v, ok := req.TenAt.Get(); ok {
|
||||
b.SetTenAt(v)
|
||||
}
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
@@ -527,6 +703,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
if req.Card != nil {
|
||||
b.ClearCard().AddCardIDs(req.Card...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@@ -560,7 +739,7 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
|
||||
// DeleteUser handles DELETE /users/{id} requests.
|
||||
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 {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
|
@@ -11,6 +11,7 @@ func NewCardCreate(e *ent.Card) *CardCreate {
|
||||
var ret CardCreate
|
||||
ret.ID = e.ID
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Skill = NewOptString(e.Skill)
|
||||
ret.Status = NewOptString(e.Status)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.URL = NewOptString(e.URL)
|
||||
@@ -43,6 +44,7 @@ func NewCardList(e *ent.Card) *CardList {
|
||||
var ret CardList
|
||||
ret.ID = e.ID
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Skill = NewOptString(e.Skill)
|
||||
ret.Status = NewOptString(e.Status)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.URL = NewOptString(e.URL)
|
||||
@@ -75,6 +77,7 @@ func NewCardRead(e *ent.Card) *CardRead {
|
||||
var ret CardRead
|
||||
ret.ID = e.ID
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Skill = NewOptString(e.Skill)
|
||||
ret.Status = NewOptString(e.Status)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.URL = NewOptString(e.URL)
|
||||
@@ -107,6 +110,7 @@ func NewCardUpdate(e *ent.Card) *CardUpdate {
|
||||
var ret CardUpdate
|
||||
ret.ID = e.ID
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Skill = NewOptString(e.Skill)
|
||||
ret.Status = NewOptString(e.Status)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.URL = NewOptString(e.URL)
|
||||
@@ -139,8 +143,29 @@ func NewCardOwnerRead(e *ent.User) *CardOwnerRead {
|
||||
var ret CardOwnerRead
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
return &ret
|
||||
}
|
||||
@@ -282,8 +307,29 @@ func NewGroupUsersList(e *ent.User) *GroupUsersList {
|
||||
var ret GroupUsersList
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
return &ret
|
||||
}
|
||||
@@ -313,8 +359,29 @@ func NewUserCreate(e *ent.User) *UserCreate {
|
||||
var ret UserCreate
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
return &ret
|
||||
}
|
||||
@@ -344,8 +411,29 @@ func NewUserList(e *ent.User) *UserList {
|
||||
var ret UserList
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
return &ret
|
||||
}
|
||||
@@ -375,8 +463,29 @@ func NewUserRead(e *ent.User) *UserRead {
|
||||
var ret UserRead
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
return &ret
|
||||
}
|
||||
@@ -406,8 +515,29 @@ func NewUserUpdate(e *ent.User) *UserUpdate {
|
||||
var ret UserUpdate
|
||||
ret.ID = e.ID
|
||||
ret.Username = e.Username
|
||||
ret.Did = NewOptString(e.Did)
|
||||
ret.Bsky = NewOptBool(e.Bsky)
|
||||
ret.Mastodon = NewOptBool(e.Mastodon)
|
||||
ret.Delete = NewOptBool(e.Delete)
|
||||
ret.Handle = NewOptBool(e.Handle)
|
||||
ret.CreatedAt = NewOptDateTime(e.CreatedAt)
|
||||
ret.UpdatedAt = NewOptDateTime(e.UpdatedAt)
|
||||
ret.RaidAt = NewOptDateTime(e.RaidAt)
|
||||
ret.Luck = NewOptInt(e.Luck)
|
||||
ret.LuckAt = NewOptDateTime(e.LuckAt)
|
||||
ret.Like = NewOptInt(e.Like)
|
||||
ret.LikeRank = NewOptInt(e.LikeRank)
|
||||
ret.LikeAt = NewOptDateTime(e.LikeAt)
|
||||
ret.Fav = NewOptInt(e.Fav)
|
||||
ret.Ten = NewOptBool(e.Ten)
|
||||
ret.TenSu = NewOptInt(e.TenSu)
|
||||
ret.TenKai = NewOptInt(e.TenKai)
|
||||
ret.Aiten = NewOptInt(e.Aiten)
|
||||
ret.TenCard = NewOptString(e.TenCard)
|
||||
ret.TenDelete = NewOptString(e.TenDelete)
|
||||
ret.TenPost = NewOptString(e.TenPost)
|
||||
ret.TenGet = NewOptString(e.TenGet)
|
||||
ret.TenAt = NewOptDateTime(e.TenAt)
|
||||
ret.Next = NewOptString(e.Next)
|
||||
return &ret
|
||||
}
|
||||
@@ -437,6 +567,7 @@ func NewUserCardList(e *ent.Card) *UserCardList {
|
||||
var ret UserCardList
|
||||
ret.ID = e.ID
|
||||
ret.Card = NewOptInt(e.Card)
|
||||
ret.Skill = NewOptString(e.Skill)
|
||||
ret.Status = NewOptString(e.Status)
|
||||
ret.Cp = NewOptInt(e.Cp)
|
||||
ret.URL = NewOptString(e.URL)
|
||||
|
689
ent/openapi.json
689
ent/openapi.json
@@ -30,7 +30,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 4000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@@ -77,12 +77,21 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"cp": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -98,6 +107,7 @@
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"password",
|
||||
"owner"
|
||||
]
|
||||
}
|
||||
@@ -233,6 +243,18 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"cp": {
|
||||
"type": "integer"
|
||||
},
|
||||
"owner": {
|
||||
"type": "integer"
|
||||
}
|
||||
@@ -362,7 +384,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 4000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@@ -412,6 +434,9 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -420,7 +445,8 @@
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
"name",
|
||||
"password"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -684,7 +710,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 4000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@@ -734,6 +760,27 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -742,6 +789,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -753,7 +852,8 @@
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"username"
|
||||
"username",
|
||||
"password"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -888,10 +988,80 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1031,12 +1201,21 @@
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"cp": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -1053,6 +1232,7 @@
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"password",
|
||||
"owner"
|
||||
]
|
||||
},
|
||||
@@ -1065,6 +1245,9 @@
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1092,6 +1275,9 @@
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1119,6 +1305,9 @@
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1146,6 +1335,9 @@
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1173,6 +1365,21 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1181,6 +1388,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1199,6 +1458,9 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -1208,7 +1470,8 @@
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
"name",
|
||||
"password"
|
||||
]
|
||||
},
|
||||
"GroupCreate": {
|
||||
@@ -1280,6 +1543,21 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1288,6 +1566,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1306,6 +1636,27 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1314,6 +1665,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1326,7 +1729,8 @@
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"username"
|
||||
"username",
|
||||
"password"
|
||||
]
|
||||
},
|
||||
"UserCreate": {
|
||||
@@ -1338,6 +1742,21 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1346,6 +1765,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1364,6 +1835,21 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1372,6 +1858,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1390,6 +1928,21 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1398,6 +1951,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1416,6 +2021,21 @@
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"did": {
|
||||
"type": "string"
|
||||
},
|
||||
"bsky": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mastodon": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"delete": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"handle": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -1424,6 +2044,58 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"raid_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"luck": {
|
||||
"type": "integer"
|
||||
},
|
||||
"luck_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"like": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_rank": {
|
||||
"type": "integer"
|
||||
},
|
||||
"like_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"fav": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ten_su": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_kai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"aiten": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ten_card": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_delete": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_post": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_get": {
|
||||
"type": "string"
|
||||
},
|
||||
"ten_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"next": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1442,6 +2114,9 @@
|
||||
"card": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skill": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@@ -4,6 +4,7 @@ package ent
|
||||
|
||||
import (
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/schema"
|
||||
"t/ent/user"
|
||||
"time"
|
||||
@@ -15,26 +16,40 @@ import (
|
||||
func init() {
|
||||
cardFields := schema.Card{}.Fields()
|
||||
_ = cardFields
|
||||
// cardDescPassword is the schema descriptor for password field.
|
||||
cardDescPassword := cardFields[0].Descriptor()
|
||||
// card.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
card.PasswordValidator = cardDescPassword.Validators[0].(func(string) error)
|
||||
// cardDescCard is the schema descriptor for card field.
|
||||
cardDescCard := cardFields[0].Descriptor()
|
||||
cardDescCard := cardFields[1].Descriptor()
|
||||
// card.DefaultCard holds the default value on creation for the card field.
|
||||
card.DefaultCard = cardDescCard.Default.(func() int)
|
||||
// cardDescSkill is the schema descriptor for skill field.
|
||||
cardDescSkill := cardFields[2].Descriptor()
|
||||
// card.DefaultSkill holds the default value on creation for the skill field.
|
||||
card.DefaultSkill = cardDescSkill.Default.(func() string)
|
||||
// cardDescStatus is the schema descriptor for status field.
|
||||
cardDescStatus := cardFields[1].Descriptor()
|
||||
cardDescStatus := cardFields[3].Descriptor()
|
||||
// card.DefaultStatus holds the default value on creation for the status field.
|
||||
card.DefaultStatus = cardDescStatus.Default.(func() string)
|
||||
// cardDescCp is the schema descriptor for cp field.
|
||||
cardDescCp := cardFields[2].Descriptor()
|
||||
cardDescCp := cardFields[5].Descriptor()
|
||||
// card.DefaultCp holds the default value on creation for the cp field.
|
||||
card.DefaultCp = cardDescCp.Default.(func() int)
|
||||
// cardDescURL is the schema descriptor for url field.
|
||||
cardDescURL := cardFields[3].Descriptor()
|
||||
cardDescURL := cardFields[6].Descriptor()
|
||||
// card.DefaultURL holds the default value on creation for the url field.
|
||||
card.DefaultURL = cardDescURL.Default.(string)
|
||||
// cardDescCreatedAt is the schema descriptor for created_at field.
|
||||
cardDescCreatedAt := cardFields[4].Descriptor()
|
||||
cardDescCreatedAt := cardFields[7].Descriptor()
|
||||
// card.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
card.DefaultCreatedAt = cardDescCreatedAt.Default.(func() time.Time)
|
||||
groupFields := schema.Group{}.Fields()
|
||||
_ = groupFields
|
||||
// groupDescPassword is the schema descriptor for password field.
|
||||
groupDescPassword := groupFields[1].Descriptor()
|
||||
// group.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
group.PasswordValidator = groupDescPassword.Validators[0].(func(string) error)
|
||||
userFields := schema.User{}.Fields()
|
||||
_ = userFields
|
||||
// userDescUsername is the schema descriptor for username field.
|
||||
@@ -55,16 +70,52 @@ func init() {
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// userDescBsky is the schema descriptor for bsky field.
|
||||
userDescBsky := userFields[2].Descriptor()
|
||||
// user.DefaultBsky holds the default value on creation for the bsky field.
|
||||
user.DefaultBsky = userDescBsky.Default.(bool)
|
||||
// userDescMastodon is the schema descriptor for mastodon field.
|
||||
userDescMastodon := userFields[3].Descriptor()
|
||||
// user.DefaultMastodon holds the default value on creation for the mastodon field.
|
||||
user.DefaultMastodon = userDescMastodon.Default.(bool)
|
||||
// userDescDelete is the schema descriptor for delete field.
|
||||
userDescDelete := userFields[4].Descriptor()
|
||||
// user.DefaultDelete holds the default value on creation for the delete field.
|
||||
user.DefaultDelete = userDescDelete.Default.(bool)
|
||||
// userDescHandle is the schema descriptor for handle field.
|
||||
userDescHandle := userFields[5].Descriptor()
|
||||
// user.DefaultHandle holds the default value on creation for the handle field.
|
||||
user.DefaultHandle = userDescHandle.Default.(bool)
|
||||
// userDescPassword is the schema descriptor for password field.
|
||||
userDescPassword := userFields[7].Descriptor()
|
||||
// user.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
user.PasswordValidator = userDescPassword.Validators[0].(func(string) error)
|
||||
// userDescCreatedAt is the schema descriptor for created_at field.
|
||||
userDescCreatedAt := userFields[1].Descriptor()
|
||||
userDescCreatedAt := userFields[8].Descriptor()
|
||||
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
|
||||
// userDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
userDescUpdatedAt := userFields[2].Descriptor()
|
||||
userDescUpdatedAt := userFields[9].Descriptor()
|
||||
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
|
||||
// userDescRaidAt is the schema descriptor for raid_at field.
|
||||
userDescRaidAt := userFields[10].Descriptor()
|
||||
// user.DefaultRaidAt holds the default value on creation for the raid_at field.
|
||||
user.DefaultRaidAt = userDescRaidAt.Default.(func() time.Time)
|
||||
// userDescLuckAt is the schema descriptor for luck_at field.
|
||||
userDescLuckAt := userFields[12].Descriptor()
|
||||
// user.DefaultLuckAt holds the default value on creation for the luck_at field.
|
||||
user.DefaultLuckAt = userDescLuckAt.Default.(func() time.Time)
|
||||
// userDescLikeAt is the schema descriptor for like_at field.
|
||||
userDescLikeAt := userFields[15].Descriptor()
|
||||
// user.DefaultLikeAt holds the default value on creation for the like_at field.
|
||||
user.DefaultLikeAt = userDescLikeAt.Default.(func() time.Time)
|
||||
// userDescTenAt is the schema descriptor for ten_at field.
|
||||
userDescTenAt := userFields[25].Descriptor()
|
||||
// user.DefaultTenAt holds the default value on creation for the ten_at field.
|
||||
user.DefaultTenAt = userDescTenAt.Default.(func() time.Time)
|
||||
// userDescNext is the schema descriptor for next field.
|
||||
userDescNext := userFields[3].Descriptor()
|
||||
userDescNext := userFields[26].Descriptor()
|
||||
// user.DefaultNext holds the default value on creation for the next field.
|
||||
user.DefaultNext = userDescNext.Default.(string)
|
||||
}
|
||||
|
@@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in t/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.11.9" // Version of ent codegen.
|
||||
Sum = "h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=" // Sum of ent codegen.
|
||||
Version = "v0.11.10" // Version of ent codegen.
|
||||
Sum = "h1:iqn32ybY5HRW3xSAyMNdNKpZhKgMf1Zunsej9yPKUI8=" // Sum of ent codegen.
|
||||
)
|
||||
|
@@ -16,29 +16,71 @@ var url = "https://card.syui.ai"
|
||||
|
||||
var card int
|
||||
var super string
|
||||
var skill string
|
||||
var cp int
|
||||
|
||||
func (Card) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
field.Int("card").
|
||||
Immutable().
|
||||
DefaultFunc(func() int {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var a = rand.Intn(10)
|
||||
if a == 1 {
|
||||
card = rand.Intn(15)
|
||||
card = rand.Intn(16)
|
||||
} else {
|
||||
card = 0
|
||||
}
|
||||
|
||||
if card == 13 {
|
||||
card = 14
|
||||
card = 2
|
||||
}
|
||||
|
||||
// 2023/04/09 premium card id:15
|
||||
if card == 15 {
|
||||
card = 3
|
||||
}
|
||||
|
||||
if card == 16 {
|
||||
card = 4
|
||||
}
|
||||
|
||||
if card == 17 {
|
||||
card = 5
|
||||
}
|
||||
|
||||
if card == 18 {
|
||||
card = 6
|
||||
}
|
||||
|
||||
return card
|
||||
}).
|
||||
Optional(),
|
||||
|
||||
field.String("skill").
|
||||
DefaultFunc(func() string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var a = rand.Intn(12)
|
||||
if a == 1 {
|
||||
skill = "critical"
|
||||
} else {
|
||||
skill = "normal"
|
||||
}
|
||||
if card == 0 {
|
||||
skill = "normal"
|
||||
}
|
||||
return skill
|
||||
}).
|
||||
Optional(),
|
||||
|
||||
field.String("status").
|
||||
Immutable().
|
||||
//Immutable().
|
||||
DefaultFunc(func() string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var a = rand.Intn(10)
|
||||
@@ -54,19 +96,35 @@ func (Card) Fields() []ent.Field {
|
||||
}).
|
||||
Optional(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
|
||||
field.Int("cp").
|
||||
Immutable().
|
||||
//Immutable().
|
||||
DefaultFunc(func() int {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var cp = rand.Intn(100)
|
||||
if cp == 1 {
|
||||
cp = rand.Intn(250)
|
||||
var cp = 1 + rand.Intn(100)
|
||||
if cp == 2 {
|
||||
cp = 50 + rand.Intn(150)
|
||||
}
|
||||
if card > 1 {
|
||||
cp = cp + rand.Intn(250)
|
||||
if card >= 1 {
|
||||
cp = 150 + cp + rand.Intn(300)
|
||||
}
|
||||
if super == "super" {
|
||||
cp = cp + rand.Intn(500)
|
||||
cp = 300 + cp + rand.Intn(500)
|
||||
}
|
||||
|
||||
if skill == "critical" {
|
||||
cp = 300 + cp + rand.Intn(500)
|
||||
}
|
||||
|
||||
if card == 22 {
|
||||
cp = 800 + cp + rand.Intn(1500)
|
||||
}
|
||||
|
||||
if card == 25 {
|
||||
cp = 0
|
||||
}
|
||||
|
||||
return cp
|
||||
@@ -93,5 +151,6 @@ func (Card) Edges() []ent.Edge {
|
||||
Ref("card").
|
||||
Unique().
|
||||
Required(),
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,11 @@ type Group struct {
|
||||
func (Group) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,13 +31,37 @@ func (User) Fields() []ent.Field {
|
||||
field.String("username").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
MaxLen(30).
|
||||
MaxLen(100).
|
||||
//Match(regexp.MustCompile("[a-z]+$")).
|
||||
Unique(),
|
||||
|
||||
//field.Bool("limit").
|
||||
//Optional().
|
||||
//Default(false),
|
||||
field.String("did").
|
||||
Optional(),
|
||||
|
||||
field.Bool("bsky").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("mastodon").
|
||||
Default(true).
|
||||
Optional(),
|
||||
|
||||
field.Bool("delete").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.Bool("handle").
|
||||
Default(false).
|
||||
Optional(),
|
||||
|
||||
field.String("token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
|
||||
field.String("password").
|
||||
NotEmpty().
|
||||
Immutable().
|
||||
Sensitive(),
|
||||
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
@@ -52,6 +76,66 @@ func (User) Fields() []ent.Field {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Time("raid_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Int("luck").
|
||||
Optional(),
|
||||
|
||||
field.Time("luck_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Int("like").
|
||||
Optional(),
|
||||
|
||||
field.Int("like_rank").
|
||||
Optional(),
|
||||
|
||||
field.Time("like_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.Int("fav").
|
||||
Optional(),
|
||||
|
||||
field.Bool("ten").
|
||||
Optional(),
|
||||
|
||||
field.Int("ten_su").
|
||||
Optional(),
|
||||
|
||||
field.Int("ten_kai").
|
||||
Optional(),
|
||||
|
||||
field.Int("aiten").
|
||||
Optional(),
|
||||
|
||||
field.String("ten_card").
|
||||
Optional(),
|
||||
|
||||
field.String("ten_delete").
|
||||
Optional(),
|
||||
|
||||
field.String("ten_post").
|
||||
Optional(),
|
||||
|
||||
field.String("ten_get").
|
||||
Optional(),
|
||||
|
||||
field.Time("ten_at").
|
||||
Optional().
|
||||
Default(func() time.Time {
|
||||
return time.Now().In(jst)
|
||||
}),
|
||||
|
||||
field.String("next").
|
||||
Default(Nextime()).
|
||||
Optional(),
|
||||
|
259
ent/user.go
259
ent/user.go
@@ -18,10 +18,56 @@ type User struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
// Username holds the value of the "username" field.
|
||||
Username string `json:"username,omitempty"`
|
||||
// Did holds the value of the "did" field.
|
||||
Did string `json:"did,omitempty"`
|
||||
// Bsky holds the value of the "bsky" field.
|
||||
Bsky bool `json:"bsky,omitempty"`
|
||||
// Mastodon holds the value of the "mastodon" field.
|
||||
Mastodon bool `json:"mastodon,omitempty"`
|
||||
// Delete holds the value of the "delete" field.
|
||||
Delete bool `json:"delete,omitempty"`
|
||||
// Handle holds the value of the "handle" field.
|
||||
Handle bool `json:"handle,omitempty"`
|
||||
// Token holds the value of the "token" field.
|
||||
Token string `json:"-"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// RaidAt holds the value of the "raid_at" field.
|
||||
RaidAt time.Time `json:"raid_at,omitempty"`
|
||||
// Luck holds the value of the "luck" field.
|
||||
Luck int `json:"luck,omitempty"`
|
||||
// LuckAt holds the value of the "luck_at" field.
|
||||
LuckAt time.Time `json:"luck_at,omitempty"`
|
||||
// Like holds the value of the "like" field.
|
||||
Like int `json:"like,omitempty"`
|
||||
// LikeRank holds the value of the "like_rank" field.
|
||||
LikeRank int `json:"like_rank,omitempty"`
|
||||
// LikeAt holds the value of the "like_at" field.
|
||||
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 bool `json:"ten,omitempty"`
|
||||
// TenSu holds the value of the "ten_su" field.
|
||||
TenSu int `json:"ten_su,omitempty"`
|
||||
// TenKai holds the value of the "ten_kai" field.
|
||||
TenKai int `json:"ten_kai,omitempty"`
|
||||
// Aiten holds the value of the "aiten" field.
|
||||
Aiten int `json:"aiten,omitempty"`
|
||||
// TenCard holds the value of the "ten_card" field.
|
||||
TenCard string `json:"ten_card,omitempty"`
|
||||
// TenDelete holds the value of the "ten_delete" field.
|
||||
TenDelete string `json:"ten_delete,omitempty"`
|
||||
// TenPost holds the value of the "ten_post" field.
|
||||
TenPost string `json:"ten_post,omitempty"`
|
||||
// TenGet holds the value of the "ten_get" field.
|
||||
TenGet string `json:"ten_get,omitempty"`
|
||||
// TenAt holds the value of the "ten_at" field.
|
||||
TenAt time.Time `json:"ten_at,omitempty"`
|
||||
// Next holds the value of the "next" field.
|
||||
Next string `json:"next,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
@@ -53,11 +99,13 @@ func (*User) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case user.FieldID:
|
||||
case user.FieldBsky, user.FieldMastodon, user.FieldDelete, user.FieldHandle, user.FieldTen:
|
||||
values[i] = new(sql.NullBool)
|
||||
case user.FieldID, user.FieldLuck, user.FieldLike, user.FieldLikeRank, user.FieldFav, user.FieldTenSu, user.FieldTenKai, user.FieldAiten:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case user.FieldUsername, 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)
|
||||
case user.FieldCreatedAt, user.FieldUpdatedAt:
|
||||
case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldRaidAt, user.FieldLuckAt, user.FieldLikeAt, user.FieldTenAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case user.ForeignKeys[0]: // group_users
|
||||
values[i] = new(sql.NullInt64)
|
||||
@@ -88,6 +136,48 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.Username = value.String
|
||||
}
|
||||
case user.FieldDid:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field did", values[i])
|
||||
} else if value.Valid {
|
||||
u.Did = value.String
|
||||
}
|
||||
case user.FieldBsky:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field bsky", values[i])
|
||||
} else if value.Valid {
|
||||
u.Bsky = value.Bool
|
||||
}
|
||||
case user.FieldMastodon:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mastodon", values[i])
|
||||
} else if value.Valid {
|
||||
u.Mastodon = value.Bool
|
||||
}
|
||||
case user.FieldDelete:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field delete", values[i])
|
||||
} else if value.Valid {
|
||||
u.Delete = value.Bool
|
||||
}
|
||||
case user.FieldHandle:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field handle", values[i])
|
||||
} else if value.Valid {
|
||||
u.Handle = value.Bool
|
||||
}
|
||||
case user.FieldToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value.Valid {
|
||||
u.Token = value.String
|
||||
}
|
||||
case user.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
u.Password = value.String
|
||||
}
|
||||
case user.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -100,6 +190,102 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
u.UpdatedAt = value.Time
|
||||
}
|
||||
case user.FieldRaidAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field raid_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.RaidAt = value.Time
|
||||
}
|
||||
case user.FieldLuck:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field luck", values[i])
|
||||
} else if value.Valid {
|
||||
u.Luck = int(value.Int64)
|
||||
}
|
||||
case user.FieldLuckAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field luck_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.LuckAt = value.Time
|
||||
}
|
||||
case user.FieldLike:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field like", values[i])
|
||||
} else if value.Valid {
|
||||
u.Like = int(value.Int64)
|
||||
}
|
||||
case user.FieldLikeRank:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field like_rank", values[i])
|
||||
} else if value.Valid {
|
||||
u.LikeRank = int(value.Int64)
|
||||
}
|
||||
case user.FieldLikeAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field like_at", values[i])
|
||||
} else if value.Valid {
|
||||
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:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten", values[i])
|
||||
} else if value.Valid {
|
||||
u.Ten = value.Bool
|
||||
}
|
||||
case user.FieldTenSu:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_su", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenSu = int(value.Int64)
|
||||
}
|
||||
case user.FieldTenKai:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_kai", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenKai = int(value.Int64)
|
||||
}
|
||||
case user.FieldAiten:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field aiten", values[i])
|
||||
} else if value.Valid {
|
||||
u.Aiten = int(value.Int64)
|
||||
}
|
||||
case user.FieldTenCard:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_card", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenCard = value.String
|
||||
}
|
||||
case user.FieldTenDelete:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_delete", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenDelete = value.String
|
||||
}
|
||||
case user.FieldTenPost:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_post", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenPost = value.String
|
||||
}
|
||||
case user.FieldTenGet:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_get", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenGet = value.String
|
||||
}
|
||||
case user.FieldTenAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ten_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.TenAt = value.Time
|
||||
}
|
||||
case user.FieldNext:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field next", values[i])
|
||||
@@ -149,12 +335,79 @@ func (u *User) String() string {
|
||||
builder.WriteString("username=")
|
||||
builder.WriteString(u.Username)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("did=")
|
||||
builder.WriteString(u.Did)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("bsky=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Bsky))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mastodon=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Mastodon))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("delete=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Delete))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("handle=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Handle))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(u.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(u.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("raid_at=")
|
||||
builder.WriteString(u.RaidAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("luck=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Luck))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("luck_at=")
|
||||
builder.WriteString(u.LuckAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("like=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Like))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("like_rank=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.LikeRank))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("like_at=")
|
||||
builder.WriteString(u.LikeAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("fav=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Fav))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Ten))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_su=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.TenSu))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_kai=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.TenKai))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("aiten=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Aiten))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_card=")
|
||||
builder.WriteString(u.TenCard)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_delete=")
|
||||
builder.WriteString(u.TenDelete)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_post=")
|
||||
builder.WriteString(u.TenPost)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_get=")
|
||||
builder.WriteString(u.TenGet)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ten_at=")
|
||||
builder.WriteString(u.TenAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("next=")
|
||||
builder.WriteString(u.Next)
|
||||
builder.WriteByte(')')
|
||||
|
@@ -13,10 +13,56 @@ const (
|
||||
FieldID = "id"
|
||||
// FieldUsername holds the string denoting the username field in the database.
|
||||
FieldUsername = "username"
|
||||
// FieldDid holds the string denoting the did field in the database.
|
||||
FieldDid = "did"
|
||||
// FieldBsky holds the string denoting the bsky field in the database.
|
||||
FieldBsky = "bsky"
|
||||
// FieldMastodon holds the string denoting the mastodon field in the database.
|
||||
FieldMastodon = "mastodon"
|
||||
// FieldDelete holds the string denoting the delete field in the database.
|
||||
FieldDelete = "delete"
|
||||
// FieldHandle holds the string denoting the handle field in the database.
|
||||
FieldHandle = "handle"
|
||||
// FieldToken holds the string denoting the token field in the database.
|
||||
FieldToken = "token"
|
||||
// FieldPassword holds the string denoting the password field in the database.
|
||||
FieldPassword = "password"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldRaidAt holds the string denoting the raid_at field in the database.
|
||||
FieldRaidAt = "raid_at"
|
||||
// FieldLuck holds the string denoting the luck field in the database.
|
||||
FieldLuck = "luck"
|
||||
// FieldLuckAt holds the string denoting the luck_at field in the database.
|
||||
FieldLuckAt = "luck_at"
|
||||
// FieldLike holds the string denoting the like field in the database.
|
||||
FieldLike = "like"
|
||||
// FieldLikeRank holds the string denoting the like_rank field in the database.
|
||||
FieldLikeRank = "like_rank"
|
||||
// FieldLikeAt holds the string denoting the like_at field in the database.
|
||||
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 = "ten"
|
||||
// FieldTenSu holds the string denoting the ten_su field in the database.
|
||||
FieldTenSu = "ten_su"
|
||||
// FieldTenKai holds the string denoting the ten_kai field in the database.
|
||||
FieldTenKai = "ten_kai"
|
||||
// FieldAiten holds the string denoting the aiten field in the database.
|
||||
FieldAiten = "aiten"
|
||||
// FieldTenCard holds the string denoting the ten_card field in the database.
|
||||
FieldTenCard = "ten_card"
|
||||
// FieldTenDelete holds the string denoting the ten_delete field in the database.
|
||||
FieldTenDelete = "ten_delete"
|
||||
// FieldTenPost holds the string denoting the ten_post field in the database.
|
||||
FieldTenPost = "ten_post"
|
||||
// FieldTenGet holds the string denoting the ten_get field in the database.
|
||||
FieldTenGet = "ten_get"
|
||||
// FieldTenAt holds the string denoting the ten_at field in the database.
|
||||
FieldTenAt = "ten_at"
|
||||
// FieldNext holds the string denoting the next field in the database.
|
||||
FieldNext = "next"
|
||||
// EdgeCard holds the string denoting the card edge name in mutations.
|
||||
@@ -36,8 +82,31 @@ const (
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldUsername,
|
||||
FieldDid,
|
||||
FieldBsky,
|
||||
FieldMastodon,
|
||||
FieldDelete,
|
||||
FieldHandle,
|
||||
FieldToken,
|
||||
FieldPassword,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldRaidAt,
|
||||
FieldLuck,
|
||||
FieldLuckAt,
|
||||
FieldLike,
|
||||
FieldLikeRank,
|
||||
FieldLikeAt,
|
||||
FieldFav,
|
||||
FieldTen,
|
||||
FieldTenSu,
|
||||
FieldTenKai,
|
||||
FieldAiten,
|
||||
FieldTenCard,
|
||||
FieldTenDelete,
|
||||
FieldTenPost,
|
||||
FieldTenGet,
|
||||
FieldTenAt,
|
||||
FieldNext,
|
||||
}
|
||||
|
||||
@@ -65,10 +134,28 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
|
||||
UsernameValidator func(string) error
|
||||
// DefaultBsky holds the default value on creation for the "bsky" field.
|
||||
DefaultBsky bool
|
||||
// DefaultMastodon holds the default value on creation for the "mastodon" field.
|
||||
DefaultMastodon bool
|
||||
// DefaultDelete holds the default value on creation for the "delete" field.
|
||||
DefaultDelete bool
|
||||
// DefaultHandle holds the default value on creation for the "handle" field.
|
||||
DefaultHandle bool
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// DefaultRaidAt holds the default value on creation for the "raid_at" field.
|
||||
DefaultRaidAt func() time.Time
|
||||
// DefaultLuckAt holds the default value on creation for the "luck_at" field.
|
||||
DefaultLuckAt func() time.Time
|
||||
// DefaultLikeAt holds the default value on creation for the "like_at" field.
|
||||
DefaultLikeAt func() time.Time
|
||||
// DefaultTenAt holds the default value on creation for the "ten_at" field.
|
||||
DefaultTenAt func() time.Time
|
||||
// DefaultNext holds the default value on creation for the "next" field.
|
||||
DefaultNext string
|
||||
)
|
||||
|
1280
ent/user/where.go
1280
ent/user/where.go
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,96 @@ func (uc *UserCreate) SetUsername(s string) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetDid sets the "did" field.
|
||||
func (uc *UserCreate) SetDid(s string) *UserCreate {
|
||||
uc.mutation.SetDid(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableDid sets the "did" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableDid(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetDid(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetBsky sets the "bsky" field.
|
||||
func (uc *UserCreate) SetBsky(b bool) *UserCreate {
|
||||
uc.mutation.SetBsky(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableBsky sets the "bsky" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableBsky(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetBsky(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetMastodon sets the "mastodon" field.
|
||||
func (uc *UserCreate) SetMastodon(b bool) *UserCreate {
|
||||
uc.mutation.SetMastodon(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableMastodon sets the "mastodon" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableMastodon(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetMastodon(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetDelete sets the "delete" field.
|
||||
func (uc *UserCreate) SetDelete(b bool) *UserCreate {
|
||||
uc.mutation.SetDelete(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableDelete sets the "delete" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableDelete(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetDelete(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetHandle sets the "handle" field.
|
||||
func (uc *UserCreate) SetHandle(b bool) *UserCreate {
|
||||
uc.mutation.SetHandle(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableHandle sets the "handle" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableHandle(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetHandle(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (uc *UserCreate) SetToken(s string) *UserCreate {
|
||||
uc.mutation.SetToken(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableToken sets the "token" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableToken(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetToken(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (uc *UserCreate) SetPassword(s string) *UserCreate {
|
||||
uc.mutation.SetPassword(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetCreatedAt(t)
|
||||
@@ -55,6 +145,230 @@ func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate {
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetRaidAt sets the "raid_at" field.
|
||||
func (uc *UserCreate) SetRaidAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetRaidAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableRaidAt sets the "raid_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableRaidAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetRaidAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLuck sets the "luck" field.
|
||||
func (uc *UserCreate) SetLuck(i int) *UserCreate {
|
||||
uc.mutation.SetLuck(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLuck sets the "luck" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLuck(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLuck(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLuckAt sets the "luck_at" field.
|
||||
func (uc *UserCreate) SetLuckAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetLuckAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLuckAt sets the "luck_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLuckAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetLuckAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLike sets the "like" field.
|
||||
func (uc *UserCreate) SetLike(i int) *UserCreate {
|
||||
uc.mutation.SetLike(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLike sets the "like" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLike(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLike(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLikeRank sets the "like_rank" field.
|
||||
func (uc *UserCreate) SetLikeRank(i int) *UserCreate {
|
||||
uc.mutation.SetLikeRank(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLikeRank sets the "like_rank" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLikeRank(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetLikeRank(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetLikeAt sets the "like_at" field.
|
||||
func (uc *UserCreate) SetLikeAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetLikeAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableLikeAt sets the "like_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableLikeAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetLikeAt(*t)
|
||||
}
|
||||
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.
|
||||
func (uc *UserCreate) SetTen(b bool) *UserCreate {
|
||||
uc.mutation.SetTen(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTen sets the "ten" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTen(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetTen(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenSu sets the "ten_su" field.
|
||||
func (uc *UserCreate) SetTenSu(i int) *UserCreate {
|
||||
uc.mutation.SetTenSu(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenSu sets the "ten_su" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenSu(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetTenSu(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenKai sets the "ten_kai" field.
|
||||
func (uc *UserCreate) SetTenKai(i int) *UserCreate {
|
||||
uc.mutation.SetTenKai(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenKai sets the "ten_kai" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenKai(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetTenKai(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetAiten sets the "aiten" field.
|
||||
func (uc *UserCreate) SetAiten(i int) *UserCreate {
|
||||
uc.mutation.SetAiten(i)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableAiten sets the "aiten" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableAiten(i *int) *UserCreate {
|
||||
if i != nil {
|
||||
uc.SetAiten(*i)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenCard sets the "ten_card" field.
|
||||
func (uc *UserCreate) SetTenCard(s string) *UserCreate {
|
||||
uc.mutation.SetTenCard(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenCard sets the "ten_card" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenCard(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetTenCard(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenDelete sets the "ten_delete" field.
|
||||
func (uc *UserCreate) SetTenDelete(s string) *UserCreate {
|
||||
uc.mutation.SetTenDelete(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenDelete sets the "ten_delete" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenDelete(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetTenDelete(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenPost sets the "ten_post" field.
|
||||
func (uc *UserCreate) SetTenPost(s string) *UserCreate {
|
||||
uc.mutation.SetTenPost(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenPost sets the "ten_post" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenPost(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetTenPost(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenGet sets the "ten_get" field.
|
||||
func (uc *UserCreate) SetTenGet(s string) *UserCreate {
|
||||
uc.mutation.SetTenGet(s)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenGet sets the "ten_get" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenGet(s *string) *UserCreate {
|
||||
if s != nil {
|
||||
uc.SetTenGet(*s)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetTenAt sets the "ten_at" field.
|
||||
func (uc *UserCreate) SetTenAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetTenAt(t)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableTenAt sets the "ten_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableTenAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetTenAt(*t)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNext sets the "next" field.
|
||||
func (uc *UserCreate) SetNext(s string) *UserCreate {
|
||||
uc.mutation.SetNext(s)
|
||||
@@ -119,6 +433,22 @@ func (uc *UserCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UserCreate) defaults() {
|
||||
if _, ok := uc.mutation.Bsky(); !ok {
|
||||
v := user.DefaultBsky
|
||||
uc.mutation.SetBsky(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Mastodon(); !ok {
|
||||
v := user.DefaultMastodon
|
||||
uc.mutation.SetMastodon(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Delete(); !ok {
|
||||
v := user.DefaultDelete
|
||||
uc.mutation.SetDelete(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Handle(); !ok {
|
||||
v := user.DefaultHandle
|
||||
uc.mutation.SetHandle(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
v := user.DefaultCreatedAt()
|
||||
uc.mutation.SetCreatedAt(v)
|
||||
@@ -127,6 +457,22 @@ func (uc *UserCreate) defaults() {
|
||||
v := user.DefaultUpdatedAt()
|
||||
uc.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.RaidAt(); !ok {
|
||||
v := user.DefaultRaidAt()
|
||||
uc.mutation.SetRaidAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LuckAt(); !ok {
|
||||
v := user.DefaultLuckAt()
|
||||
uc.mutation.SetLuckAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.LikeAt(); !ok {
|
||||
v := user.DefaultLikeAt()
|
||||
uc.mutation.SetLikeAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.TenAt(); !ok {
|
||||
v := user.DefaultTenAt()
|
||||
uc.mutation.SetTenAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Next(); !ok {
|
||||
v := user.DefaultNext
|
||||
uc.mutation.SetNext(v)
|
||||
@@ -143,6 +489,14 @@ func (uc *UserCreate) check() error {
|
||||
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Password(); ok {
|
||||
if err := user.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -173,6 +527,34 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||
_node.Username = value
|
||||
}
|
||||
if value, ok := uc.mutation.Did(); ok {
|
||||
_spec.SetField(user.FieldDid, field.TypeString, value)
|
||||
_node.Did = value
|
||||
}
|
||||
if value, ok := uc.mutation.Bsky(); ok {
|
||||
_spec.SetField(user.FieldBsky, field.TypeBool, value)
|
||||
_node.Bsky = value
|
||||
}
|
||||
if value, ok := uc.mutation.Mastodon(); ok {
|
||||
_spec.SetField(user.FieldMastodon, field.TypeBool, value)
|
||||
_node.Mastodon = value
|
||||
}
|
||||
if value, ok := uc.mutation.Delete(); ok {
|
||||
_spec.SetField(user.FieldDelete, field.TypeBool, value)
|
||||
_node.Delete = value
|
||||
}
|
||||
if value, ok := uc.mutation.Handle(); ok {
|
||||
_spec.SetField(user.FieldHandle, field.TypeBool, value)
|
||||
_node.Handle = value
|
||||
}
|
||||
if value, ok := uc.mutation.Token(); ok {
|
||||
_spec.SetField(user.FieldToken, field.TypeString, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := uc.mutation.Password(); ok {
|
||||
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
@@ -181,6 +563,70 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.RaidAt(); ok {
|
||||
_spec.SetField(user.FieldRaidAt, field.TypeTime, value)
|
||||
_node.RaidAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Luck(); ok {
|
||||
_spec.SetField(user.FieldLuck, field.TypeInt, value)
|
||||
_node.Luck = value
|
||||
}
|
||||
if value, ok := uc.mutation.LuckAt(); ok {
|
||||
_spec.SetField(user.FieldLuckAt, field.TypeTime, value)
|
||||
_node.LuckAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Like(); ok {
|
||||
_spec.SetField(user.FieldLike, field.TypeInt, value)
|
||||
_node.Like = value
|
||||
}
|
||||
if value, ok := uc.mutation.LikeRank(); ok {
|
||||
_spec.SetField(user.FieldLikeRank, field.TypeInt, value)
|
||||
_node.LikeRank = value
|
||||
}
|
||||
if value, ok := uc.mutation.LikeAt(); ok {
|
||||
_spec.SetField(user.FieldLikeAt, field.TypeTime, 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 {
|
||||
_spec.SetField(user.FieldTen, field.TypeBool, value)
|
||||
_node.Ten = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenSu(); ok {
|
||||
_spec.SetField(user.FieldTenSu, field.TypeInt, value)
|
||||
_node.TenSu = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenKai(); ok {
|
||||
_spec.SetField(user.FieldTenKai, field.TypeInt, value)
|
||||
_node.TenKai = value
|
||||
}
|
||||
if value, ok := uc.mutation.Aiten(); ok {
|
||||
_spec.SetField(user.FieldAiten, field.TypeInt, value)
|
||||
_node.Aiten = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenCard(); ok {
|
||||
_spec.SetField(user.FieldTenCard, field.TypeString, value)
|
||||
_node.TenCard = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenDelete(); ok {
|
||||
_spec.SetField(user.FieldTenDelete, field.TypeString, value)
|
||||
_node.TenDelete = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenPost(); ok {
|
||||
_spec.SetField(user.FieldTenPost, field.TypeString, value)
|
||||
_node.TenPost = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenGet(); ok {
|
||||
_spec.SetField(user.FieldTenGet, field.TypeString, value)
|
||||
_node.TenGet = value
|
||||
}
|
||||
if value, ok := uc.mutation.TenAt(); ok {
|
||||
_spec.SetField(user.FieldTenAt, field.TypeTime, value)
|
||||
_node.TenAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Next(); ok {
|
||||
_spec.SetField(user.FieldNext, field.TypeString, value)
|
||||
_node.Next = value
|
||||
@@ -193,10 +639,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
Columns: []string{user.CardColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: card.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
1314
ent/user_update.go
1314
ent/user_update.go
File diff suppressed because it is too large
Load Diff
6
go.mod
6
go.mod
@@ -5,7 +5,7 @@ go 1.19
|
||||
//replace ariga.io/ogent => ../../
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.11.9
|
||||
entgo.io/ent v0.11.10
|
||||
github.com/go-faster/errors v0.6.1
|
||||
github.com/go-faster/jx v0.42.0-alpha.1
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
@@ -18,7 +18,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.9.1 // indirect
|
||||
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338 // indirect
|
||||
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c // indirect
|
||||
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e // indirect
|
||||
entgo.io/contrib v0.3.5 // indirect
|
||||
@@ -31,10 +31,12 @@ require (
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/kyokomi/lottery v1.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
|
11
go.sum
11
go.sum
@@ -1,5 +1,7 @@
|
||||
ariga.io/atlas v0.9.1 h1:EpoPMnwsQG0vn9c0sYExpwSYtr7bvuSUXzQclU2pMjc=
|
||||
ariga.io/atlas v0.9.1/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
|
||||
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338 h1:8kmSV3mbQKn0niZ/EdE11uhFvFKiW1VlaqVBIYOyahM=
|
||||
ariga.io/atlas v0.9.2-0.20230303073438-03a4779a6338/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
|
||||
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c h1:7FbOjKKWKqD7FZXQq3qWcRlvGFO1LGYvVZIWQ2D9Evs=
|
||||
ariga.io/entviz v0.0.0-20230125130633-6c9be8e08c7c/go.mod h1:wArXZPqbbWBcOmkqwmIF6hIcW+3T1NLDde0iRhW6an8=
|
||||
ariga.io/ogent v0.0.0-20230309073626-8dc564a6a73e h1:8mxC+4Y7pVKgfoUJIMdChrS95d+TcJ6xuhw49nVYIAY=
|
||||
@@ -8,6 +10,8 @@ entgo.io/contrib v0.3.5 h1:wY85TgRp3j5ix/SZ9IE6Ob5lObHFmVUYH0ZFw1D5Hzc=
|
||||
entgo.io/contrib v0.3.5/go.mod h1:R5HiFszVD8OVOZKFGRbqYogRxK7z1ruzWyEEesjQwE0=
|
||||
entgo.io/ent v0.11.9 h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=
|
||||
entgo.io/ent v0.11.9/go.mod h1:KWHOcDZn1xk3mz3ipWdKrQpMvwqa/9B69TUuAPP9W6g=
|
||||
entgo.io/ent v0.11.10 h1:iqn32ybY5HRW3xSAyMNdNKpZhKgMf1Zunsej9yPKUI8=
|
||||
entgo.io/ent v0.11.10/go.mod h1:mzTZ0trE+jCQw/fnzijbm5Mck/l8Gbg7gC/+L1COyzM=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/Khan/genqlient v0.5.0 h1:TMZJ+tl/BpbmGyIBiXzKzUftDhw4ZWxQZ+1ydn0gyII=
|
||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||
@@ -38,6 +42,7 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
@@ -47,6 +52,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8=
|
||||
github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -61,6 +68,7 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mazen160/go-random v0.0.0-20210308102632-d2b501c85c03 h1:iM7JTVzKOYKWjzhGcgHAgFVQt5QfiHIVrRUaWPfh0Q4=
|
||||
@@ -69,6 +77,7 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
github.com/ogen-go/ogen v0.59.0 h1:9aSSZ1KCLJIcRyjkO7IHrG0vAI6l1BO877LwTbMcX+k=
|
||||
github.com/ogen-go/ogen v0.59.0/go.mod h1:0MHLcWEbxwdvR+R9E05paQSRh/2vHtVSJgKqmwYyW8M=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@@ -76,6 +85,8 @@ github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
|
||||
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
13
main.go
13
main.go
@@ -9,6 +9,7 @@ import (
|
||||
"t/ent/ogent"
|
||||
"entgo.io/ent/dialect"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -50,14 +51,20 @@ func (h handler) DrawDone(ctx context.Context, params ogent.DrawDoneParams) erro
|
||||
|
||||
func main() {
|
||||
// Create ent client.
|
||||
client, err := ent.Open(dialect.SQLite, "file:/data/ent.sqlite?_fk=1")
|
||||
client, err := ent.Open(dialect.SQLite, "file:/data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data/new.sqlite?_fk=1")
|
||||
//client, err := ent.Open(dialect.SQLite, "file:data?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Run the migrations.
|
||||
if err := client.Schema.Create(context.Background()); err != nil {
|
||||
log.Fatal(err)
|
||||
//if err := client.Schema.Create(context.Background()); err != nil {
|
||||
// log.Fatal(err)
|
||||
//}
|
||||
ctx := context.Background()
|
||||
err = client.Schema.Create(ctx, schema.WithAtlas(true))
|
||||
if err != nil {
|
||||
log.Fatalf("failed creating schema resources: %v", err)
|
||||
}
|
||||
// Create the handler.
|
||||
h := handler{
|
||||
|
31
readme.md
31
readme.md
@@ -8,9 +8,10 @@ $ go build
|
||||
$ ./card
|
||||
|
||||
$ go generate ./...
|
||||
$ go run -mod=mod main.go
|
||||
$ curl -X POST -H "Content-Type: application/json" -d '{"username":"syui"}' localhost:8080/users
|
||||
$ curl -X POST -H "Content-Type: application/json" -d '{"owner":1}' localhost:8080/cards
|
||||
$ PASS=`cat ./token.json|jq -r .password` TOKEN=`cat ./token.json|jq -r .token` go run -mod=mod main.go
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"syui\",\"password\":\"$pass\"}" localhost:8080/users
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"owner\":1,\"password\":\"$pass\"}" localhost:8080/cards
|
||||
$ curl -X POST -H "Content-Type: application/json" -d "{\"owner\":1,\"card\":1,\"cp\":11,\"status\":\"normal\",\"password\":\"$pass\"}" localhost:8080/cards
|
||||
$ curl localhost:8080/users
|
||||
$ curl localhost:8080/cards
|
||||
$ curl localhost:8080/users/1
|
||||
@@ -20,7 +21,7 @@ $ curl localhost:8080/users/1/card
|
||||
### use
|
||||
|
||||
```sh
|
||||
$ curl -X POST -H "Content-Type: application/json" -d '{"username":"syui"}' https://api.syui.ai/users
|
||||
$ curl -X POST -H "Content-Type: application/json" -d '{"username":"syui",\"password\":\"$pass\"}' https://api.syui.ai/users
|
||||
|
||||
# onconflict
|
||||
$ !!
|
||||
@@ -28,6 +29,13 @@ $ !!
|
||||
$ curl -sL https://api.syui.ai/users/1
|
||||
```
|
||||
|
||||
```sh
|
||||
# item select
|
||||
$ curl -sL "https://api.syui.ai/users?itemsPerPage=255"
|
||||
$ curl -sL "https://api.syui.ai/cards?itemsPerPage=255"
|
||||
$ curl -sL "https://api.syui.ai/users/1/card?itemsPerPage=255"
|
||||
```
|
||||
|
||||
### ref
|
||||
|
||||
```sh
|
||||
@@ -69,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
|
||||
|
||||
|
||||
### 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")
|
||||
```
|
||||
|
3
run.zsh
Executable file
3
run.zsh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
d=${0:a:h}
|
||||
PASS=`cat token.json|jq -r .password` go run -mod=mod main.go
|
31
tmp/card_account_change.zsh
Executable file
31
tmp/card_account_change.zsh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/zsh
|
||||
echo old_id new_id
|
||||
host=https://api.syui.ai
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo old-id new-id
|
||||
|
||||
id=$1
|
||||
data=`curl -sL "$host/users/$id/card?itemsPerPage=2550"`
|
||||
echo $data
|
||||
id_n=$2
|
||||
echo $id_n
|
||||
read
|
||||
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
card=`echo $data|jq -r ".[$i].card"`
|
||||
s=`echo $data|jq -r ".[$i].status"`
|
||||
cp=`echo $data|jq -r ".[$i].cp"`
|
||||
skill=`echo $data|jq -r ".[$i].skill"`
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id_n,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards
|
||||
done
|
12
tmp/card_account_delete.zsh
Executable file
12
tmp/card_account_delete.zsh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/zsh
|
||||
echo id
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .pass`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":true,\"token\":\"$token\"}" -s $host/users/$id
|
||||
|
27
tmp/card_account_select_delete.zsh
Executable file
27
tmp/card_account_select_delete.zsh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/zsh
|
||||
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
d=${0:a:h}
|
||||
f=$d/t.txt
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f $f ];then
|
||||
echo $f
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
n=`cat $f|wc -l`
|
||||
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
card=`cat $d/t.txt|awk "NR==$i"`
|
||||
echo $card
|
||||
read
|
||||
curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$id\"}" https://api.syui.ai/cards/$card
|
||||
done
|
||||
|
||||
rm $d/t.txt
|
22
tmp/card_add.zsh
Executable file
22
tmp/card_add.zsh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/zsh
|
||||
|
||||
host=https://api.syui.ai
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
exit
|
||||
fi
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo username card cp
|
||||
read
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
card=$2
|
||||
cp=$3
|
||||
s=super
|
||||
skill=normal
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards
|
20
tmp/card_did_change.zsh
Executable file
20
tmp/card_did_change.zsh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/zsh
|
||||
echo id
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
echo $token
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .pass`
|
||||
if [ -z "$1" ];then
|
||||
echo 1 : id
|
||||
exit
|
||||
fi
|
||||
if [ -z "$2" ];then
|
||||
echo 2 : did
|
||||
exit
|
||||
fi
|
||||
|
||||
id=$1
|
||||
did=$2
|
||||
|
||||
id=$1
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"did\":\"$did\",\"token\":\"$token\"}" -s $host/users/$id
|
29
tmp/card_fav_first.zsh
Executable file
29
tmp/card_fav_first.zsh
Executable 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
32
tmp/card_fav_second.zsh
Executable 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
|
40
tmp/card_limit_all.zsh
Executable file
40
tmp/card_limit_all.zsh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
host_users="$host/users?itemsPerPage=2550"
|
||||
updated_at_n=`date --iso-8601=seconds -d '1 days ago'`
|
||||
now_at=`date --iso-8601=seconds`
|
||||
raid_at_n=`date --iso-8601=seconds -d '1 days ago'`
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
nd=`date +"%Y%m%d"`
|
||||
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
|
||||
if [ -n "$1" ];then
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
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
|
||||
else
|
||||
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
|
||||
exit
|
||||
fi
|
||||
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
name=`echo $data|jq ".[$i]"|jq -r .username`
|
||||
id=`echo $data|jq ".[$i]"|jq -r .id`
|
||||
echo "{\"updated_at\":\"$updated_at_n\"} -s $host/users/$id"
|
||||
if [ "ai" = "$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}" -s $host/users/$id
|
||||
else
|
||||
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\", \"ten_at\": \"$updated_at_n\"}" -s $host/users/$id
|
||||
fi
|
||||
done
|
69
tmp/card_sqlite.zsh
Executable file
69
tmp/card_sqlite.zsh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/zsh
|
||||
|
||||
host=https://api.syui.ai
|
||||
api=localhost:8080
|
||||
|
||||
host_users="$host/users?itemsPerPage=2550"
|
||||
d=${0:a:h}
|
||||
dd=${0:a:h:h}
|
||||
pass=`cat $dd/token.json|jq -r .password`
|
||||
host_at=bsky.social
|
||||
|
||||
if [ -f $d/user.json ] && [ "$1" = "-s" ];then
|
||||
rm $d/user.json
|
||||
fi
|
||||
function did() {
|
||||
unset did
|
||||
url="https://$host_at/xrpc/com.atproto.repo.listRecords?repo=${name}.${host_at}&collection=app.bsky.actor.profile"
|
||||
if [ "`curl -sL $url| jq -r .error`" = "null" ];then
|
||||
t=`curl -sL $url | jq -r ".records|.[]|.uri"|cut -d / -f 3`
|
||||
did=$t
|
||||
else
|
||||
#did=`curl -sL "search.bsky.social/search/posts?q=$name" | jq -r ".[0].user.did"`
|
||||
did="null"
|
||||
fi
|
||||
echo "{\"name\":\"$name\",\"did\":\"$did\"}," >> $d/user.json
|
||||
}
|
||||
|
||||
function l_users() {
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"$name\",\"password\":\"$pass\",\"did\":\"$did\"}" $api/users
|
||||
#sleep 1
|
||||
}
|
||||
|
||||
function l_cards() {
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" $api/cards
|
||||
#sleep 1
|
||||
}
|
||||
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
|
||||
name=`echo $data|jq ".[$i]"|jq -r .username`
|
||||
id=`echo $data|jq ".[$i]"|jq -r .id`
|
||||
did=`echo $data|jq ".[$i]"|jq -r .did`
|
||||
|
||||
echo "{\"username\":\"$name\", \"password\":\"$pass\",\"did\":\"$did\"} localhost:8080/users"
|
||||
if [ "$1" = "-a" ];then
|
||||
l_users
|
||||
fi
|
||||
|
||||
data_card=`curl -sL "$host/users/$id/card?itemsPerPage=2550"`
|
||||
nn=`echo $data_card|jq length`
|
||||
nn=$((nn - 1))
|
||||
|
||||
if [ "$1" != "-s" ];then
|
||||
for ((ii=0;ii<=$nn;ii++))
|
||||
do
|
||||
card=`echo $data_card|jq -r ".[$ii].card"`
|
||||
s=`echo $data_card|jq -r ".[$ii].status"`
|
||||
cp=`echo $data_card|jq -r ".[$ii].cp"`
|
||||
echo "{\"owner\":$id,\"card\":\"$card\",\"status\":\"$s\",\"cp\":\"$cp\", \"password\":\"$pass\"} localhost:8080/cards"
|
||||
if [ "$1" = "-a" ];then
|
||||
l_cards
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
79
tmp/card_test.zsh
Executable file
79
tmp/card_test.zsh
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
username=ai
|
||||
id=2
|
||||
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
host_users="$host/users?itemsPerPage=255"
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
nd=`date +"%Y%m%d"`
|
||||
nd=20230101
|
||||
|
||||
#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
|
||||
#
|
||||
## card pass
|
||||
echo "\ntest get card (no password)"
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" $host/cards
|
||||
echo "\ntest select card (no password)"
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":0,\"status\":\"normal\",\"cp\":1}" $host/cards
|
||||
|
||||
## token
|
||||
echo "\ntest token (no token)"
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"1\"}" -s $host/users/$id
|
||||
echo "\ntest token (yes token)"
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id
|
||||
|
||||
read
|
||||
|
||||
## users
|
||||
curl -sL "$host/users?itemsPerPage=2550"|jq .
|
||||
read
|
||||
curl -sL "$host/users/$id?itemsPerPage=2550"|jq .
|
||||
read
|
||||
curl -sL "$host/users/$id/card?itemsPerPage=2550"|jq .
|
||||
read
|
||||
|
||||
## cards
|
||||
curl -sL "$host/cards?itemsPerPage=2550"|jq .
|
||||
read
|
||||
|
||||
|
||||
|
||||
read
|
||||
## delete
|
||||
echo "\ntest delete"
|
||||
data=`curl -sL https://api.syui.ai/users/$id/card`
|
||||
n=`echo $data|jq length`
|
||||
n=$((n - 1))
|
||||
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
card=`echo $data|jq -r ".[$i].id"`
|
||||
echo "\ncard id : $card"
|
||||
curl -X DELETE -H "Content-Type: application/json" -d "{'owner':\"$id\"}" $host/cards/$card
|
||||
done
|
||||
curl -X DELETE -H "Content-Type: application/json" https://api.syui.ai/users/$id
|
||||
|
||||
## card select
|
||||
echo "\ntest select card (no password)"
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":0,\"status\":\"normal\",\"cp\":1}" $host/cards
|
||||
echo "\ntest get card (no password)"
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" $host/cards
|
||||
#echo "\ntest get card (yes password)"
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"password\":\"$pass\"}" $host/cards
|
||||
|
||||
## create user
|
||||
echo "\ntest create user (no password)"
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\"}" $host/users
|
1184
tmp/ogent/oas_response_encoders_gen.go
Normal file
1184
tmp/ogent/oas_response_encoders_gen.go
Normal file
File diff suppressed because it is too large
Load Diff
837
tmp/ogent/ogent.go
Normal file
837
tmp/ogent/ogent.go
Normal file
@@ -0,0 +1,837 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ogent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"t/ent"
|
||||
"t/ent/card"
|
||||
"t/ent/group"
|
||||
"t/ent/user"
|
||||
|
||||
"github.com/go-faster/jx"
|
||||
"os"
|
||||
)
|
||||
|
||||
// origin-config
|
||||
var password = os.Getenv("PASS")
|
||||
var token = os.Getenv("TOKEN")
|
||||
|
||||
// OgentHandler implements the ogen generated Handler interface and uses Ent as data layer.
|
||||
type OgentHandler struct {
|
||||
client *ent.Client
|
||||
}
|
||||
|
||||
// NewOgentHandler returns a new OgentHandler.
|
||||
func NewOgentHandler(c *ent.Client) *OgentHandler { return &OgentHandler{c} }
|
||||
|
||||
// rawError renders err as json string.
|
||||
func rawError(err error) jx.Raw {
|
||||
var e jx.Encoder
|
||||
e.Str(err.Error())
|
||||
return e.Bytes()
|
||||
}
|
||||
|
||||
// CreateCard handles POST /cards requests.
|
||||
func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (CreateCardRes, error) {
|
||||
b := h.client.Card.Create()
|
||||
// Add all fields.
|
||||
b.SetPassword(req.Password)
|
||||
if v, ok := req.Card.Get(); ok {
|
||||
b.SetCard(v)
|
||||
}
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// origin-config
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Card.Query().Where(card.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewCardCreate(e), nil
|
||||
}
|
||||
|
||||
// ReadCard handles GET /cards/{id} requests.
|
||||
func (h *OgentHandler) ReadCard(ctx context.Context, params ReadCardParams) (ReadCardRes, error) {
|
||||
q := h.client.Card.Query().Where(card.IDEQ(params.ID))
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewCardRead(e), nil
|
||||
}
|
||||
|
||||
// UpdateCard handles PATCH /cards/{id} requests.
|
||||
func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, params UpdateCardParams) (UpdateCardRes, error) {
|
||||
b := h.client.Card.UpdateOneID(params.ID)
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
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 {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Card.Query().Where(card.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewCardUpdate(e), nil
|
||||
}
|
||||
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return new(DeleteCardNoContent), nil
|
||||
|
||||
}
|
||||
|
||||
// ListCard handles GET /cards requests.
|
||||
func (h *OgentHandler) ListCard(ctx context.Context, params ListCardParams) (ListCardRes, error) {
|
||||
q := h.client.Card.Query()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewCardLists(es)
|
||||
return (*ListCardOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ReadCardOwner handles GET /cards/{id}/owner requests.
|
||||
func (h *OgentHandler) ReadCardOwner(ctx context.Context, params ReadCardOwnerParams) (ReadCardOwnerRes, error) {
|
||||
q := h.client.Card.Query().Where(card.IDEQ(params.ID)).QueryOwner()
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewCardOwnerRead(e), nil
|
||||
}
|
||||
|
||||
// CreateGroup handles POST /groups requests.
|
||||
func (h *OgentHandler) CreateGroup(ctx context.Context, req *CreateGroupReq) (CreateGroupRes, error) {
|
||||
b := h.client.Group.Create()
|
||||
// Add all fields.
|
||||
b.SetName("")
|
||||
b.SetPassword(req.Password)
|
||||
// Add all edges.
|
||||
b.AddUserIDs(req.Users...)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Group.Query().Where(group.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewGroupCreate(e), nil
|
||||
}
|
||||
|
||||
// ReadGroup handles GET /groups/{id} requests.
|
||||
func (h *OgentHandler) ReadGroup(ctx context.Context, params ReadGroupParams) (ReadGroupRes, error) {
|
||||
q := h.client.Group.Query().Where(group.IDEQ(params.ID))
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewGroupRead(e), nil
|
||||
}
|
||||
|
||||
// UpdateGroup handles PATCH /groups/{id} requests.
|
||||
func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, params UpdateGroupParams) (UpdateGroupRes, error) {
|
||||
b := h.client.Group.UpdateOneID(0)
|
||||
// Add all fields.
|
||||
if v, ok := req.Name.Get(); ok {
|
||||
b.SetName(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if req.Users != nil {
|
||||
b.ClearUsers().AddUserIDs(req.Users...)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.Group.Query().Where(group.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewGroupUpdate(e), nil
|
||||
}
|
||||
|
||||
// DeleteGroup handles DELETE /groups/{id} requests.
|
||||
func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
|
||||
err := h.client.Group.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return new(DeleteGroupNoContent), nil
|
||||
|
||||
}
|
||||
|
||||
// ListGroup handles GET /groups requests.
|
||||
func (h *OgentHandler) ListGroup(ctx context.Context, params ListGroupParams) (ListGroupRes, error) {
|
||||
q := h.client.Group.Query()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewGroupLists(es)
|
||||
return (*ListGroupOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ListGroupUsers handles GET /groups/{id}/users requests.
|
||||
func (h *OgentHandler) ListGroupUsers(ctx context.Context, params ListGroupUsersParams) (ListGroupUsersRes, error) {
|
||||
q := h.client.Group.Query().Where(group.IDEQ(params.ID)).QueryUsers()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewGroupUsersLists(es)
|
||||
return (*ListGroupUsersOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// CreateUser handles POST /users requests.
|
||||
func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) {
|
||||
b := h.client.User.Create()
|
||||
|
||||
// Add all fields.
|
||||
//b.SetUsername(req.Username)
|
||||
//origin-config
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
if v, ok := req.Handle.Get(); ok {
|
||||
b.SetHandle(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.LuckAt.Get(); ok {
|
||||
b.SetLuckAt(v)
|
||||
}
|
||||
if v, ok := req.Like.Get(); ok {
|
||||
b.SetLike(v)
|
||||
}
|
||||
if v, ok := req.LikeRank.Get(); ok {
|
||||
b.SetLikeRank(v)
|
||||
}
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
if v, ok := req.TenSu.Get(); ok {
|
||||
b.SetTenSu(v)
|
||||
}
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
if v, ok := req.TenDelete.Get(); ok {
|
||||
b.SetTenDelete(v)
|
||||
}
|
||||
if v, ok := req.TenPost.Get(); ok {
|
||||
b.SetTenPost(v)
|
||||
}
|
||||
if v, ok := req.TenGet.Get(); ok {
|
||||
b.SetTenGet(v)
|
||||
}
|
||||
if v, ok := req.TenAt.Get(); ok {
|
||||
b.SetTenAt(v)
|
||||
}
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
// Add all edges.
|
||||
b.AddCardIDs(req.Card...)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.User.Query().Where(user.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewUserCreate(e), nil
|
||||
}
|
||||
|
||||
// ReadUser handles GET /users/{id} requests.
|
||||
func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (ReadUserRes, error) {
|
||||
q := h.client.User.Query().Where(user.IDEQ(params.ID))
|
||||
e, err := q.Only(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return NewUserRead(e), nil
|
||||
}
|
||||
|
||||
// UpdateUser handles PATCH /users/{id} requests.
|
||||
func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
|
||||
b := h.client.User.UpdateOneID(params.ID)
|
||||
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
if v, ok := req.Bsky.Get(); ok {
|
||||
b.SetBsky(v)
|
||||
}
|
||||
if v, ok := req.Mastodon.Get(); ok {
|
||||
b.SetMastodon(v)
|
||||
}
|
||||
if v, ok := req.Delete.Get(); ok {
|
||||
b.SetDelete(v)
|
||||
}
|
||||
if v, ok := req.Handle.Get(); ok {
|
||||
b.SetHandle(v)
|
||||
}
|
||||
if v, ok := req.UpdatedAt.Get(); ok {
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
if v, ok := req.RaidAt.Get(); ok {
|
||||
b.SetRaidAt(v)
|
||||
}
|
||||
if v, ok := req.Aiten.Get(); ok {
|
||||
b.SetAiten(v)
|
||||
}
|
||||
if v, ok := req.Luck.Get(); ok {
|
||||
b.SetLuck(v)
|
||||
}
|
||||
if v, ok := req.LuckAt.Get(); ok {
|
||||
b.SetLuckAt(v)
|
||||
}
|
||||
if v, ok := req.Like.Get(); ok {
|
||||
b.SetLike(v)
|
||||
}
|
||||
if v, ok := req.LikeRank.Get(); ok {
|
||||
b.SetLikeRank(v)
|
||||
}
|
||||
if v, ok := req.LikeAt.Get(); ok {
|
||||
b.SetLikeAt(v)
|
||||
}
|
||||
if v, ok := req.Ten.Get(); ok {
|
||||
b.SetTen(v)
|
||||
}
|
||||
if v, ok := req.TenSu.Get(); ok {
|
||||
b.SetTenSu(v)
|
||||
}
|
||||
if v, ok := req.TenKai.Get(); ok {
|
||||
b.SetTenKai(v)
|
||||
}
|
||||
if v, ok := req.TenCard.Get(); ok {
|
||||
b.SetTenCard(v)
|
||||
}
|
||||
if v, ok := req.TenDelete.Get(); ok {
|
||||
b.SetTenDelete(v)
|
||||
}
|
||||
if v, ok := req.TenPost.Get(); ok {
|
||||
b.SetTenPost(v)
|
||||
}
|
||||
if v, ok := req.TenGet.Get(); ok {
|
||||
b.SetTenGet(v)
|
||||
}
|
||||
if v, ok := req.TenAt.Get(); ok {
|
||||
b.SetTenAt(v)
|
||||
}
|
||||
if v, ok := req.Next.Get(); ok {
|
||||
b.SetNext(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if req.Card != nil {
|
||||
b.ClearCard().AddCardIDs(req.Card...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Reload the entity to attach all eager-loaded edges.
|
||||
q := h.client.User.Query().Where(user.ID(e.ID))
|
||||
e, err = q.Only(ctx)
|
||||
if err != nil {
|
||||
// This should never happen.
|
||||
return nil, err
|
||||
}
|
||||
return NewUserUpdate(e), nil
|
||||
}
|
||||
|
||||
// DeleteUser handles DELETE /users/{id} requests.
|
||||
func (h *OgentHandler) DeleteUser(ctx context.Context, params DeleteUserParams) (DeleteUserRes, error) {
|
||||
err := h.client.User.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsConstraintError(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return new(DeleteUserNoContent), nil
|
||||
|
||||
}
|
||||
|
||||
// ListUser handles GET /users requests.
|
||||
func (h *OgentHandler) ListUser(ctx context.Context, params ListUserParams) (ListUserRes, error) {
|
||||
q := h.client.User.Query()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewUserLists(es)
|
||||
return (*ListUserOKApplicationJSON)(&r), nil
|
||||
}
|
||||
|
||||
// ListUserCard handles GET /users/{id}/card requests.
|
||||
func (h *OgentHandler) ListUserCard(ctx context.Context, params ListUserCardParams) (ListUserCardRes, error) {
|
||||
q := h.client.User.Query().Where(user.IDEQ(params.ID)).QueryCard()
|
||||
page := 1
|
||||
if v, ok := params.Page.Get(); ok {
|
||||
page = v
|
||||
}
|
||||
itemsPerPage := 30
|
||||
if v, ok := params.ItemsPerPage.Get(); ok {
|
||||
itemsPerPage = v
|
||||
}
|
||||
q.Limit(itemsPerPage).Offset((page - 1) * itemsPerPage)
|
||||
es, err := q.All(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
return &R404{
|
||||
Code: http.StatusNotFound,
|
||||
Status: http.StatusText(http.StatusNotFound),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
case ent.IsNotSingular(err):
|
||||
return &R409{
|
||||
Code: http.StatusConflict,
|
||||
Status: http.StatusText(http.StatusConflict),
|
||||
Errors: rawError(err),
|
||||
}, nil
|
||||
default:
|
||||
// Let the server handle the error.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
r := NewUserCardLists(es)
|
||||
return (*ListUserCardOKApplicationJSON)(&r), nil
|
||||
}
|
24
tmp/t.zsh
Normal file
24
tmp/t.zsh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/zsh
|
||||
host=https://api.syui.ai
|
||||
uid=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
did=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .did`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
card=36
|
||||
cp=`echo $(($RANDOM % 1000 + 400))`
|
||||
s=$(($RANDOM % 7))
|
||||
if [ $s -eq 1 ];then
|
||||
s=super
|
||||
skill=post
|
||||
plus=$(($RANDOM % 1000 + 300))
|
||||
cp=$((cp + plus))
|
||||
else
|
||||
s=normal
|
||||
skill=ten
|
||||
fi
|
||||
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$uid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards`
|
||||
|
||||
card=`echo $tmp|jq -r .card`
|
||||
cp=`echo $tmp|jq -r .cp`
|
||||
body="[card]\nid : $card\ncp : $cp"
|
||||
|
||||
atr @ $did -p "`echo $body`"
|
75
tmp/test.zsh
Executable file
75
tmp/test.zsh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
u=ai
|
||||
s=normal
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
host_users="$host/users?itemsPerPage=2550"
|
||||
updated_at_n=`date --iso-8601=seconds -d '1 days ago'`
|
||||
now_at=`date --iso-8601=seconds`
|
||||
raid_at_n=`date --iso-8601=seconds -d '1 days ago'`
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
nd=`date +"%Y%m%d"`
|
||||
card=0
|
||||
cp=0
|
||||
body="next[y]"
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$u\")"|jq -r .id`
|
||||
echo $id
|
||||
|
||||
#echo no token
|
||||
#curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 1, \"luck_at\": \"$now_at\", \"ten_at\": \"$updated_at_n\"}" -s $host/users/$id
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo yes token
|
||||
#echo $token
|
||||
#curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 1, \"luck_at\": \"$now_at\", \"ten_at\": \"$updated_at_n\",\"token\": \"$token\"}" -s $host/users/$id
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo account delete id no token
|
||||
#curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":true}" -s $host/users/381
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo account delete id token
|
||||
#curl -X PATCH -H "Content-Type: application/json" -d "{\"delete\":false,\"token\":\"$token\"}" -s $host/users/381
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo add card no pass
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp}" -sL $host/cards
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo add card no pass
|
||||
#echo $id
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" -sL $host/cards
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo add user
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\",\"did\":\"t\"}" -s "$host/users"
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo add user pass
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\",\"did\":\"t\",\"password\":\"$pass\"}" -s "$host/users"
|
||||
#echo $body
|
||||
#read
|
||||
|
||||
#echo card draw no pass
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" -s $host/cards
|
||||
#echo $body
|
||||
#read
|
||||
#
|
||||
#echo card draw ok pass
|
||||
#curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"password\":\"$pass\"}" -s $host/cards
|
||||
#echo $body
|
||||
#read
|
21
tmp/user_did.zsh
Executable file
21
tmp/user_did.zsh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/zsh
|
||||
|
||||
username=$1
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
host=https://api.syui.ai
|
||||
token=`cat ~/.config/atr/api_card.json|jq -r .token`
|
||||
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
|
||||
host_users="$host/users?itemsPerPage=255"
|
||||
data=`curl -sL "$host_users"|jq .`
|
||||
nd=`date +"%Y%m%d"`
|
||||
nd=20230101
|
||||
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
|
||||
|
||||
echo username did
|
||||
read
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"did\":\"$2\",\"token\":\"$token\"}" -s $host/users/$id
|
Reference in New Issue
Block a user