代码拉取完成,页面将自动刷新
package api
import (
"github.com/emicklei/go-restful/v3"
"github.com/infraboard/mcube/http/response"
"gitee.com/MinKo-U/keyauth/apps/user"
)
func (h *handler) CreateUser(r *restful.Request, w *restful.Response) {
req := user.NewCreateUserRequest()
if err := r.ReadEntity(req); err != nil {
response.Failed(w.ResponseWriter, err)
return
}
h.log.Debug(req)
err := req.Validate()
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
set, err := h.service.CreateUser(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
func (h *handler) QueryUser(r *restful.Request, w *restful.Response) {
req := user.NewQueryUserRequestFromHTTP(r.Request)
set, err := h.service.QueryUser(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
func (h *handler) DescribeUser(r *restful.Request, w *restful.Response) {
req := user.NewDescribeUserRequest(r.PathParameter("id"))
ins, err := h.service.DescribeUser(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, ins)
}
func (h *handler) UpdateUser(r *restful.Request, w *restful.Response) {
req := user.NewPutUserRequest(r.PathParameter("id"))
if err := r.ReadEntity(req.Data); err != nil {
response.Failed(w.ResponseWriter, err)
return
}
set, err := h.service.UpdateUser(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
func (h *handler) PatchUser(r *restful.Request, w *restful.Response) {
req := user.NewPatchUserRequest(r.PathParameter("id"))
h.log.Debugf("id:%s", req.Id)
if err := r.ReadEntity(req.Data); err != nil {
h.log.Debugf("data:%v", req)
response.Failed(w.ResponseWriter, err)
return
}
h.log.Debugf("data:%v", req)
set, err := h.service.UpdateUser(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
func (h *handler) DeleteUser(r *restful.Request, w *restful.Response) {
req := user.NewDeleteUserRequestWithID(r.PathParameter("id"))
set, err := h.service.DeleteUser(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。