From 53f275cbb32fa6deadc371a7e294a65b8d342d6a Mon Sep 17 00:00:00 2001 From: syui Date: Sat, 1 Jul 2023 18:45:06 +0900 Subject: [PATCH] test delete --- ent/migrate/schema.go | 2 +- ent/ogent/ogent.go | 4 ++-- ent/openapi.json | 23 +++++++++-------------- tmp/card_account_change.zsh | 5 ++++- tmp/ogent/ogent.go | 4 ++-- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 1f799b1..171b85a 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -79,7 +79,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: "20230621"}, + {Name: "next", Type: field.TypeString, Nullable: true, Default: "20230701"}, {Name: "group_users", Type: field.TypeInt, Nullable: true}, } // UsersTable holds the schema information for the "users" table. diff --git a/ent/ogent/ogent.go b/ent/ogent/ogent.go index 71e7b6a..d43bde7 100644 --- a/ent/ogent/ogent.go +++ b/ent/ogent/ogent.go @@ -170,7 +170,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(0).Exec(ctx) + err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -711,7 +711,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(0).Exec(ctx) + err := h.client.User.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): diff --git a/ent/openapi.json b/ent/openapi.json index cb42ce5..50efe9b 100644 --- a/ent/openapi.json +++ b/ent/openapi.json @@ -831,7 +831,6 @@ } }, "required": [ - "username", "password" ] } @@ -967,6 +966,9 @@ "schema": { "type": "object", "properties": { + "username": { + "type": "string" + }, "did": { "type": "string" }, @@ -1403,8 +1405,7 @@ } }, "required": [ - "id", - "username" + "id" ] }, "Group": { @@ -1572,8 +1573,7 @@ } }, "required": [ - "id", - "username" + "id" ] }, "User": { @@ -1669,7 +1669,6 @@ }, "required": [ "id", - "username", "password" ] }, @@ -1753,8 +1752,7 @@ } }, "required": [ - "id", - "username" + "id" ] }, "UserList": { @@ -1837,8 +1835,7 @@ } }, "required": [ - "id", - "username" + "id" ] }, "UserRead": { @@ -1921,8 +1918,7 @@ } }, "required": [ - "id", - "username" + "id" ] }, "UserUpdate": { @@ -2005,8 +2001,7 @@ } }, "required": [ - "id", - "username" + "id" ] }, "User_CardList": { diff --git a/tmp/card_account_change.zsh b/tmp/card_account_change.zsh index 486c329..a1021ce 100755 --- a/tmp/card_account_change.zsh +++ b/tmp/card_account_change.zsh @@ -9,6 +9,8 @@ if [ -z "$2" ];then exit fi +echo old-id new-id + id=$1 data=`curl -sL "$host/users/$id/card?itemsPerPage=2550"` echo $data @@ -24,5 +26,6 @@ do card=`echo $data|jq -r ".[$i].card"` s=`echo $data|jq -r ".[$i].status"` cp=`echo $data|jq -r ".[$i].cp"` - curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id_n,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" -sL $host/cards + skill=`echo $data|jq -r ".[$i].skill"` + curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id_n,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards done diff --git a/tmp/ogent/ogent.go b/tmp/ogent/ogent.go index 71e7b6a..d43bde7 100644 --- a/tmp/ogent/ogent.go +++ b/tmp/ogent/ogent.go @@ -170,7 +170,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(0).Exec(ctx) + err := h.client.Card.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err): @@ -711,7 +711,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(0).Exec(ctx) + err := h.client.User.DeleteOneID(params.ID).Exec(ctx) if err != nil { switch { case ent.IsNotFound(err):