fix
This commit is contained in:
parent
bc6faa76f6
commit
d2d97dc4aa
@ -583,7 +583,7 @@ func decodeListCardParams(args [0]string, r *http.Request) (params ListCardParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 5000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -748,7 +748,7 @@ func decodeListGroupParams(args [0]string, r *http.Request) (params ListGroupPar
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 5000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -1080,7 +1080,7 @@ func decodeListMaParams(args [0]string, r *http.Request) (params ListMaParams, _
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 5000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -1245,7 +1245,7 @@ func decodeListUeParams(args [0]string, r *http.Request) (params ListUeParams, _
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 5000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
@ -1410,7 +1410,7 @@ func decodeListUserParams(args [0]string, r *http.Request) (params ListUserParam
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 255,
|
||||
Max: 5000,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
|
@ -13,9 +13,14 @@ import (
|
||||
"api/ent/ue"
|
||||
"api/ent/user"
|
||||
|
||||
"os"
|
||||
"github.com/go-faster/jx"
|
||||
)
|
||||
|
||||
// origin-config
|
||||
var password = os.Getenv("PASS")
|
||||
var token = os.Getenv("TOKEN")
|
||||
|
||||
// OgentHandler implements the ogen generated Handler interface and uses Ent as data layer.
|
||||
type OgentHandler struct {
|
||||
client *ent.Client
|
||||
@ -63,8 +68,13 @@ func (h *OgentHandler) CreateCard(ctx context.Context, req *CreateCardReq) (Crea
|
||||
if v, ok := req.CreatedAt.Get(); ok {
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Add all edges.
|
||||
b.SetOwnerID(req.Owner)
|
||||
//b.SetOwnerID(req.Owner)
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -151,8 +161,16 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
//if v, ok := req.Owner.Get(); ok {
|
||||
// b.SetOwnerID(v)
|
||||
//}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
@ -187,7 +205,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(params.ID).Exec(ctx)
|
||||
//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):
|
||||
@ -383,7 +402,8 @@ func (h *OgentHandler) UpdateGroup(ctx context.Context, req *UpdateGroupReq, par
|
||||
|
||||
// DeleteGroup handles DELETE /groups/{id} requests.
|
||||
func (h *OgentHandler) DeleteGroup(ctx context.Context, params DeleteGroupParams) (DeleteGroupRes, error) {
|
||||
err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Group.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Group.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -525,7 +545,12 @@ func (h *OgentHandler) CreateMa(ctx context.Context, req *CreateMaReq) (CreateMa
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
b.SetOwnerID(req.Owner)
|
||||
//b.SetOwnerID(req.Owner)
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -624,8 +649,16 @@ func (h *OgentHandler) UpdateMa(ctx context.Context, req *UpdateMaReq, params Up
|
||||
b.SetUpdatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
//if v, ok := req.Owner.Get(); ok {
|
||||
// b.SetOwnerID(v)
|
||||
//}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
@ -660,7 +693,8 @@ func (h *OgentHandler) UpdateMa(ctx context.Context, req *UpdateMaReq, params Up
|
||||
|
||||
// DeleteMa handles DELETE /mas/{id} requests.
|
||||
func (h *OgentHandler) DeleteMa(ctx context.Context, params DeleteMaParams) (DeleteMaRes, error) {
|
||||
err := h.client.Ma.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Ma.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Ma.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -807,7 +841,12 @@ func (h *OgentHandler) CreateUe(ctx context.Context, req *CreateUeReq) (CreateUe
|
||||
b.SetCreatedAt(v)
|
||||
}
|
||||
// Add all edges.
|
||||
b.SetOwnerID(req.Owner)
|
||||
//b.SetOwnerID(req.Owner)
|
||||
if req.Password == password {
|
||||
b.SetOwnerID(req.Owner)
|
||||
} else {
|
||||
b.SetOwnerID(0)
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
if err != nil {
|
||||
@ -921,8 +960,16 @@ func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params Up
|
||||
b.SetAuthor(v)
|
||||
}
|
||||
// Add all edges.
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
//if v, ok := req.Owner.Get(); ok {
|
||||
// b.SetOwnerID(v)
|
||||
//}
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
b.SetToken(v)
|
||||
if v, ok := req.Owner.Get(); ok {
|
||||
b.SetOwnerID(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
@ -957,7 +1004,8 @@ func (h *OgentHandler) UpdateUe(ctx context.Context, req *UpdateUeReq, params Up
|
||||
|
||||
// DeleteUe handles DELETE /ues/{id} requests.
|
||||
func (h *OgentHandler) DeleteUe(ctx context.Context, params DeleteUeParams) (DeleteUeRes, error) {
|
||||
err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
|
||||
//err := h.client.Ue.DeleteOneID(params.ID).Exec(ctx)
|
||||
err := h.client.Ue.DeleteOneID(0).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
@ -1048,7 +1096,12 @@ func (h *OgentHandler) ReadUeOwner(ctx context.Context, params ReadUeOwnerParams
|
||||
func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (CreateUserRes, error) {
|
||||
b := h.client.User.Create()
|
||||
// Add all fields.
|
||||
b.SetUsername(req.Username)
|
||||
//b.SetUsername(req.Username)
|
||||
if req.Password == password {
|
||||
b.SetUsername(req.Username)
|
||||
} else {
|
||||
b.SetUsername("")
|
||||
}
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
}
|
||||
@ -1258,6 +1311,9 @@ func (h *OgentHandler) ReadUser(ctx context.Context, params ReadUserParams) (Rea
|
||||
// UpdateUser handles PATCH /users/{id} requests.
|
||||
func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, params UpdateUserParams) (UpdateUserRes, error) {
|
||||
b := h.client.User.UpdateOneID(params.ID)
|
||||
if v, ok := req.Token.Get(); ok {
|
||||
if v == token {
|
||||
|
||||
// Add all fields.
|
||||
if v, ok := req.Did.Get(); ok {
|
||||
b.SetDid(v)
|
||||
@ -1409,6 +1465,9 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
|
||||
}
|
||||
if req.Ma != nil {
|
||||
b.ClearMa().AddMaIDs(req.Ma...)
|
||||
}
|
||||
b.SetToken(v)
|
||||
}
|
||||
}
|
||||
// Persist to storage.
|
||||
e, err := b.Save(ctx)
|
||||
@ -1443,7 +1502,8 @@ 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)
|
||||
//err := h.client.User.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
|
@ -30,7 +30,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 5000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -402,7 +402,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 5000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -728,7 +728,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 5000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -1101,7 +1101,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 5000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
@ -1502,7 +1502,7 @@
|
||||
"description": "item count to render per page",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"maximum": 5000,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user