1
0

update readme

This commit is contained in:
syui 2023-04-06 13:08:53 +09:00
parent e025b48fb4
commit 175ab09869
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
3 changed files with 60 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,5 +1,5 @@
t
.env
*.zsh
*.json
#*.sqlite
*.sqlite
#*.zsh

View File

@ -21,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
$ !!
@ -29,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

50
tmp/card_sqlite.zsh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/zsh
host=https://api.syui.ai
api=localhost:8080
host_users="$host/users?itemsPerPage=255"
d=${0:a:h}
dd=${0:a:h:h}
pass=`cat $dd/token.json|jq -r .password`
function l_users() {
curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"$name\",\"password\":\"$pass\"}" $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`
echo "{\"username\":\"$name\"} localhost:8080/users"
if [ "$1" = "-a" ];then
l_users
fi
data_card=`curl -sL "$host/users/$id/card?itemsPerPage=255"`
nn=`echo $data_card|jq length`
nn=$((nn - 1))
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\"} localhost:8080/cards"
if [ "$1" = "-a" ];then
l_cards
fi
done
done