reason.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. package http
  2. import (
  3. "go-common/app/admin/main/manager/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // cateSecExtList .
  8. func cateSecExtList(c *bm.Context) {
  9. arg := new(model.CateSecExt)
  10. if err := c.Bind(arg); err != nil {
  11. return
  12. }
  13. c.JSON(mngSvc.CateSecExtList(c, arg))
  14. }
  15. // AssociationList .
  16. func associationList(c *bm.Context) {
  17. // Display all record
  18. arg := new(model.Association)
  19. if err := c.Bind(arg); err != nil {
  20. return
  21. }
  22. if arg.BusinessID < 0 {
  23. c.JSON(nil, ecode.RequestErr)
  24. return
  25. }
  26. c.JSON(mngSvc.AssociationList(c, arg))
  27. }
  28. // addCateSecExt .
  29. func addCateSecExt(c *bm.Context) {
  30. arg := new(model.CateSecExt)
  31. if err := c.Bind(arg); err != nil {
  32. return
  33. }
  34. c.JSON(nil, mngSvc.AddCateSecExt(c, arg))
  35. }
  36. // updateCateSecExt .
  37. func updateCateSecExt(c *bm.Context) {
  38. arg := new(model.CateSecExt)
  39. if err := c.Bind(arg); err != nil {
  40. return
  41. }
  42. if arg.ID <= 0 {
  43. c.JSON(nil, ecode.RequestErr)
  44. return
  45. }
  46. c.JSON(nil, mngSvc.UpdateCateSecExt(c, arg))
  47. }
  48. // banCateSecExt .
  49. func banCateSecExt(c *bm.Context) {
  50. arg := new(model.CateSecExt)
  51. if err := c.Bind(arg); err != nil {
  52. return
  53. }
  54. if arg.ID <= 0 {
  55. c.JSON(nil, ecode.RequestErr)
  56. return
  57. }
  58. c.JSON(nil, mngSvc.BanCateSecExt(c, arg))
  59. }
  60. // addAssociation .
  61. func addAssociation(c *bm.Context) {
  62. arg := new(model.Association)
  63. if err := c.Bind(arg); err != nil {
  64. return
  65. }
  66. c.JSON(nil, mngSvc.AddAssociation(c, arg))
  67. }
  68. // updateAssociation .
  69. func updateAssociation(c *bm.Context) {
  70. arg := new(model.Association)
  71. if err := c.Bind(arg); err != nil {
  72. return
  73. }
  74. if arg.ID <= 0 {
  75. c.JSON(nil, ecode.RequestErr)
  76. return
  77. }
  78. c.JSON(nil, mngSvc.UpdateAssociation(c, arg))
  79. }
  80. // banAssocaition .
  81. func banAssociation(c *bm.Context) {
  82. arg := new(model.Association)
  83. if err := c.Bind(arg); err != nil {
  84. return
  85. }
  86. if arg.ID <= 0 {
  87. c.JSON(nil, ecode.RequestErr)
  88. return
  89. }
  90. c.JSON(nil, mngSvc.BanAssociation(c, arg))
  91. }
  92. // addReason .
  93. func addReason(c *bm.Context) {
  94. arg := new(model.Reason)
  95. if err := c.Bind(arg); err != nil {
  96. return
  97. }
  98. if uid, exists := c.Get("uid"); exists {
  99. arg.UID = uid.(int64)
  100. }
  101. c.JSON(nil, mngSvc.AddReason(c, arg))
  102. }
  103. // updateReason .
  104. func updateReason(c *bm.Context) {
  105. arg := new(model.Reason)
  106. if err := c.Bind(arg); err != nil {
  107. return
  108. }
  109. if uid, exists := c.Get("uid"); exists {
  110. arg.UID = uid.(int64)
  111. }
  112. if arg.ID <= 0 {
  113. c.JSON(nil, ecode.RequestErr)
  114. return
  115. }
  116. c.JSON(nil, mngSvc.UpdateReason(c, arg))
  117. }
  118. // reasonList .
  119. func reasonList(c *bm.Context) {
  120. arg := new(model.SearchReasonParams)
  121. if err := c.Bind(arg); err != nil {
  122. return
  123. }
  124. data, total, err := mngSvc.ReasonList(c, arg)
  125. if err != nil {
  126. c.JSON(nil, err)
  127. return
  128. }
  129. page := map[string]int64{
  130. "num": arg.PN,
  131. "size": arg.PS,
  132. "total": total,
  133. }
  134. c.JSON(map[string]interface{}{
  135. "page": page,
  136. "data": data,
  137. }, err)
  138. }
  139. // batchUpdateReasonState .
  140. func batchUpdateReasonState(c *bm.Context) {
  141. arg := new(model.BatchUpdateReasonState)
  142. if err := c.Bind(arg); err != nil {
  143. return
  144. }
  145. c.JSON(nil, mngSvc.BatchUpdateReasonState(c, arg))
  146. }
  147. // dropList .
  148. func dropDownList(c *bm.Context) {
  149. arg := new(model.Association)
  150. if err := c.Bind(arg); err != nil {
  151. return
  152. }
  153. if arg.BusinessID < 0 {
  154. c.JSON(nil, ecode.RequestErr)
  155. return
  156. }
  157. c.JSON(mngSvc.DropDownList(c, arg))
  158. }
  159. // businessAttr .
  160. func businessAttr(c *bm.Context) {
  161. arg := &model.BusinessAttr{}
  162. if err := c.Bind(arg); err != nil {
  163. c.JSON(nil, ecode.RequestErr)
  164. return
  165. }
  166. c.JSON(mngSvc.BusinessAttr(c, arg))
  167. }