package service import ( "aps_crm/model" "aps_crm/pkg/ecode" ) type QuotationService struct{} func (QuotationService) AddQuotation(quotation *model.Quotation) int { err := model.NewQuotationSearch().Create(quotation) if err != nil { return ecode.QuotationExist } return ecode.OK } func (QuotationService) UpdateQuotation(quotation *model.Quotation) int { // check quotation exist _, err := model.NewQuotationSearch().SetId(quotation.Id).Find() if err != nil { return ecode.QuotationNotExist } err = model.NewQuotationSearch().SetId(quotation.Id).Update(quotation) if err != nil { return ecode.QuotationSetErr } return ecode.OK } func (QuotationService) GetQuotationList(page, pageSize int, data map[string]interface{}) ([]*model.Quotation, int64, int) { // get contact list contacts, total, err := model.NewQuotationSearch().SetPage(page, pageSize).SetSearchMap(data).FindAll() if err != nil { return nil, 0, ecode.QuotationListErr } return contacts, total, ecode.OK } func (QuotationService) DeleteQuotation(ids []int) int { // delete client err := model.NewQuotationSearch().SetIds(ids).Delete() if err != nil { return ecode.QuotationDeleteErr } return ecode.OK }