From b90a31431164b4b0756e4ef76f08b08953b8b04d Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 13 十月 2023 14:56:23 +0800 Subject: [PATCH] 服务合同简单数据权限 --- model/contract.go | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/model/contract.go b/model/contract.go index 4c75e20..29eec25 100644 --- a/model/contract.go +++ b/model/contract.go @@ -7,17 +7,18 @@ type ( Contract struct { - Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` - Client Client `json:"client" gorm:"foreignKey:ClientId"` - MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"` - Member User `json:"member" gorm:"foreignKey:MemberId"` - Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"` - QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"` - Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId;references:Id"` - StatusId int `json:"statusId" gorm:"column:status_id;type:int;comment:鍚堝悓鐘舵��"` - File string `json:"file" gorm:"column:file;type:varchar(255);comment:鍚堝悓鏂囦欢"` - CreatedAt *CustomTime `json:"created_at" gorm:"column:created_at;type:datetime;comment:鍒涘缓鏃堕棿"` + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` + Client Client `json:"client" gorm:"foreignKey:ClientId"` + MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"` + Member User `json:"member" gorm:"foreignKey:MemberId"` + Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"` + QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"` + Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId;references:Id"` + StatusId int `json:"statusId" gorm:"column:status_id;type:int;comment:鍚堝悓鐘舵��"` + ServiceContractStatus ServiceContractStatus `json:"serviceContractStatus" gorm:"foreignKey:StatusId;references:Id"` + File string `json:"file" gorm:"column:file;type:varchar(255);comment:鍚堝悓鏂囦欢"` + CreatedAt *CustomTime `json:"created_at" gorm:"column:created_at;type:datetime;comment:鍒涘缓鏃堕棿"` gormModel } @@ -69,6 +70,9 @@ db = db.Where(key+"= ?", v) } case int: + if key == "member_id" { + db = db.Where(key+"= ?", v) + } } } } @@ -113,7 +117,7 @@ db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) } - err := db.Preload("Client").Preload("Member").Preload("Quotation").Order("id desc").Find(&records).Error + err := db.Preload("ServiceContractStatus").Preload("Client").Preload("Member").Preload("Quotation").Order("id desc").Find(&records).Error return records, total, err } -- Gitblit v1.8.0