| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | |
| | | func checkContractParams(contract request.Contract) (errCode int, contractModel model.Contract) { |
| | | //if contract.Number == "" { |
| | | // return ecode.InvalidParams, contractModel |
| | |
| | | return |
| | | } |
| | | |
| | | contracts, total, errCode := contractService.GetContractList(params.Page, params.PageSize, params.Keyword) |
| | | contracts, total, errCode := contractService.GetContractList(params.Page, params.PageSize, params.SearchMap) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ContractResponse{ |
| | | List: contracts, |
| | | List: contracts, |
| | | Count: int(total), |
| | | }) |
| | | } |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContractService) GetContractList(page, pageSize int, keyword string) ([]*model.Contract, int64, int) { |
| | | func (ContractService) GetContractList(page, pageSize int, data map[string]interface{}) ([]*model.Contract, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewContractSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() |
| | | contacts, total, err := model.NewContractSearch().SetPage(page, pageSize).SetSearchMap(data).FindAll() |
| | | if err != nil { |
| | | return nil, 0, ecode.ContractListErr |
| | | } |