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/saleChance.go |  100 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 69 insertions(+), 31 deletions(-)

diff --git a/api/v1/saleChance.go b/api/v1/saleChance.go
index 9b4b26d..e8144c6 100644
--- a/api/v1/saleChance.go
+++ b/api/v1/saleChance.go
@@ -7,8 +7,8 @@
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
+	"aps_crm/utils"
 	"github.com/gin-gonic/gin"
-	"strconv"
 )
 
 type SaleChanceApi struct{}
@@ -48,17 +48,17 @@
 //	@Tags		SaleChance
 //	@Summary	鍒犻櫎閿�鍞満浼�
 //	@Produce	application/json
-//	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
+//	@Param		object	body		request.DeleteSaleChance true	"鏌ヨ鍙傛暟"
 //	@Success	200	{object}	contextx.Response{}
-//	@Router		/api/saleChance/delete/{id} [delete]
+//	@Router		/api/saleChance/delete [delete]
 func (s *SaleChanceApi) Delete(c *gin.Context) {
-	ctx, ok := contextx.NewContext(c, nil)
+	var params request.DeleteSaleChance
+	ctx, ok := contextx.NewContext(c, &params)
 	if !ok {
 		return
 	}
 
-	id, _ := strconv.Atoi(c.Param("id"))
-	errCode := saleChanceService.DeleteSaleChance(id)
+	errCode := saleChanceService.DeleteSaleChance(params.Ids)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
@@ -103,30 +103,6 @@
 	}
 
 	ctx.Ok()
-}
-
-// List
-//
-//	@Tags		SaleChance
-//	@Summary	鑾峰彇閿�鍞満浼氬垪琛�
-//	@Produce	application/json
-//	@Success	200	{object}	contextx.Response{data=response.SaleChanceResponse}
-//	@Router		/api/saleChance/list [get]
-func (s *SaleChanceApi) List(c *gin.Context) {
-	ctx, ok := contextx.NewContext(c, nil)
-	if !ok {
-		return
-	}
-
-	errCode, list := saleChanceService.GetSaleChanceList()
-	if errCode != ecode.OK {
-		ctx.Fail(errCode)
-		return
-	}
-
-	ctx.OkWithDetailed(response.SaleChanceResponse{
-		List: list,
-	})
 }
 
 // checkSaleChanceParams
@@ -186,7 +162,7 @@
 	sc.PossibilitiesId = saleChance.Possibilities
 	sc.Budget = saleChance.Budget
 	sc.ProjectedAmount = saleChance.ProjectedAmount
-	sc.Currency = constvar.CurrencyType(saleChance.Currency)
+	sc.Currency = saleChance.Currency
 	sc.StatusId = saleChance.StatusId
 	sc.PainPoints = saleChance.PainPoints
 	sc.WhetherEstablished = saleChance.WhetherEstablished
@@ -208,3 +184,65 @@
 
 	return ecode.OK, sc
 }
+
+// List
+//
+//	@Tags		SaleChance
+//	@Summary	閿�鍞満浼氬垪琛�
+//	@Produce	application/json
+//	@Param		object	body		request.GetSaleChanceList	true	"鍙傛暟"
+//
+// @Success	200		{object}	contextx.Response{data=response.SaleChanceResponse}
+//
+//	@Router		/api/saleChance/list [post]
+func (con *SaleChanceApi) List(c *gin.Context) {
+	var params request.GetSaleChanceList
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	userInfo := utils.GetUserInfo(c)
+	if userInfo.UserType == constvar.UserTypeSub {
+		if params.SearchMap == nil {
+			params.SearchMap = make(map[string]interface{}, 0)
+		}
+		params.SearchMap["member_id"] = userInfo.CrmUserId
+	}
+
+	saleChances, total, errCode := saleChanceService.GetSaleChanceList(params.Page, params.PageSize, params.SearchMap)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.SaleChanceResponse{
+		List:  saleChances,
+		Count: int(total),
+	})
+}
+
+// Push
+//
+//	@Tags		SaleChance
+//	@Summary	鎺ㄨ繘閿�鍞満浼�
+//	@Produce	application/json
+//	@Param		object	body		request.PushSaleChance  true	"鏌ヨ鍙傛暟"
+//	@Success	200	{object}	contextx.Response{}
+//	@Router		/api/saleChance/push [put]
+func (s *SaleChanceApi) Push(c *gin.Context) {
+	var params request.PushSaleChance
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		ctx.Fail(ecode.InvalidParams)
+		return
+	}
+
+	errCode := saleChanceService.PushSaleChance(params.Id, params.Step)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}

--
Gitblit v1.8.0