config.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type CygxConfig struct {
  6. ConfigValue string `description:"详情"`
  7. OperationButton bool `description:"操作按钮1,true,允许,false 不予许"`
  8. }
  9. type NameAndUrl struct {
  10. Name string `description:"名称"`
  11. Url string `description:"地址"`
  12. }
  13. type NameAndUrlList struct {
  14. List []*NameAndUrl
  15. }
  16. // 详情
  17. func GetCygxConfigDetail() (item *CygxConfig, err error) {
  18. o := orm.NewOrmUsingDB("hz_cygx")
  19. sql := `SELECT * FROM cygx_config WHERE config_code= 'is_show_sustainable'`
  20. err = o.Raw(sql).QueryRow(&item)
  21. return
  22. }
  23. // 修改
  24. func CygxConfigUpdate(newValue int) (err error) {
  25. o := orm.NewOrmUsingDB("hz_cygx")
  26. sql := `UPDATE cygx_config SET config_value=? WHERE config_code= 'is_show_sustainable'`
  27. _, err = o.Raw(sql, newValue).Exec()
  28. return
  29. }
  30. // 详情
  31. func GetCygxConfigDetailByCode(code string) (item *CygxConfig, err error) {
  32. o := orm.NewOrmUsingDB("hz_cygx")
  33. sql := `SELECT * FROM cygx_config WHERE config_code= ?`
  34. err = o.Raw(sql, code).QueryRow(&item)
  35. return
  36. }
  37. // 修改
  38. func CygxConfigUpdateByCode(configValue, newValue string) (err error) {
  39. o := orm.NewOrmUsingDB("hz_cygx")
  40. sql := `UPDATE cygx_config SET config_value=? WHERE config_code= ? `
  41. _, err = o.Raw(sql, configValue, newValue).Exec()
  42. return
  43. }
  44. func GetConfigByCode(configCode string) (item *CygxConfig, err error) {
  45. o := orm.NewOrmUsingDB("hz_cygx")
  46. sql := `SELECT * FROM cygx_config WHERE config_code=? `
  47. err = o.Raw(sql, configCode).QueryRow(&item)
  48. return
  49. }