From 4d0b38be2e3977ec390f70de2f022fe96c4cbb61 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 30 十月 2023 20:36:57 +0800 Subject: [PATCH] 数据权限支持职级 --- model/invoice.go | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/model/invoice.go b/model/invoice.go index 0db64fa..7089b18 100644 --- a/model/invoice.go +++ b/model/invoice.go @@ -36,12 +36,13 @@ // InvoiceSearch 閿�鍞彂绁ㄦ悳绱㈡潯浠� InvoiceSearch struct { Invoice - Orm *gorm.DB - QueryClass constvar.InvoiceQueryClass - KeywordType constvar.InvoiceKeywordType - Keyword string - PageNum int - PageSize int + Orm *gorm.DB + QueryClass constvar.InvoiceQueryClass + KeywordType constvar.InvoiceKeywordType + Keyword string + PageNum int + PageSize int + PrincipalIds []int } ) @@ -65,6 +66,11 @@ return slf } +func (slf *InvoiceSearch) SetPrincipalIds(principalIds []int) *InvoiceSearch { + slf.PrincipalIds = principalIds + return slf +} + func (slf *InvoiceSearch) build() *gorm.DB { var db = slf.Orm.Model(&Invoice{}) if slf.Id != 0 { @@ -81,6 +87,9 @@ if slf.Number != "" { db.Where("number = ?", slf.Number) } + if len(slf.PrincipalIds) > 0 { + db = db.Where("principal_id in ?", slf.PrincipalIds) + } return db } -- Gitblit v1.8.0