add fav
This commit is contained in:
@ -13,6 +13,8 @@ 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
|
||||
|
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
|
@ -22,7 +22,7 @@ if [ -n "$1" ];then
|
||||
if [ "ai" = "$1" ] || [ "yui" = "$1" ];then
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"token\":\"$token\", \"luck_at\": \"$now_at\", \"luck\": 7, \"like\":0,\"aiten\":1000}" -s $host/users/$id
|
||||
else
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"ten_su\": 0, \"luck_at\": \"$updated_at_n\", \"ten\":false, \"ten_at\": \"$updated_at_n\",\"token\": \"$token\",\"ten_kai\" : 0, \"aiten\":0}" -s $host/users/$id
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\", \"raid_at\":\"$raid_at_n\", \"luck_at\": \"$updated_at_n\", \"ten_at\": \"$updated_at_n\",\"token\": \"$token\"}" -s $host/users/$id
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
@ -1,13 +1,14 @@
|
||||
#!/bin/zsh
|
||||
|
||||
username=yui
|
||||
id=381
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
username=syui
|
||||
id=1
|
||||
|
||||
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`
|
||||
@ -16,6 +17,12 @@ 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
|
||||
|
||||
## users
|
||||
curl -sL "$host/users?itemsPerPage=2550"|jq .
|
||||
read
|
||||
|
@ -125,17 +125,26 @@ 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.
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
b.SetToken(v)
|
||||
}
|
||||
if v, ok := req.Cp.Get(); ok {
|
||||
b.SetCp(v)
|
||||
}
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
@ -170,7 +179,7 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
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):
|
||||
@ -478,6 +487,9 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
|
||||
|
||||
b.SetPassword(req.Password)
|
||||
|
||||
if v, ok := req.Fav.Get(); ok {
|
||||
b.SetFav(v)
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
@ -611,6 +623,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
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)
|
||||
}
|
||||
@ -711,7 +726,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):
|
||||
|
Reference in New Issue
Block a user