project.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package http
  2. import (
  3. "go-common/app/admin/ep/saga/model"
  4. bm "go-common/library/net/http/blademaster"
  5. "go-common/library/net/http/blademaster/binding"
  6. )
  7. // @params EmptyReq
  8. // @router get /ep/admin/saga/v1/projects/favorite
  9. // @response FavoriteProjectsResp
  10. func favoriteProjects(ctx *bm.Context) {
  11. var (
  12. req = &model.Pagination{}
  13. err error
  14. userName string
  15. )
  16. if err = ctx.Bind(req); err != nil {
  17. ctx.JSON(nil, err)
  18. return
  19. }
  20. if userName, err = getUsername(ctx); err != nil {
  21. ctx.JSON(nil, err)
  22. return
  23. }
  24. ctx.JSON(srv.FavoriteProjects(ctx, req, userName))
  25. }
  26. // @params EditFavoriteReq
  27. // @router post /ep/admin/saga/v1/projects/favorite/edit
  28. // @response EmptyResp
  29. func editFavorite(ctx *bm.Context) {
  30. var (
  31. req = &model.EditFavoriteReq{}
  32. err error
  33. userName string
  34. )
  35. if err = ctx.BindWith(req, binding.JSON); err != nil {
  36. ctx.JSON(nil, err)
  37. return
  38. }
  39. if userName, err = getUsername(ctx); err != nil {
  40. ctx.JSON(nil, err)
  41. return
  42. }
  43. ctx.JSON(srv.EditFavorite(ctx, req, userName))
  44. }
  45. func queryCommonProjects(ctx *bm.Context) {
  46. ctx.JSON(srv.QueryCommonProjects(ctx))
  47. }
  48. // @params QueryProjectInfoRequest
  49. // @router get /ep/admin/saga/v1/data/project
  50. // @response ProjectsResp
  51. func queryProjectInfo(c *bm.Context) {
  52. var (
  53. req = &model.ProjectInfoRequest{}
  54. err error
  55. )
  56. if err = c.Bind(req); err != nil {
  57. return
  58. }
  59. if err = req.Verify(); err != nil {
  60. c.JSON(nil, err)
  61. return
  62. }
  63. c.JSON(srv.QueryProjectInfo(c, req))
  64. }