|
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 TimelyRateApi struct{}
|
|
// Add
|
//
|
// @Tags TimelyRate
|
// @Summary 添加销售阶段
|
// @Produce application/json
|
// @Param object body request.AddTimelyRate true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/timelyRate/add [post]
|
func (s *TimelyRateApi) Add(c *gin.Context) {
|
var params request.AddTimelyRate
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
timelyRate := new(model.TimelyRate)
|
timelyRate.Name = params.Name
|
|
errCode := timelyRateService.AddTimelyRate(timelyRate)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
//
|
// @Tags TimelyRate
|
// @Summary 删除销售阶段
|
// @Produce application/json
|
// @Param id path int true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/timelyRate/delete/{id} [delete]
|
func (s *TimelyRateApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := timelyRateService.DeleteTimelyRate(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Update
|
//
|
// @Tags TimelyRate
|
// @Summary 更新销售阶段
|
// @Produce application/json
|
// @Param object body request.UpdateTimelyRates true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/timelyRate/update [put]
|
func (s *TimelyRateApi) Update(c *gin.Context) {
|
var params request.UpdateTimelyRates
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode := timelyRateService.UpdateTimelyRate(params.TimelyRates)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// List
|
//
|
// @Tags TimelyRate
|
// @Summary 获取销售阶段列表
|
// @Produce application/json
|
// @Success 200 {object} contextx.Response{data=response.TimelyRateResponse}
|
// @Router /api/timelyRate/list [get]
|
func (s *TimelyRateApi) List(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
timelyRates, errCode := timelyRateService.GetTimelyRateList()
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.OkWithDetailed(response.TimelyRateResponse{
|
List: timelyRates,
|
})
|
}
|