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

Method GetUserRoles

internal/api/role.go:167–184  ·  view source on GitHub ↗

GetUserRoles 获取用户角色

(c *gin.Context)

Source from the content-addressed store, hash-verified

165
166// GetUserRoles 获取用户角色
167func (r *RoleHandler) GetUserRoles(c *gin.Context) {
168 // 从URL参数中获取用户ID
169 id, err := strconv.Atoi(c.Param("id"))
170 if err != nil {
171 r.l.Error("解析ID失败", zap.Error(err))
172 apiresponse.Error(c)
173 return
174 }
175
176 role, err := r.svc.GetUserRole(c.Request.Context(), id)
177 if err != nil {
178 r.l.Error("获取用户角色失败", zap.Error(err))
179 apiresponse.Error(c)
180 return
181 }
182
183 apiresponse.SuccessWithData(c, role)
184}
185
186// GetRoles 获取角色详情
187func (r *RoleHandler) GetRoles(c *gin.Context) {

Callers

nothing calls this directly

Calls 3

ErrorFunction · 0.92
SuccessWithDataFunction · 0.92
GetUserRoleMethod · 0.65

Tested by

no test coverage detected