config.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/admin/ep/saga/model"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/binding"
  8. )
  9. func sagaUserList(c *bm.Context) {
  10. c.JSON(srv.SagaUserList(c))
  11. }
  12. func runnerConfig(c *bm.Context) {
  13. session, err := c.Request.Cookie("_AJSESSIONID")
  14. if err != nil {
  15. c.JSON(nil, err)
  16. return
  17. }
  18. c.JSON(srv.QueryAllConfigFile(c, session.Value, false))
  19. }
  20. func sagaConfig(c *bm.Context) {
  21. session, err := c.Request.Cookie("_AJSESSIONID")
  22. if err != nil {
  23. c.JSON(nil, err)
  24. return
  25. }
  26. c.JSON(srv.QueryAllConfigFile(c, session.Value, true))
  27. }
  28. func publicSagaConfig(c *bm.Context) {
  29. req := new(model.TagUpdate)
  30. if err := c.Bind(req); err != nil {
  31. return
  32. }
  33. session, err := c.Request.Cookie("_AJSESSIONID")
  34. if err != nil {
  35. c.JSON(nil, err)
  36. return
  37. }
  38. var user string
  39. if user, err = getUsername(c); err != nil {
  40. c.JSON(nil, err)
  41. return
  42. }
  43. c.JSON(srv.PublicConfig(c, session.Value, user, req.Names, req.Mark, true))
  44. }
  45. func existConfigSaga(c *bm.Context) {
  46. var (
  47. err error
  48. projectID int
  49. )
  50. if projectID, err = strconv.Atoi(c.Request.Form.Get("project_id")); err != nil {
  51. return
  52. }
  53. session, err := c.Request.Cookie("_AJSESSIONID")
  54. if err != nil {
  55. c.JSON(nil, err)
  56. return
  57. }
  58. c.JSON(srv.QueryProjectSagaConfig(c, session.Value, projectID))
  59. }
  60. func releaseSagaConfig(c *bm.Context) {
  61. var (
  62. err error
  63. user string
  64. )
  65. v := new(model.ConfigList)
  66. if err = c.BindWith(v, binding.JSON); err != nil {
  67. return
  68. }
  69. if user, err = getUsername(c); err != nil {
  70. c.JSON(nil, err)
  71. return
  72. }
  73. session, err := c.Request.Cookie("_AJSESSIONID")
  74. if err != nil {
  75. c.JSON(nil, err)
  76. return
  77. }
  78. c.JSON(srv.ReleaseSagaConfig(c, user, session.Value, v))
  79. }
  80. func optionSaga(c *bm.Context) {
  81. session, err := c.Request.Cookie("_AJSESSIONID")
  82. if err != nil {
  83. c.JSON(nil, err)
  84. return
  85. }
  86. projectID := c.Request.Form.Get("project_id")
  87. log.Info("=====optionSaga projectID: %s", projectID)
  88. c.JSON(srv.OptionSaga(c, projectID, session.Value))
  89. }