admin_config.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package system
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type AdminConfig struct {
  7. ConfigId int `gorm:"primaryKey;column:config_id;type:int(11);not null"`
  8. AdminId int `gorm:"column:admin_id;type:int(11);not null;default:0"` // 系统客户id
  9. ConfigCode string `gorm:"column:config_code;type:varchar(50);default:''"` // 配置编码
  10. ConfigValue string `gorm:"column:config_value;type:text"` // 配置值
  11. Remark string `gorm:"column:remark;type:varchar(255);default:''"` // 备注信息
  12. CreateTime time.Time `gorm:"column:create_time;type:datetime"` // 创建时间
  13. }
  14. func (item *AdminConfig) Update(cols []string) (err error) {
  15. err = global.DEFAULT_DmSQL.Select(cols).Updates(item).Error
  16. return
  17. }
  18. func (item *AdminConfig) Create() (err error) {
  19. err = global.DEFAULT_DmSQL.Create(item).Error
  20. return
  21. }
  22. var EdbLanguageVar = `edb_language`
  23. var PredictEdbLanguageVar = `predict_edb_language`
  24. var ChartLanguageVar = `chart_language`
  25. func GetConfigDetailByCode(adminId int, configCode string) (item *AdminConfig, err error) {
  26. sql := ` SELECT * FROM admin_config WHERE admin_id = ? AND config_code=? `
  27. err = global.DEFAULT_DmSQL.Raw(sql, adminId, configCode).First(&item).Error
  28. return
  29. }
  30. func GetDefaultConfigDetailByCode(configCode string) (item *AdminConfig, err error) {
  31. sql := ` SELECT * FROM admin_config WHERE admin_id = ? AND config_code=? `
  32. err = global.DEFAULT_DmSQL.Raw(sql, 0, configCode).First(&item).Error
  33. return
  34. }
  35. type SetAdminConfigReq struct {
  36. ConfigCode string `description:"配置编码"`
  37. ConfigValue string `description:"配置值"`
  38. }