package service import ( "aps_crm/model" "aps_crm/pkg/ecode" ) type SalesRefundService struct{} func (SalesRefundService) AddSalesRefund(salesRefund *model.SalesRefund) int { err := model.NewSalesRefundSearch().Create(salesRefund) if err != nil { return ecode.SalesRefundExist } return ecode.OK } func (SalesRefundService) DeleteSalesRefund(id int) int { _, err := model.NewSalesRefundSearch().SetId(id).Find() if err != nil { return ecode.SalesRefundNotExist } err = model.NewSalesRefundSearch().SetId(id).Delete() if err != nil { return ecode.SalesRefundNotExist } return ecode.OK } func (SalesRefundService) UpdateSalesRefund(salesRefund *model.SalesRefund) int { // check salesRefund exist _, err := model.NewSalesRefundSearch().SetId(salesRefund.Id).Find() if err != nil { return ecode.SalesRefundNotExist } err = model.NewSalesRefundSearch().SetId(salesRefund.Id).Update(salesRefund) if err != nil { return ecode.SalesRefundSetErr } return ecode.OK } func (SalesRefundService) GetSalesRefundList(page, pageSize int, keyword string) ([]*model.SalesRefund, int64, int) { // get contact list contacts, total, err := model.NewSalesRefundSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() if err != nil { return nil, 0, ecode.SalesRefundListErr } return contacts, total, ecode.OK }