fix
add conditional matching to collectionProjection and quotation
| | |
| | | return |
| | | } |
| | | |
| | | quotations, total, errCode := quotationService.GetQuotationList(params.Page, params.PageSize, params.Keyword) |
| | | quotations, total, errCode := quotationService.GetQuotationList(params.Page, params.PageSize, params.SearchMap) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | "request.GetQuotationList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "searchMap": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.GetQuotationList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "searchMap": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | }, |
| | |
| | | type: object |
| | | request.GetQuotationList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | searchMap: |
| | | additionalProperties: true |
| | | description: '搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": |
| | | 销售线索id}' |
| | | type: object |
| | | type: object |
| | | request.GetSaleChanceList: |
| | | properties: |
| | |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | case int: |
| | | if key == "client_id" { |
| | | if key == "client_id" || key == "sale_chance_id" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | } |
| | |
| | | QuotationSearch struct { |
| | | Quotation |
| | | |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | SearchMap map[string]interface{} |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *QuotationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Quotation{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if len(slf.SearchMap) > 0 { |
| | | for key, value := range slf.SearchMap { |
| | | switch v := value.(type) { |
| | | case string: |
| | | if key == "validity_date" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | case int: |
| | | if key == "client_id" || key == "sale_chance_id" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return db |
| | |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *QuotationSearch) SetKeyword(keyword string) *QuotationSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *QuotationSearch) SetPage(page, size int) *QuotationSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | |
| | | slf.OrderBy = order |
| | | return slf |
| | | } |
| | | |
| | | func (slf *QuotationSearch) SetSearchMap(searchMap map[string]interface{}) *QuotationSearch { |
| | | slf.SearchMap = searchMap |
| | | return slf |
| | | } |
| | |
| | | |
| | | type GetCollectionProjectionList struct { |
| | | PageInfo |
| | | SearchMap map[string]interface{} |
| | | SearchMap map[string]interface{} // 搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": 销售机会id} |
| | | } |
| | |
| | | |
| | | type GetQuotationList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | SearchMap map[string]interface{} // 搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": 销售线索id} |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (QuotationService) GetQuotationList(page, pageSize int, keyword string) ([]*model.Quotation, int64, int) { |
| | | func (QuotationService) GetQuotationList(page, pageSize int, data map[string]interface{}) ([]*model.Quotation, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewQuotationSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() |
| | | contacts, total, err := model.NewQuotationSearch().SetPage(page, pageSize).SetSearchMap(data).FindAll() |
| | | if err != nil { |
| | | return nil, 0, ecode.QuotationListErr |
| | | } |