⚠️feat: 优化用户选择组件

This commit is contained in:
yubaolee
2025-08-02 19:42:42 +08:00
parent c084e2409f
commit 04142acaaa
2 changed files with 44 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ using System.Linq;
using Infrastructure;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
@@ -76,16 +77,18 @@ namespace OpenAuth.App
}
/// <summary>
/// 加载特定用户的部门
/// 获取所有机构
/// </summary>
/// <param name="userId">The user unique identifier.</param>
public List<SysOrg> LoadForUser(string userId)
/// <returns></returns>
public List<OrgView> LoadAll()
{
var result = SugarClient.Queryable<Relevance>()
.LeftJoin<SysOrg>((u, o) => u.SecondId == o.Id)
.Where((u, o) => u.FirstId == userId && u.RelKey == Define.USERORG)
.Select((u, o) => o);
return result.ToList();
return SugarClient.Queryable<SysOrg>()
.LeftJoin<SysUser>((org, user) => org.ChairmanId ==user.Id)
.Select((org,user)=>new OrgView
{
Id = org.Id.SelectAll(),
ChairmanName = user.Name
}).ToList();
}
public OrgManagerApp(ISqlSugarClient client, IAuth auth,

View File

@@ -2,7 +2,9 @@
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
using System.Collections.Generic;
namespace OpenAuth.WebApi.Controllers
{
@@ -79,6 +81,37 @@ namespace OpenAuth.WebApi.Controllers
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>
/// 删除选中的部门及所有的子部门