wechat_platform.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package services
  2. import (
  3. "context"
  4. "eta/eta_task/utils"
  5. "fmt"
  6. )
  7. type WechatArticleOp struct {
  8. Source string
  9. WechatPlatformId int
  10. }
  11. // AddWechatArticleOpToCache
  12. // @Description: 将公众号文章操作加入缓存
  13. // @param wechatPlatformId
  14. // @param source
  15. // @return bool
  16. func AddWechatArticleOpToCache(wechatPlatformId int, source string) bool {
  17. record := new(WechatArticleOp)
  18. record.Source = source
  19. record.WechatPlatformId = wechatPlatformId
  20. if utils.Re == nil {
  21. err := utils.Rc.LPush(utils.CACHE_WECHAT_PLATFORM_ARTICLE, record)
  22. utils.FileLog.Info(fmt.Sprintf("将公众号文章操作 加入缓存 AddWechatArticleOpToCache LPush: 操作类型:%s,公众号id:%d", source, wechatPlatformId))
  23. if err != nil {
  24. fmt.Println("AddWechatArticleOpToCache LPush Err:" + err.Error())
  25. }
  26. return true
  27. }
  28. return false
  29. }
  30. // RefreshWechatPlatform
  31. // @Description: 刷新公众号
  32. // @author: Roc
  33. // @datetime 2025-03-14 18:46:05
  34. // @param cont context.Context
  35. // @return err error
  36. func RefreshWechatPlatform(cont context.Context) (err error) {
  37. //utils.FileLog.Debug("RefreshWechatPlatform:", time.Now().Format(utils.FormatDateTime))
  38. //obj := new(rag.WechatPlatform)
  39. //platformList, tmpErr := obj.GetListByCondition(` AND enabled = 1 `, []interface{}{}, 0, 100000)
  40. //if tmpErr != nil {
  41. // err = tmpErr
  42. // return
  43. //}
  44. //
  45. //for _, v := range platformList {
  46. // AddWechatArticleOpToCache(v.WechatPlatformId, "refresh")
  47. // time.Sleep(1 * time.Minute)
  48. //}
  49. return
  50. }