blocked.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. package http
  2. import (
  3. "strconv"
  4. model "go-common/app/interface/main/credit/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/xstr"
  9. )
  10. // requirement user status in apply jury.
  11. func blockedUserCard(c *bm.Context) {
  12. var mid, _ = c.Get("mid")
  13. rq, err := creditSvc.BlockedUserCard(c, mid.(int64))
  14. if err != nil {
  15. log.Error("creditSvc.BlockedUserCard(%d) error(%v)", mid, err)
  16. c.JSON(nil, err)
  17. }
  18. c.JSON(rq, nil)
  19. }
  20. func blockedUserList(c *bm.Context) {
  21. var mid, _ = c.Get("mid")
  22. rq, err := creditSvc.BlockedUserList(c, mid.(int64))
  23. if err != nil {
  24. log.Error("creditSvc.BlockedUserList(%d) error(%v)", mid, err)
  25. c.JSON(nil, err)
  26. return
  27. }
  28. c.JSON(rq, nil)
  29. }
  30. func blockedInfo(c *bm.Context) {
  31. var idStr = c.Request.Form.Get("id")
  32. id, err := strconv.ParseInt(idStr, 10, 64)
  33. if err != nil {
  34. log.Error("strconv.ParseInt err(%v)", err)
  35. c.JSON(nil, ecode.RequestErr)
  36. return
  37. }
  38. rq, err := creditSvc.BlockedInfo(c, id)
  39. if err != nil {
  40. log.Error("creditSvc.BlockedInfo(%d) error(%v)", id, err)
  41. c.JSON(nil, err)
  42. return
  43. }
  44. c.JSON(rq, nil)
  45. }
  46. func blockedAppeal(c *bm.Context) {
  47. var (
  48. mid int64
  49. err error
  50. idStr = c.Request.Form.Get("id")
  51. )
  52. midI, ok := c.Get("mid")
  53. if ok {
  54. mid = midI.(int64)
  55. }
  56. id, err := strconv.ParseInt(idStr, 10, 64)
  57. if err != nil {
  58. log.Error("strconv.ParseInt err(%v)", err)
  59. c.JSON(nil, ecode.RequestErr)
  60. return
  61. }
  62. rq, err := creditSvc.BlockedInfoAppeal(c, id, mid)
  63. if err != nil {
  64. log.Error("creditSvc.BlockedInfo(%d) error(%v)", id, err)
  65. c.JSON(nil, err)
  66. return
  67. }
  68. c.JSON(rq, nil)
  69. }
  70. func blockedList(c *bm.Context) {
  71. var err error
  72. v := new(model.ArgBlockedList)
  73. if err = c.Bind(v); err != nil {
  74. return
  75. }
  76. if v.PS <= 0 || v.PS > 10 {
  77. v.PS = 10
  78. }
  79. rq, err := creditSvc.BlockedList(c, v.OType, v.BType, v.PN, v.PS)
  80. if err != nil {
  81. log.Error("creditSvc.Blockedlist(%d,%d) error(%v)", v.OType, v.BType, err)
  82. c.JSON(nil, err)
  83. return
  84. }
  85. c.JSON(rq, nil)
  86. }
  87. func announcementInfo(c *bm.Context) {
  88. idStr := c.Request.Form.Get("id")
  89. id, err := strconv.ParseInt(idStr, 10, 64)
  90. if err != nil {
  91. log.Error("strconv.ParseInt err(%v)", err)
  92. c.JSON(nil, ecode.RequestErr)
  93. return
  94. }
  95. rq, err := creditSvc.AnnouncementInfo(c, id)
  96. if err != nil {
  97. log.Error("creditSvc.AnnouncementInfo(%d) error(%v)", id, err)
  98. c.JSON(nil, err)
  99. return
  100. }
  101. c.JSON(rq, nil)
  102. }
  103. func announcementList(c *bm.Context) {
  104. var (
  105. params = c.Request.Form
  106. tpStr = params.Get("tp")
  107. pnStr = params.Get("pn")
  108. psStr = params.Get("ps")
  109. )
  110. tp, err := strconv.ParseInt(tpStr, 10, 8)
  111. if err != nil {
  112. log.Error("strconv.ParseInt err(%v)", err)
  113. c.JSON(nil, ecode.RequestErr)
  114. return
  115. }
  116. pn, err := strconv.ParseInt(pnStr, 10, 64)
  117. if err != nil || pn < 1 {
  118. log.Error("strconv.ParseInt err(%v)", err)
  119. c.JSON(nil, ecode.RequestErr)
  120. return
  121. }
  122. ps, err := strconv.ParseInt(psStr, 10, 64)
  123. if err != nil {
  124. log.Error("strconv.ParseInt err(%v)", err)
  125. c.JSON(nil, ecode.RequestErr)
  126. return
  127. }
  128. if ps < 0 || ps > 10 {
  129. ps = 10
  130. }
  131. rq, err := creditSvc.AnnouncementList(c, int8(tp), pn, ps)
  132. if err != nil {
  133. log.Error("creditSvc.AnnouncementList( tp %d) error(%v)", tp, err)
  134. c.JSON(nil, err)
  135. return
  136. }
  137. c.JSON(rq, nil)
  138. }
  139. func blockedNumUser(c *bm.Context) {
  140. v := new(model.ArgBlockedNumUser)
  141. if err := c.Bind(v); err != nil {
  142. return
  143. }
  144. bn, err := creditSvc.BlockedNumUser(c, v.MID)
  145. if err != nil {
  146. log.Error("creditSvc.BlockedNumUser(%d) error(%v)", v.MID, err)
  147. c.JSON(nil, err)
  148. return
  149. }
  150. c.JSON(bn, nil)
  151. }
  152. func batchPublishs(c *bm.Context) {
  153. v := new(model.ArgIDs)
  154. if err := c.Bind(v); err != nil {
  155. return
  156. }
  157. pubs, err := creditSvc.BatchPublishs(c, v.IDs)
  158. if err != nil {
  159. log.Error("creditSvc.BatchPublishs(%s) error(%v)", xstr.JoinInts(v.IDs), err)
  160. c.JSON(nil, err)
  161. return
  162. }
  163. c.JSON(pubs, nil)
  164. }
  165. func addBlockedInfo(c *bm.Context) {
  166. var err error
  167. v := new(model.ArgJudgeBlocked)
  168. if err = c.Bind(v); err != nil {
  169. return
  170. }
  171. err = creditSvc.AddBlockedInfo(c, v)
  172. if err != nil {
  173. log.Error("creditSvc.AddBlockedInfo(%+v) error(%v)", v, err)
  174. c.JSON(nil, err)
  175. return
  176. }
  177. c.JSON(nil, nil)
  178. }
  179. func addBatchBlockedInfo(c *bm.Context) {
  180. var err error
  181. v := new(model.ArgJudgeBatchBlocked)
  182. if err = c.Bind(v); err != nil {
  183. return
  184. }
  185. err = creditSvc.AddBatchBlockedInfo(c, v)
  186. if err != nil {
  187. log.Error("creditSvc.AddBatchBlockedInfo(%+v) error(%v)", v, err)
  188. c.JSON(nil, err)
  189. return
  190. }
  191. c.JSON(nil, nil)
  192. }
  193. func blkHistorys(c *bm.Context) {
  194. v := new(model.ArgHistory)
  195. if err := c.Bind(v); err != nil {
  196. return
  197. }
  198. rhs, err := creditSvc.BLKHistorys(c, v)
  199. if err != nil {
  200. log.Error("creditSvc.BLKHistorys(%+v) error(%v)", v, err)
  201. c.JSON(nil, err)
  202. return
  203. }
  204. c.JSON(rhs, nil)
  205. }
  206. func batchBLKInfos(c *bm.Context) {
  207. v := new(model.ArgIDs)
  208. if err := c.Bind(v); err != nil {
  209. return
  210. }
  211. mbi, err := creditSvc.BatchBLKInfos(c, v.IDs)
  212. if err != nil {
  213. log.Error("creditSvc.BatchBLKInfos(%+v) error(%v)", v, err)
  214. c.JSON(nil, err)
  215. return
  216. }
  217. c.JSON(mbi, nil)
  218. }