| | |
| | | File string `json:"file" gorm:"column:file;type:varchar(255);comment:合同文件"` |
| | | CreatedAt *CustomTime `json:"created_at" gorm:"column:created_at;type:datetime;comment:创建时间"` |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | SendTime string `json:"sendTime" gorm:"column:send_time;type:varchar(255);comment:发货时间"` |
| | | gormModel |
| | | } |
| | | |
| | | ContractSearch struct { |
| | | Contract |
| | | |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | SearchMap map[string]interface{} |
| | | OrderBy string |
| | |
| | | } |
| | | } |
| | | |
| | | func (slf *ContractSearch) SetKeyword(keyword string) *ContractSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ContractSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Contract{}) |
| | | |
| | |
| | | } |
| | | if slf.Number != "" { |
| | | db = db.Where("number = ?", slf.Number) |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Joins("Client").Where("contract_name like ? or contract.number like ? or Client.name like ?", fmt.Sprintf("%%%v%%", slf.Keyword), fmt.Sprintf("%%%v%%", slf.Keyword), fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | } |
| | | |
| | | if len(slf.SearchMap) > 0 { |
| | |
| | | if key == "created_at" { |
| | | db = db.Where(key+"= ?", v) |
| | | } |
| | | |
| | | if key == "contract_name" { |
| | | db = db.Where("contract_name=?", "%"+v+"%") |
| | | } |
| | | case int: |
| | | if key == "member_id" { |
| | | db = db.Where(key+"= ?", v) |
| | | } |
| | | case []int: |
| | | if key == "member_ids" { |
| | | db = db.Where("contract.member_id in ?", v) |
| | | } |
| | | } |
| | | } |
| | | } |