From 0037c4e54788c3292652c3bf906a29e32e8c6867 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Thu, 6 May 2021 22:33:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9D=9Eadmin=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9A=84=E6=9D=83=E9=99=90=E6=95=B0=E6=8D=AE=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/log/implments/ArtDemandHead.dao.impl.go | 10 ++++++++-- dao/log/implments/ArtDemandLst.dao.impl.go | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dao/log/implments/ArtDemandHead.dao.impl.go b/dao/log/implments/ArtDemandHead.dao.impl.go index cdb8c9e..901bed6 100644 --- a/dao/log/implments/ArtDemandHead.dao.impl.go +++ b/dao/log/implments/ArtDemandHead.dao.impl.go @@ -195,7 +195,9 @@ func (impl *ArtDemandHeadDAOImplement) Select(predicates []grmi.Predicate, order } else { session = session.Where(where, parameters...) } - + if impl.userid != "admin" { + session = session.Where("ArtId in (select ArtId from LOG_VendorArtLst where VendorId in (select VendorId from LOG_VendorUserLst where UserId = ?))", impl.userid) + } session = session.OrderBy(meta.ArtDemandHead_PlantNr.ColumnName) if orderByFields != nil { for _, field := range orderByFields { @@ -231,7 +233,11 @@ func (impl *ArtDemandHeadDAOImplement) SelectAndPaging(paging *grmi.Paging, pred } else { session = session.Where(where, parameters...) } - + if impl.userid != "admin" { + where += " and ArtId in (select ArtId from LOG_VendorArtLst where VendorId in (select VendorId from LOG_VendorUserLst where UserId = ?)) " + parameters = append(parameters, impl.userid) + session = session.Where("ArtId in (select ArtId from LOG_VendorArtLst where VendorId in (select VendorId from LOG_VendorUserLst where UserId = ?))", impl.userid) + } count, err := session.Count(impl.meta.Indicator) if err != nil { return grmi.EmptyPagingResult, err diff --git a/dao/log/implments/ArtDemandLst.dao.impl.go b/dao/log/implments/ArtDemandLst.dao.impl.go index d0b5980..a98e0f9 100644 --- a/dao/log/implments/ArtDemandLst.dao.impl.go +++ b/dao/log/implments/ArtDemandLst.dao.impl.go @@ -195,7 +195,9 @@ func (impl *ArtDemandLstDAOImplement) Select(predicates []grmi.Predicate, orderB } else { session = session.Where(where, parameters...) } - + if impl.userid != "admin" { + session = session.Where("ArtId in (select ArtId from LOG_VendorArtLst where VendorId in (select VendorId from LOG_VendorUserLst where UserId = ?))", impl.userid) + } session = session.OrderBy(meta.ArtDemandLst_PlantNr.ColumnName) if orderByFields != nil { for _, field := range orderByFields { @@ -231,7 +233,11 @@ func (impl *ArtDemandLstDAOImplement) SelectAndPaging(paging *grmi.Paging, predi } else { session = session.Where(where, parameters...) } - + if impl.userid != "admin" { + where += " and ArtId in (select ArtId from LOG_VendorArtLst where VendorId in (select VendorId from LOG_VendorUserLst where UserId = ?)) " + parameters = append(parameters, impl.userid) + session = session.Where("ArtId in (select ArtId from LOG_VendorArtLst where VendorId in (select VendorId from LOG_VendorUserLst where UserId = ?))", impl.userid) + } count, err := session.Count(impl.meta.Indicator) if err != nil { return grmi.EmptyPagingResult, err @@ -248,6 +254,7 @@ func (impl *ArtDemandLstDAOImplement) SelectAndPaging(paging *grmi.Paging, predi if where != "" { where = " where " + where } + err = impl.session.Table(impl.meta.TableName).SQL("select * from "+impl.meta.TableName+where+orderBy+" offset ? row fetch next ? row only", parameters...).Find(&data) if err != nil { return grmi.EmptyPagingResult, err