From 63b531279a8ab1d609910e7db53add83bbc0b97a Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 17 十月 2023 20:21:01 +0800
Subject: [PATCH] 添加默认数据
---
api/v1/serviceFollowup.go | 114 +++++++++++++++++++++++++++++++++++---------------------
1 files changed, 71 insertions(+), 43 deletions(-)
diff --git a/api/v1/serviceFollowup.go b/api/v1/serviceFollowup.go
index 0a74b42..39af767 100644
--- a/api/v1/serviceFollowup.go
+++ b/api/v1/serviceFollowup.go
@@ -1,13 +1,14 @@
package v1
import (
+ "aps_crm/constvar"
"aps_crm/model"
"aps_crm/model/request"
"aps_crm/model/response"
"aps_crm/pkg/contextx"
"aps_crm/pkg/ecode"
+ "aps_crm/utils"
"github.com/gin-gonic/gin"
- "strconv"
)
type ServiceFollowupApi struct{}
@@ -27,6 +28,12 @@
return
}
+ if params.MemberId == 0 {
+ userInfo := utils.GetUserInfo(c)
+ if userInfo.UserType == constvar.UserTypeSub {
+ params.MemberId = userInfo.CrmUserId
+ }
+ }
errCode, serviceFollowup := checkServiceFollowupParams(params.ServiceFollowup)
if errCode != ecode.OK {
ctx.Fail(errCode)
@@ -38,6 +45,13 @@
ctx.Fail(errCode)
return
}
+ if params.CodeRule.Method == 1 {
+ autoCode := model.GetAutoCode(serviceFollowup.Id, ¶ms.CodeRule)
+ m := map[string]interface{}{
+ "number": autoCode,
+ }
+ _ = model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).UpdateByMap(m)
+ }
ctx.Ok()
}
@@ -47,17 +61,17 @@
// @Tags ServiceFollowup
// @Summary 鍒犻櫎鏈嶅姟璺熻繘
// @Produce application/json
-// @Param id path int true "鏌ヨ鍙傛暟"
+// @Param object body request.DeleteServiceFollowup true "鏌ヨ鍙傛暟"
// @Success 200 {object} contextx.Response{}
-// @Router /api/serviceFollowup/delete/{id} [delete]
+// @Router /api/serviceFollowup/delete [delete]
func (s *ServiceFollowupApi) Delete(c *gin.Context) {
- ctx, ok := contextx.NewContext(c, nil)
+ var params request.DeleteServiceFollowup
+ ctx, ok := contextx.NewContext(c, ¶ms)
if !ok {
return
}
- id, _ := strconv.Atoi(c.Param("id"))
- errCode := serviceFollowupService.DeleteServiceFollowup(id)
+ errCode := serviceFollowupService.DeleteServiceFollowup(params.Ids)
if errCode != ecode.OK {
ctx.Fail(errCode)
return
@@ -87,6 +101,8 @@
return
}
+ serviceFollowup.Id = params.Id
+
errCode = serviceFollowupService.UpdateServiceFollowup(&serviceFollowup)
if errCode != ecode.OK {
ctx.Fail(errCode)
@@ -94,30 +110,6 @@
}
ctx.Ok()
-}
-
-// List
-//
-// @Tags ServiceFollowup
-// @Summary 鏈嶅姟璺熻繘鍒楄〃
-// @Produce application/json
-// @Success 200 {object} contextx.Response{data=response.ServiceFollowupResponse}
-// @Router /api/serviceFollowup/list [get]
-func (s *ServiceFollowupApi) List(c *gin.Context) {
- ctx, ok := contextx.NewContext(c, nil)
- if !ok {
- return
- }
-
- list, errCode := serviceFollowupService.GetServiceFollowupList()
- if errCode != ecode.OK {
- ctx.Fail(errCode)
- return
- }
-
- ctx.OkWithDetailed(response.ServiceFollowupResponse{
- List: list,
- })
}
// checkServiceFollowupParams
@@ -131,20 +123,56 @@
//}
serviceFollowupModel = model.ServiceFollowup{
- ClientId: serviceFollowup.ClientId,
- Number: serviceFollowup.Number,
- ContactId: serviceFollowup.ContactId,
- ServiceId: serviceFollowup.ServiceId,
- MemberId: serviceFollowup.MemberId,
- PlanId: serviceFollowup.PlanId,
- Satisfaction: serviceFollowup.Satisfaction,
- TimelyRate: serviceFollowup.TimelyRate,
- SolveRate: serviceFollowup.SolveRate,
- IsVisit: serviceFollowup.IsVisit,
- OldMemberId: serviceFollowup.OldMemberId,
- Remark: serviceFollowup.Remark,
- File: serviceFollowup.File,
+ ClientId: serviceFollowup.ClientId,
+ Number: serviceFollowup.Number,
+ ContactId: serviceFollowup.ContactId,
+ ServiceOrderId: serviceFollowup.ServiceOrderId,
+ MemberId: serviceFollowup.MemberId,
+ PlanId: serviceFollowup.PlanId,
+ SatisfactionId: serviceFollowup.Satisfaction,
+ TimelyRateId: serviceFollowup.TimelyRate,
+ SolveRateId: serviceFollowup.SolveRate,
+ IsVisitId: serviceFollowup.IsVisit,
+ OldMemberId: serviceFollowup.OldMemberId,
+ Remark: serviceFollowup.Remark,
+ File: serviceFollowup.File,
+ CodeStandID: serviceFollowup.CodeStandID,
}
return ecode.OK, serviceFollowupModel
}
+
+// List
+//
+// @Tags ServiceFollowup
+// @Summary 鍥炶鍗曠鐞嗗垪琛�
+// @Produce application/json
+// @Param object body request.GetServiceFollowupList true "鍙傛暟"
+//
+// @Success 200 {object} contextx.Response{data=response.ServiceFollowupResponse}
+//
+// @Router /api/serviceFollowup/list [post]
+func (con *ServiceFollowupApi) List(c *gin.Context) {
+ var params request.GetServiceFollowupList
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ var memberIds []int
+ userInfo := utils.GetUserInfo(c)
+ if userInfo.UserType == constvar.UserTypeSub {
+ memberIds = []int{userInfo.CrmUserId}
+ }
+
+ serviceFollowups, total, errCode := serviceFollowupService.GetServiceFollowupList(params.Page, params.PageSize, params.KeywordType, params.Keyword, params.ServiceOrderId, memberIds)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.OkWithDetailed(response.ServiceFollowupResponse{
+ List: serviceFollowups,
+ Count: int(total),
+ })
+}
--
Gitblit v1.8.0