ugc.go 911 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package web
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/web-goblin/model/web"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _opadd = "add"
  10. _opdel = "del"
  11. _insert = "insert"
  12. _update = "update"
  13. _archive = "archive"
  14. )
  15. // UgcIncrement ugc increment .
  16. func (s *Service) UgcIncrement(ctx context.Context, arg *web.ArcMsg) (err error) {
  17. m := make(map[string]interface{})
  18. if arg.New.CTime != "" {
  19. m["ctime"] = arg.New.CTime
  20. }
  21. m["mtime"] = time.Now().Format("2006-01-02 15:04:05")
  22. if arg.New.PubTime != "" {
  23. m["ptime"] = arg.New.PubTime
  24. }
  25. m["mid"] = arg.New.Mid
  26. m["aid"] = arg.New.Aid
  27. if arg.Action == _insert {
  28. m["action"] = _opadd
  29. }
  30. if arg.Action == _update {
  31. if arg.New.State != arg.Old.State && arg.New.State < 0 {
  32. m["action"] = _opdel
  33. } else {
  34. m["action"] = _update
  35. }
  36. }
  37. if err = s.dao.UgcSearch(ctx, m); err != nil {
  38. log.Error("s.dao.UgcIncre error", err)
  39. }
  40. return
  41. }