Răsfoiți Sursa

增加FccInfo的SQLite接口与FCC配置页面连接SQLite数据库

DFS_Shuo_Chen 1 an în urmă
părinte
comite
81a9554e3e

+ 82 - 28
src/XF.Common.Api/Pages/FCC/FccIndex.razor

@@ -9,7 +9,12 @@
 @using Microsoft.AspNetCore.Components.Authorization;
 @using XF.Common.Core.VM;
 @using XF.Common.Core.Server;
+@using XF.Common.Server.Repositories.SQLLite;
+@using XF.Common.Core.Model.FCC;
+@using Microsoft.EntityFrameworkCore;
+@using XF.Common.Server.Core.Server
 
+@inject IMessageService _message;
 
 
 <PageContainer Title="FCC油机配置">
@@ -18,24 +23,26 @@
 	<ChildContent>
 
 
-		<Form Model="@model" Name="advanced_search" Class="ant-advanced-search-form">
+		<Form Model="@model" OnFinish="SaveFcc" Name="advanced_search" Class="ant-advanced-search-form">
 			<GridRow>
-				<GridCol Span="10">
-					<FormItem Label="恒山IC卡UI板">
-						<Input @bind-Value="context.ui_number" Placeholder="请输入个数" />
-					</FormItem>
-				</GridCol>
 
 
-
-				<GridCol Span="2" />
-
 				<GridCol Span="9">
 					<FormItem Label="BUID">
 						<Input Placeholder="请输入" @bind-Value="context.buid" />
 					</FormItem>
 				</GridCol>
+
+				<GridCol Span="2" />
+
+				<GridCol Span="10">
+					<FormItem Label="恒山IC卡UI板数量">
+						<Input @bind-Value="context.uiboardnumber" Placeholder="请输入个数" />
+					</FormItem>
+				</GridCol>
+
 			</GridRow>
+
 			<br />
 			<br />
 
@@ -50,7 +57,7 @@
 
 				<GridCol Span="9">
 					<label>激活配置</label>
-					<Switch @bind-Checked="context.config_active" />
+					<Switch @bind-Checked="context.sps_app_active" />
 				</GridCol>
 			</GridRow>
 			<br />
@@ -103,15 +110,21 @@
 			<FormItem>
 				<GridRow Justify="center">
 					<GridCol Span="6">
+
+						<Button Size="large" Type="@ButtonType.Primary" OnClick="selectFcc">查询</Button>
+						<Button Size="large" Type="@ButtonType.Primary" HtmlType="submit">保存</Button>
+
 						<Button Size="large" Type="@ButtonType.Primary" HtmlType="submit">
+							<!--HtmlType="submit"-->
 							下载FCC脚本
 						</Button>
+
+
 					</GridCol>
 				</GridRow>
 			</FormItem>
 
 
-
 		</Form>
 
 
@@ -142,30 +155,71 @@
 
 
 @code {
-	class FccInfo
-	{
 
-		[Required]
-		public int? ui_number { get; set; }
+	[Inject] IFccInfoServer server { get; set; }
 
-		[Required]
-		public string? buid { get; set; }
-		[Required]
-		public string? sps_app { get; set; }
 
-		[Required]
-		public bool config_active { get; set; } = false;
-		[Required]
-		public bool fcc_remote { get; set; } = true;
 
-		[Required]
-		public int ipos_cardtype { get; set; } = 0;
-		[Required]
-		public int ipos_authmode { get; set; } = 0;
 
+	void selectFcc()
+	{
+		if (model.buid == null || model.buid == "")
+		{
+			_message.Error("请输入buid!");
+			return;
+		}
+
+		FCCInfo fccinfo = new FCCInfo();
+		fccinfo = server.getFccInfosById(model.buid).Result;
+
+		if (fccinfo != null)
+		{
+			model = fccinfo;
+		}
+		else
+		{
+			_message.Info("未查到该buid!");
+		}
+	}
 
+	void SaveFcc()
+	{
+		FCCInfo info = server.getFccInfosById(model.buid).Result;
+		if (info != null)
+		{
+			bool rtn  = server.UpdateFccInfo(model).GetAwaiter().GetResult();
+			if(rtn == true)
+			{
+				_message.Success("更新信息成功!");
+			}
+			else
+			{
+				_message.Success("更新信息失败!");
+			}
+		}
+		else
+		{
+			bool rtn = server.AddFccInfo(model).GetAwaiter().GetResult();;
+			if (rtn == true)
+			{
+				_message.Success("保存信息成功!");
+			}
+			else
+			{
+				_message.Success("保存信息失败!");
+			}
+		}
+
+	}
+
+	void UpdateFcc()
+	{
+		server.UpdateFccInfo(model);
 	}
 
-	FccInfo model = new FccInfo();
+
+
+
+	FCCInfo model = new FCCInfo();
 }
 

+ 31 - 0
src/XF.Common.Api/Server/Core/Model/FCC/FCCInfo.cs

@@ -0,0 +1,31 @@
+using SqlSugar;
+using System.ComponentModel.DataAnnotations;
+
+namespace XF.Common.Core.Model.FCC
+{
+    [SugarTable("FCCInfos")]
+    public class FCCInfo
+	{
+		[SugarColumn(IsPrimaryKey = true)]
+		[Key]
+		[Required]
+		public string? buid { get; set; }
+
+
+		[Required]
+		public int? uiboardnumber { get; set; }
+
+
+		public string? sps_app { get; set; }
+
+		[Required]
+		public bool sps_app_active { get; set; } = false;
+		[Required]
+		public bool fcc_remote { get; set; } = false;
+
+		[Required]
+		public int ipos_cardtype { get; set; } = 0;
+		[Required]
+		public int ipos_authmode { get; set; } = 0;
+	}
+}

+ 10 - 0
src/XF.Common.Api/Server/Core/Repositories/IFccInfoRepository.cs

@@ -0,0 +1,10 @@
+using XF.Common.Core.Model.FCC;
+using XF.Common.Repositories.Base;
+
+namespace XF.Common.Server.Core.Repositories
+{
+	public interface IFccInfoRepository : ILiteRepository<FCCInfo>
+	{
+		Task<object> GetData();
+	}
+}

+ 16 - 0
src/XF.Common.Api/Server/Core/Server/IFccInfoServer.cs

@@ -0,0 +1,16 @@
+using Microsoft.EntityFrameworkCore;
+using XF.Common.Core.Model.FCC;
+
+namespace XF.Common.Server.Core.Server
+{
+	public interface IFccInfoServer
+	{
+		Task<List<FCCInfo>> getFccInfos();
+
+		Task<FCCInfo> getFccInfosById(string id);
+
+		Task<bool> AddFccInfo(FCCInfo info);
+
+		Task<bool> UpdateFccInfo(FCCInfo info);
+	}
+}

+ 28 - 0
src/XF.Common.Api/Server/Repositories/SQLLite/FCCDB/FccInfoRepository.cs

@@ -0,0 +1,28 @@
+using XF.Common.Repositories.Base;
+using XF.Common.Server.Core.Repositories;
+using XF.Common.Core.Model.FCC;
+using ServiceLifetime = XF.Common.Core.ServiceLifetime;
+using XF.Common.Core;
+
+namespace XF.Common.Server.Repositories.SQLLite.FCCDB
+{
+	[ServiceDescription(typeof(IFccInfoRepository), ServiceLifetime.Scoped)]
+	public class FccInfoRepository : LiteRepository<FCCInfo>, IFccInfoRepository
+	{
+		public Task<object> GetData()
+		{
+			var connect = CurrentDb.Context.CurrentConnectionConfig;
+			return null;
+		}
+
+		public async Task<object> GetObject()
+		{
+			return GetPageList<FCCInfo>(c => true, new SqlSugar.PageModel()
+			{
+				PageSize = 100,
+				PageIndex = 0
+			});
+		}
+	}
+
+}

+ 59 - 0
src/XF.Common.Api/Server/Services/FccInfoServer.cs

@@ -0,0 +1,59 @@
+using XF.Common.Core;
+using XF.Common.Server.Core.Server;
+using ServiceLifetime = XF.Common.Core.ServiceLifetime;
+using XF.Common.Server.Core.Repositories;
+using XF.Common.Core.Server;
+using XF.Common.Core.Model.FCC;
+using XF.Common.Server.Repositories.SQLLite.FCCDB;
+using XF.Common.Server.Core.VM.GasStation;
+using XF.Common.Server.Repositories.Mysql.AccountDB;
+using XF.Common.Map;
+
+namespace XF.Common.Server.Services
+{
+	[ServiceDescription(typeof(IFccInfoServer), ServiceLifetime.Scoped)]
+	public class FccInfoServer: IFccInfoServer
+	{
+		IFccInfoRepository _FccInfoRepository;
+		public FccInfoServer(IFccInfoRepository fccInfoRepository)
+		{
+			_FccInfoRepository = fccInfoRepository;
+		}
+
+
+
+		public async Task<List<FCCInfo>> getFccInfos()
+		{
+			try
+			{
+
+				var data = await _FccInfoRepository.GetListAsync();
+				return data;
+			}
+			catch (Exception n)
+			{
+				throw;
+			}
+		}
+
+		public async Task<FCCInfo> getFccInfosById(string id)
+		{
+			var list = await _FccInfoRepository.GetListAsync(k => k.buid == id);
+			
+			return list.Count > 0 ?list[0]:null;
+		}
+
+		public async Task<bool> AddFccInfo(FCCInfo info)
+		{
+			var rtn = await _FccInfoRepository.InsertAsync(info);
+			return rtn;
+		}
+
+		public async Task<bool> UpdateFccInfo(FCCInfo info)
+		{
+			var rtn = await _FccInfoRepository.UpdateAsync(info);
+			return rtn;
+		}
+
+	}
+}

+ 0 - 0
src/XF.Common.Api/liteFccCore_sqlite_database.db