MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / GetUser

Function GetUser

controller/user.go:277–302  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

275}
276
277func GetUser(c *gin.Context) {
278 id, err := strconv.Atoi(c.Param("id"))
279 if err != nil {
280 common.ApiError(c, err)
281 return
282 }
283 user, err := model.GetUserById(id, false)
284 if err != nil {
285 common.ApiError(c, err)
286 return
287 }
288 myRole := c.GetInt("role")
289 if myRole <= user.Role && myRole != common.RoleRootUser {
290 c.JSON(http.StatusOK, gin.H{
291 "success": false,
292 "message": "无权获取同级或更高等级用户的信息",
293 })
294 return
295 }
296 c.JSON(http.StatusOK, gin.H{
297 "success": true,
298 "message": "",
299 "data": user,
300 })
301 return
302}
303
304func GenerateAccessToken(c *gin.Context) {
305 id := c.GetInt("id")

Callers

nothing calls this directly

Calls 2

ApiErrorFunction · 0.92
GetUserByIdFunction · 0.92

Tested by

no test coverage detected