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 ClientStatusApi struct{}
|
|
// Add
|
//
|
// @Tags ClientStatus
|
// @Summary 添加客户状态
|
// @Produce application/json
|
// @Param object body request.AddClientStatus true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/clientStatus/add [post]
|
func (cs *ClientStatusApi) Add(c *gin.Context) {
|
var params request.AddClientStatus
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
clientStatus := new(model.ClientStatus)
|
clientStatus.Name = params.Name
|
|
errCode := clientStatusService.AddClientStatus(clientStatus)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
//
|
// @Tags ClientStatus
|
// @Summary 删除客户状态
|
// @Produce application/json
|
// @Param id path int true "客户状态ID"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/clientStatus/delete/{id} [delete]
|
func (cs *ClientStatusApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := clientStatusService.DeleteClientStatus(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// List
|
//
|
// @Tags ClientStatus
|
// @Summary 获取客户状态列表
|
// @Produce application/json
|
// @Success 200 {object} contextx.Response{data=response.ClientStatusResponse}
|
// @Router /api/clientStatus/list [get]
|
func (cs *ClientStatusApi) List(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
list, errCode := clientStatusService.GetClientStatusList()
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.OkWithDetailed(response.ClientStatusResponse{
|
List: list,
|
})
|
}
|
|
// Update
|
//
|
// @Tags ClientStatus
|
// @Summary 更新客户状态
|
// @Produce application/json
|
// @Param object body request.UpdateClientStatuses true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/clientStatus/update [put]
|
func (cs *ClientStatusApi) Update(c *gin.Context) {
|
var params request.UpdateClientStatuses
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode := clientStatusService.UpdateClientStatus(params.ClientStatuses)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|