| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContractService) DeleteContract(id int) int { |
| | | _, err := model.NewContractSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.ContractNotExist |
| | | } |
| | | |
| | | err = model.NewContractSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.ContractNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContractService) GetContractList() ([]*model.Contract, int) { |
| | | list, err := model.NewContractSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ContractListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (ContractService) UpdateContract(contract *model.Contract) int { |
| | | // check contract exist |
| | | _, err := model.NewContractSearch().SetId(contract.Id).Find() |
| | |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContractService) GetContractList(page, pageSize int, data map[string]interface{}) ([]*model.Contract, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewContractSearch().SetPage(page, pageSize).SetSearchMap(data).FindAll() |
| | | if err != nil { |
| | | return nil, 0, ecode.ContractListErr |
| | | } |
| | | return contacts, total, ecode.OK |
| | | } |
| | | |
| | | func (ContractService) DeleteContract(id int) int { |
| | | // delete client |
| | | err := model.NewContractSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.ContractDeleteErr |
| | | } |
| | | return ecode.OK |
| | | } |