Browse Source

结束任务

lin-jim-leon 8 months ago
parent
commit
ec5d250b01
2 changed files with 77 additions and 0 deletions
  1. 60 0
      handler/selection_end.go
  2. 17 0
      model/http_model/EndSelectionRequest.go

+ 60 - 0
handler/selection_end.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapEndSelectionHandler(ctx *gin.Context) {
+	handler := newEndSelectionHandler(ctx)
+	BaseRun(handler)
+}
+
+type EndSelection struct {
+	ctx  *gin.Context
+	req  *http_model.EndSelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (g EndSelection) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g EndSelection) getResponse() interface{} {
+	return g.resp
+}
+
+func (g EndSelection) getRequest() interface{} {
+	return g.req
+}
+
+func (g EndSelection) run() {
+	data := http_model.EndSelectionRequest{}
+	data = *g.req
+	res, err := service.Selection.End(g.ctx, data)
+	if err != nil {
+		logrus.Errorf("[EndSelection] call EndSelection err:%+v\n", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
+		logrus.Info("EndSelection fail,req:%+v", g.req)
+		return
+	}
+	g.resp.Message = "结束带货任务成功"
+	g.resp.Data = res
+
+}
+
+func (g EndSelection) checkParam() error {
+	return nil
+}
+
+func newEndSelectionHandler(ctx *gin.Context) *EndSelection {
+	return &EndSelection{
+		ctx:  ctx,
+		req:  http_model.NewEndSelectionRequest(),
+		resp: http_model.NewEndSelectionResponse(),
+	}
+}

+ 17 - 0
model/http_model/EndSelectionRequest.go

@@ -0,0 +1,17 @@
+package http_model
+
+type EndSelectionRequest struct {
+	SelectionId string `json:"selection_id"`
+}
+
+type EndSelectionData struct {
+	SelectionId string `json:"selection_id"`
+}
+
+func NewEndSelectionRequest() *EndSelectionRequest { return new(EndSelectionRequest) }
+
+func NewEndSelectionResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(EndSelectionData)
+	return resp
+}