65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
|
using SKIT.FlurlHttpClient.Wechat.Api;
|
|
using System.Web;
|
|
using ZR.Model.Business;
|
|
using ZR.Service.Business.IBusinessService;
|
|
using ZR.Model.Business.Dto;
|
|
using Org.BouncyCastle.Utilities;
|
|
using System.Net;
|
|
|
|
namespace ZR.Admin.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// webApi
|
|
/// </summary>
|
|
[Route("[controller]/[action]")]
|
|
[AllowAnonymous]
|
|
[ApiExplorerSettings(GroupName = "webapi")]
|
|
public class WebApiController : BaseController
|
|
{
|
|
private readonly WechatApiClient _client;
|
|
private readonly IOdfAppUpdatesService _odfAppUpdatesService;
|
|
|
|
public WebApiController(WechatApiClient client, IOdfAppUpdatesService odfAppUpdatesService)
|
|
{
|
|
_client = client;
|
|
_odfAppUpdatesService = odfAppUpdatesService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查App版本更新
|
|
/// </summary>
|
|
/// <param name="version">版本</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult CheckAppVersion([FromQuery] string version)
|
|
{
|
|
if (version == null || string.IsNullOrEmpty(version))
|
|
{
|
|
return ToResponse(ResultCode.CUSTOM_ERROR, "版本号不能为空");
|
|
}
|
|
|
|
try
|
|
{
|
|
var response = _odfAppUpdatesService.CheckAppVersion(version);
|
|
|
|
if (response.NeedUpdate)
|
|
{
|
|
return SUCCESS(response, "发现新版本");
|
|
}
|
|
else
|
|
{
|
|
return SUCCESS(new { }, "当前已是最新版本");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ToResponse(ResultCode.CUSTOM_ERROR, $"版本检查失败: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|