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 QuotationStatusApi struct{} // Add // // @Tags QuotationStatus // @Summary 添加报价单状态 // @Produce application/json // @Param object body request.AddQuotationStatus true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/quotationStatus/add [post] func (s *QuotationStatusApi) Add(c *gin.Context) { var params request.AddQuotationStatus ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } quotationStatus := new(model.QuotationStatus) quotationStatus.Name = params.Name errCode := quotationStatusService.AddQuotationStatus(quotationStatus) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // Delete // // @Tags QuotationStatus // @Summary 删除报价单状态 // @Produce application/json // @Param id path int true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/quotationStatus/delete/{id} [delete] func (s *QuotationStatusApi) Delete(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } id, _ := strconv.Atoi(c.Param("id")) errCode := quotationStatusService.DeleteQuotationStatus(id) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // Update // // @Tags QuotationStatus // @Summary 更新报价单状态 // @Produce application/json // @Param object body request.UpdateQuotationStatuss true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/quotationStatus/update [put] func (s *QuotationStatusApi) Update(c *gin.Context) { var params request.UpdateQuotationStatuss ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } errCode := quotationStatusService.UpdateQuotationStatus(params.QuotationStatuss) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // List // // @Tags QuotationStatus // @Summary 获取报价单状态列表 // @Produce application/json // @Success 200 {object} contextx.Response{data=response.QuotationStatusResponse} // @Router /api/quotationStatus/list [get] func (s *QuotationStatusApi) List(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } quotationStatuss, errCode := quotationStatusService.GetQuotationStatusList() if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.OkWithDetailed(response.QuotationStatusResponse{ List: quotationStatuss, }) }