subtitle.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/dm2/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/binding"
  8. )
  9. func subtitleLanAdd(c *bm.Context) {
  10. var (
  11. err error
  12. v = new(struct {
  13. Code uint8 `form:"code" validate:"required"`
  14. Lan string `form:"lan" validate:"required"`
  15. DocEn string `form:"doc_en" validate:"required"`
  16. DocZh string `form:"doc_zh" validate:"required"`
  17. IsDelete bool `form:"is_delete"`
  18. })
  19. )
  20. if err = c.Bind(v); err != nil {
  21. return
  22. }
  23. c.JSON(nil, dmSvc.SubtitleLanOp(c, v.Code, v.Lan, v.DocZh, v.DocEn, v.IsDelete))
  24. }
  25. func subtitleFilter(c *bm.Context) {
  26. var (
  27. err error
  28. v = new(struct {
  29. Words string `form:"words" validate:"required"`
  30. })
  31. )
  32. if err = c.Bind(v); err != nil {
  33. return
  34. }
  35. c.JSON(dmSvc.SubtitleFilter(c, v.Words))
  36. }
  37. func draftSave(c *bm.Context) {
  38. var (
  39. v = new(struct {
  40. Oid int64 `form:"oid" validate:"required"`
  41. Type int32 `form:"type" validate:"required"`
  42. Aid int64 `form:"aid" validate:"required" `
  43. Lan string `form:"lan" validate:"required"`
  44. Submit bool `form:"submit"`
  45. Sign bool `form:"sign"`
  46. OriginSubtitleID int64 `form:"origin_subtitle_id"`
  47. Data string `form:"data" validate:"required"`
  48. })
  49. )
  50. mid, _ := c.Get("mid")
  51. if err := c.Bind(v); err != nil {
  52. return
  53. }
  54. c.JSON(dmSvc.SaveSubtitleDraft(c, v.Aid, v.Oid, v.Type, mid.(int64), v.Lan, v.Submit, v.Sign, v.OriginSubtitleID, []byte(v.Data)))
  55. }
  56. func assitAudit(c *bm.Context) {
  57. var (
  58. v = new(struct {
  59. Oid int64 `form:"oid" validate:"required"`
  60. SubtitleID int64 `form:"subtitle_id" validate:"required"`
  61. Pass bool `form:"pass"`
  62. RejectComment string `form:"reject_comment"`
  63. })
  64. )
  65. mid, _ := c.Get("mid")
  66. if err := c.Bind(v); err != nil {
  67. return
  68. }
  69. c.JSON(nil, dmSvc.AuditSubtitle(c, v.Oid, v.SubtitleID, mid.(int64), v.Pass, v.RejectComment))
  70. }
  71. func subtitleDel(c *bm.Context) {
  72. var (
  73. v = new(struct {
  74. Oid int64 `form:"oid" validate:"required"`
  75. SubtitleID int64 `form:"subtitle_id" validate:"required"`
  76. })
  77. )
  78. mid, _ := c.Get("mid")
  79. if err := c.Bind(v); err != nil {
  80. return
  81. }
  82. c.JSON(nil, dmSvc.DelSubtitle(c, v.Oid, v.SubtitleID, mid.(int64)))
  83. }
  84. // 锁定发布字幕
  85. func subtitleLock(c *bm.Context) {
  86. var (
  87. v = new(struct {
  88. Oid int64 `form:"oid" validate:"required"`
  89. Type int32 `form:"type" validate:"required"`
  90. SubtitleID int64 `form:"subtitle_id" validate:"required"`
  91. Lock bool `form:"lock"`
  92. })
  93. )
  94. mid, _ := c.Get("mid")
  95. if err := c.Bind(v); err != nil {
  96. return
  97. }
  98. c.JSON(nil, dmSvc.SubtitleLock(c, v.Oid, v.Type, mid.(int64), v.SubtitleID, v.Lock))
  99. }
  100. // 署名字幕
  101. func subtitleSign(c *bm.Context) {
  102. var (
  103. v = new(struct {
  104. Oid int64 `form:"oid" validate:"required"`
  105. Type int32 `form:"type" validate:"required"`
  106. SubtitleID int64 `form:"subtitle_id" validate:"required"`
  107. Sign bool `form:"sign"`
  108. })
  109. )
  110. mid, _ := c.Get("mid")
  111. if err := c.Bind(v); err != nil {
  112. return
  113. }
  114. c.JSON(nil, dmSvc.SubtitleSign(c, v.Oid, v.Type, mid.(int64), v.SubtitleID, v.Sign))
  115. }
  116. func subtitleArchiveName(c *bm.Context) {
  117. var (
  118. v = new(struct {
  119. Aid int64 `form:"aid" validate:"required"`
  120. })
  121. )
  122. if err := c.Bind(v); err != nil {
  123. return
  124. }
  125. c.JSON(dmSvc.ArchiveName(c, v.Aid))
  126. }
  127. // 查看字幕内容
  128. func subtitleShow(c *bm.Context) {
  129. var (
  130. v = new(struct {
  131. Oid int64 `form:"oid" validate:"required"`
  132. SubtitleID int64 `form:"subtitle_id" validate:"required"`
  133. })
  134. )
  135. mid, _ := c.Get("mid")
  136. if err := c.Bind(v); err != nil {
  137. return
  138. }
  139. c.JSON(dmSvc.SubtitleShow(c, v.Oid, v.SubtitleID, mid.(int64)))
  140. }
  141. func subtitleLans(c *bm.Context) {
  142. var (
  143. v = new(struct {
  144. Oid int64 `form:"oid" validate:"required"`
  145. Type int32 `form:"type" validate:"required"`
  146. })
  147. )
  148. mid, _ := c.Get("mid")
  149. if err := c.Bind(v); err != nil {
  150. return
  151. }
  152. c.JSON(dmSvc.SubtitleLans(c, v.Oid, v.Type, mid.(int64)))
  153. }
  154. func searchAssist(c *bm.Context) {
  155. var (
  156. v = new(struct {
  157. Oid int64 `form:"oid"`
  158. Type int32 `form:"type"`
  159. Aid int64 `form:"aid"`
  160. Status int32 `form:"status"`
  161. Page int32 `form:"page"`
  162. Size int32 `form:"size" validate:"max=100"`
  163. })
  164. )
  165. mid, _ := c.Get("mid")
  166. if err := c.Bind(v); err != nil {
  167. return
  168. }
  169. c.JSON(dmSvc.SearchAssist(c, v.Aid, v.Oid, v.Type, mid.(int64), v.Status, v.Page, v.Size))
  170. }
  171. func authorList(c *bm.Context) {
  172. var (
  173. v = new(struct {
  174. Status int32 `form:"status"`
  175. Page int32 `form:"page"`
  176. Size int32 `form:"size" validate:"max=100"`
  177. })
  178. )
  179. mid, _ := c.Get("mid")
  180. if err := c.Bind(v); err != nil {
  181. return
  182. }
  183. c.JSON(dmSvc.SearchAuthor(c, mid.(int64), v.Status, v.Page, v.Size))
  184. }
  185. func subtitlePermission(c *bm.Context) {
  186. var (
  187. v = new(struct {
  188. Aid int64 `form:"aid" validate:"required"`
  189. Oid int64 `form:"oid" validate:"required"`
  190. Type int32 `form:"type" validate:"required"`
  191. })
  192. )
  193. mid, _ := c.Get("mid")
  194. if err := c.Bind(v); err != nil {
  195. return
  196. }
  197. c.JSON(nil, dmSvc.SubtitlePermission(c, v.Aid, v.Oid, v.Type, mid.(int64)))
  198. }
  199. // waveForm .
  200. func waveForm(c *bm.Context) {
  201. var (
  202. err error
  203. v = new(struct {
  204. Aid int64 `form:"aid" validate:"required"`
  205. Oid int64 `form:"oid" validate:"required"`
  206. Type int32 `form:"type" validate:"required"`
  207. })
  208. )
  209. mid, _ := c.Get("mid")
  210. if err = c.Bind(v); err != nil {
  211. return
  212. }
  213. c.JSON(dmSvc.WaveForm(c, v.Aid, v.Oid, v.Type, mid.(int64)))
  214. }
  215. // waveFormCallBack .
  216. func waveFormCallBack(c *bm.Context) {
  217. var (
  218. oid int64
  219. err error
  220. v = new(struct {
  221. OK int32 `json:"ok"`
  222. Info string `json:"info"`
  223. })
  224. )
  225. if err = c.BindWith(v, binding.JSON); err != nil {
  226. return
  227. }
  228. if oid, err = strconv.ParseInt(c.Request.URL.Query().Get("oid"), 10, 64); err != nil {
  229. c.JSON(nil, ecode.RequestErr)
  230. return
  231. }
  232. c.JSON(nil, dmSvc.WaveFormCallBack(c, oid, 1, v.OK, v.Info))
  233. }
  234. func subtitleReportAdd(c *bm.Context) {
  235. var (
  236. err error
  237. v = new(model.SubtitleReportAddParam)
  238. )
  239. mid, _ := c.Get("mid")
  240. if err = c.Bind(v); err != nil {
  241. return
  242. }
  243. c.JSON(nil, dmSvc.SubtitleReportAdd(c, mid.(int64), v))
  244. }
  245. func subtitleReportTag(c *bm.Context) {
  246. c.JSON(dmSvc.SubtitleReportList(c))
  247. }