|
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 IsVisitApi struct{}
|
|
// Add
|
//
|
// @Tags IsVisit
|
// @Summary 添加服务人员是否来过
|
// @Produce application/json
|
// @Param object body request.AddIsVisit true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/isVisit/add [post]
|
func (s *IsVisitApi) Add(c *gin.Context) {
|
var params request.AddIsVisit
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
isVisit := new(model.IsVisit)
|
isVisit.Name = params.Name
|
|
errCode := isVisitService.AddIsVisit(isVisit)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
//
|
// @Tags IsVisit
|
// @Summary 删除服务人员是否来过
|
// @Produce application/json
|
// @Param id path int true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/isVisit/delete/{id} [delete]
|
func (s *IsVisitApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := isVisitService.DeleteIsVisit(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Update
|
//
|
// @Tags IsVisit
|
// @Summary 更新服务人员是否来过
|
// @Produce application/json
|
// @Param object body request.UpdateIsVisits true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/isVisit/update [put]
|
func (s *IsVisitApi) Update(c *gin.Context) {
|
var params request.UpdateIsVisits
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode := isVisitService.UpdateIsVisit(params.IsVisits)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// List
|
//
|
// @Tags IsVisit
|
// @Summary 获取服务人员是否来过列表
|
// @Produce application/json
|
// @Success 200 {object} contextx.Response{data=response.IsVisitResponse}
|
// @Router /api/isVisit/list [get]
|
func (s *IsVisitApi) List(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
isVisits, errCode := isVisitService.GetIsVisitList()
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.OkWithDetailed(response.IsVisitResponse{
|
List: isVisits,
|
})
|
}
|