package v1
|
|
import (
|
"aps_crm/model"
|
"aps_crm/model/request"
|
"aps_crm/model/response"
|
"aps_crm/pkg/contextx"
|
"aps_crm/pkg/ecode"
|
"github.com/gin-gonic/gin"
|
"strconv"
|
)
|
|
type ServiceFollowupApi struct{}
|
|
// Add
|
//
|
// @Tags ServiceFollowup
|
// @Summary 添加服务跟进
|
// @Produce application/json
|
// @Param object body request.AddServiceFollowup true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/serviceFollowup/add [post]
|
func (s *ServiceFollowupApi) Add(c *gin.Context) {
|
var params request.AddServiceFollowup
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode, serviceFollowup := checkServiceFollowupParams(params.ServiceFollowup)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
errCode = serviceFollowupService.AddServiceFollowup(&serviceFollowup)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
//
|
// @Tags ServiceFollowup
|
// @Summary 删除服务跟进
|
// @Produce application/json
|
// @Param id path int true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/serviceFollowup/delete/{id} [delete]
|
func (s *ServiceFollowupApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := serviceFollowupService.DeleteServiceFollowup(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Update
|
//
|
// @Tags ServiceFollowup
|
// @Summary 更新服务跟进
|
// @Produce application/json
|
// @Param object body request.UpdateServiceFollowup true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/serviceFollowup/update [put]
|
func (s *ServiceFollowupApi) Update(c *gin.Context) {
|
var params request.UpdateServiceFollowup
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode, serviceFollowup := checkServiceFollowupParams(params.ServiceFollowup)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
serviceFollowup.Id = params.Id
|
|
errCode = serviceFollowupService.UpdateServiceFollowup(&serviceFollowup)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
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
|
func checkServiceFollowupParams(serviceFollowup request.ServiceFollowup) (errCode int, serviceFollowupModel model.ServiceFollowup) {
|
//if serviceFollowup.Number == "" {
|
// return ecode.InvalidParams, serviceFollowupModel
|
//}
|
//
|
//if serviceFollowup.MemberId == 0 {
|
// return ecode.InvalidParams, serviceFollowupModel
|
//}
|
|
serviceFollowupModel = model.ServiceFollowup{
|
ClientId: serviceFollowup.ClientId,
|
Number: serviceFollowup.Number,
|
ContactId: serviceFollowup.ContactId,
|
ServiceId: serviceFollowup.ServiceId,
|
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,
|
}
|
|
return ecode.OK, serviceFollowupModel
|
}
|