mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
⚠️feat: 优化用户选择组件
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository;
|
using OpenAuth.Repository;
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
using OpenAuth.Repository.Interface;
|
using OpenAuth.Repository.Interface;
|
||||||
@@ -76,16 +77,18 @@ namespace OpenAuth.App
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载特定用户的部门
|
/// 获取所有机构
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The user unique identifier.</param>
|
/// <returns></returns>
|
||||||
public List<SysOrg> LoadForUser(string userId)
|
public List<OrgView> LoadAll()
|
||||||
{
|
{
|
||||||
var result = SugarClient.Queryable<Relevance>()
|
return SugarClient.Queryable<SysOrg>()
|
||||||
.LeftJoin<SysOrg>((u, o) => u.SecondId == o.Id)
|
.LeftJoin<SysUser>((org, user) => org.ChairmanId ==user.Id)
|
||||||
.Where((u, o) => u.FirstId == userId && u.RelKey == Define.USERORG)
|
.Select((org,user)=>new OrgView
|
||||||
.Select((u, o) => o);
|
{
|
||||||
return result.ToList();
|
Id = org.Id.SelectAll(),
|
||||||
|
ChairmanName = user.Name
|
||||||
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrgManagerApp(ISqlSugarClient client, IAuth auth,
|
public OrgManagerApp(ISqlSugarClient client, IAuth auth,
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using OpenAuth.App;
|
using OpenAuth.App;
|
||||||
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace OpenAuth.WebApi.Controllers
|
namespace OpenAuth.WebApi.Controllers
|
||||||
{
|
{
|
||||||
@@ -79,6 +81,37 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有机构
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet]
|
||||||
|
public Response<List<OrgView>> LoadAll()
|
||||||
|
{
|
||||||
|
var result = new Response<List<OrgView>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.Data = _app.LoadAll();
|
||||||
|
}
|
||||||
|
catch (CommonException ex)
|
||||||
|
{
|
||||||
|
if (ex.Code == Define.INVALID_TOKEN)
|
||||||
|
{
|
||||||
|
result.Code = ex.Code;
|
||||||
|
result.Message = ex.Message;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException != null
|
||||||
|
? "OpenAuth.WebAPI数据库访问失败:" + ex.InnerException.Message
|
||||||
|
: "OpenAuth.WebAPI数据库访问失败:" + ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除选中的部门及所有的子部门
|
/// 删除选中的部门及所有的子部门
|
||||||
|
Reference in New Issue
Block a user