From 7ffcc41e597c5af4169e3e2ab809fdbf869c2154 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 18 七月 2023 16:08:47 +0800
Subject: [PATCH] add
---
model/contacts.go | 36 ++++++++++++++++++++----------------
1 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/model/contacts.go b/model/contacts.go
index c836d31..925fead 100644
--- a/model/contacts.go
+++ b/model/contacts.go
@@ -8,20 +8,18 @@
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"`
- 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"`
- 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 time.Time `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:澶囨敞"`
- Client Client
- FollowRecord []FollowRecord `gorm:"foreignKey:ContactId"`
+ 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"`
+ 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"`
+ 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 time.Time `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:澶囨敞"`
Address
gorm.Model `json:"-"`
}
@@ -29,6 +27,12 @@
ContactSearch struct {
Contact
Orm *gorm.DB
+ }
+
+ ContactDetail struct {
+ Contact
+ Client Client
+ FollowRecord []FollowRecord `gorm:"foreignKey:ContactId"`
}
)
@@ -80,9 +84,9 @@
return record, err
}
-func (slf *ContactSearch) FindAll() ([]*Contact, error) {
+func (slf *ContactSearch) FindAll() ([]*ContactDetail, error) {
var db = slf.build()
- var records = make([]*Contact, 0)
+ var records = make([]*ContactDetail, 0)
err := db.Preload("FollowRecord").Preload("Client").Preload("Country").Preload("Province").Preload("City").Preload("Region").Find(&records).Error
return records, err
}
--
Gitblit v1.8.0