gengxin
This commit is contained in:
parent
f487bb521f
commit
b0629b1001
@ -1,29 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
// GetPlatformSettingValue 从 yz_system_tenant_setting_items 表中读取平台级别(tid=0)的配置值。
|
|
||||||
// key 不存在或读取失败时返回空字符串。
|
|
||||||
func GetPlatformSettingValue(key string) string {
|
|
||||||
type row struct {
|
|
||||||
SettingValue string
|
|
||||||
}
|
|
||||||
var r row
|
|
||||||
// tid=0 表示平台全局配置,与租户无关
|
|
||||||
err := Orm.Raw(
|
|
||||||
"SELECT IFNULL(setting_value, '') AS setting_value FROM yz_system_tenant_setting_items WHERE tid = 0 AND setting_key = ? AND delete_time IS NULL LIMIT 1",
|
|
||||||
key,
|
|
||||||
).QueryRow(&r)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return r.SettingValue
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPlatformSettingValue 写入或更新平台级别(tid=0)的配置值。
|
|
||||||
func SetPlatformSettingValue(key, value string) error {
|
|
||||||
_, err := Orm.Raw(`
|
|
||||||
INSERT INTO yz_system_tenant_setting_items (tid, setting_key, setting_value, create_time, update_time)
|
|
||||||
VALUES (0, ?, ?, NOW(), NOW())
|
|
||||||
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value), update_time = NOW(), delete_time = NULL
|
|
||||||
`, key, value).Exec()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user