新增 app 版本

This commit is contained in:
tanglong 2026-04-13 10:11:41 +08:00
parent 7b4409de71
commit 2d1c2d0953
4 changed files with 124 additions and 0 deletions

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YD_YiLu.Commons.Dto.DeviceSync
{
/// <summary>
/// 添加应用版本
/// </summary>
public class AppVersionAddRequestDto
{
/// <summary>
/// 应用名称
/// </summary>
public string ApplyName { get; set; }
/// <summary>
/// 设备类型
/// </summary>
public int DeviceType { get; set; }
/// <summary>
/// 硬件类型
/// </summary>
public string HardwareType { get; set; }
/// <summary>
/// 操作系统
/// </summary>
public string OperatingSystem { get; set; }
/// <summary>
/// 版本号
/// </summary>
public string VersionNumber { get; set; }
/// <summary>
/// 版本数字(用于排序)
/// </summary>
public int VersionCode { get; set; }
/// <summary>
/// 下载地址
/// </summary>
public string UpdateUrl { get; set; }
/// <summary>
/// 是否强制更新
/// </summary>
public int NeedForcedUpdating { get; set; }
/// <summary>
/// 是否设为最新版本
/// </summary>
public int IsLatest { get; set; }
}
}

View File

@ -27,5 +27,16 @@ namespace YD_YiLu.Api.Controllers
{ {
return await _deviceSyncService.AppVerifyAsync(dto); return await _deviceSyncService.AppVerifyAsync(dto);
} }
/// <summary>
/// 新增app版本
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("app/version/add")]
public async Task<long> AddAppVersion([FromBody] AppVersionAddRequestDto dto)
{
return await _deviceSyncService.AppVersionAddAsync(dto);
}
} }
} }

View File

@ -678,6 +678,52 @@ namespace YD_YiLu.Api.Services.Impl
} }
/// <summary>
/// 新增app版本
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<long> AppVersionAddAsync(AppVersionAddRequestDto dto)
{
// 1️⃣ 如果设为最新版本,取消旧版本
if (dto.IsLatest == 1)
{
var oldList = await _context.Set<YL_AppVersion>()
.Where(x => x.ApplyName == dto.ApplyName
&& x.DeviceType == dto.DeviceType
&& x.HardwareType == dto.HardwareType
&& x.OperatingSystem == dto.OperatingSystem
&& x.Status == 1)
.ToListAsync();
foreach (var item in oldList)
{
item.IsLatest = 0;
}
}
// 2️⃣ 新版本
var entity = new YL_AppVersion
{
ApplyName = dto.ApplyName,
DeviceType = dto.DeviceType,
HardwareType = dto.HardwareType,
OperatingSystem = dto.OperatingSystem,
VersionNumber = dto.VersionNumber,
VersionCode = dto.VersionCode,
UpdateUrl = dto.UpdateUrl,
NeedForcedUpdating = dto.NeedForcedUpdating,
IsLatest = dto.IsLatest,
Status = 1,
CreateTime = DateTime.Now
};
_context.Set<YL_AppVersion>().Add(entity);
await _context.SaveChangesAsync();
return entity.Id;
}
public async Task<AppVerifyResponseDto> AppVerifyAsync(AppVerifyRequestDto dto) public async Task<AppVerifyResponseDto> AppVerifyAsync(AppVerifyRequestDto dto)
{ {
@ -783,6 +829,7 @@ namespace YD_YiLu.Api.Services.Impl
return true; return true;
} }
public async Task<DeviceSyncUserDto> GetUserDetailAsync(string deviceSerial, int userId) public async Task<DeviceSyncUserDto> GetUserDetailAsync(string deviceSerial, int userId)
{ {
var orgId = await GetOrgIdByDeviceAsync(deviceSerial); var orgId = await GetOrgIdByDeviceAsync(deviceSerial);

View File

@ -77,5 +77,12 @@ namespace YD_YiLu.Api.Services.Interface
/// 视频回放上传 /// 视频回放上传
/// </summary> /// </summary>
Task<bool> DeviceVideoUploadAsync(DeviceVideoUploadRequestDto dto); Task<bool> DeviceVideoUploadAsync(DeviceVideoUploadRequestDto dto);
/// <summary>
/// 新增app版本
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<long> AppVersionAddAsync(AppVersionAddRequestDto dto);
} }
} }