This commit is contained in:
tanglong 2026-01-13 14:24:54 +08:00
parent 2fc06708dd
commit 63322f39d7
6 changed files with 103 additions and 0 deletions

View File

@ -20,6 +20,8 @@ namespace AiSportsMicrospaceDB.DBContext
public DbSet<SixGroupPoints> SixGroupPoints { get; set; } public DbSet<SixGroupPoints> SixGroupPoints { get; set; }
public DbSet<JumpLongPoints> JumpLongPoints { get; set; } public DbSet<JumpLongPoints> JumpLongPoints { get; set; }
public DbSet<AppVersion> AppVersion { get; set; }
public DbSet<DeviceAssocSchool> DeviceAssocSchool { get; set; }
} }
} }

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AiSportsMicrospaceDB.Entities
{
[Table("AppVersion")]
public class AppVersion
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
/// <summary>
/// 应用类型
/// </summary>
[Required]
public int AppType { get; set; }
/// <summary>
/// 备注
/// </summary>
[Column(TypeName = "nvarchar(2000)")]
public string? Remarks { get; set; }
/// <summary>
/// 版本号
/// </summary>
[Column(TypeName = "nvarchar(200)")]
public string? Version { get; set; }
/// <summary>
/// 下载地址
/// </summary>
[Column(TypeName = "nvarchar(2000)")]
public string? Url { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Required]
public DateTime CreateDate { get; set; } = DateTime.MinValue;
}
}

View File

@ -1,8 +1,10 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using System.Text.Json;
namespace Common namespace Common
{ {
@ -11,6 +13,7 @@ namespace Common
public static string Code; public static string Code;
public static string SchoolCode; public static string SchoolCode;
public static string BackendUrl; public static string BackendUrl;
public static string Version;
public static void Init(IConfiguration configuration) public static void Init(IConfiguration configuration)
@ -18,6 +21,48 @@ namespace Common
Code = configuration["Code"] ?? ""; Code = configuration["Code"] ?? "";
SchoolCode = configuration["SchoolCode"] ?? ""; SchoolCode = configuration["SchoolCode"] ?? "";
BackendUrl = configuration["BackendUrl"] ?? ""; BackendUrl = configuration["BackendUrl"] ?? "";
Version = configuration["Version"] ?? "";
}
public static void UpdateCodeAndSchool(string filePath, string code, string schoolCode)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("appsettings.json not found", filePath);
// 读取 JSON
var json = File.ReadAllText(filePath);
var jsonDoc = JsonSerializer.Deserialize<Dictionary<string, object>>(json);
if (jsonDoc == null)
throw new Exception("Failed to parse JSON");
// 更新值
jsonDoc["Code"] = code;
jsonDoc["SchoolCode"] = schoolCode;
// 写回文件,缩进美化
var options = new JsonSerializerOptions { WriteIndented = true };
File.WriteAllText(filePath, JsonSerializer.Serialize(jsonDoc, options));
}
public static void UpdateVersion(string filePath, string version)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("appsettings.json not found", filePath);
// 读取 JSON
var json = File.ReadAllText(filePath);
var jsonDoc = JsonSerializer.Deserialize<Dictionary<string, object>>(json);
if (jsonDoc == null)
throw new Exception("Failed to parse JSON");
// 更新值
jsonDoc["Version"] = version;
// 写回文件,缩进美化
var options = new JsonSerializerOptions { WriteIndented = true };
File.WriteAllText(filePath, JsonSerializer.Serialize(jsonDoc, options));
} }
} }
} }

View File

@ -502,4 +502,10 @@
</Resource> </Resource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="version.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -4,5 +4,6 @@
}, },
"Code": "04-68-74-3F-87-72", "Code": "04-68-74-3F-87-72",
"SchoolCode": "202501060001", "SchoolCode": "202501060001",
"Version": "1.0.0",
"BackendUrl": "http://localhost:9991/api/StudentFace" "BackendUrl": "http://localhost:9991/api/StudentFace"
} }

View File

@ -0,0 +1 @@
v1.0.0