admin_config.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // Update 更新基础信息
  15. func (item *AdminConfig) Update(cols []string) (err error) {
  16. err = global.DEFAULT_DmSQL.Select(cols).Updates(item).Error
  17. return
  18. }
  19. func (item *AdminConfig) Create() (err error) {
  20. err = global.DEFAULT_DmSQL.Create(item).Error
  21. return
  22. }
  23. var EdbLanguageVar = `edb_language`
  24. var PredictEdbLanguageVar = `predict_edb_language`
  25. var ChartLanguageVar = `chart_language`
  26. // GetConfigDetailByCode 获取详情
  27. func GetConfigDetailByCode(adminId int, configCode string) (item *AdminConfig, err error) {
  28. sql := ` SELECT * FROM admin_config WHERE admin_id = ? AND config_code=? `
  29. err = global.DEFAULT_DmSQL.Raw(sql, adminId, configCode).First(&item).Error
  30. return
  31. }
  32. // GetDefaultConfigDetailByCode 获取默认配置详情
  33. func GetDefaultConfigDetailByCode(configCode string) (item *AdminConfig, err error) {
  34. sql := ` SELECT * FROM admin_config WHERE admin_id = ? AND config_code=? `
  35. err = global.DEFAULT_DmSQL.Raw(sql, 0, configCode).First(&item).Error
  36. return
  37. }
  38. // SetAdminConfigReq 设置用户的配置
  39. type SetAdminConfigReq struct {
  40. ConfigCode string `description:"配置编码"`
  41. ConfigValue string `description:"配置值"`
  42. }