diff --git a/UIStandardWebApi.Entity/Class1.cs b/UIStandardWebApi.Entity/Class1.cs
deleted file mode 100644
index eab2e5f..0000000
--- a/UIStandardWebApi.Entity/Class1.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace UIStandardWebApi.Entity
-{
- public class Class1
- {
-
- }
-}
diff --git a/UIStandardWebApi.Entity/Sys_BaseModel.cs b/UIStandardWebApi.Entity/Sys_BaseModel.cs
new file mode 100644
index 0000000..8142f52
--- /dev/null
+++ b/UIStandardWebApi.Entity/Sys_BaseModel.cs
@@ -0,0 +1,32 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UIStandardWebApi.Entity
+{
+ ///
+ /// 公共基础类
+ ///
+ public abstract class Sys_BaseModel
+ {
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; } = DateTime.Now;
+
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+
+
+ ///
+ ///状态
+ ///
+ public int Status { set; get; }
+ }
+}
diff --git a/UIStandardWebApi.Entity/Sys_Socket.cs b/UIStandardWebApi.Entity/Sys_Socket.cs
new file mode 100644
index 0000000..2c05331
--- /dev/null
+++ b/UIStandardWebApi.Entity/Sys_Socket.cs
@@ -0,0 +1,30 @@
+using SqlSugar;
+
+namespace UIStandardWebApi.Entity
+{
+ ///
+ /// ip 端口号保存
+ ///
+ [SugarTable("Sys_Socket")]
+ public class Sys_Socket : Sys_BaseModel
+ {
+ ///
+ /// ID
+ ///
+ [SugarColumn(ColumnName = "Id", IsIdentity = true, IsPrimaryKey = true)]
+ public int Id { get; set; }
+
+ ///
+ /// iP
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string? IP { get; set; }
+
+ ///
+ /// 端口号
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string? Port { get; set; }
+
+ }
+}
diff --git a/UIStandardWebApi.Entity/UIStandardWebApi.Entity.csproj b/UIStandardWebApi.Entity/UIStandardWebApi.Entity.csproj
index fa71b7a..408b7a9 100644
--- a/UIStandardWebApi.Entity/UIStandardWebApi.Entity.csproj
+++ b/UIStandardWebApi.Entity/UIStandardWebApi.Entity.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/UIStandardWebApi.EntityDto/BaseDTO.cs b/UIStandardWebApi.EntityDto/BaseDTO.cs
new file mode 100644
index 0000000..8f6b6ce
--- /dev/null
+++ b/UIStandardWebApi.EntityDto/BaseDTO.cs
@@ -0,0 +1,24 @@
+namespace UIStandardWebApi.EntityDto
+{
+ ///
+ /// 基础类
+ ///
+ public abstract class BaseDTO
+ {
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; } = DateTime.Now;
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? ModifyTime { get; set; }
+
+
+ ///
+ ///状态
+ ///
+ public int Status { set; get; }
+ }
+}
diff --git a/UIStandardWebApi.EntityDto/Class1.cs b/UIStandardWebApi.EntityDto/Class1.cs
deleted file mode 100644
index c6413a9..0000000
--- a/UIStandardWebApi.EntityDto/Class1.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace UIStandardWebApi.EntityDto
-{
- public class Class1
- {
-
- }
-}
diff --git a/UIStandardWebApi.EntityDto/Sys_SocketDto.cs b/UIStandardWebApi.EntityDto/Sys_SocketDto.cs
new file mode 100644
index 0000000..8d93d4f
--- /dev/null
+++ b/UIStandardWebApi.EntityDto/Sys_SocketDto.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UIStandardWebApi.EntityDto
+{
+ ///
+ /// ip 端口号保存
+ ///
+ public class Sys_SocketDto : BaseDTO
+ {
+ ///
+ /// ID
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// iP
+ ///
+ public string? IP { get; set; }
+
+ ///
+ /// 端口号
+ ///
+ public string? Port { get; set; }
+ }
+}
diff --git a/UIStandardWebApi.IService/IBaseService.cs b/UIStandardWebApi.IService/IBaseService.cs
new file mode 100644
index 0000000..71e6ad9
--- /dev/null
+++ b/UIStandardWebApi.IService/IBaseService.cs
@@ -0,0 +1,130 @@
+using SqlSugar;
+using System.Linq.Expressions;
+using UIStandardWebApi.Entity;
+
+namespace UIStandardWebApi.IService
+{
+ public interface IBaseService
+ {
+ #region Query
+ ///
+ /// 主键查询
+ ///
+ ///
+ ///
+ T Find(int id) where T : class;
+
+ ///
+ /// 主键查询-异步版本
+ ///
+ ///
+ ///
+ ///
+ Task FindAsync(int id) where T : class;
+
+ ///
+ /// 提供对单表的查询
+ ///
+ /// ISugarQueryable类型集合
+ [Obsolete("尽量避免使用,using 带表达式目录树的 代替")]
+ ISugarQueryable Set() where T : class;
+
+ ///
+ /// 条件查询
+ ///
+ ///
+ ///
+ ///
+ ISugarQueryable Query(Expression> funcWhere) where T : class;
+
+ ///
+ /// 分页查询
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ PagingData QueryPage(Expression> funcWhere, int pageSize, int pageIndex, Expression> funcOrderby, bool isAsc = true) where T : class;
+ #endregion
+
+ #region Add
+
+ ///
+ /// 新增数据-同步版本
+ ///
+ ///
+ ///
+ ///
+ T Insert(T t) where T : class, new();
+
+ ///
+ /// 新增数据-异步版本
+ ///
+ ///
+ ///
+ ///
+ Task InsertAsync(T t) where T : class, new();
+
+ ///
+ /// 批量新增
+ ///
+ ///
+ ///
+ ///
+ Task InsertList(List tList) where T : class, new();
+ #endregion
+
+ #region Update
+ ///
+ /// 更新数据
+ ///
+ ///
+ ///
+ ///
+ Task UpdateAsync(T t) where T : class, new();
+
+ ///
+ /// 更新数据,即时Commit
+ ///
+ ///
+ void Update(List tList) where T : class, new();
+ #endregion
+
+ #region Delete
+ ///
+ /// 根据主键删除数据
+ ///
+ ///
+ ///
+ ///
+ bool Delete(object pId) where T : class, new();
+
+ ///
+ /// 删除数据,即时Commit
+ ///
+ ///
+ void Delete(T t) where T : class, new();
+
+ ///
+ /// 删除数据,即时Commit
+ ///
+ ///
+ void Delete(List tList) where T : class;
+ #endregion
+
+ #region Other
+
+ ///
+ /// 执行sql 返回集合
+ ///
+ ///
+ ///
+ ///
+ ISugarQueryable ExcuteQuery(string sql) where T : class, new();
+
+ #endregion
+ }
+}
diff --git a/UIStandardWebApi.IService/ISocketConnectionService.cs b/UIStandardWebApi.IService/ISocketConnectionService.cs
new file mode 100644
index 0000000..c6fcaf8
--- /dev/null
+++ b/UIStandardWebApi.IService/ISocketConnectionService.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using UIStandardWebApi.Entity;
+
+namespace UIStandardWebApi.IService
+{
+ ///
+ /// Socket通信连接接口
+ ///
+ public interface ISocketConnectionService : IBaseService
+ {
+ ///
+ /// 获取通信连接的ip及端口号
+ ///
+ ///
+ public Sys_Socket ObtainAddress();
+
+ ///
+ /// 新增通信ip及端口号
+ ///
+ ///
+ ///
+ ///
+ public int InserAddress(string ip, string port);
+ }
+}
diff --git a/UIStandardWebApi.IService/PagingData.cs b/UIStandardWebApi.IService/PagingData.cs
new file mode 100644
index 0000000..309b9a8
--- /dev/null
+++ b/UIStandardWebApi.IService/PagingData.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UIStandardWebApi.IService
+{
+ public class PagingData where T : class
+ {
+ public int RecordCount { get; set; }
+
+ public int PageIndex { get; set; }
+
+ public int PageSize { get; set; }
+
+ public List? DataList { get; set; }
+
+ public string? SearchString { get; set; }
+ }
+}
diff --git a/UIStandardWebApi.IService/UIStandardWebApi.IService.csproj b/UIStandardWebApi.IService/UIStandardWebApi.IService.csproj
new file mode 100644
index 0000000..314a3cf
--- /dev/null
+++ b/UIStandardWebApi.IService/UIStandardWebApi.IService.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/UIStandardWebApi.Service/BaseService.cs b/UIStandardWebApi.Service/BaseService.cs
new file mode 100644
index 0000000..f96358e
--- /dev/null
+++ b/UIStandardWebApi.Service/BaseService.cs
@@ -0,0 +1,200 @@
+using SqlSugar;
+using System.Linq.Expressions;
+using UIStandardWebApi.Entity;
+using UIStandardWebApi.IService;
+
+namespace UIStandardWebApi.Service
+{
+ public abstract class BaseService : IBaseService
+ {
+ ///
+ ///
+ ///
+ protected ISqlSugarClient _Client { get; set; }
+
+ ///
+ /// 构造函数
+ ///
+ ///
+ public BaseService(ISqlSugarClient client)
+ {
+ _Client = client;
+ }
+
+ #region Query
+
+ ///
+ /// 主键查询
+ ///
+ ///
+ ///
+ ///
+ public T Find(int id) where T : class
+ {
+ return _Client.Queryable().InSingle(id);
+ }
+
+ ///
+ /// 主键查询-异步版本
+ ///
+ ///
+ ///
+ ///
+ public async Task FindAsync(int id) where T : class
+ {
+ return await _Client.Queryable().InSingleAsync(id);
+ }
+
+ ///
+ /// 不应该暴露给上端使用者,尽量少用
+ ///
+ ///
+ ///
+ [Obsolete("尽量避免使用,using 带表达式目录树的代替")]
+ public ISugarQueryable Set() where T : class
+ {
+ return _Client.Queryable();
+ }
+
+ ///
+ /// 条件查询
+ ///
+ ///
+ ///
+ ///
+ public ISugarQueryable Query(Expression> funcWhere) where T : class
+ {
+ return _Client.Queryable().Where(funcWhere);
+ }
+
+ ///
+ /// 分页查询
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public PagingData QueryPage(Expression> funcWhere, int pageSize, int pageIndex, Expression> funcOrderby, bool isAsc = true) where T : class
+ {
+ var list = _Client.Queryable();
+ if (funcWhere != null)
+ {
+ list = list.Where(funcWhere);
+ }
+ list = list.OrderByIF(true, funcOrderby, isAsc ? OrderByType.Asc : OrderByType.Desc);
+ PagingData result = new PagingData()
+ {
+ DataList = list.ToPageList(pageIndex, pageSize),
+ PageIndex = pageIndex,
+ PageSize = pageSize,
+ RecordCount = list.Count(),
+ };
+ return result;
+ }
+ #endregion
+
+ #region Insert
+
+ ///
+ /// 新增数据-同步版本
+ ///
+ ///
+ ///
+ ///
+ public T Insert(T t) where T : class, new()
+ {
+ return _Client.Insertable(t).ExecuteReturnEntity();
+ }
+
+ ///
+ /// 新增数据-异步版本
+ ///
+ ///
+ ///
+ ///
+ public async Task InsertAsync(T t) where T : class, new()
+ {
+ return await _Client.Insertable(t).ExecuteReturnEntityAsync();
+ }
+
+ ///
+ /// 批量新增-事务执行
+ ///
+ ///
+ ///
+ ///
+ public async Task InsertList(List tList) where T : class, new()
+ {
+ return await _Client.Insertable(tList.ToList()).ExecuteCommandIdentityIntoEntityAsync();
+ }
+ #endregion
+
+ #region Update
+ ///
+ /// 是没有实现查询,直接更新的,需要Attach和State
+ ///
+ /// 如果是已经在context,只能再封装一个(在具体的service)
+ ///
+ ///
+ ///
+ public async Task UpdateAsync(T t) where T : class, new()
+ {
+ if (t == null) throw new Exception("t is null");
+
+ return await _Client.Updateable(t).ExecuteCommandHasChangeAsync();
+ }
+
+ public void Update(List tList) where T : class, new()
+ {
+ _Client.Updateable(tList).ExecuteCommand();
+ }
+
+ #endregion
+
+ #region Delete
+ ///
+ /// 先附加 再删除
+ ///
+ ///
+ ///
+ public void Delete(T t) where T : class, new()
+ {
+ _Client.Deleteable(t).ExecuteCommand();
+ }
+
+ ///
+ /// 根据主键删除
+ ///
+ ///
+ ///
+ ///
+ public bool Delete(object pId) where T : class, new()
+ {
+ T t = _Client.Queryable().InSingle(pId);
+ return _Client.Deleteable(t).ExecuteCommand() > 0;
+ }
+
+ public void Delete(List tList) where T : class
+ {
+ _Client.Deleteable(tList).ExecuteCommand();
+ }
+ #endregion
+
+ #region Other
+ ISugarQueryable IBaseService.ExcuteQuery(string sql) where T : class
+ {
+ return _Client.SqlQueryable(sql);
+ }
+ public void Dispose()
+ {
+ if (_Client != null)
+ {
+ _Client.Dispose();
+ }
+ }
+ #endregion
+ }
+}
diff --git a/UIStandardWebApi.Service/SocketConnectionService.cs b/UIStandardWebApi.Service/SocketConnectionService.cs
new file mode 100644
index 0000000..33e13d2
--- /dev/null
+++ b/UIStandardWebApi.Service/SocketConnectionService.cs
@@ -0,0 +1,58 @@
+using AutoMapper;
+using Microsoft.Extensions.Caching.Memory;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using UIStandardWebApi.Entity;
+using UIStandardWebApi.IService;
+
+namespace UIStandardWebApi.Service
+{
+ ///
+ /// Socket通信连接服务层
+ ///
+ public class SocketConnectionService : BaseService, ISocketConnectionService
+ {
+ private readonly IMapper _IMapper;
+ private readonly IMemoryCache _IMemoryCache;
+
+ public SocketConnectionService(ISqlSugarClient client, IMapper mapper, IMemoryCache iMemoryCache) : base(client)
+ {
+ _IMapper = mapper;
+ _IMemoryCache = iMemoryCache;
+ }
+
+ ///
+ /// 获取通信连接的ip及端口号
+ ///
+ ///
+ public Sys_Socket ObtainAddress()
+ {
+ Sys_Socket socket = _Client.Queryable() .OrderBy(c => c.Id, OrderByType.Desc).First();
+ return socket;
+ }
+
+ ///
+ /// 新增通信信息
+ ///
+ ///
+ ///
+ ///
+ public int InserAddress(string ip, string port)
+ {
+ int inItSocketId = 0;
+ inItSocketId = _Client.Insertable(new Sys_Socket()
+ {
+ IP = ip,
+ Port = port,
+ }).ExecuteReturnIdentity();
+
+ return inItSocketId;
+ }
+
+
+ }
+}
diff --git a/UIStandardWebApi.Service/UIStandardWebApi.Service.csproj b/UIStandardWebApi.Service/UIStandardWebApi.Service.csproj
new file mode 100644
index 0000000..ece80f5
--- /dev/null
+++ b/UIStandardWebApi.Service/UIStandardWebApi.Service.csproj
@@ -0,0 +1,21 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/UIStandardWebApi.WebCore/AutoMapExtend/AutoMapperConfigs.cs b/UIStandardWebApi.WebCore/AutoMapExtend/AutoMapperConfigs.cs
index 13d6a59..ba4441f 100644
--- a/UIStandardWebApi.WebCore/AutoMapExtend/AutoMapperConfigs.cs
+++ b/UIStandardWebApi.WebCore/AutoMapExtend/AutoMapperConfigs.cs
@@ -4,6 +4,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using UIStandardWebApi.Entity;
+using UIStandardWebApi.EntityDto;
+using UIStandardWebApi.IService;
namespace UIStandardWebApi.WebCore.AutoMapExtend
{
@@ -17,7 +20,8 @@ namespace UIStandardWebApi.WebCore.AutoMapExtend
///
public AutoMapperConfigs()
{
-
+ CreateMap();
+ CreateMap, PagingData>().ReverseMap();
}
}
}
diff --git a/UIStandardWebApi.WebCore/UIStandardWebApi.WebCore.csproj b/UIStandardWebApi.WebCore/UIStandardWebApi.WebCore.csproj
index 92b8f09..caaaf49 100644
--- a/UIStandardWebApi.WebCore/UIStandardWebApi.WebCore.csproj
+++ b/UIStandardWebApi.WebCore/UIStandardWebApi.WebCore.csproj
@@ -13,4 +13,10 @@
+
+
+
+
+
+
diff --git a/UIStandardWebApi.sln b/UIStandardWebApi.sln
index 5eb7733..f016427 100644
--- a/UIStandardWebApi.sln
+++ b/UIStandardWebApi.sln
@@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIStandardWebApi.Entity", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIStandardWebApi.EntityDto", "UIStandardWebApi.EntityDto\UIStandardWebApi.EntityDto.csproj", "{F8D34A35-F030-48FF-927A-F370F803D46A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIStandardWebApi.IService", "UIStandardWebApi.IService\UIStandardWebApi.IService.csproj", "{4A5263D2-FAD5-4707-AF6E-5733830AABEE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIStandardWebApi.Service", "UIStandardWebApi.Service\UIStandardWebApi.Service.csproj", "{F8BE6A09-AC85-4F0D-BD20-DF379FA82059}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +37,14 @@ Global
{F8D34A35-F030-48FF-927A-F370F803D46A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8D34A35-F030-48FF-927A-F370F803D46A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8D34A35-F030-48FF-927A-F370F803D46A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4A5263D2-FAD5-4707-AF6E-5733830AABEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4A5263D2-FAD5-4707-AF6E-5733830AABEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4A5263D2-FAD5-4707-AF6E-5733830AABEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4A5263D2-FAD5-4707-AF6E-5733830AABEE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F8BE6A09-AC85-4F0D-BD20-DF379FA82059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F8BE6A09-AC85-4F0D-BD20-DF379FA82059}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F8BE6A09-AC85-4F0D-BD20-DF379FA82059}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F8BE6A09-AC85-4F0D-BD20-DF379FA82059}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/UIStandardWebApi/App.config b/UIStandardWebApi/App.config
index d796617..0c2b879 100644
--- a/UIStandardWebApi/App.config
+++ b/UIStandardWebApi/App.config
@@ -6,6 +6,6 @@
-
+
\ No newline at end of file
diff --git a/UIStandardWebApi/Common/PagingData.cs b/UIStandardWebApi/Common/PagingData.cs
new file mode 100644
index 0000000..ff475aa
--- /dev/null
+++ b/UIStandardWebApi/Common/PagingData.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UIStandardWebApi.Common
+{
+ public class PagingData where T : class
+ {
+ public int RecordCount { get; set; }
+
+ public int PageIndex { get; set; }
+
+ public int PageSize { get; set; }
+
+ public List? DataList { get; set; }
+
+ public string? SearchString { get; set; }
+ }
+}
diff --git a/UIStandardWebApi/Common/SocketModel/SocketStatic.cs b/UIStandardWebApi/Common/SocketModel/SocketStatic.cs
index 8517cdb..a6a7841 100644
--- a/UIStandardWebApi/Common/SocketModel/SocketStatic.cs
+++ b/UIStandardWebApi/Common/SocketModel/SocketStatic.cs
@@ -7,6 +7,11 @@ namespace UIStandardWebApi.Common.SocketModel
///
public static class SocketStatic
{
+ ///
+ /// Socket静态类
+ ///
+ public static Client _client = new Client();
+
///
/// 定义数据解析类
///
diff --git a/UIStandardWebApi/Controllers/Communication/SocketConnectionController.cs b/UIStandardWebApi/Controllers/Communication/SocketConnectionController.cs
new file mode 100644
index 0000000..2c3acbd
--- /dev/null
+++ b/UIStandardWebApi/Controllers/Communication/SocketConnectionController.cs
@@ -0,0 +1,127 @@
+using Microsoft.AspNetCore.Mvc;
+using UIStandardWebApi.Common.SocketModel;
+using UIStandardWebApi.Common;
+using UIStandardWebApi.WebCore.SwaggerExtend;
+using UIStandardWebApi.IService;
+using UIStandardWebApi.Entity;
+using System.Text;
+using AutoMapper;
+
+namespace UIStandardWebApi.Controllers.Communication
+{
+ ///
+ /// Socketͨſ
+ ///
+ [ApiController]
+ [Route("api/[controller]")]
+ [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
+ public class SocketConnectionController : ControllerBase
+ {
+ ///
+ /// ѯһεͨ
+ ///
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("ObtainAddress")]
+ public async Task ObtainAddressAsync([FromServices] ISocketConnectionService socketConnectionService, [FromServices] IMapper mapper)
+ {
+ Sys_Socket sys_Socket = socketConnectionService.ObtainAddress();
+
+ return await Task.FromResult(new JsonResult(new ApiDataResult() { Data = sys_Socket, Success = false, Message = "ɹһεͨòѯ" }));
+ }
+
+ ///
+ /// Socket
+ ///
+ [HttpGet]
+ [Route("GetSocket/{ip}/{port}")]
+ public async Task SocketConnectionAsync([FromServices] ISocketConnectionService socketConnectionService, string ip, string port)
+ {
+ //Socket
+ SocketStatic._client.InitSocket(ip, Convert.ToInt32(port));
+ bool isConnected = SocketStatic._client.Connect();
+ if (isConnected)
+ {
+ int dateid = 0;
+ Sys_Socket sys_Socket = socketConnectionService.ObtainAddress();
+ //жӵip˿ںǷΪһӵģһ
+ if (sys_Socket == null)
+ {
+ dateid = socketConnectionService.InserAddress(ip, port);
+ }
+ else if (!ip.Equals(sys_Socket.IP) || !port.Equals(sys_Socket.Port))
+ {
+ dateid = socketConnectionService.InserAddress(ip, port);
+ }
+
+ SocketStatic._client.pushSockets = ReceiveMess;//ע
+ return await Task.FromResult(new JsonResult(new ApiResult() { Success = true, Message = "Socketͨӳɹ" }));
+ }
+ else
+ {
+ return await Task.FromResult(new JsonResult(new ApiResult() { Success = false, Message = "SocketͨʧܣIP˿ںź³!" }));
+ }
+ }
+
+
+ ///
+ /// SocketϿ
+ ///
+ ///
+ [HttpPost]
+ [Route("Stop")]
+ public async Task SocketConnectionStopAsync()
+ {
+ SocketStatic._client.Stop();
+ return await Task.FromResult(new JsonResult(new ApiResult() { Success = true, Message = "SocketͨѶϿ" }));
+ }
+
+
+ #region ͻݽ
+
+ ///
+ /// ͻݽ
+ ///
+ ///
+ private void ReceiveMess(Sockets sks)
+ {
+ if (sks.ex != null)
+ {
+ if (sks.ClientDispose == true)
+ {
+ //δ֪ԭ쳣.¿ͻ. .Ͽ.
+ //wirte_textbox(string.Format("ͻ.!쳣Ϣ{0}\r\n", sks.ex));
+ }
+ else
+ {
+ //SetClientState(string.Format("쳣Ϣ{0}\r\n", sks.ex));
+ }
+ //timerConnect.Enabled = true;
+ }
+ else if (sks.Offset == 0)
+ {
+ //ͻ
+ //wirte_textbox("ͻ!");
+ }
+ else
+ {
+ byte[] buffer = new byte[sks.Offset];
+ Array.Copy(sks.RecBuffer, buffer, sks.Offset);
+ string str = Encoding.UTF8.GetString(buffer);
+
+ try
+ {
+ SocketStatic.dataParsing.ParsingData(new List(buffer));
+ }
+ catch (Exception)
+ {
+ return;
+ }
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/UIStandardWebApi/Controllers/WeatherForecastController.cs b/UIStandardWebApi/Controllers/WeatherForecastController.cs
deleted file mode 100644
index f343a01..0000000
--- a/UIStandardWebApi/Controllers/WeatherForecastController.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using UIStandardWebApi.WebCore.SwaggerExtend;
-
-namespace UIStandardWebApi.Controllers
-{
- [ApiController]
- [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
- [Route("api/[controller]")]
- public class WeatherForecastController : ControllerBase
- {
- private static readonly string[] Summaries = new[]
- {
- "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
- };
-
- private readonly ILogger _logger;
-
- public WeatherForecastController(ILogger logger)
- {
- _logger = logger;
- }
-
- [HttpGet(Name = "GetWeatherForecast")]
- public IEnumerable Get()
- {
- return Enumerable.Range(1, 5).Select(index => new WeatherForecast
- {
- Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
- TemperatureC = Random.Shared.Next(-20, 55),
- Summary = Summaries[Random.Shared.Next(Summaries.Length)]
- })
- .ToArray();
- }
- }
-}
diff --git a/UIStandardWebApi/Program.cs b/UIStandardWebApi/Program.cs
index 43e97bc..19f2375 100644
--- a/UIStandardWebApi/Program.cs
+++ b/UIStandardWebApi/Program.cs
@@ -29,6 +29,7 @@ namespace UIStandardWebApi
//Automapperע
builder.Services.AddAutoMapper(typeof(AutoMapperConfigs));
+
builder.Services.AddMemoryCache();
//
diff --git a/UIStandardWebApi/SqlSuggar/InitDatabaseExt.cs b/UIStandardWebApi/SqlSuggar/InitDatabaseExt.cs
index 062ba5b..b9d1d6f 100644
--- a/UIStandardWebApi/SqlSuggar/InitDatabaseExt.cs
+++ b/UIStandardWebApi/SqlSuggar/InitDatabaseExt.cs
@@ -24,7 +24,7 @@ namespace UIStandardWebApi.SqlSuggar
ConnectionConfig connection = new ConnectionConfig()
{
- DbType = DbType.SqlServer,
+ DbType = DbType.MySql,
IsAutoCloseConnection = true,
ConnectionString = connectionString
};
diff --git a/UIStandardWebApi/SqlSuggar/InitSqlSugarExt.cs b/UIStandardWebApi/SqlSuggar/InitSqlSugarExt.cs
index cd83ee2..92c90c8 100644
--- a/UIStandardWebApi/SqlSuggar/InitSqlSugarExt.cs
+++ b/UIStandardWebApi/SqlSuggar/InitSqlSugarExt.cs
@@ -21,7 +21,7 @@ namespace UIStandardWebApi.SqlSuggar
ConnectionConfig connection = new ConnectionConfig()
{
ConnectionString = customConnectionConfig.ConnectionString,
- DbType = DbType.SqlServer,
+ DbType = DbType.MySql,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute,
SlaveConnectionConfigs = customConnectionConfig.SlaveConnectionConfigs.Select(c => new SlaveConnectionConfig() { ConnectionString = c.ConnectionString, HitRate = c.CustomHitRate }).ToList()
diff --git a/UIStandardWebApi/UIStandardWebApi.csproj b/UIStandardWebApi/UIStandardWebApi.csproj
index b651bc9..10620b4 100644
--- a/UIStandardWebApi/UIStandardWebApi.csproj
+++ b/UIStandardWebApi/UIStandardWebApi.csproj
@@ -23,7 +23,10 @@
+
+
+
diff --git a/UIStandardWebApi/Utility/RegisterExt/RegistServiceExtension.cs b/UIStandardWebApi/Utility/RegisterExt/RegistServiceExtension.cs
index 9229ecf..4f36c7c 100644
--- a/UIStandardWebApi/Utility/RegisterExt/RegistServiceExtension.cs
+++ b/UIStandardWebApi/Utility/RegisterExt/RegistServiceExtension.cs
@@ -3,6 +3,8 @@ using Newtonsoft.Json;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using UIStandardWebApi.Common.JwtService;
+using UIStandardWebApi.IService;
+using UIStandardWebApi.Service;
namespace UIStandardWebApi.Utility.RegisterExt
{
@@ -17,7 +19,7 @@ namespace UIStandardWebApi.Utility.RegisterExt
///
public static void RegistService(this WebApplicationBuilder builder)
{
- //builder.Services.AddTransient();
+ builder.Services.AddTransient();
builder.Services.Configure(builder.Configuration.GetSection("JWTTokenOptions"));
diff --git a/UIStandardWebApi/WeatherForecast.cs b/UIStandardWebApi/WeatherForecast.cs
deleted file mode 100644
index ff6cb4b..0000000
--- a/UIStandardWebApi/WeatherForecast.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace UIStandardWebApi
-{
- public class WeatherForecast
- {
- public DateOnly Date { get; set; }
-
- public int TemperatureC { get; set; }
-
- public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
-
- public string? Summary { get; set; }
- }
-}
diff --git a/UIStandardWebApi/appsettings.json b/UIStandardWebApi/appsettings.json
index 24b7f87..b8a0a87 100644
--- a/UIStandardWebApi/appsettings.json
+++ b/UIStandardWebApi/appsettings.json
@@ -6,13 +6,13 @@
}
},
"AllowedHosts": "*",
- "IsInitDatabase": "0",
+ "IsInitDatabase": "1",
"Socket": {
"ip": "192.168.1.254",
"port": "8899"
},
"ConnectionStrings": {
- "ConnectionString": "Data Source = NB10920;Initial Catalog=InSituLaboratoryWeb;User ID=sa;Password=zttZTT123;MultipleActiveResultSets=true",
+ "ConnectionString": "server = 127.0.0.1;port = 3306;user = root;password = zttZTT1234;database = 20250418_UIStandardWebApi;Allow User Variables = True;",
"DbType": 1
},
"JWTTokenOptions": {