更新代码
This commit is contained in:
@@ -79,7 +79,7 @@ func ValidateUser(username, password string, tenantName string) (*models.User, *
|
||||
// 1. 根据租户名称查询租户(只查询未删除的)
|
||||
var tenant struct {
|
||||
Id int
|
||||
Status string
|
||||
Status int
|
||||
DeleteTime interface{} // 使用 interface{} 来处理 NULL 值
|
||||
}
|
||||
err := o.Raw("SELECT id, status, delete_time FROM yz_tenants WHERE name = ? AND delete_time IS NULL", tenantName).QueryRow(&tenant)
|
||||
@@ -91,13 +91,13 @@ func ValidateUser(username, password string, tenantName string) (*models.User, *
|
||||
return nil, nil, fmt.Errorf("查询租户失败: %v", err)
|
||||
}
|
||||
|
||||
// 检查租户状态
|
||||
if tenant.Status == "disabled" {
|
||||
// 检查租户状态(0=禁用,1=启用)
|
||||
if tenant.Status == 0 {
|
||||
return nil, nil, errors.New("租户已被禁用")
|
||||
}
|
||||
|
||||
if tenant.Status != "enabled" {
|
||||
return nil, nil, fmt.Errorf("租户状态异常: %s", tenant.Status)
|
||||
if tenant.Status != 1 {
|
||||
return nil, nil, fmt.Errorf("租户状态异常: %d", tenant.Status)
|
||||
}
|
||||
|
||||
tenantId := tenant.Id
|
||||
@@ -127,7 +127,7 @@ func AddUser(username, password, email, nickname, avatar string, tenantId, role,
|
||||
// 1. 验证租户是否存在且有效
|
||||
o := orm.NewOrm()
|
||||
var tenantExists bool
|
||||
err := o.Raw("SELECT EXISTS(SELECT 1 FROM yz_tenants WHERE id = ? AND delete_time IS NULL AND status = 'enabled')", tenantId).QueryRow(&tenantExists)
|
||||
err := o.Raw("SELECT EXISTS(SELECT 1 FROM yz_tenants WHERE id = ? AND delete_time IS NULL AND status = 1)", tenantId).QueryRow(&tenantExists)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("验证租户失败: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user