make app project standalone

This commit is contained in:
2023-08-04 09:05:13 +08:00
parent 31cfaee4f0
commit cec1e3bf71
82 changed files with 56 additions and 5124 deletions

View File

@ -66,6 +66,7 @@ public sealed class Constants
[(int)EventTypes.Death] = new("death", "死亡", true),
[(int)EventTypes.Sell] = new("sell", "出售", true),
[(int)EventTypes.Share] = new("share", "分享"),
[(int)EventTypes.Move] = new("move", "移动"),
};
}
@ -98,6 +99,10 @@ public enum EventTypes
/// 分享
/// </summary>
Share = 13,
/// <summary>
/// 移动
/// </summary>
Move = 14,
}
/// <summary>

View File

@ -32,6 +32,7 @@ public abstract partial class BaseController : ControllerBase
{
// jpeg
new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 },
new byte[] { 0xFF, 0xD8, 0xFF, 0xE1 },
new byte[] { 0xFF, 0xD8, 0xFF, 0xE2 },
new byte[] { 0xFF, 0xD8, 0xFF, 0xE3 },
// png

View File

@ -299,6 +299,14 @@ public class FlowerApiController : BaseController
return NotFound($"Flower id {id} not found");
}
var loc = database.Records
.OrderByDescending(r => r.DateUnixTime)
.FirstOrDefault(r => r.FlowerId == id && (r.EventId == (int)EventTypes.Move || r.EventId == (int)EventTypes.Born));
if (loc != null)
{
item.Location = loc.Memo;
}
if (includePhoto == true)
{
item.Photos = database.Photos.Where(p => p.FlowerId == item.Id && p.RecordId == null).ToList();
@ -459,6 +467,20 @@ public class FlowerApiController : BaseController
return NotFound();
}
FileResult? file;
if (flower.Cover?.Length > 0)
{
file = WrapFormFile(flower.Cover);
if (file == null)
{
return BadRequest();
}
}
else
{
file = null;
}
var item = new FlowerItem
{
OwnerId = user.Id,
@ -475,14 +497,24 @@ public class FlowerApiController : BaseController
SaveDatabase();
var now = user.ActiveDateUnixTime ?? DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
if (flower.Cover?.Length > 0)
if (flower.Location != null)
{
var file = WrapFormFile(flower.Cover);
if (file == null)
var record = new RecordItem
{
return BadRequest();
}
FlowerId = item.Id,
EventId = (int)EventTypes.Born,
DateUnixTime = now,
OwnerId = user.Id,
Latitude = flower.Latitude,
Longitude = flower.Longitude,
Memo = flower.Location
};
database.Records.Add(record);
SaveDatabase();
}
if (file != null)
{
try
{
await ExecuteTransaction(async token =>

View File

@ -77,6 +77,12 @@ public record FlowerParameter : CoverParameter
/// </summary>
[FromForm(Name = "lon")]
public double? Longitude { get; set; }
/// <summary>
/// 存放位置
/// </summary>
[FromForm(Name = "location")]
public string? Location { get; set; }
}
/// <summary>

View File

@ -101,4 +101,10 @@ public class FlowerItem : ILocation
/// </summary>
[NotMapped]
public int? Distance { get; set; }
/// <summary>
/// 花草位置
/// </summary>
[NotMapped]
public string? Location { get; set; }
}

View File

@ -11,7 +11,7 @@ public class Program
/// <inheritdoc/>
public const string ProjectName = "Flower Story";
/// <inheritdoc/>
public const string Version = "0.7.731";
public const string Version = "0.8.803";
/// <inheritdoc/>
public static void Main(string[] args)