From cddf1d93735052590755460f4b3c8264e0d57399 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期一, 07 八月 2023 09:39:20 +0800 Subject: [PATCH] fix --- service/serviceContract.go | 118 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 59 insertions(+), 59 deletions(-) diff --git a/service/serviceContract.go b/service/serviceContract.go index a77e154..2175971 100644 --- a/service/serviceContract.go +++ b/service/serviceContract.go @@ -1,59 +1,59 @@ -package service - -import ( - "aps_crm/model" - "aps_crm/pkg/ecode" -) - -type SContractService struct{} - -func (SContractService) AddServiceContract(serviceContract *model.ServiceContract) int { - err := model.NewServiceContractSearch().Create(serviceContract) - if err != nil { - return ecode.SContractExist - } - - return ecode.OK -} - -func (SContractService) UpdateServiceContract(serviceContract *model.ServiceContract) int { - // check serviceContract exist - _, err := model.NewServiceContractSearch().SetId(serviceContract.Id).Find() - if err != nil { - return ecode.SContractNotExist - } - - err = model.NewServiceContractSearch().SetId(serviceContract.Id).Update(serviceContract) - if err != nil { - return ecode.SContractSetErr - } - - 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 -// } -// -// return list, ecode.OK -//} - -func (SContractService) GetServiceContractList(page, pageSize int, keyword string) ([]*model.ServiceContract, int64, int) { - // get contact list - contacts, total, err := model.NewServiceContractSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() - if err != nil { - return nil, 0, ecode.SContractListErr - } - return contacts, total, 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 -} +package service + +import ( + "aps_crm/model" + "aps_crm/pkg/ecode" +) + +type SContractService struct{} + +func (SContractService) AddServiceContract(serviceContract *model.ServiceContract) int { + err := model.NewServiceContractSearch().Create(serviceContract) + if err != nil { + return ecode.SContractExist + } + + return ecode.OK +} + +func (SContractService) UpdateServiceContract(serviceContract *model.ServiceContract) int { + // check serviceContract exist + _, err := model.NewServiceContractSearch().SetId(serviceContract.Id).Find() + if err != nil { + return ecode.SContractNotExist + } + + err = model.NewServiceContractSearch().SetId(serviceContract.Id).Update(serviceContract) + if err != nil { + return ecode.SContractSetErr + } + + 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 +// } +// +// return list, ecode.OK +//} + +func (SContractService) GetServiceContractList(page, pageSize int, keyword string) ([]*model.ServiceContract, int64, int) { + // get contact list + contacts, total, err := model.NewServiceContractSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() + if err != nil { + return nil, 0, ecode.SContractListErr + } + return contacts, total, 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 +} -- Gitblit v1.8.0