1
0

test card url

This commit is contained in:
syui 2023-08-03 12:32:44 +09:00
parent 6116d5a076
commit 433959a932
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
12 changed files with 127 additions and 12 deletions

View File

@ -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)
}

View File

@ -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.

View File

@ -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()

View File

@ -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

View File

@ -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):

View File

@ -258,6 +258,9 @@
"cp": {
"type": "integer"
},
"url": {
"type": "string"
},
"owner": {
"type": "integer"
}

View File

@ -131,7 +131,6 @@ func (Card) Fields() []ent.Field {
Optional(),
field.String("url").
Immutable().
Default(url).
Optional(),

View File

@ -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

16
tmp/card_add_16.zsh Executable file
View File

@ -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

16
tmp/card_add_45.zsh Executable file
View File

@ -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

View File

@ -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

View File

@ -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)
}