根据类型获取用户

usertest
cjy 4 months ago
parent 647b09f843
commit bfcc2b81b1

@ -14,7 +14,11 @@ namespace DS.WMS.Core.Sys.Interface;
/// </summary>
public interface IClientCommonService
{
/// <summary>
/// 根据类型获取用户下拉列表
/// </summary>
/// <returns></returns>
public Task<DataResult<List<ApiSelectViewModel>>> GetUserListByCode(string code = "");
/// <summary>
/// 获取工厂信息下拉列表
/// </summary>

@ -43,7 +43,30 @@ public class ClientCommonService : IClientCommonService
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
/// <summary>
/// 根据类型获取用户下拉列表
/// </summary>
/// <returns></returns>
public async Task<DataResult<List<ApiSelectViewModel>>> GetUserListByCode(string code = "")
{
code = code.ToLower();
var data = await db.Queryable<SysUser>()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt())
.WhereIF(code == "operator", a => a.IsOperator == true)
.WhereIF(code == "doc", a => a.IsVouchingClerk == true)
.WhereIF(code == "sale", a => a.IsSale == true)
.WhereIF(code == "custom", a => a.IsCustom == true)
.WhereIF(code == "finance", a => a.IsFinancialStaff == true)
.WhereIF(code == "service", a => a.IsCustomerService == true)
.WhereIF(code == "driver", a => a.IsDriver == true)
.WhereIF(code == "dispatcher", a => a.IsDispatcher == true)
.Select(a => new ApiSelectViewModel
{
Label = a.UserName,
Value = a.Id,
}).ToListAsync();
return DataResult<List<ApiSelectViewModel>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
/// <summary>
/// 获取工厂信息下拉列表-客户端
/// </summary>

@ -29,6 +29,17 @@ public class ClientCommonController : ApiController
_invokeService = invokeService;
}
/// <summary>
/// 根据类型获取用户下拉列表
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetUserListByCode")]
public async Task<DataResult<List<ApiSelectViewModel>>> GetUserListByCode([FromQuery] string code = "")
{
var res = await _invokeService.GetUserListByCode(code);
return res;
}
/// <summary>
/// 获取工厂信息下拉列表-客户端
/// </summary>
/// <returns></returns>

Loading…
Cancel
Save