招聘后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.6 KiB

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<RoleDataEntity, long>, IRoleDataRepository
{
public RoleDataRepository()
{
}
public RoleDataRepository(IDbContextCore dbContext) : base(dbContext)
{
}
/// <summary>
/// 根据角色返回授权访问部门数据
/// </summary>
/// <param name="roleIds"></param>
/// <returns></returns>
public List<string> 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<string> resultList = connection.Query<string>(sql);
return resultList.ToList();
}
}
}
}