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 RefundMethodApi struct{} // Add // // @Tags RefundMethod // @Summary 添加退款方式 // @Produce application/json // @Param object body request.AddRefundMethod true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/refundMethod/add [post] func (s *RefundMethodApi) Add(c *gin.Context) { var params request.AddRefundMethod ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } refundMethod := new(model.RefundMethod) refundMethod.Name = params.Name errCode := refundMethodService.AddRefundMethod(refundMethod) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // Delete // // @Tags RefundMethod // @Summary 删除退款方式 // @Produce application/json // @Param id path int true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/refundMethod/delete/{id} [delete] func (s *RefundMethodApi) Delete(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } id, _ := strconv.Atoi(c.Param("id")) errCode := refundMethodService.DeleteRefundMethod(id) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // Update // // @Tags RefundMethod // @Summary 更新退款方式 // @Produce application/json // @Param object body request.UpdateRefundMethods true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/refundMethod/update [put] func (s *RefundMethodApi) Update(c *gin.Context) { var params request.UpdateRefundMethods ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } errCode := refundMethodService.UpdateRefundMethod(params.RefundMethods) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // List // // @Tags RefundMethod // @Summary 获取退款方式列表 // @Produce application/json // @Success 200 {object} contextx.Response{data=response.RefundMethodResponse} // @Router /api/refundMethod/list [get] func (s *RefundMethodApi) List(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } refundMethods, errCode := refundMethodService.GetRefundMethodList() if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.OkWithDetailed(response.RefundMethodResponse{ List: refundMethods, }) }