修改BUG:MySQL数据库下Groups未格式化,Bootstrap.DataAccess组件升级到1.3

This commit is contained in:
Argo-Surface 2019-01-20 11:45:32 +08:00
parent 4290fb65c9
commit af03539bd3
2 changed files with 13 additions and 5 deletions

View File

@ -11,7 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="1.2.0" /> <PackageReference Include="Bootstrap.Security.DataAccess" Version="1.3.0" />
<PackageReference Include="Longbow.Data" Version="2.2.2" /> <PackageReference Include="Longbow.Data" Version="2.2.2" />
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" /> <PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
<PackageReference Include="Longbow.Web" Version="2.2.2" /> <PackageReference Include="Longbow.Web" Version="2.2.2" />

View File

@ -36,7 +36,7 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
public virtual IEnumerable<Group> Retrieves() => DbManager.Create().Fetch<Group>("select * from Groups"); public virtual IEnumerable<Group> Retrieves() => DbManager.Create().Fetch<Group>();
/// <summary> /// <summary>
/// 删除群组信息 /// 删除群组信息
@ -52,7 +52,7 @@ namespace Bootstrap.DataAccess
db.BeginTransaction(); db.BeginTransaction();
db.Execute($"delete from UserGroup where GroupID in ({ids})"); db.Execute($"delete from UserGroup where GroupID in ({ids})");
db.Execute($"delete from RoleGroup 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(); db.CompleteTransaction();
ret = true; ret = true;
} }
@ -80,14 +80,22 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <returns></returns> /// <returns></returns>
public virtual IEnumerable<Group> RetrievesByUserId(string userId) => DbManager.Create().Fetch<Group>("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<Group> RetrievesByUserId(string userId)
{
var db = DbManager.Create();
return db.Fetch<Group>($"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);
}
/// <summary> /// <summary>
/// 根据角色ID指派部门 /// 根据角色ID指派部门
/// </summary> /// </summary>
/// <param name="roleId"></param> /// <param name="roleId"></param>
/// <returns></returns> /// <returns></returns>
public virtual IEnumerable<Group> RetrievesByRoleId(string roleId) => DbManager.Create().Fetch<Group>("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<Group> RetrievesByRoleId(string roleId)
{
var db = DbManager.Create();
return DbManager.Create().Fetch<Group>($"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);
}
/// <summary> /// <summary>
/// 保存用户部门关系 /// 保存用户部门关系