mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 01:58:01 +08:00
⚠️feat: 为前端穿梭框提供接口
This commit is contained in:
@@ -52,6 +52,16 @@ namespace OpenAuth.App
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID加载角色
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<Role> LoadByIds(string[] ids)
|
||||||
|
{
|
||||||
|
return UnitWork.Find<Role>(u => ids.Contains(u.Id)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加角色,如果当前登录用户不是System,则直接把新角色分配给当前登录用户
|
/// 添加角色,如果当前登录用户不是System,则直接把新角色分配给当前登录用户
|
||||||
|
@@ -340,5 +340,49 @@ namespace OpenAuth.App
|
|||||||
var users = UnitWork.FromSql<SysUser>(sql);
|
var users = UnitWork.FromSql<SysUser>(sql);
|
||||||
return users.Select(u=>u.Id).ToList();
|
return users.Select(u=>u.Id).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<UserView> LoadByIds(string[] ids)
|
||||||
|
{
|
||||||
|
var users = Repository.Find(u => ids.Contains(u.Id));
|
||||||
|
|
||||||
|
//获取用户及用户关联的机构
|
||||||
|
var userOrgs = from user in users
|
||||||
|
join relevance in UnitWork.Find<Relevance>(u => u.RelKey == "UserOrg")
|
||||||
|
on user.Id equals relevance.FirstId into temp
|
||||||
|
from r in temp.DefaultIfEmpty()
|
||||||
|
join org in UnitWork.Find<SysOrg>(null)
|
||||||
|
on r.SecondId equals org.Id into orgtmp
|
||||||
|
from o in orgtmp.DefaultIfEmpty()
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
user.Id,
|
||||||
|
user.Account,
|
||||||
|
user.Name,
|
||||||
|
user.Sex,
|
||||||
|
user.Status,
|
||||||
|
user.CreateTime,
|
||||||
|
user.CreateId,
|
||||||
|
user.ParentId,
|
||||||
|
OrgId = o.Id,
|
||||||
|
OrgName = o.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
var userViews = userOrgs.GroupBy(b => b.Account).Select(u => new UserView
|
||||||
|
{
|
||||||
|
Id = u.First().Id,
|
||||||
|
Account = u.Key,
|
||||||
|
Name = u.First().Name,
|
||||||
|
Sex = u.First().Sex,
|
||||||
|
Status = u.First().Status,
|
||||||
|
CreateTime = u.First().CreateTime,
|
||||||
|
CreateUser = u.First().CreateId,
|
||||||
|
ParentName = u.First().ParentId,
|
||||||
|
ParentId = u.First().ParentId,
|
||||||
|
OrganizationIds = string.Join(",", u.Select(x=>x.OrgId))
|
||||||
|
,Organizations = string.Join(",", u.Select(x=>x.OrgName))
|
||||||
|
});
|
||||||
|
|
||||||
|
return userViews.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -40,6 +40,24 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Response LoadByIds([FromBody]string[] ids)
|
||||||
|
{
|
||||||
|
var result = new Response<List<Role>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.Data = _app.LoadByIds(ids);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -139,6 +140,24 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Response LoadByIds([FromBody]string[] ids)
|
||||||
|
{
|
||||||
|
var result = new Response<List<UserView>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.Data = _app.LoadByIds(ids);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载指定角色的用户
|
/// 加载指定角色的用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Reference in New Issue
Block a user