From dd39909b3d8172856313ea7b2e19d1d7a039a582 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 15 八月 2023 16:43:22 +0800
Subject: [PATCH] fix

---
 model/client.go |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/model/client.go b/model/client.go
index f68f542..f7c2b5e 100644
--- a/model/client.go
+++ b/model/client.go
@@ -10,7 +10,8 @@
 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"`
 		ClientStatus      ClientStatus   `json:"client_status" gorm:"foreignKey:ClientStatusId"`
@@ -59,6 +60,15 @@
 	}
 }
 
+func (c *Client) BeforeSave(tx *gorm.DB) (err error) {
+	if c.DeletedAt.Valid {
+		c.IsDeleted = true
+	} else {
+		c.IsDeleted = false
+	}
+	return
+}
+
 func (slf *ClientSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&Client{})
 	if slf.Id != 0 {

--
Gitblit v1.8.0