(c *gin.Context)
| 566 | } |
| 567 | |
| 568 | func DeleteUser(c *gin.Context) { |
| 569 | id, err := strconv.Atoi(c.Param("id")) |
| 570 | if err != nil { |
| 571 | common.ApiError(c, err) |
| 572 | return |
| 573 | } |
| 574 | originUser, err := model.GetUserById(id, false) |
| 575 | if err != nil { |
| 576 | common.ApiError(c, err) |
| 577 | return |
| 578 | } |
| 579 | myRole := c.GetInt("role") |
| 580 | if myRole <= originUser.Role { |
| 581 | c.JSON(http.StatusOK, gin.H{ |
| 582 | "success": false, |
| 583 | "message": "无权删除同权限等级或更高权限等级的用户", |
| 584 | }) |
| 585 | return |
| 586 | } |
| 587 | err = model.HardDeleteUserById(id) |
| 588 | if err != nil { |
| 589 | c.JSON(http.StatusOK, gin.H{ |
| 590 | "success": true, |
| 591 | "message": "", |
| 592 | }) |
| 593 | return |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | func DeleteSelf(c *gin.Context) { |
| 598 | id := c.GetInt("id") |
nothing calls this directly
no test coverage detected