using Dapper; using System.Collections.Generic; using System.Data; using System.Linq; using Znyc.Recruitment.Admin.Commons.IDbContext; using Znyc.Recruitment.Admin.Commons.Repositories; using Znyc.Recruitment.Admin.Security.Entitys; using Znyc.Recruitment.Admin.Security.IRepositories; namespace Znyc.Recruitment.Admin.Security.Repositories { public class RoleDataRepository : BaseRepository, IRoleDataRepository { public RoleDataRepository() { } public RoleDataRepository(IDbContextCore dbContext) : base(dbContext) { } /// /// 根据角色返回授权访问部门数据 /// /// /// public List GetListDeptByRole(string roleIds) { string roleIDsStr = string.Format("'{0}'", roleIds.Replace(",", "','")); string where = " RoleId in(" + roleIDsStr + ") and DType='dept'"; string sql = $"select AuthorizeData from {tableName} "; if (!string.IsNullOrWhiteSpace(where)) { sql += " where " + @where; } using (IDbConnection connection = DapperConn) { bool isClosed = connection.State == ConnectionState.Closed; if (isClosed) { connection.Open(); } IEnumerable resultList = connection.Query(sql); return resultList.ToList(); } } } }