From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 19:20:21 +0800 Subject: [PATCH] 公海member_id使用0 --- model/contact.go | 42 +++++++++++++++++++++++++----------------- 1 files changed, 25 insertions(+), 17 deletions(-) diff --git a/model/contact.go b/model/contact.go index 596ecf7..a01d3be 100644 --- a/model/contact.go +++ b/model/contact.go @@ -7,20 +7,21 @@ type ( Contact struct { - Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鑱旂郴浜哄鍚�"` - Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鑱旂郴浜虹紪鍙�"` - ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛ID"` - Client Client `json:"-" gorm:"foreignKey:ClientId"` - Position string `json:"position" gorm:"column:position;type:varchar(255);comment:鑱屼綅"` - Phone string `json:"phone" gorm:"column:phone;type:varchar(255);comment:鐢佃瘽"` - MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:璐熻矗浜篒D"` - Member User `json:"member" gorm:"foreignKey:MemberId"` - IsFirst bool `json:"is_first" gorm:"column:is_first;type:tinyint(1);comment:鏄惁棣栬鑱旂郴浜�"` - Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255);comment:寰俊"` - Birthday *CustomTime `json:"birthday" gorm:"column:birthday;type:datetime;comment:鐢熸棩"` - Email string `json:"email" gorm:"column:email;type:varchar(255);comment:閭"` - Desc string `json:"desc" gorm:"column:desc;type:varchar(255);comment:澶囨敞"` + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鑱旂郴浜哄鍚�"` + Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鑱旂郴浜虹紪鍙�"` + ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛ID"` + Client Client `json:"-" gorm:"foreignKey:ClientId"` + Position string `json:"position" gorm:"column:position;type:varchar(255);comment:鑱屼綅"` + Phone string `json:"phone" gorm:"column:phone;type:varchar(255);comment:鐢佃瘽"` + MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:璐熻矗浜篒D"` + Member User `json:"member" gorm:"foreignKey:MemberId"` + IsFirst bool `json:"is_first" gorm:"column:is_first;type:tinyint(1);comment:鏄惁棣栬鑱旂郴浜�"` + Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255);comment:寰俊"` + Birthday *CustomTime `json:"birthday" gorm:"column:birthday;type:datetime;comment:鐢熸棩"` + Email string `json:"email" gorm:"column:email;type:varchar(255);comment:閭"` + Desc string `json:"desc" gorm:"column:desc;type:varchar(255);comment:澶囨敞"` + CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"` Address gorm.Model `json:"-"` } @@ -72,7 +73,7 @@ for key, value := range slf.SearchMap { switch v := value.(type) { case string: - if key == "name" || key == "position" || key == "phone" || key == "Number" { + if key == "name" || key == "position" || key == "phone" || key == "number" { db = db.Where(key+" LIKE ?", "%"+v+"%") } @@ -92,9 +93,16 @@ db = db.Where("is_first = ?", false) } } - case int: + case int, uint, int64, float64: + if key == "id" || key == "client_type_id" || key == "client_status_id" || key == "member_id" { + db = db.Where(key+" = ?", v) + } if key == "client_id" { - db = db.Where("client_id = ?", v) + db = db.Where("client_id = ? and is_first = true", v) + } + case []int: + if key == "member_ids" { + db = db.Where("contacts.member_id in ?", v) } } } -- Gitblit v1.8.0