From 2d1c2d0953d105bb00703d556e6853cc87de6c32 Mon Sep 17 00:00:00 2001
From: tanglong <842690096@qq.com>
Date: Mon, 13 Apr 2026 10:11:41 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20app=20=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/DeviceSync/AppVersionAddRequestDto.cs | 59 +++++++++++++++++++
YD_YiLu/Controllers/SettingController.cs | 11 ++++
YD_YiLu/Services/Impl/DeviceSyncService.cs | 47 +++++++++++++++
.../Services/Interface/IDeviceSyncService.cs | 7 +++
4 files changed, 124 insertions(+)
create mode 100644 YD_YiLu.Commons/Dto/DeviceSync/AppVersionAddRequestDto.cs
diff --git a/YD_YiLu.Commons/Dto/DeviceSync/AppVersionAddRequestDto.cs b/YD_YiLu.Commons/Dto/DeviceSync/AppVersionAddRequestDto.cs
new file mode 100644
index 0000000..7166103
--- /dev/null
+++ b/YD_YiLu.Commons/Dto/DeviceSync/AppVersionAddRequestDto.cs
@@ -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
+{
+ ///
+ /// 添加应用版本
+ ///
+ public class AppVersionAddRequestDto
+ {
+ ///
+ /// 应用名称
+ ///
+ public string ApplyName { get; set; }
+
+ ///
+ /// 设备类型
+ ///
+ public int DeviceType { get; set; }
+
+ ///
+ /// 硬件类型
+ ///
+ public string HardwareType { get; set; }
+
+ ///
+ /// 操作系统
+ ///
+ public string OperatingSystem { get; set; }
+
+ ///
+ /// 版本号
+ ///
+ public string VersionNumber { get; set; }
+
+ ///
+ /// 版本数字(用于排序)
+ ///
+ public int VersionCode { get; set; }
+
+ ///
+ /// 下载地址
+ ///
+ public string UpdateUrl { get; set; }
+
+ ///
+ /// 是否强制更新
+ ///
+ public int NeedForcedUpdating { get; set; }
+
+ ///
+ /// 是否设为最新版本
+ ///
+ public int IsLatest { get; set; }
+ }
+}
diff --git a/YD_YiLu/Controllers/SettingController.cs b/YD_YiLu/Controllers/SettingController.cs
index 57a90b2..d0b7260 100644
--- a/YD_YiLu/Controllers/SettingController.cs
+++ b/YD_YiLu/Controllers/SettingController.cs
@@ -27,5 +27,16 @@ namespace YD_YiLu.Api.Controllers
{
return await _deviceSyncService.AppVerifyAsync(dto);
}
+
+ ///
+ /// 新增app版本
+ ///
+ ///
+ ///
+ [HttpPost("app/version/add")]
+ public async Task AddAppVersion([FromBody] AppVersionAddRequestDto dto)
+ {
+ return await _deviceSyncService.AppVersionAddAsync(dto);
+ }
}
}
diff --git a/YD_YiLu/Services/Impl/DeviceSyncService.cs b/YD_YiLu/Services/Impl/DeviceSyncService.cs
index 73132bf..b91a0bf 100644
--- a/YD_YiLu/Services/Impl/DeviceSyncService.cs
+++ b/YD_YiLu/Services/Impl/DeviceSyncService.cs
@@ -678,6 +678,52 @@ namespace YD_YiLu.Api.Services.Impl
}
+ ///
+ /// 新增app版本
+ ///
+ ///
+ ///
+ public async Task AppVersionAddAsync(AppVersionAddRequestDto dto)
+ {
+ // 1️⃣ 如果设为最新版本,取消旧版本
+ if (dto.IsLatest == 1)
+ {
+ var oldList = await _context.Set()
+ .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().Add(entity);
+ await _context.SaveChangesAsync();
+
+ return entity.Id;
+ }
+
public async Task AppVerifyAsync(AppVerifyRequestDto dto)
{
@@ -783,6 +829,7 @@ namespace YD_YiLu.Api.Services.Impl
return true;
}
+
public async Task GetUserDetailAsync(string deviceSerial, int userId)
{
var orgId = await GetOrgIdByDeviceAsync(deviceSerial);
diff --git a/YD_YiLu/Services/Interface/IDeviceSyncService.cs b/YD_YiLu/Services/Interface/IDeviceSyncService.cs
index 82d2ca7..52daf19 100644
--- a/YD_YiLu/Services/Interface/IDeviceSyncService.cs
+++ b/YD_YiLu/Services/Interface/IDeviceSyncService.cs
@@ -77,5 +77,12 @@ namespace YD_YiLu.Api.Services.Interface
/// 视频回放上传
///
Task DeviceVideoUploadAsync(DeviceVideoUploadRequestDto dto);
+
+ ///
+ /// 新增app版本
+ ///
+ ///
+ ///
+ Task AppVersionAddAsync(AppVersionAddRequestDto dto);
}
}