mng_v2.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package http
  2. import (
  3. "go-common/app/admin/main/search/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func businessAllV2(c *bm.Context) {
  7. c.JSON(svr.BusinessAllV2(c))
  8. }
  9. func businessInfoV2(c *bm.Context) {
  10. p := new(struct {
  11. Name string `form:"name" validate:"required"`
  12. })
  13. if err := c.Bind(p); err != nil {
  14. return
  15. }
  16. c.JSON(svr.BusinessInfoV2(c, p.Name))
  17. }
  18. func businessAdd(c *bm.Context) {
  19. p := new(struct {
  20. Pid int64 `form:"pid" validate:"required,min=1"`
  21. Name string `form:"name" validate:"required"`
  22. Description string `form:"description" validate:"required"`
  23. })
  24. if err := c.Bind(p); err != nil {
  25. return
  26. }
  27. c.JSON(svr.BusinessAdd(c, p.Pid, p.Name, p.Description))
  28. }
  29. func businessUpdate(c *bm.Context) {
  30. p := new(struct {
  31. Name string `form:"name" validate:"required"`
  32. Field string `form:"field" validate:"required"`
  33. Value string `form:"value"`
  34. })
  35. if err := c.Bind(p); err != nil {
  36. return
  37. }
  38. c.JSON(svr.BusinessUpdate(c, p.Name, p.Field, p.Value))
  39. }
  40. func assetDBTables(c *bm.Context) {
  41. c.JSON(svr.AssetDBTables(c))
  42. }
  43. func assetDBConnect(c *bm.Context) {
  44. p := new(struct {
  45. Host string `form:"host" validate:"required"`
  46. Port string `form:"port" validate:"required"`
  47. User string `form:"user" validate:"required"`
  48. Password string `form:"password" validate:"required"`
  49. })
  50. if err := c.Bind(p); err != nil {
  51. return
  52. }
  53. c.JSON(svr.AssetDBConnect(c, p.Host, p.Port, p.User, p.Password))
  54. }
  55. func assetDBAdd(c *bm.Context) {
  56. p := new(struct {
  57. Name string `form:"name" validate:"required"`
  58. Description string `form:"description"`
  59. Host string `form:"host" validate:"required"`
  60. Port string `form:"port" validate:"required"`
  61. User string `form:"user" validate:"required"`
  62. Password string `form:"password" validate:"required"`
  63. })
  64. if err := c.Bind(p); err != nil {
  65. return
  66. }
  67. c.JSON(svr.AssetDBAdd(c, p.Name, p.Description, p.Host, p.Port, p.User, p.Password))
  68. }
  69. func assetTableAdd(c *bm.Context) {
  70. p := new(struct {
  71. DB string `form:"db" validate:"required"`
  72. Regex string `form:"regex" validate:"required"`
  73. Fields string `form:"fields" validate:"required"`
  74. Description string `form:"description"`
  75. })
  76. if err := c.Bind(p); err != nil {
  77. return
  78. }
  79. c.JSON(svr.AssetTableAdd(c, p.DB, p.Regex, p.Fields, p.Description))
  80. }
  81. func updateAssetTable(c *bm.Context) {
  82. p := new(struct {
  83. Name string `form:"name" validate:"required"`
  84. Fields string `form:"fields" validate:"required"`
  85. })
  86. if err := c.Bind(p); err != nil {
  87. return
  88. }
  89. c.JSON(svr.UpdateAssetTable(c, p.Name, p.Fields))
  90. }
  91. func assetInfoV2(c *bm.Context) {
  92. p := new(struct {
  93. Name string `form:"name" validate:"required"`
  94. })
  95. if err := c.Bind(p); err != nil {
  96. return
  97. }
  98. c.JSON(svr.AssetInfoV2(c, p.Name))
  99. }
  100. func assetShowTables(c *bm.Context) {
  101. p := new(struct {
  102. DB string `form:"db" validate:"required"`
  103. })
  104. if err := c.Bind(p); err != nil {
  105. return
  106. }
  107. c.JSON(svr.AssetShowTables(c, p.DB))
  108. }
  109. func assetTableFields(c *bm.Context) {
  110. p := new(struct {
  111. DB string `form:"db" validate:"required"`
  112. Regex string `form:"regex" validate:"required"`
  113. })
  114. if err := c.Bind(p); err != nil {
  115. return
  116. }
  117. fs, count, err := svr.AssetTableFields(c, p.DB, p.Regex)
  118. data := &struct {
  119. Fields []*model.TableField `json:"fields"`
  120. Count int `json:"count"`
  121. }{
  122. Fields: fs,
  123. Count: count,
  124. }
  125. c.JSON(data, err)
  126. }
  127. func clusterOwners(c *bm.Context) {
  128. c.JSON(svr.ClusterOwners(), nil)
  129. }