fix: 删除系统管理员失效的问题

This commit is contained in:
chenzifan
2024-03-13 08:47:17 +08:00
parent f4d537e0f5
commit e8d7ad58be

View File

@@ -8,7 +8,6 @@ import (
"chatplus/store/vo" "chatplus/store/vo"
"chatplus/utils" "chatplus/utils"
"chatplus/utils/resp" "chatplus/utils/resp"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gorm.io/gorm" "gorm.io/gorm"
) )
@@ -150,15 +149,12 @@ func (h *SysUserHandler) Remove(c *gin.Context) {
resp.ERROR(c, types.InvalidArgs) resp.ERROR(c, types.InvalidArgs)
return return
} }
// 默认id为1是超级管理员
if data.Id == 1 {
resp.ERROR(c, "超级管理员不能删除")
return
}
if data.Id > 0 { if data.Id > 0 {
// 默认id为1是超级管理员
if data.Id == 1 {
resp.ERROR(c, "超级管理员不能删除")
return
}
res := h.db.Where("id = ?", data.Id).Delete(&model.AdminUser{}) res := h.db.Where("id = ?", data.Id).Delete(&model.AdminUser{})
if res.Error != nil { if res.Error != nil {
resp.ERROR(c, "删除失败") resp.ERROR(c, "删除失败")