diff --git a/ent/card_update.go b/ent/card_update.go index f2354a5..c974645 100644 --- a/ent/card_update.go +++ b/ent/card_update.go @@ -142,6 +142,26 @@ func (cu *CardUpdate) ClearCp() *CardUpdate { return cu } +// SetURL sets the "url" field. +func (cu *CardUpdate) SetURL(s string) *CardUpdate { + cu.mutation.SetURL(s) + return cu +} + +// SetNillableURL sets the "url" field if the given value is not nil. +func (cu *CardUpdate) SetNillableURL(s *string) *CardUpdate { + if s != nil { + cu.SetURL(*s) + } + return cu +} + +// ClearURL clears the value of the "url" field. +func (cu *CardUpdate) ClearURL() *CardUpdate { + cu.mutation.ClearURL() + return cu +} + // SetOwnerID sets the "owner" edge to the User entity by ID. func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate { cu.mutation.SetOwnerID(id) @@ -247,6 +267,9 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) { if cu.mutation.CpCleared() { _spec.ClearField(card.FieldCp, field.TypeInt) } + if value, ok := cu.mutation.URL(); ok { + _spec.SetField(card.FieldURL, field.TypeString, value) + } if cu.mutation.URLCleared() { _spec.ClearField(card.FieldURL, field.TypeString) } @@ -416,6 +439,26 @@ func (cuo *CardUpdateOne) ClearCp() *CardUpdateOne { return cuo } +// SetURL sets the "url" field. +func (cuo *CardUpdateOne) SetURL(s string) *CardUpdateOne { + cuo.mutation.SetURL(s) + return cuo +} + +// SetNillableURL sets the "url" field if the given value is not nil. +func (cuo *CardUpdateOne) SetNillableURL(s *string) *CardUpdateOne { + if s != nil { + cuo.SetURL(*s) + } + return cuo +} + +// ClearURL clears the value of the "url" field. +func (cuo *CardUpdateOne) ClearURL() *CardUpdateOne { + cuo.mutation.ClearURL() + return cuo +} + // SetOwnerID sets the "owner" edge to the User entity by ID. func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne { cuo.mutation.SetOwnerID(id) @@ -551,6 +594,9 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error) if cuo.mutation.CpCleared() { _spec.ClearField(card.FieldCp, field.TypeInt) } + if value, ok := cuo.mutation.URL(); ok { + _spec.SetField(card.FieldURL, field.TypeString, value) + } if cuo.mutation.URLCleared() { _spec.ClearField(card.FieldURL, field.TypeString) } diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 1f80a0f..1452cb2 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -88,7 +88,7 @@ var ( {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: "20230801"}, + {Name: "next", Type: field.TypeString, Nullable: true, Default: "20230811"}, {Name: "group_users", Type: field.TypeInt, Nullable: true}, } // UsersTable holds the schema information for the "users" table. diff --git a/ent/ogent/oas_json_gen.go b/ent/ogent/oas_json_gen.go index 67593b6..131fe81 100644 --- a/ent/ogent/oas_json_gen.go +++ b/ent/ogent/oas_json_gen.go @@ -4496,6 +4496,12 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) { s.Cp.Encode(e) } } + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } { if s.Owner.Set { e.FieldStart("owner") @@ -4504,13 +4510,14 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfUpdateCardReq = [6]string{ +var jsonFieldsNameOfUpdateCardReq = [7]string{ 0: "card", 1: "skill", 2: "status", 3: "token", 4: "cp", - 5: "owner", + 5: "url", + 6: "owner", } // Decode decodes UpdateCardReq from json. @@ -4571,6 +4578,16 @@ func (s *UpdateCardReq) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"cp\"") } + case "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } case "owner": if err := func() error { s.Owner.Reset() diff --git a/ent/ogent/oas_schemas_gen.go b/ent/ogent/oas_schemas_gen.go index 0300f6d..18d430e 100644 --- a/ent/ogent/oas_schemas_gen.go +++ b/ent/ogent/oas_schemas_gen.go @@ -2092,6 +2092,7 @@ type UpdateCardReq struct { Status OptString `json:"status"` Token OptString `json:"token"` Cp OptInt `json:"cp"` + URL OptString `json:"url"` Owner OptInt `json:"owner"` } @@ -2120,6 +2121,11 @@ func (s *UpdateCardReq) GetCp() OptInt { return s.Cp } +// GetURL returns the value of URL. +func (s *UpdateCardReq) GetURL() OptString { + return s.URL +} + // GetOwner returns the value of Owner. func (s *UpdateCardReq) GetOwner() OptInt { return s.Owner @@ -2150,6 +2156,11 @@ func (s *UpdateCardReq) SetCp(val OptInt) { s.Cp = val } +// SetURL sets the value of URL. +func (s *UpdateCardReq) SetURL(val OptString) { + s.URL = val +} + // SetOwner sets the value of Owner. func (s *UpdateCardReq) SetOwner(val OptInt) { s.Owner = val diff --git a/ent/ogent/ogent.go b/ent/ogent/ogent.go index 8a3d8e2..5c5791f 100644 --- a/ent/ogent/ogent.go +++ b/ent/ogent/ogent.go @@ -131,6 +131,9 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param if v, ok := req.Skill.Get(); ok { b.SetSkill(v) } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } if v, ok := req.Status.Get(); ok { b.SetStatus(v) } @@ -182,8 +185,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param // DeleteCard handles DELETE /cards/{id} requests. func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) { - err := h.client.Card.DeleteOneID(0).Exec(ctx) - //err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) + //err := h.client.Card.DeleteOneID(0).Exec(ctx) + err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): diff --git a/ent/openapi.json b/ent/openapi.json index 020a502..3c7ea8c 100644 --- a/ent/openapi.json +++ b/ent/openapi.json @@ -258,6 +258,9 @@ "cp": { "type": "integer" }, + "url": { + "type": "string" + }, "owner": { "type": "integer" } diff --git a/ent/schema/card.go b/ent/schema/card.go index 7690a91..41f55e7 100644 --- a/ent/schema/card.go +++ b/ent/schema/card.go @@ -131,7 +131,6 @@ func (Card) Fields() []ent.Field { Optional(), field.String("url"). - Immutable(). Default(url). Optional(), diff --git a/tmp/card_add.zsh b/tmp/card_add.zsh index 3f42359..1dd0adf 100755 --- a/tmp/card_add.zsh +++ b/tmp/card_add.zsh @@ -2,6 +2,8 @@ host=https://api.syui.ai pass=`cat ~/.config/atr/api_card.json|jq -r .password` +echo username card cp +read if [ -z "$1" ];then exit fi @@ -12,11 +14,10 @@ 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=dragon +s=normal +skill=ten curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards diff --git a/tmp/card_add_16.zsh b/tmp/card_add_16.zsh new file mode 100755 index 0000000..4d3a8e7 --- /dev/null +++ b/tmp/card_add_16.zsh @@ -0,0 +1,16 @@ +#!/bin/zsh + +host=https://api.syui.ai +pass=`cat ~/.config/atr/api_card.json|jq -r .password` +if [ -z "$1" ];then + exit +fi + +echo username +read +id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id` +card=16 +cp=0 +s=super +skill=badge +curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards diff --git a/tmp/card_add_45.zsh b/tmp/card_add_45.zsh new file mode 100755 index 0000000..3e4c1e9 --- /dev/null +++ b/tmp/card_add_45.zsh @@ -0,0 +1,16 @@ +#!/bin/zsh + +host=https://api.syui.ai +pass=`cat ~/.config/atr/api_card.json|jq -r .password` +if [ -z "$1" ];then + exit +fi + +echo username +read +id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id` +card=45 +cp=0 +s=super +skill=badge +curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards diff --git a/tmp/card_limit_all.zsh b/tmp/card_limit_all.zsh index 6244044..32dfa57 100755 --- a/tmp/card_limit_all.zsh +++ b/tmp/card_limit_all.zsh @@ -20,7 +20,7 @@ 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\"}" -s $host/users/$id + curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"ten_at\":\"$updated_at_n\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"ten_kai\":0,\"ten\": false}" -s $host/users/$id else curl -X PATCH -H "Content-Type: application/json" -d "{\"ten_at\":\"$updated_at_n\", \"token\": \"$token\"}" -s $host/users/$id #curl -X PATCH -H "Content-Type: application/json" -d "{\"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"luck_at\": \"$updated_at_n\",\"egg_at\": \"$updated_at_n\", \"token\": \"$token\"}" -s $host/users/$id @@ -38,7 +38,7 @@ do 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 "{\"egg_at\":\"$raid_at_n\", \"raid_at\":\"$raid_at_n\",\"token\": \"$token\"}" -s $host/users/$id - curl -X PATCH -H "Content-Type: application/json" -d "{\"ten_at\":\"$updated_at_n\", \"token\": \"$token\"}" -s $host/users/$id + curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"luck_at\": \"$now_at\",\"ten_at\":\"$updated_at_n\", \"token\": \"$token\"}" -s $host/users/$id #curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"ten_at\": \"$updated_at_n\"}" -s $host/users/$id fi done diff --git a/tmp/ogent/ogent.go b/tmp/ogent/ogent.go index 8a3d8e2..ff42ded 100644 --- a/tmp/ogent/ogent.go +++ b/tmp/ogent/ogent.go @@ -131,6 +131,9 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param if v, ok := req.Skill.Get(); ok { b.SetSkill(v) } + if v, ok := req.URL.Get(); ok { + b.SetURL(v) + } if v, ok := req.Status.Get(); ok { b.SetStatus(v) }