(c *gin.Context)
| 275 | } |
| 276 | |
| 277 | func 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 | |
| 304 | func GenerateAccessToken(c *gin.Context) { |
| 305 | id := c.GetInt("id") |
nothing calls this directly
no test coverage detected