Skip to content

Commit

Permalink
reactor : User search using Auth sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 committed Jul 3, 2023
1 parent 486fcc0 commit 524afdf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 64 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<SAutoComplete Small Value="Value"
ValueChanged="HandleValueChanged"
TValue="List<Guid>"
TItem="UserSelectDto"
TItem="UserSelectModel"
TItemValue="Guid"
OnSearchInputUpdate=OnSearchChanged
Items="Items"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Masa.Mc.Web.Admin.Components.Modules.Subjects;

public partial class UserAutoComplete : AdminCompontentBase
{
IAutoCompleteClient? _autocompleteClient;

[Parameter]
public List<Guid> Value { get; set; } = new();

Expand All @@ -19,18 +17,14 @@ public partial class UserAutoComplete : AdminCompontentBase
[Parameter]
public EventCallback<List<Guid>> ValueChanged { get; set; }

public List<UserSelectDto> Items { get; set; } = new();
public List<UserSelectModel> Items { get; set; } = new();

public List<UserSelectDto> UserSelect { get; set; } = new();
public List<UserSelectModel> UserSelect { get; set; } = new();

public string Search { get; set; } = "";

[Inject]
public IAutoCompleteClient AutoCompleteClient
{
get => _autocompleteClient ?? throw new Exception("Please inject IAutoCompleteClient");
set => _autocompleteClient = value;
}
public IAuthClient AuthClient { get; set; } = default!;

public async Task OnSearchChanged(string search)
{
Expand All @@ -41,16 +35,12 @@ public async Task OnSearchChanged(string search)
}
else if (Search == search)
{
var response = await AutoCompleteClient.GetBySpecifyDocumentAsync<UserSelectDto>(search, new AutoCompleteOptions
{
Page = Page,
PageSize = PageSize,
});
Items = response.Data;
var response = await AuthClient.UserService.SearchAsync(search);
Items = response;
}
}

public string TextView(UserSelectDto user)
public string TextView(UserSelectModel user)
{
if (!string.IsNullOrEmpty(user.DisplayName)) return user.DisplayName;
if (!string.IsNullOrEmpty(user.Account)) return user.Account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void HandleUserChange(List<Guid> userId)
}).ToList();
}

private string GetChannelUserIdentity(UserSelectDto user, ChannelTypes? type)
private string GetChannelUserIdentity(UserSelectModel user, ChannelTypes? type)
{
return type switch
{
Expand Down

0 comments on commit 524afdf

Please sign in to comment.