智盟项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 regels
900 B

  1. package offical
  2. import (
  3. "applet/app/db"
  4. officialModel "applet/app/db/model"
  5. "applet/app/utils/logx"
  6. )
  7. func SysCfgByKey(key string) *officialModel.SysCfg {
  8. var data officialModel.SysCfg
  9. get, err := db.Db.Where("k=?", key).Get(&data)
  10. if get == false || err != nil {
  11. return nil
  12. }
  13. return &data
  14. }
  15. func SysCfgByKeyStr(key string) string {
  16. var data officialModel.SysCfg
  17. get, err := db.Db.Where("k=?", key).Get(&data)
  18. if get == false || err != nil {
  19. return ""
  20. }
  21. return data.V
  22. }
  23. func DbsSysCfgInserts(key, val string) bool {
  24. cfg := officialModel.SysCfg{K: key, V: val}
  25. _, err := db.Db.InsertOne(&cfg)
  26. if err != nil {
  27. logx.Error(err)
  28. return false
  29. }
  30. return true
  31. }
  32. func DbsSysCfgUpdate(key, val string) bool {
  33. cfg := officialModel.SysCfg{K: key, V: val}
  34. _, err := db.Db.Where("`k`=?", key).Cols("v").Update(&cfg)
  35. if err != nil {
  36. logx.Error(err)
  37. return false
  38. }
  39. return true
  40. }