fix
add conditional matching to collectionProjection
| | |
| | | return |
| | | } |
| | | |
| | | total, errCode, list := collectionProjectionService.GetCollectionProjectionList(params.Page, params.PageSize) |
| | | total, errCode, list := collectionProjectionService.GetCollectionProjectionList(params.Page, params.PageSize, params.SearchMap) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | CollectionProjectionSearch struct { |
| | | CollectionProjection |
| | | |
| | | Orm *gorm.DB |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | SearchMap map[string]interface{} |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | var db = slf.Orm.Model(&CollectionProjection{}) |
| | | 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 == "estimated_collection_date" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | case int: |
| | | if key == "client_id" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return db |
| | |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *CollectionProjectionSearch) SetSearchMap(data map[string]interface{}) *CollectionProjectionSearch { |
| | | slf.SearchMap = data |
| | | return slf |
| | | } |
| | |
| | | } |
| | | } |
| | | case int: |
| | | if key == "client_id" { |
| | | db = db.Where("client_id = ?", v) |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | type GetCollectionProjectionList struct { |
| | | PageInfo |
| | | SearchMap map[string]interface{} |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (CollectionProjectionService) GetCollectionProjectionList(page, pageSize int) (int64, int, []*model.CollectionProjection) { |
| | | func (CollectionProjectionService) GetCollectionProjectionList(page, pageSize int, data map[string]interface{}) (int64, int, []*model.CollectionProjection) { |
| | | |
| | | total, err, list := model.NewCollectionProjectionSearch().SetPage(page, pageSize).Find() |
| | | total, err, list := model.NewCollectionProjectionSearch().SetPage(page, pageSize).SetSearchMap(data).Find() |
| | | if err != nil { |
| | | return total, ecode.CollectionProjectionListErr, list |
| | | } |