From c5a0eb549cba2cd358a2d0496c44f3a289f15d9c Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期一, 28 八月 2023 14:22:06 +0800
Subject: [PATCH] fix

---
 model/client.go |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/model/client.go b/model/client.go
index f68f542..fcd3023 100644
--- a/model/client.go
+++ b/model/client.go
@@ -10,15 +10,16 @@
 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:瀹㈡埛鐘舵�両D"`
+		ClientStatusId    int            `json:"client_status_id" gorm:"column:client_status_id;type:int(11);default:1;comment:瀹㈡埛鐘舵�両D"`
 		ClientStatus      ClientStatus   `json:"client_status" gorm:"foreignKey:ClientStatusId"`
-		ClientTypeId      int            `json:"client_type_id" gorm:"column:client_type_id;type:int(11);comment:瀹㈡埛绫诲瀷ID"`
+		ClientTypeId      int            `json:"client_type_id" gorm:"column:client_type_id;type:int(11);default:1;comment:瀹㈡埛绫诲瀷ID"`
 		ClientType        ClientType     `json:"client_type" gorm:"foreignKey:ClientTypeId"`
-		ClientOriginId    int            `json:"client_origin_id" gorm:"column:client_origin_id;type:int(11);comment:瀹㈡埛鏉ユ簮ID"`
+		ClientOriginId    int            `json:"client_origin_id" gorm:"column:client_origin_id;type:int(11);default:1;comment:瀹㈡埛鏉ユ簮ID"`
 		ClientOrigin      ClientOrigin   `json:"client_origin" gorm:"foreignKey:ClientOriginId"`
-		ClientLevelId     int            `json:"client_level_id" gorm:"column:client_level_id;type:int(11);comment:瀹㈡埛绛夌骇ID"`
+		ClientLevelId     int            `json:"client_level_id" gorm:"column:client_level_id;type:int(11);default:1;comment:瀹㈡埛绛夌骇ID"`
 		ClientLevel       ClientLevel    `json:"client_level" gorm:"foreignKey:ClientLevelId"`
 		Contacts          []Contact      `json:"contacts" gorm:"foreignKey:ClientId"`
 		MemberId          int            `json:"member_id" gorm:"column:member_id;type:int(11);comment:閿�鍞礋璐d汉ID"`
@@ -26,12 +27,13 @@
 		ServiceMemberId   int            `json:"service_member_id" gorm:"column:service_member_id;type:int(11);comment:鏈嶅姟璐熻矗浜篒D"`
 		DetailAddress     string         `json:"detail_address" gorm:"column:detail_address;type:varchar(255);comment:璇︾粏鍦板潃"`
 		Remark            string         `json:"remark" gorm:"column:remark;type:varchar(255);comment:澶囨敞"`
+		CreatorId         int            `json:"creator_id" gorm:"column:creator_id;type:int;comment:鍒涘缓浜篿d"`
 		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 {
@@ -72,7 +74,7 @@
 		for key, value := range slf.SearchMap {
 			switch v := value.(type) {
 			case string:
-				if key == "name" || key == "number" || key == "detail_address" {
+				if key == "name" || key == "number" || key == "detail_address" || key == "remark" || key == "business_scope" || key == "registration_time" || key == "representative" {
 					db = db.Where(key+" LIKE ?", "%"+v+"%")
 				}
 
@@ -111,9 +113,20 @@
 				}
 
 			case int:
+			case int64:
+			case float64:
 				if key == "id" || key == "client_type_id" || key == "client_status_id" || key == "member_id" {
 					db = db.Where(key+" = ?", v)
 				}
+
+				if key == "not_admin" {
+					if v == float64(constvar.NotAdminYes) {
+						db = db.Where("member_id != ?", constvar.UserTypeSuper)
+					} else {
+						db = db.Where("member_id = ?", constvar.UserTypeSuper)
+					}
+				}
+
 			}
 		}
 	}
@@ -133,6 +146,7 @@
 
 func (slf *ClientSearch) Delete() error {
 	var db = slf.build()
+	db.Update("is_deleted", 1)
 	return db.Delete(&Client{}).Error
 }
 

--
Gitblit v1.8.0