package v1
|
|
import (
|
"aps_crm/model/request"
|
"aps_crm/model/response"
|
"aps_crm/pkg/contextx"
|
"aps_crm/pkg/ecode"
|
"aps_crm/service"
|
"github.com/gin-gonic/gin"
|
"strconv"
|
)
|
|
type WechatOrderStatusApi struct{}
|
|
// Add
|
// @Tags 微信订单状态
|
// @Summary 添加微信订单状态
|
// @Produce application/json
|
// @Param object body request.AddWechatOrderStatus true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/wechatOrderStatus/add [post]
|
func (s *WechatOrderStatusApi) Add(c *gin.Context) {
|
var params request.AddWechatOrderStatus
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode := service.NewWechatOrderStatusService().AddWechatOrderStatus(¶ms.WechatOrderStatus)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
// @Tags 微信订单状态
|
// @Summary 删除微信订单状态
|
// @Produce application/json
|
// @Param id path int true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/wechatOrderStatus/delete/{id} [delete]
|
func (s *WechatOrderStatusApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := service.NewWechatOrderStatusService().DeleteWechatOrderStatus(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Update
|
// @Tags 微信订单状态
|
// @Summary 更新微信订单状态
|
// @Produce application/json
|
// @Param object body request.UpdateWechatOrderStatus true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/wechatOrderStatus/update [put]
|
func (s *WechatOrderStatusApi) Update(c *gin.Context) {
|
var params request.UpdateWechatOrderStatus
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
if params.Id == 0 {
|
ctx.Fail(ecode.ParamsErr)
|
}
|
params.WechatOrderStatus.Id = params.Id
|
|
errCode := service.NewWechatOrderStatusService().UpdateWechatOrderStatus(¶ms.WechatOrderStatus)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// List
|
// @Tags 微信订单状态
|
// @Summary 获取微信订单状态列表
|
// @Produce application/json
|
// @Param object query request.GetWechatOrderStatusList true "参数"
|
// @Success 200 {object} response.ListResponse{data=[]model.WechatOrderStatus}
|
// @Router /api/wechatOrderStatus/list [get]
|
func (s *WechatOrderStatusApi) List(c *gin.Context) {
|
var params request.GetWechatOrderStatusList
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
wechatOrderStatus, total, errCode := service.NewWechatOrderStatusService().GetWechatOrderStatusList()
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.OkWithDetailed(response.ListResponse{
|
Data: wechatOrderStatus,
|
Count: total,
|
})
|
}
|