From 7438f17c0b3a9f79ee5890c554bedc64c362859b Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 13 十月 2023 14:04:59 +0800 Subject: [PATCH] 销售计划简单数据权限 --- api/v1/serviceOrder.go | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 41 insertions(+), 5 deletions(-) diff --git a/api/v1/serviceOrder.go b/api/v1/serviceOrder.go index 3beabbd..887979d 100644 --- a/api/v1/serviceOrder.go +++ b/api/v1/serviceOrder.go @@ -6,6 +6,7 @@ "aps_crm/model/response" "aps_crm/pkg/contextx" "aps_crm/pkg/ecode" + "aps_crm/pkg/structx" "aps_crm/service" "github.com/gin-gonic/gin" "strconv" @@ -28,6 +29,10 @@ } serviceOrder := new(model.ServiceOrder) + if err := structx.AssignTo(params, serviceOrder); err != nil { + ctx.Fail(ecode.ParamsErr) + return + } errCode := service.NewServiceOrderService().AddServiceOrder(serviceOrder) if errCode != ecode.OK { @@ -61,6 +66,29 @@ ctx.Ok() } +// BatchDelete +// @Tags 鏈嶅姟鍗� +// @Summary 鎵归噺鍒犻櫎鏈嶅姟鍗� +// @Produce application/json +// @Param object body request.CommonIds true "鍙傛暟" +// @Success 200 {object} contextx.Response{} +// @Router /api/serviceOrder/delete [delete] +func (s *ServiceOrderApi) BatchDelete(c *gin.Context) { + var params request.CommonIds + ctx, ok := contextx.NewContext(c, ¶ms) + if !ok { + return + } + + errCode := service.NewServiceOrderService().BatchDeleteServiceOrder(params.Ids) + if errCode != ecode.OK { + ctx.Fail(errCode) + return + } + + ctx.Ok() +} + // Update // @Tags 鏈嶅姟鍗曠鐞� // @Summary 鏇存柊鏈嶅姟鍗� @@ -75,7 +103,13 @@ return } - errCode := service.NewServiceOrderService().UpdateServiceOrder(¶ms.ServiceOrder) + serviceOrder := new(model.ServiceOrder) + if err := structx.AssignTo(params, serviceOrder); err != nil { + ctx.Fail(ecode.ParamsErr) + return + } + + errCode := service.NewServiceOrderService().UpdateServiceOrder(serviceOrder) if errCode != ecode.OK { ctx.Fail(errCode) return @@ -88,22 +122,24 @@ // @Tags 鏈嶅姟鍗曠鐞� // @Summary 鑾峰彇鏈嶅姟鍗曞垪琛� // @Produce application/json +// @Param object body request.GetServiceOrderList true "鍙傛暟" // @Success 200 {object} response.ListResponse{data=[]model.ServiceOrder} -// @Router /api/serviceOrder/list [get] +// @Router /api/serviceOrder/list [post] func (s *ServiceOrderApi) List(c *gin.Context) { - ctx, ok := contextx.NewContext(c, nil) + var params request.GetServiceOrderList + ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } - serviceOrder, total, errCode := service.NewServiceOrderService().GetServiceOrderList() + serviceOrder, total, errCode := service.NewServiceOrderService().GetServiceOrderList(params.Page, params.PageSize, params.QueryClass, params.KeywordType, params.Keyword, params.ServiceContractId, params.SalesDetailsId) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.OkWithDetailed(response.ListResponse{ - Data: serviceOrder, + Data: serviceOrder, Count: total, }) } -- Gitblit v1.8.0