admin_config.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package system
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type AdminConfig struct {
  7. ConfigId int `orm:"column(config_id);pk" description:"配置id"`
  8. AdminId int `description:"系统客户id"`
  9. ConfigCode string `description:"配置编码"`
  10. ConfigValue string `description:"配置值"`
  11. Remark string `description:"备注信息"`
  12. CreateTime time.Time `description:"创建时间"`
  13. }
  14. // Update 更新基础信息
  15. func (item *AdminConfig) Update(cols []string) (err error) {
  16. o := orm.NewOrm()
  17. _, err = o.Update(item, cols...)
  18. return
  19. }
  20. func (item *AdminConfig) Create() (err error) {
  21. o := orm.NewOrm()
  22. id, err := o.Insert(item)
  23. if err != nil {
  24. return
  25. }
  26. item.ConfigId = int(id)
  27. return
  28. }
  29. var EdbLanguageVar = `edb_language`
  30. var PredictEdbLanguageVar = `predict_edb_language`
  31. var ChartLanguageVar = `chart_language`
  32. // GetConfigDetailByCode 获取详情
  33. func GetConfigDetailByCode(adminId int, configCode string) (item *AdminConfig, err error) {
  34. o := orm.NewOrm()
  35. sql := ` SELECT * FROM admin_config WHERE admin_id = ? AND config_code=? `
  36. err = o.Raw(sql, adminId, configCode).QueryRow(&item)
  37. return
  38. }
  39. // GetDefaultConfigDetailByCode 获取默认配置详情
  40. func GetDefaultConfigDetailByCode(configCode string) (item *AdminConfig, err error) {
  41. o := orm.NewOrm()
  42. sql := ` SELECT * FROM admin_config WHERE admin_id = ? AND config_code=? `
  43. err = o.Raw(sql, 0, configCode).QueryRow(&item)
  44. return
  45. }
  46. // SetAdminConfigReq 设置用户的配置
  47. type SetAdminConfigReq struct {
  48. ConfigCode string `description:"配置编码"`
  49. ConfigValue string `description:"配置值"`
  50. }