| | |
| | | type ( |
| | | Client struct { |
| | | Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"` |
| | | Name string `json:"name" gorm:"column:name;unique;type:varchar(255);comment:客户名称"` |
| | | Name string `json:"name" gorm:"column:name;uniqueIndex:name_isDeleted_idx;type:varchar(255);comment:客户名称"` |
| | | IsDeleted bool `json:"-" gorm:"column:is_deleted;uniqueIndex:name_isDeleted_idx;type:tinyint(1);comment:是否删除"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:客户编号"` |
| | | ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态ID"` |
| | | ClientStatus ClientStatus `json:"client_status" gorm:"foreignKey:ClientStatusId"` |
| | |
| | | ServiceMemberId int `json:"service_member_id" gorm:"column:service_member_id;type:int(11);comment:服务负责人ID"` |
| | | DetailAddress string `json:"detail_address" gorm:"column:detail_address;type:varchar(255);comment:详细地址"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:varchar(255);comment:备注"` |
| | | NextVisitTime time.Time `json:"next_visit_time" gorm:"column:next_visit_time;type:datetime;comment:下次回访时间"` |
| | | LatestServiceTime time.Time `json:"latest_service_time" gorm:"column:latest_service_time;type:datetime;comment:最晚服务时间"` |
| | | CreatorId int `json:"creator_id" gorm:"column:creator_id;type:int;comment:创建人id"` |
| | | NextVisitTime *CustomTime `json:"next_visit_time" gorm:"column:next_visit_time;type:datetime;comment:下次回访时间"` |
| | | LatestServiceTime *CustomTime `json:"latest_service_time" gorm:"column:latest_service_time;type:datetime;comment:最晚服务时间"` |
| | | FollowRecord []FollowRecord `json:"follow_record" gorm:"foreignKey:ClientId"` |
| | | Address |
| | | Business |
| | | gorm.Model `json:"-"` |
| | | gormModel |
| | | } |
| | | |
| | | ClientSearch struct { |
| | |
| | | |
| | | func (slf *ClientSearch) Delete() error { |
| | | var db = slf.build() |
| | | db.Update("is_deleted", 1) |
| | | return db.Delete(&Client{}).Error |
| | | } |
| | | |
| | |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Preload("Member").Preload("ClientStatus").Preload("ClientType").Preload("ClientOrigin").Preload("ClientLevel").Preload("FollowRecord").Preload("EnterpriseNature").Preload("RegisteredCapital").Preload("Industry").Preload("EnterpriseScale").Preload("Contacts").Preload("Country").Preload("Province").Preload("City").Preload("Region").Find(&records).Error |
| | | err := db.Preload("Member").Preload("ClientStatus").Preload("ClientType").Preload("ClientOrigin").Preload("ClientLevel").Preload("FollowRecord").Preload("EnterpriseNature").Preload("RegisteredCapital").Preload("Industry").Preload("EnterpriseScale").Preload("Contacts").Preload("Country").Preload("Province").Preload("City").Preload("Region").Order("id desc").Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |