| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | |
| | | return ecode.SContractExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SContractService) DeleteServiceContract(id int) int { |
| | | _, err := model.NewServiceContractSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SContractNotExist |
| | | } |
| | | |
| | | err = model.NewServiceContractSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SContractNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SContractService) GetServiceContractByContractId(contractId int) ([]*model.ServiceContract, int) { |
| | | list, err := model.NewServiceContractSearch().SetId(contractId).FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SContractListErr |
| | | } |
| | | //func (SContractService) GetServiceContractByContractId(contractId int) ([]*model.ServiceContract, int) { |
| | | // list, err := model.NewServiceContractSearch().SetId(contractId).FindAll() |
| | | // if err != nil { |
| | | // return nil, ecode.SContractListErr |
| | | // } |
| | | // |
| | | // return list, ecode.OK |
| | | //} |
| | | |
| | | return list, ecode.OK |
| | | func (SContractService) DeleteServiceContract(ids []int) int { |
| | | // delete client |
| | | err := model.NewServiceContractSearch().SetIds(ids).Delete() |
| | | if err != nil { |
| | | return ecode.SContractDeleteErr |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SContractService) GetServiceContractList(page, pageSize int, keyword string) ([]*model.ServiceContract, int) { |
| | | func (SContractService) GetServiceContractList(page, pageSize int, queryClass constvar.ServiceContractQueryClass, keywordType constvar.ServiceContractKeywordType, keyword string) ([]*model.ServiceContract, int64, int) { |
| | | // get contact list |
| | | contacts, err := model.NewServiceContractSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() |
| | | contacts, total, err := model.NewServiceContractSearch(). |
| | | SetKeyword(keyword). |
| | | SetKeywordType(keywordType). |
| | | SetQueryClass(queryClass). |
| | | SetPage(page, pageSize).FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SContractListErr |
| | | return nil, 0, ecode.SContractListErr |
| | | } |
| | | return contacts, ecode.OK |
| | | return contacts, total, ecode.OK |
| | | } |