fix
wangpengfei
2023-08-11 4dd4ae617e7f37817d2c795ff011d73a67dc29bf
fix

add conditional matching to collectionProjection and quotation
9个文件已修改
73 ■■■■■ 已修改文件
api/v1/quotation.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/collectionProjection.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/quotation.go 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/collectionProjection.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/quotation.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/quotation.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/quotation.go
@@ -160,7 +160,7 @@
        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
docs/docs.go
@@ -14624,9 +14624,6 @@
        "request.GetQuotationList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -14634,6 +14631,11 @@
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "searchMap": {
                    "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id}",
                    "type": "object",
                    "additionalProperties": true
                }
            }
        },
docs/swagger.json
@@ -14612,9 +14612,6 @@
        "request.GetQuotationList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -14622,6 +14619,11 @@
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "searchMap": {
                    "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id}",
                    "type": "object",
                    "additionalProperties": true
                }
            }
        },
docs/swagger.yaml
@@ -3178,14 +3178,17 @@
    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:
model/collectionProjection.go
@@ -51,7 +51,7 @@
                    db = db.Where(key+" = ?", v)
                }
            case int:
                if key == "client_id" {
                if key == "client_id" || key == "sale_chance_id" {
                    db = db.Where(key+" = ?", v)
                }
            }
model/quotation.go
@@ -29,11 +29,11 @@
    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
    }
)
@@ -49,11 +49,23 @@
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
@@ -106,11 +118,6 @@
    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
@@ -120,3 +127,8 @@
    slf.OrderBy = order
    return slf
}
func (slf *QuotationSearch) SetSearchMap(searchMap map[string]interface{}) *QuotationSearch {
    slf.SearchMap = searchMap
    return slf
}
model/request/collectionProjection.go
@@ -17,5 +17,5 @@
type GetCollectionProjectionList struct {
    PageInfo
    SearchMap map[string]interface{}
    SearchMap map[string]interface{} // 搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": 销售机会id}
}
model/request/quotation.go
@@ -26,5 +26,5 @@
type GetQuotationList struct {
    PageInfo
    Keyword string `json:"keyword"`
    SearchMap map[string]interface{} // 搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": 销售线索id}
}
service/quotation.go
@@ -44,9 +44,9 @@
    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
    }