package controller import ( "cold-logistics/app/admin/model" "cold-logistics/app/admin/service" "cold-logistics/app/admin/service/dto" "cold-logistics/common/actions" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "gogs.baozhida.cn/zoie/OAuth-core/api" "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/user" _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response" ) type WaybillLogisticsController struct { api.Api } // GetPage 获取运单物流信息列表 // @Summary 获取运单物流信息列表 // @Description 获取运单物流信息列表 // @Tags 运单物流信息 // @Param waybillNo query string false "运单号" // @Param status query int false "状态" // @Param pageSize query int false "页条数" // @Param page query int false "页码" // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillLogistics}} "{"code": 200, "data": [...]}" // @Router /api/waybill-logistics [get] // @Security Bearer func (e WaybillLogisticsController) GetPage(c *gin.Context) { s := service.WaybillLogistics{} req := dto.WaybillLogisticsGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Query). MakeService(&s.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } list := make([]model.WaybillLogistics, 0) var count int64 err = s.GetPage(&req, &list, &count) if err != nil { e.Error(500, err, err.Error()) return } //e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") e.PageOK(list, int(count), 0, 0, "查询成功") } // Update 修改运单物流 // @Summary 修改运单物流 // @Description 修改运单物流 // @Tags 运单物流信息 // @Accept application/json // @Product application/json // @Param data body dto.WaybillLogisticsUpdateReq true "body" // @Success 200 {string} string "{"code": 200, "message": "修改成功"}" // @Success 200 {string} string "{"code": -1, "message": "修改失败"}" // @Router /api/waybill [put] // @Security Bearer func (e WaybillLogisticsController) Update(c *gin.Context) { s := service.WaybillLogistics{} req := dto.WaybillLogisticsUpdateReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req). MakeService(&s.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } p := actions.GetPermissionFromContext(c) req.SetUpdateBy(user.GetUserId(c)) err = s.Update(&req, p) if err != nil { e.Error(500, err, err.Error()) return } e.OK(nil, "修改成功") }