namespace JiDangJia.Contracts;
public sealed record AppUpdateOffer(AppRelease? Release);
public sealed record AppRelease(string Id,string PackageId,int VersionCode,string VersionName,int MinimumVersionCode,string Notes,long Size,string Sha256,string PublishedAt,bool Enabled)
{
public string DownloadPath=>"/api/updates/"+Id+"/apk";
public bool RequiredFor(int installed)=>installed<MinimumVersionCode;
}
public sealed record PublishReleaseRequest(int MinimumVersionCode,string Notes);
public static class AppUpdateRules
{
public const string PackageId="com.xfestudio.jidangjia";
public const long MaxApkSize=250L*1024*1024;
public static void Validate(PublishReleaseRequest request,int version)
{
if(version<=0||request.MinimumVersionCode<0||request.MinimumVersionCode>version)throw new ArgumentException("最低可用版本号应在 0 与新版本号之间,0 表示可稍后更新");
if(string.IsNullOrWhiteSpace(request.Notes)||request.Notes.Length>8000)throw new ArgumentException("更新说明请填写 1–8000 个字符");
}
}
namespace JiDangJia.Contracts;
public sealed record AppUpdateOffer(AppRelease? Release);
public sealed record AppRelease(string Id,string PackageId,int VersionCode,string VersionName,int MinimumVersionCode,string Notes,long Size,string Sha256,string PublishedAt,bool Enabled)
{
public string DownloadPath=>"/api/updates/"+Id+"/apk";
public bool RequiredFor(int installed)=>installed<MinimumVersionCode;
}
public sealed record PublishReleaseRequest(int MinimumVersionCode,string Notes);
public static class AppUpdateRules
{
public const string PackageId="com.xfestudio.jidangjia";
public const long MaxApkSize=250L*1024*1024;
public static void Validate(PublishReleaseRequest request,int version)
{
if(version<=0||request.MinimumVersionCode<0||request.MinimumVersionCode>version)throw new ArgumentException("最低可用版本号应在 0 与新版本号之间,0 表示可稍后更新");
if(string.IsNullOrWhiteSpace(request.Notes)||request.Notes.Length>8000)throw new ArgumentException("更新说明请填写 1–8000 个字符");
}
}