fix
add search criteria to contract
| | |
| | | "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" |
| | |
| | | "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": { |
| | |
| | | }, |
| | | "statusId": { |
| | | "type": "integer" |
| | | }, |
| | | "updated_at": { |
| | | "description": "The date when the item was last updated\nexample: 2023-08-10 15:48:25", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.GetContractList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "search_map": { |
| | | "description": "搜索条件: map[string]interface{} {\"member_name\": \"销售负责人\", \"number\": \"合同编号\", \"created_at\": \"创建时间\"}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | }, |
| | |
| | | "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" |
| | |
| | | "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": { |
| | |
| | | }, |
| | | "statusId": { |
| | | "type": "integer" |
| | | }, |
| | | "updated_at": { |
| | | "description": "The date when the item was last updated\nexample: 2023-08-10 15:48:25", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.GetContractList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "search_map": { |
| | | "description": "搜索条件: map[string]interface{} {\"member_name\": \"销售负责人\", \"number\": \"合同编号\", \"created_at\": \"创建时间\"}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | }, |
| | |
| | | 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 |
| | |
| | | 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: |
| | |
| | | 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 |
| | |
| | | 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: |
| | |
| | | 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: |
| | |
| | | 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 |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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 |
| | | } |
| | |
| | | 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 { |
| | |
| | | |
| | | type GetContractList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | SearchMap map[string]interface{} `json:"search_map"` // 搜索条件: map[string]interface{} {"member_name": "销售负责人", "number": "合同编号", "created_at": "创建时间"} |
| | | } |