Files
Gatedge.NewOrientLandMark.BOS/Gatedge.ScanCode/Controllers/VsersionController.cs
liqionghai ff810cd931 1
2025-11-21 10:19:46 +08:00

80 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Gatedge.K3Cloud.Utils;
using Gatedge.K3Cloud.Utils.Common;
using Gatedge.K3Cloud.Utils.Model.K3Request;
using Gatedge.ScanCode.Common;
using Gatedge.ScanCode.Extension;
using Gatedge.ScanCode.Services;
using Gatedge.ScanCode.Services.IServices;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace Gatedge.ScanCode.Controllers
{
/// <summary>
/// 版本控制
/// </summary>
[Route("api/[controller]")]
[Authorize]
[ApiController]
public class VsersionController : ControllerBase
{
private readonly string _FormName = "扫码APP版本";
private readonly string _FormId = "k25663a1521d147669932af94b9146d86";
private readonly K3CloudApiUtils _utils;
private readonly IK3FileService _k3FileService;
/// <summary>
/// 构造方法
/// </summary>
/// <param name="utils"></param>
/// <param name="k3FileService"></param>
public VsersionController(K3CloudApiUtils utils, IK3FileService k3FileService)
{
_utils = utils;
_k3FileService = k3FileService;
}
/// <summary>
/// 获取最后的版本
/// </summary>
/// <returns></returns>
[HttpGet("LastVersion")]
public AjaxResult LastVersion()
{
Query queryParam = new Query()
{
FormId = this._FormId,
FieldKeys = "FID",
OrderString = "FID desc"
};
//// 已审核
//FilterList filterString = new FilterList().AddAuditedItems();
//queryParam.FilterString = filterString.GetFilterString();
var loginInfo = User.GetLoginInfoByClaimsPrincipal();
// 需要获取具有BOS权限的用户
var k3Apiutil = _utils.GetDefaultK3CloudApiUtil(loginInfo);
IVsersionService service = new VsersionService(k3Apiutil);
var data = service.List(queryParam);
if (data.List.Count == 0)
{
return AjaxResult.Error("没有找到App版本信息请联系管理员!");
}
var lastVersion = data.List.First();
var dyobj = lastVersion;
var id = dyobj["FID"];
View viewBill = new View();
viewBill.Id = id.ToString();
var billData = service.View(viewBill);
var file = billData.FAppFile_Files.First();
_k3FileService.SetK3Util(k3Apiutil);
var fileFullName = _k3FileService.GetFilePath(billData.FAppFile_Files.First());
var result = AjaxResult
.Success(billData)
.AddBillId(_FormId);
result.Add("downloadUrl", $"/Download/{file.FileName}");
return result;
}
}
}