selection_detail.go 1.4 KB

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