Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #100 from MaaAssistantArknights/fix/query
Browse files Browse the repository at this point in the history
检索更新
  • Loading branch information
AlisaAkiron authored Sep 14, 2022
2 parents b45c0b7 + 08f7ea4 commit 30c8014
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,14 @@
"type": "string"
}
},
{
"name": "document",
"in": "query",
"description": "The Title and Details to search for.",
"schema": {
"type": "string"
}
},
{
"name": "operator",
"in": "query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public GetLevelListDto(string catOne, string catTwo, string catThree, string nam
public GetLevelListDto() { }
#pragma warning restore CS8618

private string _levelId = string.Empty;

/// <summary>
/// Category one of the level.
/// </summary>
Expand Down Expand Up @@ -72,7 +74,10 @@ public GetLevelListDto() { }
/// </summary>
[Required]
[JsonPropertyName("level_id")]
public string LevelId { get; set; }
public string LevelId {
get => Custom ? _levelId.Replace("copilot-custom/", string.Empty) : _levelId;
set => _levelId = value;
}

/// <summary>
/// The width of the level.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ public async Task<MaaApiResponse> Handle(CreateCopilotOperationCommand request,
// Get user
var user = (await _currentUserService.GetUser()).IsNotNull();

// Check if the stage is custom stage or not
var realContent = validationResult.ArkLevel!.Custom
? request.Content!.Replace(
validationResult.ArkLevel.LevelId,
validationResult.ArkLevel.LevelId.Replace("copilot-custom/", string.Empty))
: request.Content!;

// Build entity
var entity = new Domain.Entities.CopilotOperation(
request.Content!,
realContent,
obj.MinimumRequired!,
obj.Doc!.Title!,
obj.Doc!.Details!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public record QueryCopilotOperationsQuery : IRequest<MaaApiResponse>
[FromQuery(Name = "level_keyword")]
public string? Keyword { get; set; }

/// <summary>
/// The Title and Details to search for.
/// </summary>
[FromQuery(Name = "document")]
public string? Document { get; set; } = null;

/// <summary>
/// The operator query string. Use `,` to split multiple expressions. All expressions will be combined with AND.
/// The expression defaults to `Include`, add `~` at the beginning to perform an `Exclude` operation. Eg: `A,~B,C`
Expand Down Expand Up @@ -169,6 +175,15 @@ public async Task<MaaApiResponse> Handle(
queryable = request.Language.GetQueryKeywordFunc().Invoke(queryable, request.Keyword);
}

if (string.IsNullOrEmpty(request.Document) is false)
{
// if document is set, filter by it
// match both Title and Details fields
queryable = queryable.Where(x =>
EF.Functions.ILike(x.Title, $"%{request.Document}%") ||
EF.Functions.ILike(x.Details, $"%{request.Document}%"));
}

if (uploaderId is not null)
{
// if uploader id is set, filter by it
Expand Down

0 comments on commit 30c8014

Please sign in to comment.