1 Star 0 Fork 0

谈子文/keyauth-tz

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
role.go 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
谈子文 提交于 2023-10-27 01:41 . 更新policy 和 role api create 功能
package api
import (
"github.com/emicklei/go-restful/v3"
"github.com/infraboard/mcube/http/response"
"gitee.com/talk-about-articles/keyauth-tz/apps/role"
)
func (h *handler) CreateRole(r *restful.Request, w *restful.Response) {
req := role.NewCreateRoleRequest()
if err := r.ReadEntity(req); err != nil {
response.Failed(w.ResponseWriter, err)
return
}
set, err := h.service.CreateRole(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
func (h *handler) QueryRole(r *restful.Request, w *restful.Response) {
req := role.NewQueryRoleRequestFromHTTP(r.Request)
set, err := h.service.QueryRole(r.Request.Context(), req)
if err != nil {
response.Failed(w.ResponseWriter, err)
return
}
response.Success(w.ResponseWriter, set)
}
//func (h *handler) DescribeRole(r *restful.Request, w *restful.Response) {
// req := role.NewDescribeRoleRequest(r.PathParameter("id"))
// ins, err := h.service.DescribeRole(r.Request.Context(), req)
// if err != nil {
// response.Failed(w.ResponseWriter, err)
// return
// }
//
// response.Success(w.ResponseWriter, ins)
//}
//
//func (h *handler) UpdateRole(r *restful.Request, w *restful.Response) {
// req := role.NewPutRoleRequest(r.PathParameter("id"))
//
// if err := r.ReadEntity(req.Data); err != nil {
// response.Failed(w.ResponseWriter, err)
// return
// }
//
// set, err := h.service.UpdateRole(r.Request.Context(), req)
// if err != nil {
// response.Failed(w.ResponseWriter, err)
// return
// }
// response.Success(w.ResponseWriter, set)
//}
//
//func (h *handler) PatchRole(r *restful.Request, w *restful.Response) {
// req := role.NewPatchRoleRequest(r.PathParameter("id"))
//
// if err := r.ReadEntity(req.Data); err != nil {
// response.Failed(w.ResponseWriter, err)
// return
// }
//
// set, err := h.service.UpdateRole(r.Request.Context(), req)
// if err != nil {
// response.Failed(w.ResponseWriter, err)
// return
// }
// response.Success(w.ResponseWriter, set)
//}
//
//func (h *handler) DeleteRole(r *restful.Request, w *restful.Response) {
// req := role.NewDeleteRoleRequestWithID(r.PathParameter("id"))
// set, err := h.service.DeleteRole(r.Request.Context(), req)
// if err != nil {
// response.Failed(w.ResponseWriter, err)
// return
// }
// response.Success(w.ResponseWriter, set)
//}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/talk-about-articles/keyauth-tz.git
git@gitee.com:talk-about-articles/keyauth-tz.git
talk-about-articles
keyauth-tz
keyauth-tz
v1.0.33

搜索帮助

0d507c66 1850385 C8b1a773 1850385