MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / ListRoles

Method ListRoles

internal/api/role.go:44–64  ·  view source on GitHub ↗

ListRoles 获取角色列表

(c *gin.Context)

Source from the content-addressed store, hash-verified

42
43// ListRoles 获取角色列表
44func (r *RoleHandler) ListRoles(c *gin.Context) {
45 var req req.ListRolesRequest
46 if err := c.ShouldBindJSON(&req); err != nil {
47 r.l.Error("绑定请求参数失败", zap.Error(err))
48 apiresponse.Error(c)
49 return
50 }
51
52 // 调用service获取角色列表
53 roles, total, err := r.svc.ListRoles(c.Request.Context(), req.PageNumber, req.PageSize)
54 if err != nil {
55 r.l.Error("获取角色列表失败", zap.Error(err))
56 apiresponse.Error(c)
57 return
58 }
59
60 apiresponse.SuccessWithData(c, gin.H{
61 "list": roles,
62 "total": total,
63 })
64}
65
66// CreateRole 创建角色
67func (r *RoleHandler) CreateRole(c *gin.Context) {

Callers

nothing calls this directly

Calls 3

ErrorFunction · 0.92
SuccessWithDataFunction · 0.92
ListRolesMethod · 0.65

Tested by

no test coverage detected