oper.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "strconv"
  6. "time"
  7. "go-common/app/admin/main/videoup/model/archive"
  8. "strings"
  9. )
  10. func (s *Service) addVideoOper(c context.Context, oper *archive.VideoOper) (err error) {
  11. if oldOper, _ := s.arc.VideoOper(c, oper.VID); oldOper != nil && oldOper.LastID == 1 {
  12. oper.LastID = oldOper.ID
  13. s.arc.AddVideoOper(c, oper.AID, oper.UID, oper.VID, oper.Attribute, oper.Status, oper.LastID, oper.Content, oper.Remark)
  14. return
  15. }
  16. if lastID, _ := s.arc.AddVideoOper(c, oper.AID, oper.UID, oper.VID, oper.Attribute, oper.Status, oper.LastID, oper.Content, oper.Remark); lastID > 0 {
  17. s.arc.UpVideoOper(c, lastID, lastID)
  18. return
  19. }
  20. return
  21. }
  22. func (s *Service) addArchiveOper(c context.Context, oper *archive.ArcOper) (err error) {
  23. if oldOper, _ := s.arc.ArchiveOper(c, oper.Aid); oldOper != nil && oldOper.LastID == 1 {
  24. oper.LastID = oldOper.ID
  25. }
  26. s.arc.AddArcOper(c, oper.Aid, oper.UID, oper.Attribute, oper.TypeID, oper.State, oper.Round, oper.LastID, oper.Content, oper.Remark)
  27. return
  28. }
  29. func (s *Service) diffVideoOper(vp *archive.VideoParam) (conts []string) {
  30. if vp.TagID > 0 {
  31. var operType int8
  32. if vp.Status >= archive.VideoStatusOpen {
  33. operType = archive.OperTypeOpenTag
  34. } else {
  35. operType = archive.OperTypeRecicleTag
  36. }
  37. conts = append(conts, archive.Operformat(operType, "tagid", vp.TagID, archive.OperStyleTwo))
  38. }
  39. if vp.Reason != "" {
  40. conts = append(conts, archive.Operformat(archive.OperTypeAduitReason, "reason", vp.Reason, archive.OperStyleTwo))
  41. }
  42. if vp.TaskID > 0 {
  43. conts = append(conts, archive.Operformat(archive.OperTypeTaskID, "task", vp.TaskID, archive.OperStyleTwo))
  44. }
  45. return
  46. }
  47. func (s *Service) diffArchiveOper(ap *archive.ArcParam, a *archive.Archive, addit *archive.Addit, forbid *archive.ForbidAttr) (conts []string, changeTypeID, changeCopyright, changeTitle, changeCover bool) {
  48. if ap.CanCelMission {
  49. conts = append(conts, archive.Operformat(archive.OperTypeMission, addit.MissionID, 0, archive.OperStyleOne))
  50. }
  51. if ap.Cover != a.Cover {
  52. if strings.HasPrefix(a.Cover, "http://") && strings.Contains(a.Cover, ap.Cover) {
  53. changeCover = false
  54. } else {
  55. changeCover = true
  56. }
  57. }
  58. if ap.Title != a.Title {
  59. changeTitle = true
  60. }
  61. if ap.Copyright != a.Copyright {
  62. changeCopyright = true
  63. conts = append(conts, archive.Operformat(archive.OperTypeCopyright, archive.CopyrightsDesc(a.Copyright), archive.CopyrightsDesc(ap.Copyright), archive.OperStyleOne))
  64. }
  65. if cont, _ := s.diffTypeID(ap.TypeID, a.TypeID, ap.State); cont != "" {
  66. changeTypeID = true
  67. conts = append(conts, cont)
  68. }
  69. if ap.RejectReason != "" && ap.RejectReason != a.RejectReason {
  70. if a.RejectReason == "" {
  71. a.RejectReason = "无"
  72. }
  73. var operType int8
  74. if a.Round > 20 {
  75. operType = archive.OperTypeRejectReason
  76. } else {
  77. operType = archive.OperTypeAduitReason
  78. }
  79. conts = append(conts, archive.Operformat(operType, a.RejectReason, ap.RejectReason, archive.OperStyleOne))
  80. }
  81. if ap.Forward != a.Forward {
  82. conts = append(conts, archive.Operformat(archive.OperTypeForwardID, a.Forward, ap.Forward, archive.OperStyleOne))
  83. }
  84. if ap.Notify {
  85. conts = append(conts, archive.Operformat(archive.OperNotify, "无", "发送通知", archive.OperStyleOne))
  86. }
  87. if forbid == nil || (forbid.OnFlowID != ap.OnFlowID) {
  88. if forbid != nil {
  89. conts = append(conts, archive.Operformat(archive.OperTypeFlowID, s.flowsCache[forbid.OnFlowID], s.flowsCache[ap.OnFlowID], archive.OperStyleOne))
  90. } else {
  91. conts = append(conts, archive.Operformat(archive.OperTypeFlowID, "无", s.flowsCache[ap.OnFlowID], archive.OperStyleOne))
  92. }
  93. }
  94. if ap.PTime != a.PTime {
  95. conts = append(conts, archive.Operformat(archive.OperTypePtime, time.Unix(int64(a.PTime), 0).Format("2006-01-02 15:04:05"), time.Unix(int64(ap.PTime), 0).Format("2006-01-02 15:04:05"), archive.OperStyleOne))
  96. }
  97. if ap.Access != a.Access {
  98. conts = append(conts, archive.Operformat(archive.OperTypeAccess, archive.AccessDesc(a.Access), archive.AccessDesc(ap.Access), archive.OperStyleOne))
  99. }
  100. if ap.Dynamic != addit.Dynamic {
  101. conts = append(conts, archive.Operformat(archive.OperTypeDynamic, addit.Dynamic, ap.Dynamic, archive.OperStyleOne))
  102. }
  103. return
  104. }
  105. func (s *Service) diffBatchArchiveOper(ap *archive.ArcParam, a *archive.Archive) (conts []string) {
  106. if ap.Access != a.Access {
  107. conts = append(conts, archive.Operformat(archive.OperTypeAccess, archive.AccessDesc(a.Access), archive.AccessDesc(ap.Access), archive.OperStyleOne))
  108. }
  109. if ap.PTime != a.PTime {
  110. conts = append(conts, archive.Operformat(archive.OperTypePtime, time.Unix(int64(a.PTime), 0).Format("2006-01-02 15:04:05"), time.Unix(int64(ap.PTime), 0).Format("2006-01-02 15:04:05"), archive.OperStyleOne))
  111. }
  112. if ap.FlagCopyright && ap.Copyright != a.Copyright {
  113. conts = append(conts, archive.Operformat(archive.OperTypeCopyright, archive.CopyrightsDesc(a.Copyright), archive.CopyrightsDesc(ap.Copyright), archive.OperStyleOne))
  114. }
  115. if ap.RejectReason != "" && ap.RejectReason != a.RejectReason {
  116. if a.RejectReason == "" {
  117. a.RejectReason = "无"
  118. }
  119. var operType int8
  120. if a.Round > 20 {
  121. operType = archive.OperTypeRejectReason
  122. } else {
  123. operType = archive.OperTypeAduitReason
  124. }
  125. conts = append(conts, archive.Operformat(operType, a.RejectReason, ap.RejectReason, archive.OperStyleOne))
  126. }
  127. return
  128. }
  129. func (s *Service) diffTypeID(newTypeID, oldTypeID int16, state int8) (cont string, changeTypeID bool) {
  130. if newTypeID != oldTypeID {
  131. changeTypeID = true
  132. var oldCont, newCont string
  133. if ok := s.isTypeID(oldTypeID); ok {
  134. oldCont = s.typeCache[oldTypeID].Name
  135. } else {
  136. oldCont = strconv.Itoa(int(oldTypeID))
  137. }
  138. if ok := s.isTypeID(newTypeID); ok {
  139. newCont = s.typeCache[newTypeID].Name
  140. } else {
  141. newCont = strconv.Itoa(int(newTypeID))
  142. }
  143. cont = archive.Operformat(archive.OperTypeTypeID, oldCont, newCont, archive.OperStyleOne)
  144. if state < 0 {
  145. cont = fmt.Sprintf("%s,过审后生效", cont)
  146. }
  147. }
  148. return
  149. }
  150. //私单修改日志
  151. func (s *Service) diffPorder(c context.Context, aid int64, ap *archive.ArcParam) (conts []string, porder *archive.Porder) {
  152. porder, _ = s.arc.Porder(c, aid)
  153. if porder.IndustryID > 0 {
  154. var yesOrNo = map[int8]string{int8(1): "是", int8(0): "否"}
  155. if porder.IndustryID != ap.IndustryID {
  156. conts = append(conts, archive.Operformat(archive.OperPorderIndustryID, s.porderConfigCache[porder.IndustryID].Name, s.porderConfigCache[ap.IndustryID].Name, archive.OperStyleOne))
  157. }
  158. if porder.Official != ap.Official {
  159. conts = append(conts, archive.Operformat(archive.OperPorderOfficial, yesOrNo[porder.Official], yesOrNo[ap.Official], archive.OperStyleOne))
  160. }
  161. //game ID
  162. if porder.BrandID != ap.BrandID {
  163. conts = append(conts, archive.Operformat(archive.OperPorderBrandID, porder.BrandID, ap.BrandID, archive.OperStyleOne))
  164. }
  165. //custom brandName
  166. if porder.BrandName != ap.BrandName {
  167. conts = append(conts, archive.Operformat(archive.OperPorderBrandName, porder.BrandName, ap.BrandName, archive.OperStyleOne))
  168. }
  169. //porderConfigCache
  170. if porder.ShowType != ap.ShowType {
  171. conts = append(conts, archive.Operformat(archive.OperPorderShowType, porder.ShowType, ap.ShowType, archive.OperStyleOne))
  172. }
  173. if porder.Advertiser != ap.Advertiser {
  174. conts = append(conts, archive.Operformat(archive.OperPorderAdvertiser, porder.Advertiser, ap.Advertiser, archive.OperStyleOne))
  175. }
  176. if porder.Agent != ap.Agent {
  177. conts = append(conts, archive.Operformat(archive.OperPorderAgent, porder.Agent, ap.Agent, archive.OperStyleOne))
  178. }
  179. }
  180. return
  181. }