From af03539bd373f49f4895a62c83e0c2b7d259c754 Mon Sep 17 00:00:00 2001 From: Argo-Surface Date: Sun, 20 Jan 2019 11:45:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9AMySQL=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E4=B8=8BGroups=E6=9C=AA=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=EF=BC=8CBootstrap.DataAccess=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B01.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess/Bootstrap.DataAccess.csproj | 2 +- Bootstrap.DataAccess/Group.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj index a997dabb..0c65f6ac 100644 --- a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj +++ b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj @@ -11,7 +11,7 @@ - + diff --git a/Bootstrap.DataAccess/Group.cs b/Bootstrap.DataAccess/Group.cs index b35db99d..0e689286 100644 --- a/Bootstrap.DataAccess/Group.cs +++ b/Bootstrap.DataAccess/Group.cs @@ -36,7 +36,7 @@ namespace Bootstrap.DataAccess /// /// /// - public virtual IEnumerable Retrieves() => DbManager.Create().Fetch("select * from Groups"); + public virtual IEnumerable Retrieves() => DbManager.Create().Fetch(); /// /// 删除群组信息 @@ -52,7 +52,7 @@ namespace Bootstrap.DataAccess db.BeginTransaction(); db.Execute($"delete from UserGroup where GroupID in ({ids})"); db.Execute($"delete from RoleGroup where GroupID in ({ids})"); - db.Execute($"delete from Groups where ID in ({ids})"); + db.Execute($"delete from {db.Provider.EscapeSqlIdentifier("Groups")} where ID in ({ids})"); db.CompleteTransaction(); ret = true; } @@ -80,14 +80,22 @@ namespace Bootstrap.DataAccess /// /// /// - public virtual IEnumerable RetrievesByUserId(string userId) => DbManager.Create().Fetch("select g.ID, g.GroupName, g.Description, case ug.GroupID when g.ID then 'checked' else '' end Checked from Groups g left join UserGroup ug on g.ID = ug.GroupID and UserID = @0", userId); + public virtual IEnumerable RetrievesByUserId(string userId) + { + var db = DbManager.Create(); + return db.Fetch($"select g.ID, g.GroupName, g.Description, case ug.GroupID when g.ID then 'checked' else '' end Checked from {db.Provider.EscapeSqlIdentifier("Groups")} g left join UserGroup ug on g.ID = ug.GroupID and UserID = @0", userId); + } /// /// 根据角色ID指派部门 /// /// /// - public virtual IEnumerable RetrievesByRoleId(string roleId) => DbManager.Create().Fetch("select g.ID, g.GroupName, g.Description, case rg.GroupID when g.ID then 'checked' else '' end Checked from Groups g left join RoleGroup rg on g.ID = rg.GroupID and RoleID = @0", roleId); + public virtual IEnumerable RetrievesByRoleId(string roleId) + { + var db = DbManager.Create(); + return DbManager.Create().Fetch($"select g.ID, g.GroupName, g.Description, case rg.GroupID when g.ID then 'checked' else '' end Checked from {db.Provider.EscapeSqlIdentifier("Groups")} g left join RoleGroup rg on g.ID = rg.GroupID and RoleID = @0", roleId); + } /// /// 保存用户部门关系