1
0

add skill

This commit is contained in:
syui 2023-05-03 19:16:36 +09:00
parent 2883ab052c
commit 33944caab7
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
15 changed files with 540 additions and 44 deletions

View File

@ -21,6 +21,8 @@ type Card struct {
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"`
// Cp holds the value of the "cp" field.
@ -64,7 +66,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.FieldPassword, card.FieldStatus, card.FieldURL:
case card.FieldPassword, card.FieldSkill, card.FieldStatus, card.FieldURL:
values[i] = new(sql.NullString)
case card.FieldCreatedAt:
values[i] = new(sql.NullTime)
@ -103,6 +105,12 @@ func (c *Card) assignValues(columns []string, values []any) error {
} 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])
@ -172,6 +180,9 @@ func (c *Card) String() string {
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(", ")

View File

@ -15,6 +15,8 @@ const (
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"
// FieldCp holds the string denoting the cp field in the database.
@ -41,6 +43,7 @@ var Columns = []string{
FieldID,
FieldPassword,
FieldCard,
FieldSkill,
FieldStatus,
FieldCp,
FieldURL,
@ -73,6 +76,8 @@ var (
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.

View File

@ -65,6 +65,11 @@ 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))
@ -200,6 +205,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))

View File

@ -41,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)
@ -147,6 +161,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)
@ -212,6 +230,10 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
_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

View File

@ -28,6 +28,26 @@ 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
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
cu.mutation.SetOwnerID(id)
@ -100,6 +120,12 @@ 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 cu.mutation.StatusCleared() {
_spec.ClearField(card.FieldStatus, field.TypeString)
}
@ -161,6 +187,26 @@ 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
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
cuo.mutation.SetOwnerID(id)
@ -263,6 +309,12 @@ 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 cuo.mutation.StatusCleared() {
_spec.ClearField(card.FieldStatus, field.TypeString)
}

View File

@ -13,6 +13,7 @@ var (
{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: "cp", Type: field.TypeInt, Nullable: true},
{Name: "url", Type: field.TypeString, Nullable: true, Default: "https://card.syui.ai"},
@ -27,7 +28,7 @@ var (
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "cards_users_card",
Columns: []*schema.Column{CardsColumns[7]},
Columns: []*schema.Column{CardsColumns[8]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.NoAction,
},
@ -62,7 +63,7 @@ var (
{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: "20230503"},
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230504"},
{Name: "group_users", Type: field.TypeInt, Nullable: true},
}
// UsersTable holds the schema information for the "users" table.

View File

@ -40,6 +40,7 @@ type CardMutation struct {
password *string
card *int
addcard *int
skill *string
status *string
cp *int
addcp *int
@ -257,6 +258,55 @@ func (m *CardMutation) ResetCard() {
delete(m.clearedFields, card.FieldCard)
}
// SetSkill sets the "skill" field.
func (m *CardMutation) SetSkill(s string) {
m.skill = &s
}
// Skill returns the value of the "skill" field in the mutation.
func (m *CardMutation) Skill() (r string, exists bool) {
v := m.skill
if v == nil {
return
}
return *v, true
}
// OldSkill returns the old "skill" field's value of the Card entity.
// If the Card object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CardMutation) OldSkill(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSkill is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSkill requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSkill: %w", err)
}
return oldValue.Skill, nil
}
// ClearSkill clears the value of the "skill" field.
func (m *CardMutation) ClearSkill() {
m.skill = nil
m.clearedFields[card.FieldSkill] = struct{}{}
}
// SkillCleared returns if the "skill" field was cleared in this mutation.
func (m *CardMutation) SkillCleared() bool {
_, ok := m.clearedFields[card.FieldSkill]
return ok
}
// ResetSkill resets all changes to the "skill" field.
func (m *CardMutation) ResetSkill() {
m.skill = nil
delete(m.clearedFields, card.FieldSkill)
}
// SetStatus sets the "status" field.
func (m *CardMutation) SetStatus(s string) {
m.status = &s
@ -547,13 +597,16 @@ func (m *CardMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *CardMutation) Fields() []string {
fields := make([]string, 0, 6)
fields := make([]string, 0, 7)
if m.password != nil {
fields = append(fields, card.FieldPassword)
}
if m.card != nil {
fields = append(fields, card.FieldCard)
}
if m.skill != nil {
fields = append(fields, card.FieldSkill)
}
if m.status != nil {
fields = append(fields, card.FieldStatus)
}
@ -578,6 +631,8 @@ func (m *CardMutation) Field(name string) (ent.Value, bool) {
return m.Password()
case card.FieldCard:
return m.Card()
case card.FieldSkill:
return m.Skill()
case card.FieldStatus:
return m.Status()
case card.FieldCp:
@ -599,6 +654,8 @@ func (m *CardMutation) OldField(ctx context.Context, name string) (ent.Value, er
return m.OldPassword(ctx)
case card.FieldCard:
return m.OldCard(ctx)
case card.FieldSkill:
return m.OldSkill(ctx)
case card.FieldStatus:
return m.OldStatus(ctx)
case card.FieldCp:
@ -630,6 +687,13 @@ func (m *CardMutation) SetField(name string, value ent.Value) error {
}
m.SetCard(v)
return nil
case card.FieldSkill:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSkill(v)
return nil
case card.FieldStatus:
v, ok := value.(string)
if !ok {
@ -718,6 +782,9 @@ func (m *CardMutation) ClearedFields() []string {
if m.FieldCleared(card.FieldCard) {
fields = append(fields, card.FieldCard)
}
if m.FieldCleared(card.FieldSkill) {
fields = append(fields, card.FieldSkill)
}
if m.FieldCleared(card.FieldStatus) {
fields = append(fields, card.FieldStatus)
}
@ -747,6 +814,9 @@ func (m *CardMutation) ClearField(name string) error {
case card.FieldCard:
m.ClearCard()
return nil
case card.FieldSkill:
m.ClearSkill()
return nil
case card.FieldStatus:
m.ClearStatus()
return nil
@ -773,6 +843,9 @@ func (m *CardMutation) ResetField(name string) error {
case card.FieldCard:
m.ResetCard()
return nil
case card.FieldSkill:
m.ResetSkill()
return nil
case card.FieldStatus:
m.ResetStatus()
return nil

View File

@ -34,6 +34,12 @@ func (s *CardCreate) encodeFields(e *jx.Encoder) {
s.Card.Encode(e)
}
}
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Status.Set {
e.FieldStart("status")
@ -60,13 +66,14 @@ func (s *CardCreate) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfCardCreate = [6]string{
var jsonFieldsNameOfCardCreate = [7]string{
0: "id",
1: "card",
2: "status",
3: "cp",
4: "url",
5: "created_at",
2: "skill",
3: "status",
4: "cp",
5: "url",
6: "created_at",
}
// Decode decodes CardCreate from json.
@ -100,6 +107,16 @@ func (s *CardCreate) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"card\"")
}
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "status":
if err := func() error {
s.Status.Reset()
@ -216,6 +233,12 @@ func (s *CardList) encodeFields(e *jx.Encoder) {
s.Card.Encode(e)
}
}
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Status.Set {
e.FieldStart("status")
@ -242,13 +265,14 @@ func (s *CardList) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfCardList = [6]string{
var jsonFieldsNameOfCardList = [7]string{
0: "id",
1: "card",
2: "status",
3: "cp",
4: "url",
5: "created_at",
2: "skill",
3: "status",
4: "cp",
5: "url",
6: "created_at",
}
// Decode decodes CardList from json.
@ -282,6 +306,16 @@ func (s *CardList) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"card\"")
}
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "status":
if err := func() error {
s.Status.Reset()
@ -598,6 +632,12 @@ func (s *CardRead) encodeFields(e *jx.Encoder) {
s.Card.Encode(e)
}
}
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Status.Set {
e.FieldStart("status")
@ -624,13 +664,14 @@ func (s *CardRead) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfCardRead = [6]string{
var jsonFieldsNameOfCardRead = [7]string{
0: "id",
1: "card",
2: "status",
3: "cp",
4: "url",
5: "created_at",
2: "skill",
3: "status",
4: "cp",
5: "url",
6: "created_at",
}
// Decode decodes CardRead from json.
@ -664,6 +705,16 @@ func (s *CardRead) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"card\"")
}
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "status":
if err := func() error {
s.Status.Reset()
@ -780,6 +831,12 @@ func (s *CardUpdate) encodeFields(e *jx.Encoder) {
s.Card.Encode(e)
}
}
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Status.Set {
e.FieldStart("status")
@ -806,13 +863,14 @@ func (s *CardUpdate) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfCardUpdate = [6]string{
var jsonFieldsNameOfCardUpdate = [7]string{
0: "id",
1: "card",
2: "status",
3: "cp",
4: "url",
5: "created_at",
2: "skill",
3: "status",
4: "cp",
5: "url",
6: "created_at",
}
// Decode decodes CardUpdate from json.
@ -846,6 +904,16 @@ func (s *CardUpdate) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"card\"")
}
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "status":
if err := func() error {
s.Status.Reset()
@ -962,6 +1030,12 @@ func (s *CreateCardReq) encodeFields(e *jx.Encoder) {
s.Card.Encode(e)
}
}
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Status.Set {
e.FieldStart("status")
@ -993,14 +1067,15 @@ func (s *CreateCardReq) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfCreateCardReq = [7]string{
var jsonFieldsNameOfCreateCardReq = [8]string{
0: "password",
1: "card",
2: "status",
3: "cp",
4: "url",
5: "created_at",
6: "owner",
2: "skill",
3: "status",
4: "cp",
5: "url",
6: "created_at",
7: "owner",
}
// Decode decodes CreateCardReq from json.
@ -1034,6 +1109,16 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"card\"")
}
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "status":
if err := func() error {
s.Status.Reset()
@ -1075,7 +1160,7 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"created_at\"")
}
case "owner":
requiredBitSet[0] |= 1 << 6
requiredBitSet[0] |= 1 << 7
if err := func() error {
v, err := d.Int()
s.Owner = int(v)
@ -1096,7 +1181,7 @@ func (s *CreateCardReq) Decode(d *jx.Decoder) error {
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b01000001,
0b10000001,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
@ -3130,6 +3215,12 @@ func (s *UpdateCardReq) Encode(e *jx.Encoder) {
// encodeFields encodes fields.
func (s *UpdateCardReq) encodeFields(e *jx.Encoder) {
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Owner.Set {
e.FieldStart("owner")
@ -3138,8 +3229,9 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfUpdateCardReq = [1]string{
0: "owner",
var jsonFieldsNameOfUpdateCardReq = [2]string{
0: "skill",
1: "owner",
}
// Decode decodes UpdateCardReq from json.
@ -3150,6 +3242,16 @@ func (s *UpdateCardReq) Decode(d *jx.Decoder) error {
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "owner":
if err := func() error {
s.Owner.Reset()
@ -3458,6 +3560,12 @@ func (s *UserCardList) encodeFields(e *jx.Encoder) {
s.Card.Encode(e)
}
}
{
if s.Skill.Set {
e.FieldStart("skill")
s.Skill.Encode(e)
}
}
{
if s.Status.Set {
e.FieldStart("status")
@ -3484,13 +3592,14 @@ func (s *UserCardList) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfUserCardList = [6]string{
var jsonFieldsNameOfUserCardList = [7]string{
0: "id",
1: "card",
2: "status",
3: "cp",
4: "url",
5: "created_at",
2: "skill",
3: "status",
4: "cp",
5: "url",
6: "created_at",
}
// Decode decodes UserCardList from json.
@ -3524,6 +3633,16 @@ func (s *UserCardList) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"card\"")
}
case "skill":
if err := func() error {
s.Skill.Reset()
if err := s.Skill.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"skill\"")
}
case "status":
if err := func() error {
s.Status.Reset()

View File

@ -12,6 +12,7 @@ import (
type CardCreate struct {
ID int `json:"id"`
Card OptInt `json:"card"`
Skill OptString `json:"skill"`
Status OptString `json:"status"`
Cp OptInt `json:"cp"`
URL OptString `json:"url"`
@ -28,6 +29,11 @@ func (s *CardCreate) GetCard() OptInt {
return s.Card
}
// GetSkill returns the value of Skill.
func (s *CardCreate) GetSkill() OptString {
return s.Skill
}
// GetStatus returns the value of Status.
func (s *CardCreate) GetStatus() OptString {
return s.Status
@ -58,6 +64,11 @@ func (s *CardCreate) SetCard(val OptInt) {
s.Card = val
}
// SetSkill sets the value of Skill.
func (s *CardCreate) SetSkill(val OptString) {
s.Skill = val
}
// SetStatus sets the value of Status.
func (s *CardCreate) SetStatus(val OptString) {
s.Status = val
@ -84,6 +95,7 @@ func (*CardCreate) createCardRes() {}
type CardList struct {
ID int `json:"id"`
Card OptInt `json:"card"`
Skill OptString `json:"skill"`
Status OptString `json:"status"`
Cp OptInt `json:"cp"`
URL OptString `json:"url"`
@ -100,6 +112,11 @@ func (s *CardList) GetCard() OptInt {
return s.Card
}
// GetSkill returns the value of Skill.
func (s *CardList) GetSkill() OptString {
return s.Skill
}
// GetStatus returns the value of Status.
func (s *CardList) GetStatus() OptString {
return s.Status
@ -130,6 +147,11 @@ func (s *CardList) SetCard(val OptInt) {
s.Card = val
}
// SetSkill sets the value of Skill.
func (s *CardList) SetSkill(val OptString) {
s.Skill = val
}
// SetStatus sets the value of Status.
func (s *CardList) SetStatus(val OptString) {
s.Status = val
@ -237,6 +259,7 @@ func (*CardOwnerRead) readCardOwnerRes() {}
type CardRead struct {
ID int `json:"id"`
Card OptInt `json:"card"`
Skill OptString `json:"skill"`
Status OptString `json:"status"`
Cp OptInt `json:"cp"`
URL OptString `json:"url"`
@ -253,6 +276,11 @@ func (s *CardRead) GetCard() OptInt {
return s.Card
}
// GetSkill returns the value of Skill.
func (s *CardRead) GetSkill() OptString {
return s.Skill
}
// GetStatus returns the value of Status.
func (s *CardRead) GetStatus() OptString {
return s.Status
@ -283,6 +311,11 @@ func (s *CardRead) SetCard(val OptInt) {
s.Card = val
}
// SetSkill sets the value of Skill.
func (s *CardRead) SetSkill(val OptString) {
s.Skill = val
}
// SetStatus sets the value of Status.
func (s *CardRead) SetStatus(val OptString) {
s.Status = val
@ -309,6 +342,7 @@ func (*CardRead) readCardRes() {}
type CardUpdate struct {
ID int `json:"id"`
Card OptInt `json:"card"`
Skill OptString `json:"skill"`
Status OptString `json:"status"`
Cp OptInt `json:"cp"`
URL OptString `json:"url"`
@ -325,6 +359,11 @@ func (s *CardUpdate) GetCard() OptInt {
return s.Card
}
// GetSkill returns the value of Skill.
func (s *CardUpdate) GetSkill() OptString {
return s.Skill
}
// GetStatus returns the value of Status.
func (s *CardUpdate) GetStatus() OptString {
return s.Status
@ -355,6 +394,11 @@ func (s *CardUpdate) SetCard(val OptInt) {
s.Card = val
}
// SetSkill sets the value of Skill.
func (s *CardUpdate) SetSkill(val OptString) {
s.Skill = val
}
// SetStatus sets the value of Status.
func (s *CardUpdate) SetStatus(val OptString) {
s.Status = val
@ -380,6 +424,7 @@ func (*CardUpdate) updateCardRes() {}
type CreateCardReq struct {
Password string `json:"password"`
Card OptInt `json:"card"`
Skill OptString `json:"skill"`
Status OptString `json:"status"`
Cp OptInt `json:"cp"`
URL OptString `json:"url"`
@ -397,6 +442,11 @@ func (s *CreateCardReq) GetCard() OptInt {
return s.Card
}
// GetSkill returns the value of Skill.
func (s *CreateCardReq) GetSkill() OptString {
return s.Skill
}
// GetStatus returns the value of Status.
func (s *CreateCardReq) GetStatus() OptString {
return s.Status
@ -432,6 +482,11 @@ func (s *CreateCardReq) SetCard(val OptInt) {
s.Card = val
}
// SetSkill sets the value of Skill.
func (s *CreateCardReq) SetSkill(val OptString) {
s.Skill = val
}
// SetStatus sets the value of Status.
func (s *CreateCardReq) SetStatus(val OptString) {
s.Status = val
@ -1229,7 +1284,13 @@ func (*R500) updateGroupRes() {}
func (*R500) updateUserRes() {}
type UpdateCardReq struct {
Owner OptInt `json:"owner"`
Skill OptString `json:"skill"`
Owner OptInt `json:"owner"`
}
// GetSkill returns the value of Skill.
func (s *UpdateCardReq) GetSkill() OptString {
return s.Skill
}
// GetOwner returns the value of Owner.
@ -1237,6 +1298,11 @@ func (s *UpdateCardReq) GetOwner() OptInt {
return s.Owner
}
// SetSkill sets the value of Skill.
func (s *UpdateCardReq) SetSkill(val OptString) {
s.Skill = val
}
// SetOwner sets the value of Owner.
func (s *UpdateCardReq) SetOwner(val OptInt) {
s.Owner = val
@ -1340,6 +1406,7 @@ func (s *UpdateUserReq) SetCard(val []int) {
type UserCardList struct {
ID int `json:"id"`
Card OptInt `json:"card"`
Skill OptString `json:"skill"`
Status OptString `json:"status"`
Cp OptInt `json:"cp"`
URL OptString `json:"url"`
@ -1356,6 +1423,11 @@ func (s *UserCardList) GetCard() OptInt {
return s.Card
}
// GetSkill returns the value of Skill.
func (s *UserCardList) GetSkill() OptString {
return s.Skill
}
// GetStatus returns the value of Status.
func (s *UserCardList) GetStatus() OptString {
return s.Status
@ -1386,6 +1458,11 @@ func (s *UserCardList) SetCard(val OptInt) {
s.Card = val
}
// SetSkill sets the value of Skill.
func (s *UserCardList) SetSkill(val OptString) {
s.Skill = val
}
// SetStatus sets the value of Status.
func (s *UserCardList) SetStatus(val OptString) {
s.Status = val

View File

@ -54,6 +54,9 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
if v, ok := req.CreatedAt.Get(); ok {
b.SetCreatedAt(v)
}
if v, ok := req.Skill.Get(); ok {
b.SetSkill(v)
}
// Add all edges.
if req.Password == password {

View File

@ -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)
@ -449,6 +453,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)

View File

@ -83,6 +83,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},
@ -237,6 +240,9 @@
"schema": {
"type": "object",
"properties": {
"skill": {
"type": "string"
},
"owner": {
"type": "integer"
}
@ -1067,6 +1073,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},
@ -1099,6 +1108,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},
@ -1126,6 +1138,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},
@ -1153,6 +1168,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},
@ -1180,6 +1198,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},
@ -1529,6 +1550,9 @@
"card": {
"type": "integer"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
},

View File

@ -24,20 +24,24 @@ func init() {
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[2].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[3].Descriptor()
cardDescCp := cardFields[4].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[4].Descriptor()
cardDescURL := cardFields[5].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[5].Descriptor()
cardDescCreatedAt := cardFields[6].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()

View File

@ -16,6 +16,7 @@ var url = "https://card.syui.ai"
var card int
var super string
var skill string
var cp int
func (Card) Fields() []ent.Field {
@ -62,6 +63,22 @@ func (Card) Fields() []ent.Field {
}).
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().
DefaultFunc(func() string {

View File

@ -54,6 +54,9 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
if v, ok := req.CreatedAt.Get(); ok {
b.SetCreatedAt(v)
}
if v, ok := req.Skill.Get(); ok {
b.SetSkill(v)
}
// Add all edges.
if req.Password == password {