蛋蛋星球 后台端
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.
 
 
 
 
 

59 lines
1.2 KiB

  1. package svc
  2. import (
  3. cfgMd "applet/app/cfg"
  4. db2 "applet/app/db"
  5. db "applet/app/db/im"
  6. "applet/app/utils/cache"
  7. )
  8. // 多条记录获取
  9. func SysCfgFind(keys ...string) map[string]string {
  10. tmp := SysCfgFindComm(keys...)
  11. return tmp
  12. }
  13. // SysCfgFindComm get cfg by master id
  14. func SysCfgFindComm(keys ...string) map[string]string {
  15. res := map[string]string{}
  16. cfgList, _ := db.SysCfgGetAll(db2.DbIm)
  17. if cfgList == nil {
  18. return nil
  19. }
  20. for _, v := range *cfgList {
  21. res[v.Key] = v.Val
  22. }
  23. if len(keys) == 0 {
  24. return res
  25. }
  26. tmp := map[string]string{}
  27. for _, v := range keys {
  28. if val, ok := res[v]; ok {
  29. tmp[v] = val
  30. } else {
  31. tmp[v] = ""
  32. }
  33. }
  34. return tmp
  35. }
  36. // SysCfgCleanCache 清理系统配置信息
  37. func SysCfgCleanCache() {
  38. cache.SelectDb(1) //TODO::IM统一放1号库
  39. cache.Del(cfgMd.IM_KEY_SYS_CFG_CACHE)
  40. }
  41. // SysCfgSet 写入系统设置
  42. func SysCfgSet(key, val, memo string) bool {
  43. cfg, err := db.SysCfgGetOne(db2.DbIm, key)
  44. if err != nil || cfg == nil {
  45. return db.SysCfgInsert(db2.DbIm, key, val, memo)
  46. }
  47. if memo != "" && cfg.Memo != memo {
  48. cfg.Memo = memo
  49. }
  50. SysCfgCleanCache()
  51. return db.SysCfgUpdate(db2.DbIm, key, val, cfg.Memo)
  52. }