xxe vor 2 Jahren
Ursprung
Commit
bdc3db6a27
7 geänderte Dateien mit 148 neuen und 12 gelöschten Zeilen
  1. +41
    -0
      HKLib/DB/DbContext.cs
  2. +20
    -0
      HKLib/DB/Model/BaseEntity.cs
  3. +21
    -0
      HKLib/DB/Model/Entity/OrgTable.cs
  4. +0
    -8
      HKLib/Dto/ReportDto.cs
  5. +1
    -0
      HKLib/HKLib.csproj
  6. +30
    -4
      HKLib/Interfaces/HKLibHelper.cs
  7. +35
    -0
      HKLib/Logic/ServiceHandler.cs

+ 41
- 0
HKLib/DB/DbContext.cs Datei anzeigen

@@ -0,0 +1,41 @@
using HKLib.DB.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using XExten.Advance.StaticFramework;

namespace HKLib.DB
{
public class DbContext
{
public static SqlSugarScope Context = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = Route(),
DbType = DbType.Sqlite,//数据库类型
IsAutoCloseConnection = true //不设成true要手动close
}, db =>
{
db.Aop.OnLogExecuting = (sql, pars) =>
{

};
});

static string Route()
{
var dir = SyncStatic.CreateDir(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Database"));
return SyncStatic.CreateFile(Path.Combine(dir, "data.db3"));
}
public static void InitTable()
{
var Tables = Assembly.GetAssembly(typeof(DbContext))
.GetTypes().Where(t => t.BaseType == typeof(BaseEntity)).ToArray();
Context.CodeFirst.InitTables(Tables);
}
}
}

+ 20
- 0
HKLib/DB/Model/BaseEntity.cs Datei anzeigen

@@ -0,0 +1,20 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace HKLib.DB.Model
{
public class BaseEntity
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; }
[SugarColumn(ColumnDataType = "DATETIME")]
public DateTime CreateTime { get; set; }
public void Create()
{
this.Id = Guid.NewGuid();
this.CreateTime = DateTime.Now;
}
}
}

+ 21
- 0
HKLib/DB/Model/Entity/OrgTable.cs Datei anzeigen

@@ -0,0 +1,21 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace HKLib.DB.Model.Entity
{
[SugarTable("Org")]
public class OrgTable : BaseEntity
{
/// <summary>
/// 机构名称
/// </summary>
public string Name { get; set; }

/// <summary>
/// 加盟返回的Id
/// </summary>
public string SId { get; set; }
}
}

+ 0
- 8
HKLib/Dto/ReportDto.cs Datei anzeigen

@@ -18,13 +18,5 @@ namespace HKLib.Dto
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 组织
/// </summary>
public string Org { get; set; }
/// <summary>
/// 设备位置
/// </summary>
public string Location { get; set; }
}
}

+ 1
- 0
HKLib/HKLib.csproj Datei anzeigen

@@ -9,5 +9,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Snowflake.Core" Version="2.0.0" />
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" />
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" />
</ItemGroup>
</Project>

+ 30
- 4
HKLib/Interfaces/HKLibHelper.cs Datei anzeigen

@@ -1,10 +1,10 @@
using HKLib.Dto;
using HKLib.RabbitMQ.Config;
using HKLib.RabbitMQ.Publisher;
using Newtonsoft.Json.Linq;
using XExten.Advance.HttpFramework.MultiCommon;
using XExten.Advance.HttpFramework.MultiFactory;
using XExten.Advance.LinqFramework;
using static RabbitMQ.Client.Logging.RabbitMqClientEventSource;

namespace HKLib.Interfaces
{
@@ -23,11 +23,36 @@ namespace HKLib.Interfaces
}).Build().RunStringFirst();
}

/// <summary>
/// 添加机构
/// </summary>
public static string SetOrg(string input)
{
return IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = $"{Configer.SaasRoute}/{input}";
t.ReqType = MultiType.GET;
}).Build().RunStringFirst().ToModel<JObject>()["data"].ToString();
}

/// <summary>
/// 修改机构
/// </summary>
public static bool AlterOrg(string input,string Sid)
{
return IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = $"{Configer.SaasRoute}";
t.ReqType = MultiType.POST;
t.JsonParam = (new { Name = input, Id = Sid }).ToJson();
}).Build().RunStringFirst().ToModel<JObject>()["isSuccess"].ToString().AsBool();
}

/// <summary>
/// 根据用户命获取下拉用户列表
/// </summary>
/// <param name="keyword"></param>
public static void GetUserList(string keyword)
public static void GetUserList(string keyword)
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{
@@ -52,7 +77,7 @@ namespace HKLib.Interfaces
/// 变更卡状态 销户
/// </summary>
/// <param name="input"></param>
public static void CardStutasChange(CardStutasDto input)
public static void CardStutasChange(CardStutasDto input)
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{
@@ -66,7 +91,8 @@ namespace HKLib.Interfaces
/// 报表数据
/// </summary>
/// <param name="input"></param>
public static void Report(ReportDto input)
/// <param name="type">1 计次就餐天消费表(每人),2每月餐段消费报表,3月餐段汇总表</param>
public static void Report(ReportDto input,int type=1)
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{


+ 35
- 0
HKLib/Logic/ServiceHandler.cs Datei anzeigen

@@ -0,0 +1,35 @@
using HKLib.DB;
using HKLib.DB.Model.Entity;
using HKLib.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;

namespace HKLib.Logic
{
public class ServiceHandler
{
#region 机构类
public static bool AddOrg(string Name)
{
var SiD = HKLibHelper.SetOrg(Name);
return DbContext.Context.Insertable(new OrgTable
{
Name = Name,
SId = SiD
}).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0;
}
public static List<OrgTable> GetOrgList()
{
return DbContext.Context.Queryable<OrgTable>().ToList();
}
public static bool AlterOrg(string Name, string Id)
{
var s = HKLibHelper.AlterOrg(Name, Id);
if (s)
return DbContext.Context.Updateable<OrgTable>().SetColumns(t => t.Name == Name).Where(t => t.SId == Id).ExecuteCommandHasChange();
else return false;
}
#endregion
}
}

Laden…
Abbrechen
Speichern