fix
wangpengfei
2023-08-14 18f5a87f2b647a27417aaffd62f48ff38be1d0d8
fix

add search criteria to contract
6个文件已修改
150 ■■■■ 已修改文件
docs/docs.go 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contract.go 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/model.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contract.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go
@@ -10709,16 +10709,16 @@
        "model.CollectionProjection": {
            "type": "object",
            "properties": {
                "_": {
                    "description": "The date when the item was deleted\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "created_at": {
                    "description": "The date when the item was created\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "creator": {
                    "type": "integer"
                },
                "deleted_at": {
                    "description": "The date when the item was deleted\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "estimated_collection_amount": {
                    "type": "number"
@@ -10884,13 +10884,22 @@
        "model.Contract": {
            "type": "object",
            "properties": {
                "_": {
                    "description": "The date when the item was deleted\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "clientId": {
                    "type": "integer"
                },
                "created_at": {
                    "description": "The date when the item was created\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "description": "The ID of the item\nexample: 1",
                    "type": "integer"
                },
                "memberId": {
@@ -10907,6 +10916,10 @@
                },
                "statusId": {
                    "type": "integer"
                },
                "updated_at": {
                    "description": "The date when the item was last updated\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                }
            }
        },
@@ -14727,9 +14740,6 @@
        "request.GetContractList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -14737,6 +14747,11 @@
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "search_map": {
                    "description": "搜索条件: map[string]interface{} {\"member_name\": \"销售负责人\", \"number\": \"合同编号\", \"created_at\": \"创建时间\"}",
                    "type": "object",
                    "additionalProperties": true
                }
            }
        },
docs/swagger.json
@@ -10697,16 +10697,16 @@
        "model.CollectionProjection": {
            "type": "object",
            "properties": {
                "_": {
                    "description": "The date when the item was deleted\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "created_at": {
                    "description": "The date when the item was created\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "creator": {
                    "type": "integer"
                },
                "deleted_at": {
                    "description": "The date when the item was deleted\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "estimated_collection_amount": {
                    "type": "number"
@@ -10872,13 +10872,22 @@
        "model.Contract": {
            "type": "object",
            "properties": {
                "_": {
                    "description": "The date when the item was deleted\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "clientId": {
                    "type": "integer"
                },
                "created_at": {
                    "description": "The date when the item was created\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "description": "The ID of the item\nexample: 1",
                    "type": "integer"
                },
                "memberId": {
@@ -10895,6 +10904,10 @@
                },
                "statusId": {
                    "type": "integer"
                },
                "updated_at": {
                    "description": "The date when the item was last updated\nexample: 2023-08-10 15:48:25",
                    "type": "string"
                }
            }
        },
@@ -14715,9 +14728,6 @@
        "request.GetContractList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -14725,6 +14735,11 @@
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "search_map": {
                    "description": "搜索条件: map[string]interface{} {\"member_name\": \"销售负责人\", \"number\": \"合同编号\", \"created_at\": \"创建时间\"}",
                    "type": "object",
                    "additionalProperties": true
                }
            }
        },
docs/swagger.yaml
@@ -532,6 +532,11 @@
    type: object
  model.CollectionProjection:
    properties:
      _:
        description: |-
          The date when the item was deleted
          example: 2023-08-10 15:48:25
        type: string
      created_at:
        description: |-
          The date when the item was created
@@ -539,11 +544,6 @@
        type: string
      creator:
        type: integer
      deleted_at:
        description: |-
          The date when the item was deleted
          example: 2023-08-10 15:48:25
        type: string
      estimated_collection_amount:
        type: number
      estimated_collection_date:
@@ -657,11 +657,24 @@
    type: object
  model.Contract:
    properties:
      _:
        description: |-
          The date when the item was deleted
          example: 2023-08-10 15:48:25
        type: string
      clientId:
        type: integer
      created_at:
        description: |-
          The date when the item was created
          example: 2023-08-10 15:48:25
        type: string
      file:
        type: string
      id:
        description: |-
          The ID of the item
          example: 1
        type: integer
      memberId:
        type: integer
@@ -673,6 +686,11 @@
        type: integer
      statusId:
        type: integer
      updated_at:
        description: |-
          The date when the item was last updated
          example: 2023-08-10 15:48:25
        type: string
    type: object
  model.Country:
    properties:
@@ -3245,14 +3263,17 @@
    type: object
  request.GetContractList:
    properties:
      keyword:
        type: string
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
      search_map:
        additionalProperties: true
        description: '搜索条件: map[string]interface{} {"member_name": "销售负责人", "number":
          "合同编号", "created_at": "创建时间"}'
        type: object
    type: object
  request.GetFaqList:
    properties:
model/contract.go
@@ -15,18 +15,17 @@
        Quotation   Quotation `json:"quotation" gorm:"foreignKey:QuotationId;references:Id"`
        StatusId    int       `json:"statusId" gorm:"column:status_id;type:int;comment:合同状态"`
        File        string    `json:"file" gorm:"column:file;type:varchar(255);comment:合同文件"`
        gorm.Model  `json:"-"`
        gormModel
    }
    ContractSearch struct {
        Contract
                Orm      *gorm.DB
        Keyword  string
        OrderBy  string
        PageNum  int
        PageSize int
        Orm       *gorm.DB
        SearchMap map[string]interface{}
        OrderBy   string
        PageNum   int
        PageSize  int
    }
)
@@ -42,11 +41,33 @@
func (slf *ContractSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&Contract{})
    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 == "client_name" {
                    db = db.Joins("Client").Where("Client.name LIKE ?", "%"+v+"%")
                }
                if key == "member_name" {
                    db = db.Joins("User").Where("User.username LIKE ?", "%"+v+"%")
                }
                if key == "number" {
                    db = db.Where("number LIKE ?", "%"+v+"%")
                }
                if key == "created_at" {
                    db = db.Where(key+"= ?", v)
                }
            case int:
            }
        }
    }
    return db
@@ -98,11 +119,6 @@
    return slf
}
func (slf *ContractSearch) SetKeyword(keyword string) *ContractSearch {
    slf.Keyword = keyword
    return slf
}
func (slf *ContractSearch) SetPage(page, size int) *ContractSearch {
    slf.PageNum, slf.PageSize = page, size
    return slf
@@ -111,4 +127,9 @@
func (slf *ContractSearch) SetOrder(order string) *ContractSearch {
    slf.OrderBy = order
    return slf
}
}
func (slf *ContractSearch) SetSearchMap(data map[string]interface{}) *ContractSearch {
    slf.SearchMap = data
    return slf
}
model/model.go
@@ -20,7 +20,7 @@
    UpdatedAt time.Time `json:"updated_at"`
    // The date when the item was deleted
    // example: 2023-08-10 15:48:25
    DeletedAt *time.Time `json:"deleted_at,omitempty"`
    DeletedAt *time.Time `json:"_"`
}
type CrmModel struct {
model/request/contract.go
@@ -20,5 +20,5 @@
type GetContractList struct {
    PageInfo
    Keyword string `json:"keyword"`
    SearchMap map[string]interface{} `json:"search_map"` // 搜索条件: map[string]interface{} {"member_name": "销售负责人", "number": "合同编号", "created_at": "创建时间"}
}