MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / DeleteUser

Function DeleteUser

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

Source from the content-addressed store, hash-verified

566}
567
568func 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
597func DeleteSelf(c *gin.Context) {
598 id := c.GetInt("id")

Callers

nothing calls this directly

Calls 3

ApiErrorFunction · 0.92
GetUserByIdFunction · 0.92
HardDeleteUserByIdFunction · 0.92

Tested by

no test coverage detected