package service import ( "aps_crm/model" "aps_crm/pkg/ecode" ) type CustomerServiceSheetService struct{} func (CustomerServiceSheetService) AddCustomerServiceSheet(customerServiceSheet *model.CustomerServiceSheet) int { err := model.NewCustomerServiceSheetSearch().Create(customerServiceSheet) if err != nil { return ecode.CustomerServiceSheetExist } return ecode.OK } func (CustomerServiceSheetService) DeleteCustomerServiceSheet(id int) int { _, err := model.NewCustomerServiceSheetSearch().SetId(id).Find() if err != nil { return ecode.CustomerServiceSheetNotExist } err = model.NewCustomerServiceSheetSearch().SetId(id).Delete() if err != nil { return ecode.CustomerServiceSheetNotExist } return ecode.OK } func (CustomerServiceSheetService) GetCustomerServiceSheetList() ([]*model.CustomerServiceSheet, int) { list, err := model.NewCustomerServiceSheetSearch().FindAll() if err != nil { return nil, ecode.CustomerServiceSheetListErr } return list, ecode.OK } func (CustomerServiceSheetService) UpdateCustomerServiceSheet(customerServiceSheet *model.CustomerServiceSheet) int { // check customerServiceSheet exist _, err := model.NewCustomerServiceSheetSearch().SetId(customerServiceSheet.Id).Find() if err != nil { return ecode.CustomerServiceSheetNotExist } err = model.NewCustomerServiceSheetSearch().SetId(customerServiceSheet.Id).Update(customerServiceSheet) if err != nil { return ecode.CustomerServiceSheetSetErr } return ecode.OK }