mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	fix: 删除系统管理员失效的问题
This commit is contained in:
		@@ -8,7 +8,6 @@ import (
 | 
			
		||||
	"chatplus/store/vo"
 | 
			
		||||
	"chatplus/utils"
 | 
			
		||||
	"chatplus/utils/resp"
 | 
			
		||||
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"gorm.io/gorm"
 | 
			
		||||
)
 | 
			
		||||
@@ -150,15 +149,12 @@ func (h *SysUserHandler) Remove(c *gin.Context) {
 | 
			
		||||
		resp.ERROR(c, types.InvalidArgs)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	// 默认id为1是超级管理员
 | 
			
		||||
	if data.Id == 1 {
 | 
			
		||||
		resp.ERROR(c, "超级管理员不能删除")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if data.Id > 0 {
 | 
			
		||||
 | 
			
		||||
		// 默认id为1是超级管理员
 | 
			
		||||
		if data.Id == 1 {
 | 
			
		||||
			resp.ERROR(c, "超级管理员不能删除")
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		res := h.db.Where("id = ?", data.Id).Delete(&model.AdminUser{})
 | 
			
		||||
		if res.Error != nil {
 | 
			
		||||
			resp.ERROR(c, "删除失败")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user