selection_detail.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/middleware"
  7. "youngee_b_api/model/http_model"
  8. "youngee_b_api/service/selection_service"
  9. "youngee_b_api/util"
  10. )
  11. func WrapSelectionDetailHandler(ctx *gin.Context) {
  12. handler := newSelectionDetail(ctx)
  13. baseRun(handler)
  14. }
  15. type SelectionDetailHandler struct {
  16. ctx *gin.Context
  17. req *http_model.SelectionDetailRequest
  18. resp *http_model.CommonResponse
  19. }
  20. func (s SelectionDetailHandler) getContext() *gin.Context {
  21. return s.ctx
  22. }
  23. func (s SelectionDetailHandler) getResponse() interface{} {
  24. return s.resp
  25. }
  26. func (s SelectionDetailHandler) getRequest() interface{} {
  27. return s.req
  28. }
  29. func (s SelectionDetailHandler) run() {
  30. enterpriseID := middleware.GetSessionAuth(s.ctx).EnterpriseID
  31. res, err := selection_service.Selection.GetSelectionDetail(s.ctx, s.req.SelectionId, enterpriseID)
  32. if err != nil {
  33. logrus.Errorf("[GetSelectionDetail] call Show err:%+v\n", err)
  34. util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, "")
  35. logrus.Info("GetSelectionDetail fail,req:%+v", s.req)
  36. return
  37. }
  38. s.resp.Message = "成功查询项目"
  39. s.resp.Data = res
  40. }
  41. func (s SelectionDetailHandler) checkParam() error {
  42. return nil
  43. }
  44. func newSelectionDetail(ctx *gin.Context) *SelectionDetailHandler {
  45. return &SelectionDetailHandler{
  46. ctx: ctx,
  47. req: http_model.NewSelectionDetailRequest(),
  48. resp: http_model.NewSelectionDetailResponse(),
  49. }
  50. }