using System.Security.Cryptography;
using Microsoft.Extensions.Options;
using YD_Event.Application.Auth;
using YD_Event.Application.Common;
using YD_Event.Core.Options;
namespace YD_Event.Application.AppUpdate;
/// 内部 Android 裁判端 APK 发布与升级检查。
[ApiDescriptionSettings("裁判端升级")]
[Route("api/app-updates")]
[Authorize]
public class AppUpdateController : IDynamicApiController
{
private const string PackageName = "com.yd.event.yd_pattern_scoring_system";
private const long MaxApkSize = 200L * 1024 * 1024;
private readonly ISqlSugarRepository _releases;
private readonly AuthManager _auth;
private readonly IIdGenerator _ids;
private readonly FileService _files;
private readonly IOptionsMonitor _ossOptions;
private readonly string _channel;
public AppUpdateController(ISqlSugarRepository releases,
AuthManager auth, IIdGenerator ids, FileService files,
IOptionsMonitor ossOptions)
{
_releases = releases;
_auth = auth;
_ids = ids;
_files = files;
_ossOptions = ossOptions;
_channel = Environment.GetEnvironmentVariable("APP_UPDATE_CHANNEL")?.Trim().ToLowerInvariant() ?? "production";
}
/// 登录前即可查询当前环境的最新 APK。
[HttpGet("latest")]
[AllowAnonymous]
public async Task