selection_detail.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. s.resp.Status = 20000
  41. return
  42. }
  43. func (s SelectionDetailHandler) checkParam() error {
  44. return nil
  45. }
  46. func newSelectionDetail(ctx *gin.Context) *SelectionDetailHandler {
  47. return &SelectionDetailHandler{
  48. ctx: ctx,
  49. req: http_model.NewSelectionDetailRequest(),
  50. resp: http_model.NewSelectionDetailResponse(),
  51. }
  52. }