feature: add flower
This commit is contained in:
@ -11,7 +11,7 @@ internal sealed class Constants
|
||||
public const string LastTokenName = "last_token";
|
||||
|
||||
public const string BaseUrl = "https://app.blahblaho.com";
|
||||
public const string AppVersion = "0.2.801";
|
||||
public const string AppVersion = "0.3.802";
|
||||
public const string UserAgent = $"FlowerApp/{AppVersion}";
|
||||
|
||||
public const SQLiteOpenFlags SQLiteFlags =
|
||||
@ -64,14 +64,14 @@ internal record Definitions
|
||||
public required Dictionary<int, EventItem> Events { get; init; }
|
||||
}
|
||||
|
||||
internal record NamedItem(string Name, string? Description)
|
||||
public record NamedItem(string Name, string? Description)
|
||||
{
|
||||
public string Name { get; init; } = Name;
|
||||
|
||||
public string? Description { get; init; } = Description;
|
||||
}
|
||||
|
||||
internal record EventItem(string Name, string? Description, bool Unique) : NamedItem(Name, Description)
|
||||
public record EventItem(string Name, string? Description, bool Unique) : NamedItem(Name, Description)
|
||||
{
|
||||
public bool Unique { get; init; } = Unique;
|
||||
}
|
@ -21,6 +21,8 @@ public class FlowerDatabase : ILoggerContent
|
||||
|
||||
private Dictionary<int, EventItem>? events;
|
||||
|
||||
public Dictionary<int, NamedItem>? Categories => categories;
|
||||
|
||||
public string Category(int categoryId)
|
||||
{
|
||||
if (categories?.TryGetValue(categoryId, out var category) == true)
|
||||
@ -168,6 +170,18 @@ public class FlowerDatabase : ILoggerContent
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> GetLogCount()
|
||||
{
|
||||
await Init();
|
||||
return await database.Table<LogItem>().Where(l => l.OwnerId < 0 || l.OwnerId == AppResources.User.Id).CountAsync();
|
||||
}
|
||||
|
||||
public async Task<LogItem[]> GetLogs()
|
||||
{
|
||||
await Init();
|
||||
return await database.Table<LogItem>().Where(l => l.OwnerId < 0 || l.OwnerId == AppResources.User.Id).OrderByDescending(l => l.LogUnixTime).ToArrayAsync();
|
||||
}
|
||||
|
||||
public async Task<int> AddLog(LogItem log)
|
||||
{
|
||||
await Init();
|
||||
|
@ -41,4 +41,10 @@ public class FlowerItem
|
||||
|
||||
[Ignore]
|
||||
public int? Distance { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
// TODO:
|
||||
return $"id: {Id}, owner: {OwnerId}, category: {CategoryId}, name: {Name}, date: {DateBuyUnixTime}, ...";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user