Files
web_ylsa/api_iris/utils/sysSettings.go
2025-07-11 16:54:11 +08:00

39 lines
908 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package utils
import (
"github.com/sirupsen/logrus"
"main/database"
"main/model"
)
var SysSettings []model.SysSettings
func UpdateSysSettings() {
db := database.GetInstance().GetMysqlDb()
if err := db.Order("name").Find(&SysSettings).Error; err != nil {
logrus.Errorln("sql执行失败", err)
}
if len(SysSettings) == 0 {
if err := db.Create(&model.SysSettings{
Name: "user_type",
CnName: "系统管理员",
Value: "admin",
DType: "",
}).Error; err != nil {
logrus.Errorln("sql执行失败", err)
}
if err := db.Create(&model.SysSettings{
Name: "user_type",
CnName: "系统用户",
Value: "user",
DType: "",
}).Error; err != nil {
logrus.Errorln("sql执行失败", err)
}
if err := db.Order("name").Find(&SysSettings).Error; err != nil {
logrus.Errorln("sql执行失败", err)
}
}
logrus.Infoln("更新系统配置列表")
}