diff --git a/Txgy.RBS.BLL/LoginBll.cs b/Txgy.RBS.BLL/LoginBll.cs
new file mode 100644
index 0000000..a338756
--- /dev/null
+++ b/Txgy.RBS.BLL/LoginBll.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Txgy.RBS.IBLL;
+
+namespace Txgy.RBS.BLL
+{
+ public class LoginBll: ILoginBll
+ {
+ public
+ public void Test()
+ {
+
+ }
+ }
+}
diff --git a/Txgy.RBS.BLL/Txgy.RBS.BLL.csproj b/Txgy.RBS.BLL/Txgy.RBS.BLL.csproj
new file mode 100644
index 0000000..e6bfe82
--- /dev/null
+++ b/Txgy.RBS.BLL/Txgy.RBS.BLL.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.DAL/BaseService.cs b/Txgy.RBS.DAL/BaseService.cs
new file mode 100644
index 0000000..6a71971
--- /dev/null
+++ b/Txgy.RBS.DAL/BaseService.cs
@@ -0,0 +1,161 @@
+using SqlSugar;
+using System.Linq.Expressions;
+using Txgy.RBS.IDAL;
+
+namespace Txgy.RBS.DAL
+{
+ public 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);
+ }
+
+ ///
+ /// 不应该暴露给上端使用者,尽量少用
+ ///
+ ///
+ ///
+ //[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
+ ///
+ /// 即使保存 不需要再Commit
+ ///
+ ///
+ ///
+ ///
+ public T Insert(T t) where T : class, new()
+ {
+ _Client.Insertable(t).ExecuteCommand();
+ return t;
+ }
+
+ public IEnumerable Insert(List tList) where T : class, new()
+ {
+ _Client.Insertable(tList.ToList()).ExecuteCommand();
+ return tList;
+ }
+ #endregion
+
+ #region Update
+ ///
+ /// 是没有实现查询,直接更新的,需要Attach和State
+ ///
+ /// 如果是已经在context,只能再封装一个(在具体的service)
+ ///
+ ///
+ ///
+ public void Update(T t) where T : class, new()
+ {
+ if (t == null) throw new Exception("t is null");
+
+ _Client.Updateable(t).ExecuteCommand();
+ }
+
+ 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();
+ }
+
+ ///
+ /// 还可以增加非即时commit版本的,
+ /// 做成protected
+ ///
+ ///
+ ///
+ public void Delete(int Id) where T : class, new()
+ {
+ T t = _Client.Queryable().InSingle(Id);
+ _Client.Deleteable(t).ExecuteCommand();
+ }
+
+ public void Delete(List tList) where T : class
+ {
+ _Client.Deleteable(tList).ExecuteCommand();
+ }
+ #endregion
+
+
+ #region Other
+
+ public ISugarQueryable ExcuteQuery(string sql) where T : class, new()
+ {
+ return _Client.SqlQueryable(sql);
+ }
+ public void Dispose()
+ {
+ if (_Client != null)
+ {
+ _Client.Dispose();
+ }
+ }
+
+ //public ISugarQueryable ExcuteQuery(string sql) where T : class, new()
+ //{
+ // return _Client.SqlQueryable(sql);
+ //}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Txgy.RBS.DAL/DataAccessDal.cs b/Txgy.RBS.DAL/DataAccessDal.cs
new file mode 100644
index 0000000..b18519d
--- /dev/null
+++ b/Txgy.RBS.DAL/DataAccessDal.cs
@@ -0,0 +1,43 @@
+using SqlSugar;
+using System.Data;
+using Txgy.RBS.DbModel;
+using Txgy.RBS.IDAL;
+
+namespace Txgy.RBS.DAL
+{
+ //sqlite数据库操作
+ public class DataAccessDal : BaseService, IDataAccessDal
+ {
+
+ public DataAccessDal( ISqlSugarClient sqlSugarClient) : base(sqlSugarClient)
+ {
+
+ }
+
+ public List GetIcons()
+ {
+ var data= _Client.Queryable().ToList();
+ return null;
+ }
+
+
+ public Setting GetClientType(int userId = 1)
+ {
+ return new Setting();
+ }
+ public void UpdateClientDetail(double createTime, int mailRule, string mailbox, string appMessage)
+ {
+
+ }
+
+ public string GetDevices(int roadId)
+ {
+ return string.Empty;
+ }
+
+ public void UpdateDeviceType(int currentDevice)
+ {
+
+ }
+ }
+}
diff --git a/Txgy.RBS.DAL/LoginDal.cs b/Txgy.RBS.DAL/LoginDal.cs
new file mode 100644
index 0000000..c3bbc1a
--- /dev/null
+++ b/Txgy.RBS.DAL/LoginDal.cs
@@ -0,0 +1,14 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Txgy.RBS.IDAL;
+
+
+namespace Txgy.RBS.DAL
+{
+ public class LoginDal : BaseService, ILoginDal
+ {
+ public LoginDal(ISqlSugarClient sqlSugarClient) : base(sqlSugarClient) { }
+ }
+}
diff --git a/Txgy.RBS.DAL/Txgy.RBS.DAL.csproj b/Txgy.RBS.DAL/Txgy.RBS.DAL.csproj
new file mode 100644
index 0000000..b72e9be
--- /dev/null
+++ b/Txgy.RBS.DAL/Txgy.RBS.DAL.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.DTO/Reception/JWTTokenOptions.cs b/Txgy.RBS.DTO/Reception/JWTTokenOptions.cs
new file mode 100644
index 0000000..9bec159
--- /dev/null
+++ b/Txgy.RBS.DTO/Reception/JWTTokenOptions.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.DTO.Reception
+{
+ public class JWTTokenOptions
+ {
+ public string? Audience
+ {
+ get;
+ set;
+ }
+ public string? SecurityKey
+ {
+ get;
+ set;
+ }
+ //public SigningCredentials Credentials
+ //{
+ // get;
+ // set;
+ //}
+ public string? Issuer
+ {
+ get;
+ set;
+ }
+ }
+}
diff --git a/Txgy.RBS.DTO/ResultJsonDTO.cs b/Txgy.RBS.DTO/ResultJsonDTO.cs
new file mode 100644
index 0000000..75b051f
--- /dev/null
+++ b/Txgy.RBS.DTO/ResultJsonDTO.cs
@@ -0,0 +1,31 @@
+namespace Txgy.RBS.DTO
+{
+ ///
+ ///
+ ///
+ public partial class ResultJsonDTO
+ {
+ public int Id { get; set; }
+ public string? Name { get; set; }
+
+ public string? Mobile { get; set; }
+
+ public string? Address { get; set; }
+
+ public string? Email { get; set; }
+
+ public long? QQ { get; set; }
+
+ public string? WeChat { get; set; }
+
+ public int? Sex { get; set; }
+
+ ///
+ /// Desc:
+ /// Default:
+ /// Nullable:True
+ ///
+ public string? UserImageUrl { get; set; }
+
+ }
+}
diff --git a/Txgy.RBS.DTO/Txgy.RBS.DTO.csproj b/Txgy.RBS.DTO/Txgy.RBS.DTO.csproj
new file mode 100644
index 0000000..278d183
--- /dev/null
+++ b/Txgy.RBS.DTO/Txgy.RBS.DTO.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.DbModel/CurrentMonitoring.cs b/Txgy.RBS.DbModel/CurrentMonitoring.cs
new file mode 100644
index 0000000..4981508
--- /dev/null
+++ b/Txgy.RBS.DbModel/CurrentMonitoring.cs
@@ -0,0 +1,15 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.DbModel
+{
+
+ [SugarTable("current_monitoring")]
+ public class CurrentMonitoring
+ {
+ [SugarColumn(ColumnName = "current_moni_id", IsPrimaryKey = true, IsIdentity = true)]
+ public int CurrentMoniId { get; set; }
+ }
+}
diff --git a/Txgy.RBS.DbModel/CurrentWorkarea.cs b/Txgy.RBS.DbModel/CurrentWorkarea.cs
new file mode 100644
index 0000000..843e3a5
--- /dev/null
+++ b/Txgy.RBS.DbModel/CurrentWorkarea.cs
@@ -0,0 +1,14 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.DbModel
+{
+ [SugarTable("current_workarea")]
+ public class CurrentWorkarea
+ {
+ [SugarColumn(ColumnName = "current_workarea_id", IsPrimaryKey = true, IsIdentity = true)]
+ public int CurrentWorkareaId { get; set; }
+ }
+}
diff --git a/Txgy.RBS.DbModel/MonitoringInfo.cs b/Txgy.RBS.DbModel/MonitoringInfo.cs
new file mode 100644
index 0000000..441afc3
--- /dev/null
+++ b/Txgy.RBS.DbModel/MonitoringInfo.cs
@@ -0,0 +1,22 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.DbModel
+{
+ [SugarTable("monitoring_info")]
+ public class MonitoringInfo
+ {
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ [SugarColumn(ColumnName = "work_area_id")]
+ public int WorkAreaId { get; set; }
+ [SugarColumn(ColumnName = "layer_num")]
+ public int LayerNum { get; set; }
+ [SugarColumn(ColumnName = "moni_num")]
+ public int MoniNum { get; set; }
+ [SugarColumn(ColumnName = "moni_date")]
+ public string MoniDate { get; set; }
+ }
+}
diff --git a/Txgy.RBS.DbModel/Result.cs b/Txgy.RBS.DbModel/Result.cs
new file mode 100644
index 0000000..37984ae
--- /dev/null
+++ b/Txgy.RBS.DbModel/Result.cs
@@ -0,0 +1,39 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.DbModel
+{
+
+ [SugarTable("result")]
+ public class Result
+ {
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ [SugarColumn(ColumnName = "project_id")]
+ public int ProjectId { get; set; }
+ [SugarColumn(ColumnName = "otime")]
+ public string Otime { get; set; }
+ [SugarColumn(ColumnName = "e")]
+ public double E { get; set; }
+ [SugarColumn(ColumnName = "n")]
+ public double N { get; set; }
+ [SugarColumn(ColumnName = "depth")]
+ public double Depth { get; set; }
+ [SugarColumn(ColumnName = "ml")]
+ public double Ml { get; set; }
+ [SugarColumn(ColumnName = "energy")]
+ public double Energy { get; set; }
+ [SugarColumn(ColumnName = "rms")]
+ public double Rms { get; set; }
+ [SugarColumn(ColumnName = "phases_count")]
+ public int PhasesCount { get; set; }
+ [SugarColumn(ColumnName = "amps_count")]
+ public int AmpsCount { get; set; }
+ [SugarColumn(ColumnName = "seismic_source")]
+ public string SeismicSource { get; set; }
+ [SugarColumn(ColumnName = "seismic_direction")]
+ public double SeismicDirection { get; set; }
+ }
+}
diff --git a/Txgy.RBS.DbModel/ResultJson.cs b/Txgy.RBS.DbModel/ResultJson.cs
new file mode 100644
index 0000000..3396934
--- /dev/null
+++ b/Txgy.RBS.DbModel/ResultJson.cs
@@ -0,0 +1,19 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.DbModel
+{
+
+ [SugarTable("result_json")]
+ public class ResultJson
+ {
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ [SugarColumn(ColumnName = "result_id")]
+ public int ResultId { get; set; }
+ [SugarColumn(ColumnName = "json")]
+ public string Json { get; set; }
+ }
+}
diff --git a/Txgy.RBS.DbModel/Txgy.RBS.DbModel.csproj b/Txgy.RBS.DbModel/Txgy.RBS.DbModel.csproj
new file mode 100644
index 0000000..99e7b2f
--- /dev/null
+++ b/Txgy.RBS.DbModel/Txgy.RBS.DbModel.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.DbModel/Workarea.cs b/Txgy.RBS.DbModel/Workarea.cs
new file mode 100644
index 0000000..39bf472
--- /dev/null
+++ b/Txgy.RBS.DbModel/Workarea.cs
@@ -0,0 +1,59 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.DbModel
+{
+
+ [SugarTable("workarea")]
+ public class Workarea
+ {
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ [SugarColumn(ColumnName = "name")]
+ public string Name { get; set; }
+ [SugarColumn(ColumnName = "csv_path")]
+ public string CsvPath { get; set; }
+ [SugarColumn(ColumnName = "ttime_path")]
+ public string TtimePath { get; set; }
+ [SugarColumn(ColumnName = "x_min")]
+ public double Xmin { get; set; }
+ [SugarColumn(ColumnName = "x_max")]
+ public double Xmax { get; set; }
+ [SugarColumn(ColumnName = "y_min")]
+ public double Ymin { get; set; }
+ [SugarColumn(ColumnName = "y_max")]
+ public double Ymax { get; set; }
+ [SugarColumn(ColumnName = "z_min")]
+ public double Zmin { get; set; }
+ [SugarColumn(ColumnName = "z_max")]
+ public double Zmax { get; set; }
+ [SugarColumn(ColumnName = "save_result")]
+ public int SaveResult { get; set; }
+ [SugarColumn(ColumnName = "save_result_path")]
+ public string SaveResultPath { get; set; }
+ [SugarColumn(ColumnName = "push_wx")]
+ public int PushWx { get; set; }
+ [SugarColumn(ColumnName = "push_wx_value")]
+ public double PushWxValue { get; set; }
+ [SugarColumn(ColumnName = "push_dd")]
+ public int PushDd { get; set; }
+ [SugarColumn(ColumnName = "push_dd_value")]
+ public double PushDdValue { get; set; }
+ [SugarColumn(ColumnName = "save_waves")]
+ public int SaveWaves { get; set; }
+ [SugarColumn(ColumnName = "save_waves_path")]
+ public double SaveWavesPath { get; set; }
+ [SugarColumn(ColumnName = "send_redis")]
+ public int SendRedis { get; set; }
+ [SugarColumn(ColumnName = "mqtt_Server")]
+ public string MqttServer { get; set; }
+ [SugarColumn(ColumnName = "network")]
+ public string Network { get; set; }
+ [SugarColumn(ColumnName = "location")]
+ public string Location { get; set; }
+ [SugarColumn(ColumnName = "channels")]
+ public string Channels { get; set; }
+ }
+}
diff --git a/Txgy.RBS.Framework/Api/ApiResult.cs b/Txgy.RBS.Framework/Api/ApiResult.cs
new file mode 100644
index 0000000..2665ac5
--- /dev/null
+++ b/Txgy.RBS.Framework/Api/ApiResult.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.Framework.Api
+{
+ public class ApiResult
+ {
+ ///
+ /// 是否成功
+ ///
+ public bool Success
+ {
+ get
+ {
+ return string.IsNullOrWhiteSpace(Message);
+ }
+ }
+
+ public ReponseCodeEnum Code { get; set; }
+
+ ///
+ /// 特指错误消息
+ ///
+ public string? Message { get; set; }
+
+ ///
+ /// 数据源
+ ///
+ public object? Data { get; set; }
+
+ ///
+ /// 额外数据
+ ///
+ public object? Tag { get; set; }
+ }
+
+ public enum ReponseCodeEnum
+ {
+ NoAuthorize = 1
+ }
+}
diff --git a/Txgy.RBS.Framework/CustomEnum/ApprovalStatusEnum.cs b/Txgy.RBS.Framework/CustomEnum/ApprovalStatusEnum.cs
new file mode 100644
index 0000000..c2bcf7d
--- /dev/null
+++ b/Txgy.RBS.Framework/CustomEnum/ApprovalStatusEnum.cs
@@ -0,0 +1,42 @@
+namespace Txgy.RBS.Framework.CustomEnum
+{
+ ///
+ /// 审批状态
+ ///
+ public enum ApprovalStatusEnum
+ {
+ ///
+ /// 普通用户 无需要审批
+ ///
+ NoApproval = 0,
+
+ ///
+ /// 审批驳回
+ ///
+ [Remark("审批驳回")]
+ ApprovalRejected = 1,
+
+ ///
+ ///发起审批
+ ///
+ [Remark("发起审批")]
+ PendingApproval = 2,
+
+ ///
+ /// 审批通过
+ ///
+ [Remark("审批通过")]
+ Approved = 3
+ }
+
+ public class RemarkAttribute : Attribute
+ {
+ private string _Rmark;
+ public RemarkAttribute(string remark)
+ {
+ this._Rmark = remark;
+ }
+
+ public string GetRemark() => _Rmark;
+ }
+}
diff --git a/Txgy.RBS.Framework/CustomEnum/GenderEnum.cs b/Txgy.RBS.Framework/CustomEnum/GenderEnum.cs
new file mode 100644
index 0000000..1d00e0d
--- /dev/null
+++ b/Txgy.RBS.Framework/CustomEnum/GenderEnum.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.Framework.CustomEnum
+{
+ ///
+ /// 性别
+ ///
+ public enum GenderEnum
+ {
+ [Remark("男")]
+ Male = 1,
+ [Remark("女")]
+ Female = 2,
+ [Remark("人妖")]
+ Simon = 3
+ }
+}
diff --git a/Txgy.RBS.Framework/CustomEnum/StatusEnum.cs b/Txgy.RBS.Framework/CustomEnum/StatusEnum.cs
new file mode 100644
index 0000000..767918a
--- /dev/null
+++ b/Txgy.RBS.Framework/CustomEnum/StatusEnum.cs
@@ -0,0 +1,26 @@
+namespace Txgy.RBS.Framework.CustomEnum
+{
+ ///
+ /// 通用状态
+ ///
+ public enum StatusEnum
+ {
+ ///
+ /// 禁用
+ ///
+ [Remark("禁用")]
+ Disable = 0,
+
+ ///
+ /// 正常
+ ///
+ [Remark("正常")]
+ Normal = 1,
+
+ ///
+ /// 已删除
+ ///
+ [Remark("已删除")]
+ Delete = 2
+ }
+}
diff --git a/Txgy.RBS.Framework/CustomEnum/UserStatusEnum.cs b/Txgy.RBS.Framework/CustomEnum/UserStatusEnum.cs
new file mode 100644
index 0000000..0c748e8
--- /dev/null
+++ b/Txgy.RBS.Framework/CustomEnum/UserStatusEnum.cs
@@ -0,0 +1,26 @@
+namespace Txgy.RBS.Framework.CustomEnum
+{
+ ///
+ /// 用户状态
+ ///
+ public enum UserStatusEnum
+ {
+ ///
+ /// 已冻结
+ ///
+ [Remark("已冻结")]
+ Frozen = 0,
+
+ ///
+ /// 正常
+ ///
+ [Remark("正常")]
+ Normal = 1,
+
+ ///
+ /// 已删除
+ ///
+ [Remark("已删除")]
+ Delete = 2
+ }
+}
diff --git a/Txgy.RBS.Framework/CustomEnum/UserTypeEnum.cs b/Txgy.RBS.Framework/CustomEnum/UserTypeEnum.cs
new file mode 100644
index 0000000..769c393
--- /dev/null
+++ b/Txgy.RBS.Framework/CustomEnum/UserTypeEnum.cs
@@ -0,0 +1,26 @@
+namespace Txgy.RBS.Framework.CustomEnum
+{
+ ///
+ /// 用户类别
+ ///
+ public enum UserTypeEnum
+ {
+ ///
+ /// 后台用户
+ ///
+ [Remark("后台用户")]
+ Administrators = 1,
+
+ ///
+ /// 普通用户
+ ///
+ [Remark("普通用户")]
+ Member = 2,
+
+ ///
+ /// 主播用户
+ ///
+ [Remark("主播用户")]
+ Anchor = 3
+ }
+}
diff --git a/Txgy.RBS.Framework/MD5Encrypt.cs b/Txgy.RBS.Framework/MD5Encrypt.cs
new file mode 100644
index 0000000..52b4dd2
--- /dev/null
+++ b/Txgy.RBS.Framework/MD5Encrypt.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Txgy.RBS.Framework
+{
+ public class MD5Encrypt
+ {
+ #region MD5
+ ///
+ /// MD5加密,和动网上的16/32位MD5加密结果相同,
+ /// 使用的UTF8编码
+ ///
+ /// 待加密字串
+ /// 16或32值之一,其它则采用.net默认MD5加密算法
+ /// 加密后的字串
+ public static string Encrypt(string source, int length = 32)//默认参数
+ {
+ if (string.IsNullOrEmpty(source)) return string.Empty;
+ HashAlgorithm provider = CryptoConfig.CreateFromName("MD5") as HashAlgorithm;
+ byte[] bytes = Encoding.UTF8.GetBytes(source);//这里需要区别编码的
+ byte[] hashValue = provider.ComputeHash(bytes);
+ StringBuilder sb = new StringBuilder();
+ switch (length)
+ {
+ case 16://16位密文是32位密文的9到24位字符
+ for (int i = 4; i < 12; i++)
+ {
+ sb.Append(hashValue[i].ToString("x2"));
+ }
+ break;
+ case 32:
+ for (int i = 0; i < 16; i++)
+ {
+ sb.Append(hashValue[i].ToString("x2"));
+ }
+ break;
+ default:
+ for (int i = 0; i < hashValue.Length; i++)
+ {
+ sb.Append(hashValue[i].ToString("x2"));
+ }
+ break;
+ }
+ return sb.ToString();
+ }
+ #endregion MD5
+
+ #region MD5摘要
+ ///
+ /// 获取文件的MD5摘要
+ ///
+ ///
+ ///
+ public static string AbstractFile(string fileName)
+ {
+ using (FileStream file = new FileStream(fileName, FileMode.Open))
+ {
+ return AbstractFile(file);
+ }
+ }
+
+
+ ///
+ /// 根据stream获取文件摘要
+ ///
+ ///
+ ///
+ public static string AbstractFile(Stream stream)
+ {
+ MD5 md5 = new MD5CryptoServiceProvider();
+ byte[] retVal = md5.ComputeHash(stream);
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < retVal.Length; i++)
+ {
+ sb.Append(retVal[i].ToString("x2"));
+ }
+ return sb.ToString();
+ }
+ #endregion
+ }
+}
diff --git a/Txgy.RBS.Framework/PagingData.cs b/Txgy.RBS.Framework/PagingData.cs
new file mode 100644
index 0000000..1bc6bcc
--- /dev/null
+++ b/Txgy.RBS.Framework/PagingData.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.Framework
+{
+ 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/Txgy.RBS.Framework/RedisHelper/Init/RedisConfigInfo.cs b/Txgy.RBS.Framework/RedisHelper/Init/RedisConfigInfo.cs
new file mode 100644
index 0000000..36025a1
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Init/RedisConfigInfo.cs
@@ -0,0 +1,45 @@
+using System.Configuration;
+
+namespace Txgy.RBS.Framework.RedisHelper.Init
+{
+ ///
+ /// redis配置文件信息
+ /// 也可以放到配置文件去
+ ///
+ public sealed class RedisConfigInfo
+ {
+ ///
+ /// 可写的Redis链接地址
+ /// format:ip1,ip2
+ ///
+ /// 默认6379端口
+ ///
+ public string WriteServerList = "127.0.0.1:6379";
+ ///
+ /// 可读的Redis链接地址
+ /// format:ip1,ip2
+ ///
+ public string ReadServerList = "127.0.0.1:6379";
+ ///
+ /// 最大写链接数
+ ///
+ public int MaxWritePoolSize = 60;
+ ///
+ /// 最大读链接数
+ ///
+ public int MaxReadPoolSize = 60;
+ ///
+ /// 本地缓存到期时间,单位:秒
+ ///
+ public int LocalCacheTime = 180;
+ ///
+ /// 自动重启
+ ///
+ public bool AutoStart = true;
+ ///
+ /// 是否记录日志,该设置仅用于排查redis运行时出现的问题,
+ /// 如redis工作正常,请关闭该项
+ ///
+ public bool RecordeLog = false;
+ }
+}
\ No newline at end of file
diff --git a/Txgy.RBS.Framework/RedisHelper/Init/RedisManager.cs b/Txgy.RBS.Framework/RedisHelper/Init/RedisManager.cs
new file mode 100644
index 0000000..0c92439
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Init/RedisManager.cs
@@ -0,0 +1,52 @@
+using ServiceStack.Redis;
+
+namespace Txgy.RBS.Framework.RedisHelper.Init
+{
+ ///
+ /// Redis管理中心 创建Redis链接
+ ///
+ public class RedisManager
+ {
+ ///
+ /// redis配置文件信息
+ ///
+ private static RedisConfigInfo RedisConfigInfo = new RedisConfigInfo();
+
+ ///
+ /// Redis客户端池化管理
+ ///
+ private static PooledRedisClientManager prcManager;
+
+ ///
+ /// 静态构造方法,初始化链接池管理对象
+ ///
+ static RedisManager()
+ {
+ CreateManager();
+ }
+
+ ///
+ /// 创建链接池管理对象
+ ///
+ private static void CreateManager()
+ {
+ string[] WriteServerConStr = RedisConfigInfo.WriteServerList.Split(',');
+ string[] ReadServerConStr = RedisConfigInfo.ReadServerList.Split(',');
+ prcManager = new PooledRedisClientManager(ReadServerConStr, WriteServerConStr,
+ new RedisClientManagerConfig
+ {
+ MaxWritePoolSize = RedisConfigInfo.MaxWritePoolSize,
+ MaxReadPoolSize = RedisConfigInfo.MaxReadPoolSize,
+ AutoStart = RedisConfigInfo.AutoStart,
+ });
+ }
+
+ ///
+ /// 客户端缓存操作对象
+ ///
+ public static IRedisClient GetClient(RedisConfigInfo configInfo)
+ {
+ return prcManager.GetClient();
+ }
+ }
+}
diff --git a/Txgy.RBS.Framework/RedisHelper/Interface/RedisBase.cs b/Txgy.RBS.Framework/RedisHelper/Interface/RedisBase.cs
new file mode 100644
index 0000000..f57e04d
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Interface/RedisBase.cs
@@ -0,0 +1,88 @@
+using Microsoft.Extensions.Options;
+using ServiceStack.Redis;
+using Txgy.RBS.Framework.RedisHelper.Init;
+
+namespace Txgy.RBS.Framework.RedisHelper.Interface
+{
+ ///
+ /// RedisBase类,是redis操作的基类,继承自IDisposable接口,主要用于释放内存
+ ///
+ public abstract class RedisBase : IDisposable
+ {
+ public IRedisClient IClient { get; private set; }
+ ///
+ /// 构造时完成链接的打开
+ ///
+ public RedisBase(IOptionsMonitor options)
+ {
+ IClient = RedisManager.GetClient(options.CurrentValue);
+ }
+
+ //public static IRedisClient iClient { get; private set; }
+ //static RedisBase()
+ //{
+ // iClient = RedisManager.GetClient();
+ //}
+
+
+ private bool _disposed = false;
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ IClient.Dispose();
+ IClient = null;
+ }
+ }
+ _disposed = true;
+ }
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ public void Transcation()
+ {
+ using IRedisTransaction irt = IClient.CreateTransaction();
+ try
+ {
+ irt.QueueCommand(r => r.Set("key", 20));
+ irt.QueueCommand(r => r.Increment("key", 1));
+ irt.Commit(); // 提交事务
+ }
+ catch (Exception)
+ {
+ irt.Rollback();
+ throw;
+ }
+ }
+
+
+ ///
+ /// 清除全部数据 请小心
+ ///
+ public virtual void FlushAll()
+ {
+ IClient.FlushAll();
+ }
+
+ ///
+ /// 保存数据DB文件到硬盘
+ ///
+ public void Save()
+ {
+ IClient.Save();//阻塞式save
+ }
+
+ ///
+ /// 异步保存数据DB文件到硬盘
+ ///
+ public void SaveAsync()
+ {
+ IClient.SaveAsync();//异步save
+ }
+ }
+}
diff --git a/Txgy.RBS.Framework/RedisHelper/Service/RedisHashService.cs b/Txgy.RBS.Framework/RedisHelper/Service/RedisHashService.cs
new file mode 100644
index 0000000..4aebd9b
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Service/RedisHashService.cs
@@ -0,0 +1,143 @@
+
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Txgy.RBS.Framework.RedisHelper.Init;
+using Txgy.RBS.Framework.RedisHelper.Interface;
+
+namespace Txgy.RBS.Framework.RedisHelper.Service
+{
+ ///
+ /// Hash:类似dictionary,通过索引快速定位到指定元素的,耗时均等,跟string的区别在于不用反序列化,直接修改某个字段
+ /// string的话要么是 001:序列化整个实体
+ /// 要么是 001_name: 001_pwd: 多个key-value
+ /// Hash的话,一个hashid-{key:value;key:value;key:value;}
+ /// 可以一次性查找实体,也可以单个,还可以单个修改
+ ///
+ public class RedisHashService : RedisBase
+ {
+ public RedisHashService(IOptionsMonitor options) : base(options)
+ {
+ }
+ #region 添加
+ ///
+ /// 向hashid集合中添加key/value
+ ///
+ public bool SetEntryInHash(string hashid, string key, string value)
+ {
+ return IClient.SetEntryInHash(hashid, key, value);
+ }
+
+
+ public void SetRangeInHash(string hashid, IEnumerable> value)
+ {
+ IClient.SetRangeInHash(hashid, value);
+ }
+
+ ///
+ /// 如果hashid集合中存在key/value则不添加返回false,
+ /// 如果不存在在添加key/value,返回true
+ ///
+ public bool SetEntryInHashIfNotExists(string hashid, string key, string value)
+ {
+ return IClient.SetEntryInHashIfNotExists(hashid, key, value);
+ }
+ ///
+ /// 存储对象T t到hash集合中
+ /// 需要包含Id,然后用Id获取
+ ///
+ public void StoreAsHash(T t)
+ {
+ IClient.StoreAsHash(t);
+ }
+ #endregion
+
+ #region 获取
+ ///
+ /// 获取对象T中ID为id的数据。
+ ///
+ public T GetFromHash(object id)
+ {
+ return IClient.GetFromHash(id);
+ }
+ ///
+ /// 获取所有hashid数据集的key/value数据集合
+ ///
+ public Dictionary GetAllEntriesFromHash(string hashid)
+ {
+ return IClient.GetAllEntriesFromHash(hashid);
+ }
+ ///
+ /// 获取hashid数据集中的数据总数
+ ///
+ public long GetHashCount(string hashid)
+ {
+ return IClient.GetHashCount(hashid);
+ }
+ ///
+ /// 获取hashid数据集中所有key的集合
+ ///
+ public List GetHashKeys(string hashid)
+ {
+ return IClient.GetHashKeys(hashid);
+ }
+ ///
+ /// 获取hashid数据集中的所有value集合
+ ///
+ public List GetHashValues(string hashid)
+ {
+ return IClient.GetHashValues(hashid);
+ }
+ ///
+ /// 获取hashid数据集中,key的value数据
+ ///
+ public string GetValueFromHash(string hashid, string key)
+ {
+ return IClient.GetValueFromHash(hashid, key);
+ }
+ ///
+ /// 获取hashid数据集中,多个keys的value集合
+ ///
+ public List GetValuesFromHash(string hashid, string[] keys)
+ {
+ return IClient.GetValuesFromHash(hashid, keys);
+ }
+ #endregion
+
+ #region 删除
+ ///
+ /// 删除hashid数据集中的key数据
+ ///
+ public bool RemoveEntryFromHash(string hashid, string key)
+ {
+ return IClient.RemoveEntryFromHash(hashid, key);
+ }
+
+ public bool RemoveEntry(string hashid)
+ {
+ return IClient.Remove(hashid);
+ }
+ #endregion
+
+ #region 其它
+ ///
+ /// 判断hashid数据集中是否存在key的数据
+ ///
+ public bool HashContainsEntry(string hashid, string key)
+ {
+ return IClient.HashContainsEntry(hashid, key);
+ }
+ ///
+ /// 给hashid数据集key的value加countby,返回相加后的数据
+ ///
+ public double IncrementValueInHash(string hashid, string key, double countBy)
+ {
+ return IClient.IncrementValueInHash(hashid, key, countBy);
+ }
+
+ #endregion
+ }
+}
diff --git a/Txgy.RBS.Framework/RedisHelper/Service/RedisListService.cs b/Txgy.RBS.Framework/RedisHelper/Service/RedisListService.cs
new file mode 100644
index 0000000..efbf1f2
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Service/RedisListService.cs
@@ -0,0 +1,271 @@
+
+using Microsoft.Extensions.Options;
+using ServiceStack.Redis;
+using Txgy.RBS.Framework.RedisHelper.Init;
+using Txgy.RBS.Framework.RedisHelper.Interface;
+
+namespace Txgy.RBS.Framework.RedisHelper.Service
+{
+ ///
+ /// Redis list的实现为一个双向链表,即可以支持反向查找和遍历,更方便操作,不过带来了部分额外的内存开销,
+ /// Redis内部的很多实现,包括发送缓冲队列等也都是用的这个数据结构。
+ ///
+ public class RedisListService : RedisBase
+ {
+ public RedisListService(IOptionsMonitor options) : base(options)
+ {
+ }
+ #region 赋值
+ ///
+ /// 从左侧向list中添加值
+ ///
+ public void LPush(string key, string value)
+ {
+ IClient.PushItemToList(key, value);
+ }
+ ///
+ /// 从左侧向list中添加值,并设置过期时间
+ ///
+ public void LPush(string key, string value, DateTime dt)
+ {
+
+ IClient.PushItemToList(key, value);
+ IClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 从左侧向list中添加值,设置过期时间
+ ///
+ public void LPush(string key, string value, TimeSpan sp)
+ {
+ IClient.PushItemToList(key, value);
+ IClient.ExpireEntryIn(key, sp);
+ }
+ ///
+ /// 从右侧向list中添加值
+ ///
+ public void RPush(string key, string value)
+ {
+ IClient.PrependItemToList(key, value);
+ }
+ ///
+ /// 从右侧向list中添加值,并设置过期时间
+ ///
+ public void RPush(string key, string value, DateTime dt)
+ {
+ IClient.PrependItemToList(key, value);
+ IClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 从右侧向list中添加值,并设置过期时间
+ ///
+ public void RPush(string key, string value, TimeSpan sp)
+ {
+ IClient.PrependItemToList(key, value);
+ IClient.ExpireEntryIn(key, sp);
+ }
+ ///
+ /// 添加key/value
+ ///
+ public void Add(string key, string value)
+ {
+ IClient.AddItemToList(key, value);
+ }
+ ///
+ /// 添加key/value ,并设置过期时间
+ ///
+ public void Add(string key, string value, DateTime dt)
+ {
+ IClient.AddItemToList(key, value);
+ IClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 添加key/value。并添加过期时间
+ ///
+ public void Add(string key, string value, TimeSpan sp)
+ {
+ IClient.AddItemToList(key, value);
+ IClient.ExpireEntryIn(key, sp);
+ }
+ ///
+ /// 为key添加多个值
+ ///
+ public void Add(string key, List values)
+ {
+ IClient.AddRangeToList(key, values);
+ }
+ ///
+ /// 为key添加多个值,并设置过期时间
+ ///
+ public void Add(string key, List values, DateTime dt)
+ {
+ IClient.AddRangeToList(key, values);
+ IClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 为key添加多个值,并设置过期时间
+ ///
+ public void Add(string key, List values, TimeSpan sp)
+ {
+ IClient.AddRangeToList(key, values);
+ IClient.ExpireEntryIn(key, sp);
+ }
+ #endregion
+
+ #region 获取值
+ ///
+ /// 获取list中key包含的数据数量
+ ///
+ public long Count(string key)
+ {
+ return IClient.GetListCount(key);
+ }
+ ///
+ /// 获取key包含的所有数据集合
+ ///
+ public List Get(string key)
+ {
+ return IClient.GetAllItemsFromList(key);
+ }
+ ///
+ /// 获取key中下标为star到end的值集合
+ ///
+ public List Get(string key, int star, int end)
+ {
+ return IClient.GetRangeFromList(key, star, end);
+ }
+ #endregion
+
+ #region 阻塞命令
+ ///
+ /// 阻塞命令:从list为key的尾部移除一个值,并返回移除的值,阻塞时间为sp
+ ///
+ public string BlockingPopItemFromList(string key, TimeSpan? sp)
+ {
+ return IClient.BlockingPopItemFromList(key, sp);
+ }
+ ///
+ /// 阻塞命令:从多个list中尾部移除一个值,并返回移除的值&key,阻塞时间为sp
+ ///
+ public ItemRef BlockingPopItemFromLists(string[] keys, TimeSpan? sp)
+ {
+ return IClient.BlockingPopItemFromLists(keys, sp);
+ }
+
+
+ ///
+ /// 阻塞命令:从list中keys的尾部移除一个值,并返回移除的值,阻塞时间为sp
+ ///
+ public string BlockingDequeueItemFromList(string key, TimeSpan? sp)
+ {
+ return IClient.BlockingDequeueItemFromList(key, sp);
+ }
+
+ ///
+ /// 阻塞命令:从多个list中尾部移除一个值,并返回移除的值&key,阻塞时间为sp
+ ///
+ public ItemRef BlockingDequeueItemFromLists(string[] keys, TimeSpan? sp)
+ {
+ return IClient.BlockingDequeueItemFromLists(keys, sp);
+ }
+
+ ///
+ /// 阻塞命令:从list中一个fromkey的尾部移除一个值,添加到另外一个tokey的头部,并返回移除的值,阻塞时间为sp
+ ///
+ public string BlockingPopAndPushItemBetweenLists(string fromkey, string tokey, TimeSpan? sp)
+ {
+ return IClient.BlockingPopAndPushItemBetweenLists(fromkey, tokey, sp);
+ }
+ #endregion
+
+ #region 删除
+ ///
+ /// 从尾部移除数据,返回移除的数据
+ ///
+ public string PopItemFromList(string key)
+ {
+ var sa = IClient.CreateSubscription();
+ return IClient.PopItemFromList(key);
+ }
+ ///
+ /// 从尾部移除数据,返回移除的数据
+ ///
+ public string DequeueItemFromList(string key)
+ {
+ return IClient.DequeueItemFromList(key);
+ }
+
+ ///
+ /// 移除list中,key/value,与参数相同的值,并返回移除的数量
+ ///
+ public long RemoveItemFromList(string key, string value)
+ {
+ return IClient.RemoveItemFromList(key, value);
+ }
+ ///
+ /// 从list的尾部移除一个数据,返回移除的数据
+ ///
+ public string RemoveEndFromList(string key)
+ {
+ return IClient.RemoveEndFromList(key);
+ }
+ ///
+ /// 从list的头部移除一个数据,返回移除的值
+ ///
+ public string RemoveStartFromList(string key)
+ {
+ return IClient.RemoveStartFromList(key);
+ }
+ #endregion
+
+ #region 其它
+ ///
+ /// 从一个list的尾部移除一个数据,添加到另外一个list的头部,并返回移动的值
+ ///
+ public string PopAndPushItemBetweenLists(string fromKey, string toKey)
+ {
+ return IClient.PopAndPushItemBetweenLists(fromKey, toKey);
+ }
+
+
+ public void TrimList(string key, int start, int end)
+ {
+ IClient.TrimList(key, start, end);
+ }
+ #endregion
+
+ #region 发布订阅
+ public void Publish(string channel, string message)
+ {
+ IClient.PublishMessage(channel, message);
+ }
+
+ public void Subscribe(string channel, Action actionOnMessage)
+ {
+ var subscription = IClient.CreateSubscription();
+ subscription.OnSubscribe = c =>
+ {
+ Console.WriteLine($"订阅频道{c}");
+ Console.WriteLine();
+ };
+ //取消订阅
+ subscription.OnUnSubscribe = c =>
+ {
+ Console.WriteLine($"取消订阅 {c}");
+ Console.WriteLine();
+ };
+ subscription.OnMessage += (c, s) =>
+ {
+ actionOnMessage(c, s, subscription);
+ };
+ Console.WriteLine($"开始启动监听 {channel}");
+ subscription.SubscribeToChannels(channel); //blocking
+ }
+
+ public void UnSubscribeFromChannels(string channel)
+ {
+ var subscription = IClient.CreateSubscription();
+ subscription.UnSubscribeFromChannels(channel);
+ }
+ #endregion
+ }
+}
diff --git a/Txgy.RBS.Framework/RedisHelper/Service/RedisSetService.cs b/Txgy.RBS.Framework/RedisHelper/Service/RedisSetService.cs
new file mode 100644
index 0000000..2e7c426
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Service/RedisSetService.cs
@@ -0,0 +1,124 @@
+using Microsoft.Extensions.Options;
+using Txgy.RBS.Framework.RedisHelper.Init;
+using Txgy.RBS.Framework.RedisHelper.Interface;
+
+namespace Txgy.RBS.Framework.RedisHelper.Service
+{
+ ///
+ /// Set:用哈希表来保持字符串的唯一性,没有先后顺序,存储一些集合性的数据
+ /// 1.共同好友、二度好友
+ /// 2.利用唯一性,可以统计访问网站的所有独立 IP
+ ///
+ public class RedisSetService : RedisBase
+ {
+ public RedisSetService(IOptionsMonitor options) : base(options)
+ {
+ }
+ #region 添加
+ ///
+ /// key集合中添加value值
+ ///
+ public void Add(string key, string value)
+ {
+ IClient.AddItemToSet(key, value);
+ }
+ ///
+ /// key集合中添加list集合
+ ///
+ public void Add(string key, List list)
+ {
+ IClient.AddRangeToSet(key, list);
+
+ }
+ #endregion
+
+ #region 获取
+ ///
+ /// 随机获取key集合中的一个值
+ ///
+ public string GetRandomItemFromSet(string key)
+ {
+ return IClient.GetRandomItemFromSet(key);
+ }
+ ///
+ /// 获取key集合值的数量
+ ///
+ public long GetCount(string key)
+ {
+ return IClient.GetSetCount(key);
+ }
+ ///
+ /// 获取所有key集合的值
+ ///
+ public HashSet GetAllItemsFromSet(string key)
+ {
+ return IClient.GetAllItemsFromSet(key);
+ }
+ #endregion
+
+ #region 删除
+ ///
+ /// 随机删除key集合中的一个值
+ ///
+ public string RandomRemoveItemFromSet(string key)
+ {
+ return IClient.PopItemFromSet(key);
+ }
+ ///
+ /// 删除key集合中的value
+ ///
+ public void RemoveItemFromSet(string key, string value)
+ {
+ IClient.RemoveItemFromSet(key, value);
+ }
+ #endregion
+
+ #region 其它
+ ///
+ /// 从fromkey集合中移除值为value的值,并把value添加到tokey集合中
+ ///
+ public void MoveBetweenSets(string fromkey, string tokey, string value)
+ {
+ IClient.MoveBetweenSets(fromkey, tokey, value);
+ }
+ ///
+ /// 返回keys多个集合中的并集,返还hashset
+ ///
+ public HashSet GetUnionFromSets(params string[] keys)
+ {
+ return IClient.GetUnionFromSets(keys);
+ }
+ ///
+ /// 返回keys多个集合中的交集,返还hashset
+ ///
+ public HashSet GetIntersectFromSets(params string[] keys)
+ {
+ return IClient.GetIntersectFromSets(keys);
+ }
+ ///
+ /// 返回keys多个集合中的差集,返还hashset
+ ///
+ /// 原集合
+ /// 其他集合
+ /// 出现在原集合,但不包含在其他集合
+ public HashSet GetDifferencesFromSet(string fromKey, params string[] keys)
+ {
+ return IClient.GetDifferencesFromSet(fromKey, keys);
+ }
+ ///
+ /// keys多个集合中的并集,放入newkey集合中
+ ///
+ public void StoreUnionFromSets(string newkey, string[] keys)
+ {
+ IClient.StoreUnionFromSets(newkey, keys);
+ }
+ ///
+ /// 把fromkey集合中的数据与keys集合中的数据对比,fromkey集合中不存在keys集合中,则把这些不存在的数据放入newkey集合中
+ ///
+ public void StoreDifferencesFromSet(string newkey, string fromkey, string[] keys)
+ {
+ IClient.StoreDifferencesFromSet(newkey, fromkey, keys);
+ }
+ #endregion
+ }
+}
diff --git a/Txgy.RBS.Framework/RedisHelper/Service/RedisStringService.cs b/Txgy.RBS.Framework/RedisHelper/Service/RedisStringService.cs
new file mode 100644
index 0000000..46cbc0b
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Service/RedisStringService.cs
@@ -0,0 +1,164 @@
+
+using Microsoft.Extensions.Options;
+using ServiceStack.Redis;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Txgy.RBS.Framework.RedisHelper.Init;
+using Txgy.RBS.Framework.RedisHelper.Interface;
+
+namespace Txgy.RBS.Framework.RedisHelper.Service
+{
+ ///
+ /// key-value 键值对:value可以是序列化的数据
+ ///
+ public class RedisStringService : RedisBase
+ {
+ public RedisStringService(IOptionsMonitor options) : base(options)
+ {
+ }
+ #region 赋值
+ ///
+ /// 设置key的value
+ ///
+ public bool Set(string key, T value)
+ {
+ //iClient.Db =2;
+ return IClient.Set(key, value);
+ }
+ ///
+ /// 设置key的value并设置过期时间
+ ///
+ public bool Set(string key, T value, DateTime dt)
+ {
+ //iClient.Db = 2;
+ return IClient.Set(key, value, dt);
+ }
+ ///
+ /// 设置key的value并设置过期时间
+ ///
+ public bool Set(string key, T value, TimeSpan sp)
+ {
+ //iClient.Db = 2;
+ return IClient.Set(key, value, sp);
+ }
+ ///
+ /// 设置多个key/value 可以一次保存多个key value ---多个key value 不是分多次,是一个独立的命令;
+ ///
+ public void Set(Dictionary dic)
+ {
+ //iClient.Db = 2;
+ IClient.SetAll(dic);
+ }
+
+ #endregion
+
+ #region 追加
+ ///
+ /// 在原有key的value值之后追加value,没有就新增一项
+ ///
+ public long Append(string key, string value)
+ {
+ return IClient.AppendToValue(key, value);
+ }
+ #endregion
+
+ #region 获取值
+ ///
+ /// 获取key的value值
+ ///
+ public string Get(string key)
+ {
+ return IClient.GetValue(key);
+ }
+ ///
+ /// 获取多个key的value值
+ ///
+ public List Get(List keys)
+ {
+ return IClient.GetValues(keys);
+ }
+ ///
+ /// 获取多个key的value值
+ ///
+ public List Get(List keys)
+ {
+ return IClient.GetValues(keys);
+ }
+
+
+ public T Get(string key)
+ {
+ return IClient.Get(key);
+ }
+
+
+ #endregion
+
+ #region 获取旧值赋上新值
+ ///
+ /// 获取旧值赋上新值
+ ///
+ public string GetAndSetValue(string key, string value)
+ {
+ return IClient.GetAndSetValue(key, value);
+ }
+ #endregion
+
+ #region 辅助方法
+ ///
+ /// 获取值的长度
+ ///
+ public long GetLength(string key)
+ {
+ return IClient.GetStringCount(key);
+ }
+ ///
+ /// 自增1,返回自增后的值 保存的是10 调用后,+1 返回11
+ ///
+ public long Incr(string key)
+ {
+ return IClient.IncrementValue(key);
+ }
+ ///
+ /// 自增count,返回自增后的值 自定义自增的步长值
+ ///
+ public long IncrBy(string key, int count)
+ {
+ return IClient.IncrementValueBy(key, count);
+ }
+ ///
+ /// 自减1,返回自减后的值,Redis操作是单线程操作;不会出现超卖的情况
+ ///
+ public long Decr(string key)
+ {
+ return IClient.DecrementValue(key);
+ }
+ ///
+ /// 自减count ,返回自减后的值
+ ///
+ ///
+ ///
+ ///
+ public long DecrBy(string key, int count)
+ {
+ return IClient.DecrementValueBy(key, count);
+ }
+
+ ///
+ /// 设置滑动过期时间
+ ///
+ ///
+ ///
+ ///
+ public bool ExpireEntryIn(string key, TimeSpan timeSpan)
+ {
+ return IClient.ExpireEntryIn(key, timeSpan);
+ }
+
+
+ #endregion
+ }
+}
diff --git a/Txgy.RBS.Framework/RedisHelper/Service/RedisZSetService.cs b/Txgy.RBS.Framework/RedisHelper/Service/RedisZSetService.cs
new file mode 100644
index 0000000..800d92b
--- /dev/null
+++ b/Txgy.RBS.Framework/RedisHelper/Service/RedisZSetService.cs
@@ -0,0 +1,233 @@
+
+using Microsoft.Extensions.Options;
+using Txgy.RBS.Framework.RedisHelper.Init;
+using Txgy.RBS.Framework.RedisHelper.Interface;
+
+namespace Txgy.RBS.Framework.RedisHelper.Service
+{
+ ///
+ /// Sorted Sets是将 Set 中的元素增加了一个权重参数 score,使得集合中的元素能够按 score 进行有序排列
+ /// 1.带有权重的元素,比如一个游戏的用户得分排行榜
+ /// 2.比较复杂的数据结构,一般用到的场景不算太多
+ ///
+ public class RedisZSetService : RedisBase
+ {
+ public RedisZSetService(IOptionsMonitor options) : base(options)
+ {
+ }
+ #region 添加
+ ///
+ /// 添加key/value,默认分数是从1.多*10的9次方以此递增的,自带自增效果
+ ///
+ public bool Add(string key, string value)
+ {
+ return IClient.AddItemToSortedSet(key, value);
+ }
+ ///
+ /// 添加key/value,并设置value的分数
+ ///
+ public bool AddItemToSortedSet(string key, string value, double score)
+ {
+ return IClient.AddItemToSortedSet(key, value, score);
+ }
+ ///
+ /// 为key添加values集合,values集合中每个value的分数设置为score
+ ///
+ public bool AddRangeToSortedSet(string key, List values, double score)
+ {
+ return IClient.AddRangeToSortedSet(key, values, score);
+ }
+ ///
+ /// 为key添加values集合,values集合中每个value的分数设置为score
+ ///
+ public bool AddRangeToSortedSet(string key, List values, long score)
+ {
+ return IClient.AddRangeToSortedSet(key, values, score);
+ }
+ #endregion
+
+ #region 获取
+ ///
+ /// 获取key的所有集合
+ ///
+ public List GetAll(string key)
+ {
+ return IClient.GetAllItemsFromSortedSet(key);
+ }
+ ///
+ /// 获取key的所有集合,倒叙输出
+ ///
+ public List GetAllDesc(string key)
+ {
+ return IClient.GetAllItemsFromSortedSetDesc(key);
+ }
+ ///
+ /// 获取集合,带分数
+ ///
+ public IDictionary GetAllWithScoresFromSortedSet(string key)
+ {
+ return IClient.GetAllWithScoresFromSortedSet(key);
+ }
+ ///
+ /// 获取key为value的下标值
+ ///
+ public long GetItemIndexInSortedSet(string key, string value)
+ {
+ return IClient.GetItemIndexInSortedSet(key, value);
+ }
+ ///
+ /// 倒叙排列获取key为value的下标值
+ ///
+ public long GetItemIndexInSortedSetDesc(string key, string value)
+ {
+ return IClient.GetItemIndexInSortedSetDesc(key, value);
+ }
+ ///
+ /// 获取key为value的分数
+ ///
+ public double GetItemScoreInSortedSet(string key, string value)
+ {
+ return IClient.GetItemScoreInSortedSet(key, value);
+ }
+ ///
+ /// 获取key所有集合的数据总数
+ ///
+ public long GetSortedSetCount(string key)
+ {
+ return IClient.GetSortedSetCount(key);
+ }
+ ///
+ /// key集合数据从分数为fromscore到分数为toscore的数据总数
+ ///
+ public long GetSortedSetCount(string key, double fromScore, double toScore)
+ {
+ return IClient.GetSortedSetCount(key, fromScore, toScore);
+ }
+ ///
+ /// 获取key集合从高分到低分排序数据,分数从fromscore到分数为toscore的数据
+ ///
+ public List GetRangeFromSortedSetByHighestScore(string key, double fromscore, double toscore)
+ {
+ return IClient.GetRangeFromSortedSetByHighestScore(key, fromscore, toscore);
+ }
+ ///
+ /// 获取key集合从低分到高分排序数据,分数从fromscore到分数为toscore的数据
+ ///
+ public List GetRangeFromSortedSetByLowestScore(string key, double fromscore, double toscore)
+ {
+ return IClient.GetRangeFromSortedSetByLowestScore(key, fromscore, toscore);
+ }
+ ///
+ /// 获取key集合从高分到低分排序数据,分数从fromscore到分数为toscore的数据,带分数
+ ///
+ public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string key, double fromscore, double toscore)
+ {
+ return IClient.GetRangeWithScoresFromSortedSetByHighestScore(key, fromscore, toscore);
+ }
+ ///
+ /// 获取key集合从低分到高分排序数据,分数从fromscore到分数为toscore的数据,带分数
+ ///
+ public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string key, double fromscore, double toscore)
+ {
+ return IClient.GetRangeWithScoresFromSortedSetByLowestScore(key, fromscore, toscore);
+ }
+ ///
+ /// 获取key集合数据,下标从fromRank到分数为toRank的数据
+ ///
+ public List GetRangeFromSortedSet(string key, int fromRank, int toRank)
+ {
+ return IClient.GetRangeFromSortedSet(key, fromRank, toRank);
+ }
+ ///
+ /// 获取key集合倒叙排列数据,下标从fromRank到分数为toRank的数据
+ ///
+ public List GetRangeFromSortedSetDesc(string key, int fromRank, int toRank)
+ {
+ return IClient.GetRangeFromSortedSetDesc(key, fromRank, toRank);
+ }
+ ///
+ /// 获取key集合数据,下标从fromRank到分数为toRank的数据,带分数
+ ///
+ public IDictionary GetRangeWithScoresFromSortedSet(string key, int fromRank, int toRank)
+ {
+ return IClient.GetRangeWithScoresFromSortedSet(key, fromRank, toRank);
+ }
+ ///
+ /// 获取key集合倒叙排列数据,下标从fromRank到分数为toRank的数据,带分数
+ ///
+ public IDictionary GetRangeWithScoresFromSortedSetDesc(string key, int fromRank, int toRank)
+ {
+ return IClient.GetRangeWithScoresFromSortedSetDesc(key, fromRank, toRank);
+ }
+ #endregion
+
+ #region 删除
+ ///
+ /// 删除key为value的数据
+ ///
+ public bool RemoveItemFromSortedSet(string key, string value)
+ {
+ return IClient.RemoveItemFromSortedSet(key, value);
+ }
+ ///
+ /// 删除下标从minRank到maxRank的key集合数据
+ ///
+ public long RemoveRangeFromSortedSet(string key, int minRank, int maxRank)
+ {
+ return IClient.RemoveRangeFromSortedSet(key, minRank, maxRank);
+ }
+ ///
+ /// 删除分数从fromscore到toscore的key集合数据
+ ///
+ public long RemoveRangeFromSortedSetByScore(string key, double fromscore, double toscore)
+ {
+ return IClient.RemoveRangeFromSortedSetByScore(key, fromscore, toscore);
+ }
+ ///
+ /// 删除key集合中分数最大的数据
+ ///
+ public string PopItemWithHighestScoreFromSortedSet(string key)
+ {
+ return IClient.PopItemWithHighestScoreFromSortedSet(key);
+ }
+ ///
+ /// 删除key集合中分数最小的数据
+ ///
+ public string PopItemWithLowestScoreFromSortedSet(string key)
+ {
+ return IClient.PopItemWithLowestScoreFromSortedSet(key);
+ }
+ #endregion
+
+ #region 其它
+ ///
+ /// 判断key集合中是否存在value数据
+ ///
+ public bool SortedSetContainsItem(string key, string value)
+ {
+ return IClient.SortedSetContainsItem(key, value);
+ }
+ ///
+ /// 为key集合值为value的数据,分数加scoreby,返回相加后的分数
+ ///
+ public double IncrementItemInSortedSet(string key, string value, double scoreBy)
+ {
+ return IClient.IncrementItemInSortedSet(key, value, scoreBy);
+ }
+ ///
+ /// 获取keys多个集合的交集,并把交集添加的newkey集合中,返回交集数据的总数
+ ///
+ public long StoreIntersectFromSortedSets(string newkey, string[] keys)
+ {
+ return IClient.StoreIntersectFromSortedSets(newkey, keys);
+ }
+ ///
+ /// 获取keys多个集合的并集,并把并集数据添加到newkey集合中,返回并集数据的总数
+ ///
+ public long StoreUnionFromSortedSets(string newkey, string[] keys)
+ {
+ return IClient.StoreUnionFromSortedSets(newkey, keys);
+ }
+ #endregion
+ }
+}
diff --git a/Txgy.RBS.Framework/Txgy.RBS.Framework.csproj b/Txgy.RBS.Framework/Txgy.RBS.Framework.csproj
new file mode 100644
index 0000000..99b0833
--- /dev/null
+++ b/Txgy.RBS.Framework/Txgy.RBS.Framework.csproj
@@ -0,0 +1,15 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.IBLL/ILoginBll.cs b/Txgy.RBS.IBLL/ILoginBll.cs
new file mode 100644
index 0000000..a4a5990
--- /dev/null
+++ b/Txgy.RBS.IBLL/ILoginBll.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IBLL
+{
+ public interface ILoginBll
+ {
+ }
+}
diff --git a/Txgy.RBS.IBLL/Txgy.RBS.IBLL.csproj b/Txgy.RBS.IBLL/Txgy.RBS.IBLL.csproj
new file mode 100644
index 0000000..da387e5
--- /dev/null
+++ b/Txgy.RBS.IBLL/Txgy.RBS.IBLL.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.IDAL/DbConnectionOptions.cs b/Txgy.RBS.IDAL/DbConnectionOptions.cs
new file mode 100644
index 0000000..8b2fc46
--- /dev/null
+++ b/Txgy.RBS.IDAL/DbConnectionOptions.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IDAL
+{
+ public class DbConnectionOptions
+ {
+ public string ConnectionString { get; set; } = string.Empty;
+ public ConnectionTypeEnum ConnectionType { get; set; }
+ }
+
+ public enum ConnectionTypeEnum
+ {
+ Sqlite = 0,
+ SqlServer = 1
+ }
+}
diff --git a/Txgy.RBS.IDAL/IBaseService.cs b/Txgy.RBS.IDAL/IBaseService.cs
new file mode 100644
index 0000000..6ecf759
--- /dev/null
+++ b/Txgy.RBS.IDAL/IBaseService.cs
@@ -0,0 +1,106 @@
+using SqlSugar;
+using System.Linq.Expressions;
+
+namespace Txgy.RBS.IDAL
+{
+ public interface IBaseService
+ {
+ #region Query
+ ///
+ /// 根据id查询实体
+ ///
+ ///
+ ///
+ T Find(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
+ ///
+ /// 新增数据,即时Commit
+ ///
+ ///
+ /// 返回带主键的实体
+ T Insert(T t) where T : class, new();
+
+ ///
+ /// 新增数据,即时Commit
+ /// 多条sql 一个连接,事务插入
+ ///
+ ///
+ IEnumerable Insert(List tList) where T : class, new();
+ #endregion
+
+ #region Update
+ ///
+ /// 更新数据,即时Commit
+ ///
+ ///
+ void Update(T t) where T : class, new();
+
+ ///
+ /// 更新数据,即时Commit
+ ///
+ ///
+ void Update(List tList) where T : class, new();
+ #endregion
+
+ #region Delete
+ ///
+ /// 根据主键删除数据,即时Commit
+ ///
+ ///
+ void Delete(int Id) 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
+ }
+}
\ No newline at end of file
diff --git a/Txgy.RBS.IDAL/IDataAccessDal.cs b/Txgy.RBS.IDAL/IDataAccessDal.cs
new file mode 100644
index 0000000..75b180e
--- /dev/null
+++ b/Txgy.RBS.IDAL/IDataAccessDal.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IDAL
+{
+ public interface IDataAccessDal
+ {
+ List GetIcons();
+
+ ///
+ /// 获取客户端类型
+ ///
+ ///
+ Setting GetClientType(int useId = 1);
+
+ void UpdateClientDetail(double createTime, int mailRule, string mailbox, string appMessage);
+ ///
+ /// 根据车道ID获取对应的设备信息
+ ///
+ ///
+ ///
+ string GetDevices(int roadId);
+ void UpdateDeviceType(int currentDevice);
+ }
+}
diff --git a/Txgy.RBS.IDAL/ILoginDal.cs b/Txgy.RBS.IDAL/ILoginDal.cs
new file mode 100644
index 0000000..e6356e1
--- /dev/null
+++ b/Txgy.RBS.IDAL/ILoginDal.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.IDAL
+{
+ public interface ILoginDal : IBaseService
+ {
+ }
+}
diff --git a/Txgy.RBS.IDAL/PageResult.cs b/Txgy.RBS.IDAL/PageResult.cs
new file mode 100644
index 0000000..adbd494
--- /dev/null
+++ b/Txgy.RBS.IDAL/PageResult.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IDAL
+{
+ public class PageResult
+ {
+ public PageResult()
+ { }
+
+ public PageResult(int pageIndex, int pageSize)
+ {
+ PageIndex = pageIndex;
+ PageSize = pageSize;
+ }
+
+ public int PageIndex { get; set; }
+ public int PageSize { get; set; }
+ public long TotalCount { get; set; }
+
+ public List DataList { get; set; }
+ }
+}
diff --git a/Txgy.RBS.IDAL/PagingData.cs b/Txgy.RBS.IDAL/PagingData.cs
new file mode 100644
index 0000000..3d252c5
--- /dev/null
+++ b/Txgy.RBS.IDAL/PagingData.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IDAL
+{
+ 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/Txgy.RBS.IDAL/Setting.cs b/Txgy.RBS.IDAL/Setting.cs
new file mode 100644
index 0000000..bdda52f
--- /dev/null
+++ b/Txgy.RBS.IDAL/Setting.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IDAL
+{
+ public class Setting
+ {
+ public int ClientType { get; set; }
+
+ public string Mailbox { get; set; }
+
+ public int MailRule { get; set; }
+
+ //为了统计1个整月的数据,如果修改时间超过每月28号统一设置成每月28号;
+ public double CreateTime { get; set; }
+
+ public int CurrentDevice { get; set; }
+
+ public string AppMessage { get; set; }
+ }
+}
diff --git a/Txgy.RBS.IDAL/Txgy.RBS.IDAL.csproj b/Txgy.RBS.IDAL/Txgy.RBS.IDAL.csproj
new file mode 100644
index 0000000..99e7b2f
--- /dev/null
+++ b/Txgy.RBS.IDAL/Txgy.RBS.IDAL.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.IServices/AutoMapObject.cs b/Txgy.RBS.IServices/AutoMapObject.cs
new file mode 100644
index 0000000..e8240f4
--- /dev/null
+++ b/Txgy.RBS.IServices/AutoMapObject.cs
@@ -0,0 +1,18 @@
+using AutoMapper;
+using Txgy.RBS.DbModel;
+using Txgy.RBS.DTO;
+using Txgy.RBS.DTO.Reception;
+using Txgy.RBS.Framework;
+
+namespace Txgy.RBS.IServices
+{
+ public class AutoMapObject : Profile
+ {
+ public AutoMapObject()
+ {
+ CreateMap().ReverseMap();
+ //CreateMap().ReverseMap();
+ //CreateMap, PagingData>();
+ }
+ }
+}
diff --git a/Txgy.RBS.IServices/IBaseService.cs b/Txgy.RBS.IServices/IBaseService.cs
new file mode 100644
index 0000000..ab2f5fe
--- /dev/null
+++ b/Txgy.RBS.IServices/IBaseService.cs
@@ -0,0 +1,108 @@
+using SqlSugar;
+using System.Linq.Expressions;
+using Txgy.RBS.Framework;
+
+namespace Txgy.RBS.IServices
+{
+ public interface IBaseService
+ {
+ #region Query
+ ///
+ /// 根据id查询实体
+ ///
+ ///
+ ///
+ T Find(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
+ ///
+ /// 新增数据,即时Commit
+ ///
+ ///
+ /// 返回带主键的实体
+ T Insert(T t) where T : class, new();
+
+ ///
+ /// 新增数据,即时Commit
+ /// 多条sql 一个连接,事务插入
+ ///
+ ///
+ IEnumerable Insert(List tList) where T : class, new();
+ #endregion
+
+ #region Update
+ ///
+ /// 更新数据,即时Commit
+ ///
+ ///
+ void Update(T t) where T : class, new();
+
+ ///
+ /// 更新数据,即时Commit
+ ///
+ ///
+ void Update(List tList) where T : class, new();
+ #endregion
+
+ #region Delete
+ ///
+ /// 根据主键删除数据,即时Commit
+ ///
+ ///
+ void Delete(int Id) 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
+ }
+}
\ No newline at end of file
diff --git a/Txgy.RBS.IServices/IDataAccessService.cs b/Txgy.RBS.IServices/IDataAccessService.cs
new file mode 100644
index 0000000..8500cd9
--- /dev/null
+++ b/Txgy.RBS.IServices/IDataAccessService.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IServices
+{
+ public interface IDataAccessService
+ {
+ List GetIcons();
+
+ ///
+ /// 获取客户端类型
+ ///
+ ///
+ Setting GetClientType(int useId = 1);
+
+ void UpdateClientDetail(double createTime, int mailRule, string mailbox, string appMessage);
+ ///
+ /// 根据车道ID获取对应的设备信息
+ ///
+ ///
+ ///
+ string GetDevices(int roadId);
+ void UpdateDeviceType(int currentDevice);
+ }
+}
diff --git a/Txgy.RBS.IServices/ILoginDal.cs b/Txgy.RBS.IServices/ILoginDal.cs
new file mode 100644
index 0000000..5144a74
--- /dev/null
+++ b/Txgy.RBS.IServices/ILoginDal.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Txgy.RBS.IServices
+{
+ public interface ILoginService : IBaseService
+ {
+ }
+}
\ No newline at end of file
diff --git a/Txgy.RBS.IServices/Setting.cs b/Txgy.RBS.IServices/Setting.cs
new file mode 100644
index 0000000..985a90e
--- /dev/null
+++ b/Txgy.RBS.IServices/Setting.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Txgy.RBS.IServices
+{
+ public class Setting
+ {
+ public int ClientType { get; set; }
+
+ public string Mailbox { get; set; }
+
+ public int MailRule { get; set; }
+
+ //为了统计1个整月的数据,如果修改时间超过每月28号统一设置成每月28号;
+ public double CreateTime { get; set; }
+
+ public int CurrentDevice { get; set; }
+
+ public string AppMessage { get; set; }
+ }
+}
diff --git a/Txgy.RBS.IServices/Txgy.RBS.IServices.csproj b/Txgy.RBS.IServices/Txgy.RBS.IServices.csproj
new file mode 100644
index 0000000..793175b
--- /dev/null
+++ b/Txgy.RBS.IServices/Txgy.RBS.IServices.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Txgy.RBS.Server.WebApi.sln b/Txgy.RBS.Server.WebApi.sln
new file mode 100644
index 0000000..ec4b0a6
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi.sln
@@ -0,0 +1,55 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34316.72
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Txgy.RBS.DbModel", "Txgy.RBS.DbModel\Txgy.RBS.DbModel.csproj", "{4C41E1CF-BA9C-45F8-9055-70EDA35579A2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Txgy.RBS.Server.WebApi", "Txgy.RBS.Server.WebApi\Txgy.RBS.Server.WebApi.csproj", "{AA0B6F7F-60BE-4194-AF85-ABD5F9CEB949}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Txgy.RBS.IServices", "Txgy.RBS.IServices\Txgy.RBS.IServices.csproj", "{E80A6A7C-514E-4E98-B5D3-92076960D15D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Txgy.RBS.Services", "Txgy.RBS.Services\Txgy.RBS.Services.csproj", "{62C154B8-02B1-4373-9CC3-E1BE98BD5185}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Txgy.RBS.DTO", "Txgy.RBS.DTO\Txgy.RBS.DTO.csproj", "{AD9839D2-4CDE-49CC-BFC2-B5E2C7A3D8D8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Txgy.RBS.Framework", "Txgy.RBS.Framework\Txgy.RBS.Framework.csproj", "{192F744E-9C15-46F5-94CE-801C65E67AED}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4C41E1CF-BA9C-45F8-9055-70EDA35579A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4C41E1CF-BA9C-45F8-9055-70EDA35579A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4C41E1CF-BA9C-45F8-9055-70EDA35579A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4C41E1CF-BA9C-45F8-9055-70EDA35579A2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AA0B6F7F-60BE-4194-AF85-ABD5F9CEB949}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AA0B6F7F-60BE-4194-AF85-ABD5F9CEB949}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AA0B6F7F-60BE-4194-AF85-ABD5F9CEB949}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AA0B6F7F-60BE-4194-AF85-ABD5F9CEB949}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E80A6A7C-514E-4E98-B5D3-92076960D15D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E80A6A7C-514E-4E98-B5D3-92076960D15D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E80A6A7C-514E-4E98-B5D3-92076960D15D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E80A6A7C-514E-4E98-B5D3-92076960D15D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {62C154B8-02B1-4373-9CC3-E1BE98BD5185}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {62C154B8-02B1-4373-9CC3-E1BE98BD5185}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {62C154B8-02B1-4373-9CC3-E1BE98BD5185}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {62C154B8-02B1-4373-9CC3-E1BE98BD5185}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AD9839D2-4CDE-49CC-BFC2-B5E2C7A3D8D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AD9839D2-4CDE-49CC-BFC2-B5E2C7A3D8D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AD9839D2-4CDE-49CC-BFC2-B5E2C7A3D8D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AD9839D2-4CDE-49CC-BFC2-B5E2C7A3D8D8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {192F744E-9C15-46F5-94CE-801C65E67AED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {192F744E-9C15-46F5-94CE-801C65E67AED}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {192F744E-9C15-46F5-94CE-801C65E67AED}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {192F744E-9C15-46F5-94CE-801C65E67AED}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {3E38EDAF-193F-45CF-8DAD-2449AF53DAAB}
+ EndGlobalSection
+EndGlobal
diff --git a/Txgy.RBS.Server.WebApi/Controllers/WeatherForecastController.cs b/Txgy.RBS.Server.WebApi/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..a882e1c
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/Controllers/WeatherForecastController.cs
@@ -0,0 +1,37 @@
+using Microsoft.AspNetCore.Mvc;
+using Txgy.RBS.IServices;
+
+namespace Txgy.RBS.Server.WebApi.Controllers
+{
+ [ApiController]
+ [Route("[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;
+ private readonly IDataAccessService _dataAccessDal;
+
+ public WeatherForecastController(ILogger logger, IDataAccessService dataAccessDal)
+ {
+ _logger = logger;
+ this._dataAccessDal = dataAccessDal;
+ }
+
+ [HttpGet(Name = "GetWeatherForecast")]
+ public IEnumerable Get()
+ {
+ var a = _dataAccessDal.GetIcons();
+ return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+ {
+ Date = DateTime.Now.AddDays(index),
+ TemperatureC = Random.Shared.Next(-20, 55),
+ Summary = Summaries[Random.Shared.Next(Summaries.Length)]
+ })
+ .ToArray();
+ }
+ }
+}
diff --git a/Txgy.RBS.Server.WebApi/Program.cs b/Txgy.RBS.Server.WebApi/Program.cs
new file mode 100644
index 0000000..5513f3f
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/Program.cs
@@ -0,0 +1,53 @@
+using SqlSugar;
+using System.ComponentModel;
+using Txgy.RBS.IServices;
+using Txgy.RBS.Server.WebApi.Register;
+
+var builder = WebApplication.CreateBuilder(args);
+
+// Add services to the container.
+
+builder.Register(); //ҵע
+//֧Automapperӳ
+builder.Services.AddAutoMapper(typeof(AutoMapObject));
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+ //sqlsugar
+ builder.Services.AddTransient(context =>
+ {
+ string con = builder.Configuration.GetConnectionString("ConnectionSqlite");
+ SqlSugarClient client = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = builder.Configuration.GetConnectionString("ConnectionSqlite"),
+ DbType = DbType.Sqlite,
+ InitKeyType = InitKeyType.Attribute,
+ });
+ //֧sqlų
+ client.Aop.OnLogExecuting = (sql, par) =>
+ {
+ Console.WriteLine("\r\n");
+ Console.WriteLine($"Sql:{sql}");
+ Console.WriteLine($"======================================================================");
+ };
+ return client;
+ });
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.UseHttpsRedirection();
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
diff --git a/Txgy.RBS.Server.WebApi/Properties/launchSettings.json b/Txgy.RBS.Server.WebApi/Properties/launchSettings.json
new file mode 100644
index 0000000..cec3019
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:37391",
+ "sslPort": 44354
+ }
+ },
+ "profiles": {
+ "Txgy.RBS.Server.WebApi": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7117;http://localhost:5094",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/Txgy.RBS.Server.WebApi/Register/AuthorizationExtend.cs b/Txgy.RBS.Server.WebApi/Register/AuthorizationExtend.cs
new file mode 100644
index 0000000..8f96054
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/Register/AuthorizationExtend.cs
@@ -0,0 +1,46 @@
+using Microsoft.IdentityModel.Tokens;
+using System.Text;
+
+namespace Txgy.RBS.Server.WebApi.Register
+{
+ ///
+ ///
+ ///
+ public static class AuthorizationExtend
+ {
+ ///
+ /// 支持授权的扩展方法
+ ///
+ ///
+ public static void AuthorizationExt(this WebApplicationBuilder builder)
+ {
+ //JWTTokenOptions tokenOptions = new JWTTokenOptions();
+ //builder.Configuration.Bind("JWTTokenOptions", tokenOptions);
+
+ //builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)//Scheme
+ //.AddJwtBearer(options => //这里是配置的鉴权的逻辑
+ //{
+ // options.TokenValidationParameters = new TokenValidationParameters
+ // {
+ // //JWT有一些默认的属性,就是给鉴权时就可以筛选了
+ // ValidateIssuer = true,//是否验证Issuer
+ // ValidateAudience = true,//是否验证Audience
+ // ValidateLifetime = true,//是否验证失效时间
+ // ValidateIssuerSigningKey = true,//是否验证SecurityKey
+ // ValidAudience = tokenOptions.Audience,//
+ // ValidIssuer = tokenOptions.Issuer,//Issuer,这两项和前面签发jwt的设置一致
+ // IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenOptions.SecurityKey)),
+ // AudienceValidator = (m, n, z) => //可以添加一些自定义的动作
+ // {
+ // return true;
+ // },
+ // LifetimeValidator = (notBefore, expires, securityToken, validationParameters) =>
+ // {
+ // return true;
+ // }
+ // };
+ //});
+
+ }
+ }
+}
diff --git a/Txgy.RBS.Server.WebApi/Register/HostBuilderExtend.cs b/Txgy.RBS.Server.WebApi/Register/HostBuilderExtend.cs
new file mode 100644
index 0000000..f1a9cb0
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/Register/HostBuilderExtend.cs
@@ -0,0 +1,73 @@
+using Autofac;
+using Autofac.Extensions.DependencyInjection;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using System.Reflection;
+
+namespace Txgy.RBS.Server.WebApi.Register
+{
+ public static class HostBuilderExtend
+ {
+ public static void Register(this WebApplicationBuilder applicationBuilder)
+ {
+
+ //替换容器Autofac
+ applicationBuilder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
+ applicationBuilder.Host.ConfigureContainer(ConfigurationBinder =>
+ {
+ //ConfigurationBinder.RegisterType().As();
+
+ #region 通过接口和实现类所在程序集注册
+ Assembly interfaceAssembly = Assembly.Load("Txgy.RBS.Services");
+ Assembly serviceAssembly = Assembly.Load("Txgy.RBS.IServices");
+ ConfigurationBinder.RegisterAssemblyTypes(interfaceAssembly, serviceAssembly).AsImplementedInterfaces();
+ #endregion
+
+ #region 注册每个控制器和抽象之间的关系
+ var controllerBaseType = typeof(ControllerBase);
+ ConfigurationBinder.RegisterAssemblyTypes(typeof(Program).Assembly)
+ .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType);
+ #endregion
+
+ #region 注册SqlSugar
+ ConfigurationBinder.Register(context =>
+ {
+ SqlSugarClient client = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = applicationBuilder.Configuration.GetConnectionString("ConnectionSqlite"), // "Data Source=DESKTOP-T2D6ILD;Initial Catalog=LiveBackgroundManagementNew;Persist Security Info=True;User ID=sa;Password=sa123",
+ DbType = DbType.Sqlite,
+ InitKeyType = InitKeyType.Attribute,
+ //SlaveConnectionConfigs = new List {
+ // new SlaveConnectionConfig(){
+ // ConnectionString="Data Source=DESKTOP-T2D6ILD;Initial Catalog=LiveBackgroundManagementNew;Persist Security Info=True;User ID=sa;Password=sa123",
+ // HitRate=10
+ // }
+ // }
+ });
+
+ //支持sql语句的输出,方便排除错误
+ client.Aop.OnLogExecuting = (sql, par) =>
+ {
+ Console.WriteLine("\r\n");
+ Console.WriteLine($"Sql语句:{sql}");
+ Console.WriteLine($"=========================================================================================================================================================================================================");
+ };
+ return client;
+ });
+ #endregion
+
+ #region 注册Redis
+ //{
+ // ConfigurationBinder.RegisterType();
+ // ConfigurationBinder.RegisterType();
+ // ConfigurationBinder.RegisterType();
+ // ConfigurationBinder.RegisterType();
+ // ConfigurationBinder.RegisterType();
+ //}
+ #endregion
+
+ });
+
+ }
+ }
+}
diff --git a/Txgy.RBS.Server.WebApi/Txgy.RBS.Server.WebApi.csproj b/Txgy.RBS.Server.WebApi/Txgy.RBS.Server.WebApi.csproj
new file mode 100644
index 0000000..3513498
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/Txgy.RBS.Server.WebApi.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
diff --git a/Txgy.RBS.Server.WebApi/WeatherForecast.cs b/Txgy.RBS.Server.WebApi/WeatherForecast.cs
new file mode 100644
index 0000000..835ff9c
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/WeatherForecast.cs
@@ -0,0 +1,13 @@
+namespace Txgy.RBS.Server.WebApi
+{
+ public class WeatherForecast
+ {
+ public DateTime Date { get; set; }
+
+ public int TemperatureC { get; set; }
+
+ public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
+
+ public string? Summary { get; set; }
+ }
+}
diff --git a/Txgy.RBS.Server.WebApi/appsettings.Development.json b/Txgy.RBS.Server.WebApi/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/Txgy.RBS.Server.WebApi/appsettings.json b/Txgy.RBS.Server.WebApi/appsettings.json
new file mode 100644
index 0000000..549a3c4
--- /dev/null
+++ b/Txgy.RBS.Server.WebApi/appsettings.json
@@ -0,0 +1,14 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "ConnectionStrings": {
+ "ConnectionSqlServer": "Server=localhost;Database=rbs_server_db.db;Trusted_Connection=True;",
+ "ConnectionSqlite": "Data Source=rbs_server_db.db",
+ "ConnectionType": "0"
+ },
+ "AllowedHosts": "*"
+}
diff --git a/Txgy.RBS.Server.WebApi/rbs_server_db.db b/Txgy.RBS.Server.WebApi/rbs_server_db.db
new file mode 100644
index 0000000..b3311cf
Binary files /dev/null and b/Txgy.RBS.Server.WebApi/rbs_server_db.db differ
diff --git a/Txgy.RBS.Services/BaseService.cs b/Txgy.RBS.Services/BaseService.cs
new file mode 100644
index 0000000..aff16b2
--- /dev/null
+++ b/Txgy.RBS.Services/BaseService.cs
@@ -0,0 +1,157 @@
+using SqlSugar;
+using System.Linq.Expressions;
+using Txgy.RBS.Framework;
+using Txgy.RBS.IServices;
+
+namespace Txgy.RBS.Services
+{
+ public 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);
+ }
+
+ ///
+ /// 不应该暴露给上端使用者,尽量少用
+ ///
+ ///
+ ///
+ [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
+ ///
+ /// 即使保存 不需要再Commit
+ ///
+ ///
+ ///
+ ///
+ public T Insert(T t) where T : class, new()
+ {
+ _Client.Insertable(t).ExecuteCommand();
+ return t;
+ }
+
+ public IEnumerable Insert(List tList) where T : class, new()
+ {
+ _Client.Insertable(tList.ToList()).ExecuteCommand();
+ return tList;
+ }
+ #endregion
+
+ #region Update
+ ///
+ /// 是没有实现查询,直接更新的,需要Attach和State
+ ///
+ /// 如果是已经在context,只能再封装一个(在具体的service)
+ ///
+ ///
+ ///
+ public void Update(T t) where T : class, new()
+ {
+ if (t == null) throw new Exception("t is null");
+
+ _Client.Updateable(t).ExecuteCommand();
+ }
+
+ 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();
+ }
+
+ ///
+ /// 还可以增加非即时commit版本的,
+ /// 做成protected
+ ///
+ ///
+ ///
+ public void Delete(int Id) where T : class, new()
+ {
+ T t = _Client.Queryable().InSingle(Id);
+ _Client.Deleteable(t).ExecuteCommand();
+ }
+
+ 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
+ }
+}
\ No newline at end of file
diff --git a/Txgy.RBS.Services/DataAccessService.cs b/Txgy.RBS.Services/DataAccessService.cs
new file mode 100644
index 0000000..31ada9b
--- /dev/null
+++ b/Txgy.RBS.Services/DataAccessService.cs
@@ -0,0 +1,43 @@
+using SqlSugar;
+using System.Data;
+using Txgy.RBS.DbModel;
+using Txgy.RBS.IServices;
+
+namespace Txgy.RBS.Services
+{
+ //sqlite数据库操作
+ public class DataAccessService : BaseService, IDataAccessService
+ {
+
+ public DataAccessService(ISqlSugarClient sqlSugarClient) : base(sqlSugarClient)
+ {
+
+ }
+
+ public List GetIcons()
+ {
+ var data = _Client.Queryable().ToList();
+ return null;
+ }
+
+
+ public Setting GetClientType(int userId = 1)
+ {
+ return new Setting();
+ }
+ public void UpdateClientDetail(double createTime, int mailRule, string mailbox, string appMessage)
+ {
+
+ }
+
+ public string GetDevices(int roadId)
+ {
+ return string.Empty;
+ }
+
+ public void UpdateDeviceType(int currentDevice)
+ {
+
+ }
+ }
+}
diff --git a/Txgy.RBS.Services/LoginService.cs b/Txgy.RBS.Services/LoginService.cs
new file mode 100644
index 0000000..9047d0f
--- /dev/null
+++ b/Txgy.RBS.Services/LoginService.cs
@@ -0,0 +1,14 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Txgy.RBS.IServices;
+
+
+namespace Txgy.RBS.Services
+{
+ public class LoginService : BaseService, ILoginService
+ {
+ public LoginService(ISqlSugarClient sqlSugarClient) : base(sqlSugarClient) { }
+ }
+}
diff --git a/Txgy.RBS.Services/Txgy.RBS.Services.csproj b/Txgy.RBS.Services/Txgy.RBS.Services.csproj
new file mode 100644
index 0000000..7a495c9
--- /dev/null
+++ b/Txgy.RBS.Services/Txgy.RBS.Services.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+