Added primitive search mechanism in backend.
Began implementing search mechanism for frontend.
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Props.Models.Search
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string OriginName { get; set; }
|
||||
public string ShopName { get; set; }
|
||||
|
||||
public uint Hits { get; set; }
|
||||
|
||||
|
34
Props/Models/Search/QueryWordInfo.cs
Normal file
34
Props/Models/Search/QueryWordInfo.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Props.Models.Search
|
||||
{
|
||||
public class QueryWordInfo
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Word { get; set; }
|
||||
public uint Hits { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ISet<QueryWordInfo> Preceding { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ISet<QueryWordInfo> Following { get; set; }
|
||||
|
||||
public QueryWordInfo()
|
||||
{
|
||||
this.Preceding = new HashSet<QueryWordInfo>();
|
||||
this.Following = new HashSet<QueryWordInfo>();
|
||||
}
|
||||
|
||||
public QueryWordInfo(ISet<QueryWordInfo> preceding, ISet<QueryWordInfo> following)
|
||||
{
|
||||
this.Preceding = preceding;
|
||||
this.Following = following;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,10 +17,13 @@ namespace Props.Models.Search
|
||||
[Required]
|
||||
public virtual ApplicationUser ApplicationUser { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; } = "Default";
|
||||
|
||||
public Filters Filters { get; set; } = new Filters();
|
||||
|
||||
[Required]
|
||||
public ShopsDisabled Disabled { get; set; } = new ShopsDisabled();
|
||||
public ShopsDisabled Enabled { get; set; } = new ShopsDisabled();
|
||||
|
||||
public sealed class ShopsDisabled : HashSet<string>
|
||||
{
|
||||
@@ -68,12 +71,26 @@ namespace Props.Models.Search
|
||||
return
|
||||
Id == other.Id &&
|
||||
Filters.Equals(other.Filters) &&
|
||||
Disabled.Equals(other.Disabled);
|
||||
Enabled.Equals(other.Enabled);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id;
|
||||
return HashCode.Combine(Id, Name);
|
||||
}
|
||||
|
||||
public SearchOutline()
|
||||
{
|
||||
this.Name = "Default";
|
||||
this.Filters = new Filters();
|
||||
this.Enabled = new ShopsDisabled();
|
||||
}
|
||||
|
||||
public SearchOutline(string name, Filters filters, ShopsDisabled disabled)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Filters = filters;
|
||||
this.Enabled = disabled;
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Props.Models.Search;
|
||||
using Props.Shared.Models.User;
|
||||
|
||||
@@ -11,7 +12,8 @@ namespace Props.Models.User
|
||||
{
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
public virtual ISet<SearchOutline> SearchOutlines { get; set; }
|
||||
[Required]
|
||||
public virtual SearchOutlinePreferences searchOutlinePreferences { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ResultsPreferences ResultsPreferences { get; private set; }
|
||||
@@ -19,15 +21,16 @@ namespace Props.Models.User
|
||||
[Required]
|
||||
public virtual ApplicationPreferences ApplicationPreferences { get; private set; }
|
||||
|
||||
// TODO: Write project system.
|
||||
public ApplicationUser()
|
||||
{
|
||||
searchOutlinePreferences = new SearchOutlinePreferences();
|
||||
ResultsPreferences = new ResultsPreferences();
|
||||
ApplicationPreferences = new ApplicationPreferences();
|
||||
}
|
||||
|
||||
public ApplicationUser(ResultsPreferences resultsPreferences, ApplicationPreferences applicationPreferences)
|
||||
public ApplicationUser(SearchOutlinePreferences searchOutlinePreferences, ResultsPreferences resultsPreferences, ApplicationPreferences applicationPreferences)
|
||||
{
|
||||
this.searchOutlinePreferences = searchOutlinePreferences;
|
||||
this.ResultsPreferences = resultsPreferences;
|
||||
this.ApplicationPreferences = applicationPreferences;
|
||||
}
|
||||
|
37
Props/Models/User/SearchOutlinePreferences.cs
Normal file
37
Props/Models/User/SearchOutlinePreferences.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Props.Models.Search;
|
||||
using Props.Models.User;
|
||||
|
||||
namespace Props.Models.User
|
||||
{
|
||||
public class SearchOutlinePreferences
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ApplicationUser ApplicationUser { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ISet<SearchOutline> SearchOutlines { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual SearchOutline ActiveSearchOutline { get; set; }
|
||||
|
||||
public SearchOutlinePreferences()
|
||||
{
|
||||
SearchOutlines = new HashSet<SearchOutline>();
|
||||
ActiveSearchOutline = new SearchOutline();
|
||||
SearchOutlines.Add(ActiveSearchOutline);
|
||||
}
|
||||
|
||||
public SearchOutlinePreferences(ISet<SearchOutline> searchOutlines, SearchOutline activeSearchOutline)
|
||||
{
|
||||
this.SearchOutlines = searchOutlines;
|
||||
this.ActiveSearchOutline = activeSearchOutline;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user