移除轮询
This commit is contained in:
@@ -8,34 +8,29 @@ import (
|
||||
"server/models"
|
||||
)
|
||||
|
||||
/* findTenantByLoginName 根据租户简称、短名或编码查找租户。
|
||||
*
|
||||
* 当前表结构中 tenant_name 的业务含义就是“租户简称”,同时兼容
|
||||
* tenant_short_name 和 tenant_code 两个历史/备用登录标识。
|
||||
*/
|
||||
|
||||
func findTenantByLoginName(loginName string) (*models.SystemTenant, error) {
|
||||
loginName = strings.TrimSpace(loginName)
|
||||
if loginName == "" {
|
||||
return nil, orm.ErrNoRows
|
||||
}
|
||||
|
||||
qs := models.Orm.QueryTable(new(models.SystemTenant)).
|
||||
Filter("status", 1).
|
||||
Filter("delete_time__isnull", true)
|
||||
|
||||
// tenant_name 的业务含义是租户简称。使用 TRIM 兼容历史数据中字段值
|
||||
// 前后存在空格的情况;参数通过 SetArgs 绑定,避免 SQL 注入。
|
||||
tenant := &models.SystemTenant{}
|
||||
query := `
|
||||
SELECT id, tenant_code, tenant_name, tenant_short_name,
|
||||
contact_person, contact_phone, contact_email, address,
|
||||
worktime, status, remark, create_time, update_time, delete_time
|
||||
FROM yz_system_tenant
|
||||
WHERE (TRIM(tenant_name) = TRIM(?) OR
|
||||
TRIM(tenant_short_name) = TRIM(?) OR
|
||||
TRIM(tenant_code) = TRIM(?))
|
||||
AND status <> 0
|
||||
ORDER BY id ASC
|
||||
LIMIT 1`
|
||||
err := models.Orm.Raw(query).
|
||||
SetArgs(loginName, loginName, loginName).
|
||||
QueryRow(tenant)
|
||||
err := qs.Filter("tenant_name", loginName).One(tenant)
|
||||
if err == nil {
|
||||
return tenant, nil
|
||||
}
|
||||
|
||||
tenant = &models.SystemTenant{}
|
||||
err = models.Orm.QueryTable(new(models.SystemTenant)).
|
||||
Filter("status", 1).
|
||||
Filter("delete_time__isnull", true).
|
||||
Filter("tenant_code", loginName).
|
||||
One(tenant)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user