| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/pkg/structx" |
| | | "aps_crm/utils" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | |
| | | return |
| | | } |
| | | |
| | | serviceContracts, total, errCode := serviceContractService.GetServiceContractList(params.Page, params.PageSize, params.QueryClass, params.KeywordType, params.Keyword) |
| | | var memberIds []int |
| | | userInfo := utils.GetUserInfo(c) |
| | | if userInfo.UserType == constvar.UserTypeSub { |
| | | memberIds = []int{userInfo.CrmUserId} |
| | | } |
| | | |
| | | serviceContracts, total, errCode := serviceContractService.GetServiceContractList(params.Page, params.PageSize, params.QueryClass, params.KeywordType, params.Keyword, memberIds) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | PageNum int |
| | | PageSize int |
| | | Preload bool |
| | | MemberIds []int |
| | | } |
| | | ) |
| | | |
| | |
| | | db = db.Where("amount_receivable = ?", slf.Keyword) |
| | | |
| | | } |
| | | |
| | | if len(slf.MemberIds) > 0 { |
| | | db = db.Where("member_id in ?", slf.MemberIds) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db. |
| | | Preload("Client"). |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) SetMemberIds(memberIds []int) *ServiceContractSearch { |
| | | slf.MemberIds = memberIds |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) SetPreload(preload bool) *ServiceContractSearch { |
| | | slf.Preload = preload |
| | | return slf |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SContractService) GetServiceContractList(page, pageSize int, queryClass constvar.ServiceContractQueryClass, keywordType constvar.ServiceContractKeywordType, keyword string) ([]*model.ServiceContract, int64, int) { |
| | | func (SContractService) GetServiceContractList(page, pageSize int, queryClass constvar.ServiceContractQueryClass, keywordType constvar.ServiceContractKeywordType, keyword string, memberIds []int) ([]*model.ServiceContract, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewServiceContractSearch(). |
| | | SetKeyword(keyword). |
| | | SetKeywordType(keywordType). |
| | | SetQueryClass(queryClass). |
| | | SetMemberIds(memberIds). |
| | | SetPage(page, pageSize). |
| | | SetPreload(true). |
| | | Find() |