Fix enums in generated admin schema code.
This commit is contained in:
parent
f154d42e67
commit
9d75c2a665
5 changed files with 36 additions and 10 deletions
|
|
@ -199,6 +199,9 @@ func (h *Handler) UserCreate(ctx echo.Context) error {
|
|||
if payload.CreatedAt != nil {
|
||||
op.SetCreatedAt(*payload.CreatedAt)
|
||||
}
|
||||
if payload.Role != nil {
|
||||
op.SetRole(*payload.Role)
|
||||
}
|
||||
_, err := op.Save(ctx.Request().Context())
|
||||
return err
|
||||
}
|
||||
|
|
@ -222,6 +225,12 @@ func (h *Handler) UserUpdate(ctx echo.Context, id int) error {
|
|||
}
|
||||
op.SetVerified(payload.Verified)
|
||||
op.SetAdmin(payload.Admin)
|
||||
if payload.Role == nil {
|
||||
var empty user.Role
|
||||
op.SetRole(empty)
|
||||
} else {
|
||||
op.SetRole(*payload.Role)
|
||||
}
|
||||
_, err = op.Save(ctx.Request().Context())
|
||||
return err
|
||||
}
|
||||
|
|
@ -251,6 +260,7 @@ func (h *Handler) UserList(ctx echo.Context) (*EntityList, error) {
|
|||
"Verified",
|
||||
"Admin",
|
||||
"Created at",
|
||||
"Role",
|
||||
},
|
||||
Entities: make([]EntityValues, 0, len(res)),
|
||||
Page: page,
|
||||
|
|
@ -266,6 +276,7 @@ func (h *Handler) UserList(ctx echo.Context) (*EntityList, error) {
|
|||
fmt.Sprint(res[i].Verified),
|
||||
fmt.Sprint(res[i].Admin),
|
||||
res[i].CreatedAt.Format(h.Config.TimeFormat),
|
||||
fmt.Sprint(res[i].Role),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -284,6 +295,7 @@ func (h *Handler) UserGet(ctx echo.Context, id int) (url.Values, error) {
|
|||
v.Set("email", entity.Email)
|
||||
v.Set("verified", fmt.Sprint(entity.Verified))
|
||||
v.Set("admin", fmt.Sprint(entity.Admin))
|
||||
v.Set("role", fmt.Sprint(entity.Role))
|
||||
return v, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue