apm.go 883 B

123456789101112131415161718192021222324252627282930313233343536
  1. package http
  2. import (
  3. "go-common/app/admin/main/config/model"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func apmCopy(c *bm.Context) {
  8. res := map[string]interface{}{}
  9. user := user(c)
  10. v := new(model.ApmCopyReq)
  11. err := c.Bind(v)
  12. if err != nil {
  13. return
  14. }
  15. if _, err = svr.AuthApp(c, user, c.Request.Header.Get("Cookie"), v.TreeID); err != nil {
  16. res["message"] = "服务树权限不足"
  17. c.JSONMap(res, err)
  18. return
  19. }
  20. cnt := 0
  21. if err = svr.DB.Model(&model.App{}).Where("tree_id=?", v.TreeID).Count(&cnt).Error; err != nil {
  22. log.Error("svr.ApmCopy count error(%v)", err)
  23. res["message"] = "查询该服务失败"
  24. c.JSONMap(res, err)
  25. return
  26. }
  27. if cnt <= 0 {
  28. log.Error("svr.ApmCopy count (%v)", cnt)
  29. res["message"] = "未找到该服务"
  30. c.JSONMap(res, err)
  31. return
  32. }
  33. c.JSON(nil, svr.Apm(v.TreeID, v.Name, v.ApmName, user))
  34. }