package service import ( "aps_crm/model" "aps_crm/pkg/ecode" ) type FollowupService struct{} func (FollowupService) AddServiceFollowup(serviceFollowup *model.ServiceFollowup) int { err := model.NewServiceFollowupSearch().Create(serviceFollowup) if err != nil { return ecode.ServiceFollowupExist } return ecode.OK } func (FollowupService) DeleteServiceFollowup(id int) int { _, err := model.NewServiceFollowupSearch().SetId(id).Find() if err != nil { return ecode.ServiceFollowupNotExist } err = model.NewServiceFollowupSearch().SetId(id).Delete() if err != nil { return ecode.ServiceFollowupNotExist } return ecode.OK } func (FollowupService) GetServiceFollowupList() ([]*model.ServiceFollowup, int) { list, err := model.NewServiceFollowupSearch().FindAll() if err != nil { return nil, ecode.ServiceFollowupListErr } return list, ecode.OK } func (FollowupService) UpdateServiceFollowup(serviceFollowup *model.ServiceFollowup) int { // check serviceFollowup exist _, err := model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).Find() if err != nil { return ecode.ServiceFollowupNotExist } err = model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).Update(serviceFollowup) if err != nil { return ecode.ServiceFollowupSetErr } return ecode.OK }