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

Method UpdateUserRole

internal/api/role.go:148–164  ·  view source on GitHub ↗

UpdateUserRole 更新用户角色

(c *gin.Context)

Source from the content-addressed store, hash-verified

146
147// UpdateUserRole 更新用户角色
148func (r *RoleHandler) UpdateUserRole(c *gin.Context) {
149 var req req.UpdateUserRoleRequest
150 if err := c.ShouldBindJSON(&req); err != nil {
151 r.l.Error("绑定请求参数失败", zap.Error(err))
152 apiresponse.Error(c)
153 return
154 }
155
156 // 分配用户角色和权限
157 if err := r.permissionSvc.AssignRoleToUser(c.Request.Context(), req.UserId, req.RoleIds, req.MenuIds, req.ApiIds); err != nil {
158 r.l.Error("分配API权限失败", zap.Error(err))
159 apiresponse.Error(c)
160 return
161 }
162
163 apiresponse.Success(c)
164}
165
166// GetUserRoles 获取用户角色
167func (r *RoleHandler) GetUserRoles(c *gin.Context) {

Callers

nothing calls this directly

Calls 3

ErrorFunction · 0.92
SuccessFunction · 0.92
AssignRoleToUserMethod · 0.65

Tested by

no test coverage detected