rpc.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. package model
  2. import (
  3. xtime "go-common/library/time"
  4. "time"
  5. )
  6. // ArgArticle .
  7. type ArgArticle struct {
  8. Action int
  9. Aid int64
  10. Category int64
  11. Title string
  12. Summary string
  13. BannerURL string
  14. TemplateID int32
  15. State int32
  16. Mid int64
  17. Reprint int32
  18. ImageURLs []string
  19. OriginImageURLs []string
  20. Tags []string
  21. Content string
  22. Words int64
  23. DynamicIntro string
  24. ActivityID int64
  25. ListID int64
  26. RealIP string
  27. MediaID int64
  28. Spoiler int32
  29. }
  30. // ArgAid .
  31. type ArgAid struct {
  32. Aid int64
  33. RealIP string
  34. }
  35. // ArgPtime .
  36. type ArgPtime struct {
  37. Aid int64
  38. PubTime int64
  39. RealIP string
  40. }
  41. // ArgAidMid .
  42. type ArgAidMid struct {
  43. Aid int64
  44. Mid int64
  45. RealIP string
  46. }
  47. // ArgAids .
  48. type ArgAids struct {
  49. Aids []int64
  50. RealIP string
  51. }
  52. // ArgMid .
  53. type ArgMid struct {
  54. Mid int64
  55. RealIP string
  56. }
  57. // ArgMidAids .
  58. type ArgMidAids struct {
  59. Mid int64
  60. Aids []int64
  61. RealIP string
  62. }
  63. // ArgCreationArts .
  64. type ArgCreationArts struct {
  65. Mid int64
  66. Sort int
  67. Group int
  68. Category int
  69. Pn, Ps int
  70. RealIP string
  71. }
  72. // ArgStats .
  73. type ArgStats struct {
  74. *Stats
  75. Aid int64
  76. }
  77. // ArgIP .
  78. type ArgIP struct {
  79. RealIP string
  80. }
  81. // ArgUpsArts .
  82. type ArgUpsArts struct {
  83. Mids []int64
  84. Pn, Ps int
  85. RealIP string
  86. }
  87. // ArgUpArts .
  88. type ArgUpArts struct {
  89. Mid int64
  90. Pn, Ps int
  91. Sort int
  92. RealIP string
  93. }
  94. // ArgRecommends .
  95. type ArgRecommends struct {
  96. Cid int64
  97. Sort int
  98. Aids []int64
  99. Pn, Ps int
  100. RealIP string
  101. }
  102. // ArgUpDraft .
  103. type ArgUpDraft struct {
  104. Mid int64
  105. Pn, Ps int
  106. RealIP string
  107. }
  108. // ArgAidCid .
  109. type ArgAidCid struct {
  110. Aid int64
  111. Cid int64
  112. RealIP string
  113. }
  114. // ArgAidContent .
  115. type ArgAidContent struct {
  116. Aid int64
  117. Content string
  118. RealIP string
  119. }
  120. // ArgFav .
  121. type ArgFav struct {
  122. Mid int64
  123. Pn, Ps int
  124. RealIP string
  125. }
  126. // ArgAuthor .
  127. type ArgAuthor struct {
  128. Mid int64
  129. RealIP string
  130. }
  131. // ArgSort .
  132. type ArgSort struct {
  133. Aid int64
  134. Changed [][2]int64
  135. RealIP string
  136. }
  137. // ArgNewArt .
  138. type ArgNewArt struct {
  139. PubTime int64
  140. RealIP string
  141. }
  142. // TransformArticle .
  143. func TransformArticle(arg *ArgArticle) *Article {
  144. a := &Article{
  145. Meta: &Meta{
  146. ID: arg.Aid,
  147. Category: &Category{ID: arg.Category},
  148. Title: arg.Title,
  149. Summary: arg.Summary,
  150. BannerURL: arg.BannerURL,
  151. TemplateID: arg.TemplateID,
  152. State: arg.State,
  153. Author: &Author{Mid: arg.Mid},
  154. Reprint: arg.Reprint,
  155. ImageURLs: arg.ImageURLs,
  156. OriginImageURLs: arg.OriginImageURLs,
  157. Words: arg.Words,
  158. Dynamic: arg.DynamicIntro,
  159. Media: &Media{MediaID: arg.MediaID, Spoiler: arg.Spoiler},
  160. },
  161. Content: arg.Content,
  162. }
  163. for _, t := range arg.Tags {
  164. a.Tags = append(a.Tags, &Tag{Name: t})
  165. }
  166. return a
  167. }
  168. // TransformDraft .
  169. func TransformDraft(arg *ArgArticle) *Draft {
  170. return &Draft{
  171. Article: &Article{
  172. Meta: &Meta{
  173. ID: arg.Aid,
  174. Author: &Author{Mid: arg.Mid},
  175. Category: &Category{ID: arg.Category},
  176. Title: arg.Title,
  177. Summary: arg.Summary,
  178. BannerURL: arg.BannerURL,
  179. TemplateID: arg.TemplateID,
  180. Reprint: arg.Reprint,
  181. ImageURLs: arg.ImageURLs,
  182. OriginImageURLs: arg.OriginImageURLs,
  183. Mtime: xtime.Time(time.Now().Unix()),
  184. Dynamic: arg.DynamicIntro,
  185. Media: &Media{MediaID: arg.MediaID, Spoiler: arg.Spoiler},
  186. },
  187. Content: arg.Content,
  188. },
  189. Tags: arg.Tags,
  190. ListID: arg.ListID,
  191. }
  192. }
  193. // ArgForce force update
  194. type ArgForce struct {
  195. Force bool
  196. RealIP string
  197. }