GetUserRoles 获取用户角色
(c *gin.Context)
| 165 | |
| 166 | // GetUserRoles 获取用户角色 |
| 167 | func (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 获取角色详情 |
| 187 | func (r *RoleHandler) GetRoles(c *gin.Context) { |
nothing calls this directly
no test coverage detected