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) DeleteQuotation(id int) int { _, err := model.NewQuotationSearch().SetId(id).Find() if err != nil { return ecode.QuotationNotExist } err = model.NewQuotationSearch().SetId(id).Delete() if err != nil { return ecode.QuotationNotExist } 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, keyword string) ([]*model.Quotation, int) { // get contact list contacts, err := model.NewQuotationSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() if err != nil { return nil, ecode.QuotationListErr } return contacts, ecode.OK }