mng.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package http
  2. import (
  3. "go-common/app/admin/main/search/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func businessList(ctx *bm.Context) {
  7. p := &model.ParamMngBusiness{}
  8. if err := ctx.Bind(p); err != nil {
  9. return
  10. }
  11. list, total, err := svr.BusinessList(ctx, p.Name, p.Pn, p.Ps)
  12. if err != nil {
  13. ctx.JSON(nil, err)
  14. return
  15. }
  16. data := make(map[string]interface{}, 2)
  17. data["list"] = list
  18. data["page"] = &model.Page{
  19. Pn: p.Pn,
  20. Ps: p.Ps,
  21. Total: total,
  22. }
  23. ctx.JSON(data, nil)
  24. }
  25. func businessAll(ctx *bm.Context) {
  26. ctx.JSON(svr.BusinessAll(ctx))
  27. }
  28. func businessInfo(ctx *bm.Context) {
  29. p := &model.ParamMngBusiness{}
  30. if err := ctx.Bind(p); err != nil {
  31. return
  32. }
  33. ctx.JSON(svr.BusinessInfo(ctx, p.ID))
  34. }
  35. func addBusiness(ctx *bm.Context) {
  36. p := &model.ParamMngBusiness{}
  37. if err := ctx.Bind(p); err != nil {
  38. return
  39. }
  40. b := &model.MngBusiness{Name: p.Name, Desc: p.Desc, AppsJSON: "[]"}
  41. ctx.JSON(svr.AddBusiness(ctx, b))
  42. }
  43. func updateBusiness(ctx *bm.Context) {
  44. p := &model.ParamMngBusiness{}
  45. if err := ctx.Bind(p); err != nil {
  46. return
  47. }
  48. b := &model.MngBusiness{ID: p.ID, Name: p.Name, Desc: p.Desc, AppsJSON: p.Apps}
  49. ctx.JSON(nil, svr.UpdateBusiness(ctx, b))
  50. }
  51. func updateBusinessApp(ctx *bm.Context) {
  52. p := &model.ParamMngBusinessApp{}
  53. if err := ctx.Bind(p); err != nil {
  54. return
  55. }
  56. ctx.JSON(nil, svr.UpdateBusinessApp(ctx, p.Business, p.App, p.IncrWay, p.IsJob, p.IncrOpen))
  57. }
  58. func assetList(ctx *bm.Context) {
  59. p := &model.ParamMngAsset{}
  60. if err := ctx.Bind(p); err != nil {
  61. return
  62. }
  63. list, total, err := svr.AssetList(ctx, p.Type, p.Name, p.Pn, p.Ps)
  64. if err != nil {
  65. ctx.JSON(nil, err)
  66. return
  67. }
  68. data := make(map[string]interface{}, 2)
  69. data["list"] = list
  70. data["page"] = &model.Page{
  71. Pn: p.Pn,
  72. Ps: p.Ps,
  73. Total: total,
  74. }
  75. ctx.JSON(data, nil)
  76. }
  77. func assetAll(ctx *bm.Context) {
  78. ctx.JSON(svr.AssetAll(ctx))
  79. }
  80. func assetInfo(ctx *bm.Context) {
  81. p := &model.ParamMngAsset{}
  82. if err := ctx.Bind(p); err != nil {
  83. return
  84. }
  85. ctx.JSON(svr.AssetInfo(ctx, p.ID))
  86. }
  87. func addAsset(ctx *bm.Context) {
  88. p := &model.ParamMngAsset{}
  89. if err := ctx.Bind(p); err != nil {
  90. return
  91. }
  92. a := &model.MngAsset{Name: p.Name, Type: p.Type, Config: p.Config, Desc: p.Desc}
  93. ctx.JSON(svr.AddAsset(ctx, a))
  94. }
  95. func updateAsset(ctx *bm.Context) {
  96. p := &model.ParamMngAsset{}
  97. if err := ctx.Bind(p); err != nil {
  98. return
  99. }
  100. a := &model.MngAsset{ID: p.ID, Name: p.Name, Type: p.Type, Config: p.Config, Desc: p.Desc}
  101. ctx.JSON(nil, svr.UpdateAsset(ctx, a))
  102. }
  103. func appList(ctx *bm.Context) {
  104. p := &model.MngApp{}
  105. if err := ctx.Bind(p); err != nil {
  106. return
  107. }
  108. ctx.JSON(svr.AppList(ctx, p.Business))
  109. }
  110. func appInfo(ctx *bm.Context) {
  111. p := &model.MngApp{}
  112. if err := ctx.Bind(p); err != nil {
  113. return
  114. }
  115. ctx.JSON(svr.AppInfo(ctx, p.ID))
  116. }
  117. func addApp(ctx *bm.Context) {
  118. p := &model.MngApp{}
  119. if err := ctx.Bind(p); err != nil {
  120. return
  121. }
  122. ctx.JSON(svr.AddApp(ctx, p))
  123. }
  124. func updateApp(ctx *bm.Context) {
  125. p := &model.MngApp{}
  126. if err := ctx.Bind(p); err != nil {
  127. return
  128. }
  129. ctx.JSON(nil, svr.UpdateApp(ctx, p))
  130. }
  131. func countlist(ctx *bm.Context) {
  132. ctx.JSON(svr.MngCountList(ctx))
  133. }
  134. func count(ctx *bm.Context) {
  135. p := &model.MngCount{}
  136. if err := ctx.Bind(p); err != nil {
  137. return
  138. }
  139. ctx.JSON(svr.MngCount(ctx, p))
  140. }
  141. func percent(ctx *bm.Context) {
  142. p := &model.MngCount{}
  143. if err := ctx.Bind(p); err != nil {
  144. return
  145. }
  146. ctx.JSON(svr.MngPercent(ctx, p))
  147. }