Browse Source

增加开发分钟

develop
anerx 4 months ago
parent
commit
958bc4eab0
  1. 4
      Admin.NET.Application/Configuration/Database.json
  2. 36
      Admin.NET.Bodk.Genetic/GeneReportService.cs
  3. 2
      Admin.NET.Bodk.Project/Entities/AreaExtEntity.cs
  4. 10
      Admin.NET.Core/Entity/IDataAuth.cs
  5. 19
      Admin.NET.Core/Entity/SysOrg.cs
  6. 4
      Admin.NET.Core/SeedData/SysOrgSeedData.cs
  7. 212
      Admin.NET.Core/Service/Org/SysOrgService.cs
  8. 3
      Admin.NET.Core/SqlSugar/SqlSugarRepository.cs
  9. 62
      Admin.NET.Core/SqlSugar/SqlSugarSetup.cs
  10. 17
      Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj
  11. BIN
      Admin.NET.Web.Entry/Admin.NET.db
  12. 37
      Admin.NET.sln
  13. 2
      Admin.NET.sln.DotSettings
  14. 13
      Bodk.NET.Core/Bodk.NET.Core.csproj
  15. 13
      Bodk.NET.Customer/Bodk.NET.Customer.csproj
  16. 31
      Bodk.NET.Customer/Entities/BodkCustomer.cs
  17. 85
      Bodk.NET.Customer/Models/Customer.cs
  18. 86
      Bodk.NET.Customer/Services/CustomerService.cs
  19. 9
      Bodk.NET.Device/Bodk.NET.Device.csproj
  20. 13
      Bodk.NET.LocalServer/Bodk.NET.LocalServer.csproj
  21. 22
      Bodk.NET.Project/Bodk.NET.Project.csproj

4
Admin.NET.Application/Configuration/Database.json

@ -7,8 +7,8 @@
"ConnectionConfigs": [ "ConnectionConfigs": [
{ {
//"ConfigId": "1300000000001", // - //"ConfigId": "1300000000001", // -
"DbType": "Sqlite", // MySqlSqlServerSqliteOraclePostgreSQLDmKdbndpOscarMySqlConnectorAccessOpenGaussQuestDBHGClickHouseGBaseOdbcCustom "DbType": "MySql", // MySqlSqlServerSqliteOraclePostgreSQLDmKdbndpOscarMySqlConnectorAccessOpenGaussQuestDBHGClickHouseGBaseOdbcCustom
"ConnectionString": "DataSource=./Admin.NET.db", // "ConnectionString": "server=113.45.158.49;Database=test_bodk_cloud_db;Uid=root;Pwd=Bodk365@mysql", //
//"SlaveConnectionConfigs": [ // / //"SlaveConnectionConfigs": [ // /
// { // {
// "HitRate": 10, // "HitRate": 10,

36
Admin.NET.Bodk.Genetic/GeneReportService.cs

@ -11,6 +11,7 @@ using Admin.NET.Bodk.Genetic.Models.Reports;
using Admin.NET.Core; using Admin.NET.Core;
using Admin.NET.Core.Service; using Admin.NET.Core.Service;
using Furion.FriendlyException; using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -35,23 +36,24 @@ public class GeneReportService(
try try
{ {
await db.Ado.BeginTranAsync(); await db.Ado.BeginTranAsync();
var entity = new GeneTestingReportEntity() var entity = input.Adapt<GeneTestingReportEntity>();
{ // var entity = new GeneTestingReportEntity()
SampleType = input.SampleType, // {
TestingType = input.TestingType, // SampleType = input.SampleType,
TestingMethod = input.TestingMethod, // TestingType = input.TestingType,
TofMs = input.TofMs, // TestingMethod = input.TestingMethod,
GenotypingAnalysis = input.GenotypingAnalysis, // TofMs = input.TofMs,
SampleQuality = input.SampleQuality, // GenotypingAnalysis = input.GenotypingAnalysis,
GeneticRiskAssessment = input.GeneticRiskAssessment, // SampleQuality = input.SampleQuality,
Barcode = input.Barcode, // GeneticRiskAssessment = input.GeneticRiskAssessment,
DnaExtraction = input.DnaExtraction, // Barcode = input.Barcode,
CustomerId = input.CustomerId, // DnaExtraction = input.DnaExtraction,
ReportTime = input.ReportTime, // CustomerId = input.CustomerId,
Report = input.Report, // ReportTime = input.ReportTime,
Pcr = input.Pcr, // Report = input.Report,
SubmissionTime = input.SubmissionTime, // Pcr = input.Pcr,
}; // SubmissionTime = input.SubmissionTime,
// };
entity = await AddBefore(entity); entity = await AddBefore(entity);
var reportId = await db.Insertable(entity).ExecuteReturnSnowflakeIdAsync(); var reportId = await db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
foreach (var tumor in input.Tumors) foreach (var tumor in input.Tumors)

2
Admin.NET.Bodk.Project/Entities/AreaExtEntity.cs

@ -8,7 +8,7 @@ using SqlSugar;
namespace Admin.NET.Bodk.Project.Entities; namespace Admin.NET.Bodk.Project.Entities;
[SugarTable("bodk_org_area_ext")] [SugarTable("bodk_org_area_ext")]
public class AreaExtEntity : EntityBase public class AreaExtEntity : EntityBaseData
{ {
public long OrgId { get; set; } public long OrgId { get; set; }
} }

10
Admin.NET.Core/Entity/IDataAuth.cs

@ -0,0 +1,10 @@
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
namespace Admin.NET.Core;
public interface IDataAuth
{
long OrgId { get; set; }
}

19
Admin.NET.Core/Entity/SysOrg.cs

@ -97,19 +97,14 @@ public class SysOrg : EntityTenant
[SugarColumn(IsNullable = true, ColumnDataType = "TEXT")] [SugarColumn(IsNullable = true, ColumnDataType = "TEXT")]
public string? Position { get; set; } public string? Position { get; set; }
[SugarColumn(ColumnDataType = "json")] public string ServiceIdsJson { get; set; } [SugarColumn(IsNullable = true, ColumnDescription = "服务列表", IsArray = true)]
public long[]? ServiceIds { get; set; }
[SugarColumn(IsIgnore = true)] public List<SysStationService>? Services { get; set; } [SugarColumn(IsIgnore = true)] public List<SysStationService>? Services { get; set; }
[SugarColumn(IsIgnore = true)] [SugarColumn(IsNullable = true, ColumnDescription = "经度")]
public List<long>? ServiceIds public decimal? Longitude { get; set; }
{
get [SugarColumn(IsNullable = true, ColumnDescription = "维度")]
{ public decimal? Latitude { get; set; }
if (string.IsNullOrWhiteSpace(ServiceIdsJson))
return null;
return JsonSerializer.Deserialize<List<long>>(ServiceIdsJson);
}
set { ServiceIdsJson = JsonSerializer.Serialize(value); }
}
} }

4
Admin.NET.Core/SeedData/SysOrgSeedData.cs

@ -20,8 +20,8 @@ public class SysOrgSeedData : ISqlSugarEntitySeedData<SysOrg>
new SysOrg new SysOrg
{ {
Id = 1300000000101, Pid = 0, Name = "博工科技", Code = "1", Type = "101", Level = 1, Id = 1300000000101, Pid = 0, Name = "博工科技", Code = "1", Type = "101", Level = 1,
CreateTime = DateTime.Parse("2022-02-10 00:00:00"), Remark = "松山湖基地", TenantId = 1300000000001, CreateTime = DateTime.Parse("2022-02-10 00:00:00"), Remark = "总机构", TenantId = 1300000000001,
ServiceIds = new List<long>() ServiceIds =[]
} }
}; };
} }

212
Admin.NET.Core/Service/Org/SysOrgService.cs

@ -48,18 +48,33 @@ public class SysOrgService : IDynamicApiController, ITransient
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name)) .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name))
.WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code == input.Code) .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code == input.Code)
.WhereIF(!string.IsNullOrWhiteSpace(input.Type), u => u.Type == input.Type) .WhereIF(!string.IsNullOrWhiteSpace(input.Type), u => u.Type == input.Type)
.Mapper(o =>
{
o.Services = SqlFunc.Subqueryable<SysStationService>()
.WhereIF(o.ServiceIds is not null, s => o.ServiceIds.Contains(s.Id)).ToList();
})
.ToListAsync(); .ToListAsync();
} }
var orgTree = new List<SysOrg>(); var orgTree = new List<SysOrg>();
if (_userManager.SuperAdmin) if (_userManager.SuperAdmin)
{ {
orgTree = await iSugarQueryable.ToTreeAsync(u => u.Children, u => u.Pid, input.Id); orgTree = await iSugarQueryable
.Mapper(o =>
{
o.Services = SqlFunc.Subqueryable<SysStationService>()
.WhereIF(o.ServiceIds is not null, s => o.ServiceIds.Contains(s.Id)).ToList();
}).ToTreeAsync(u => u.Children, u => u.Pid, input.Id);
} }
else else
{ {
orgTree = await iSugarQueryable.ToTreeAsync(u => u.Children, u => u.Pid, input.Id, orgTree = await iSugarQueryable.Mapper(o =>
userOrgIdList.Select(d => (object)d).ToArray()); {
o.Services = SqlFunc.Subqueryable<SysStationService>()
.WhereIF(o.ServiceIds is not null, s => o.ServiceIds.Contains(s.Id)).ToList();
})
.ToTreeAsync(u => u.Children, u => u.Pid, input.Id,
userOrgIdList.Select(d => (object)d).ToArray());
// 递归禁用没权限的机构(防止用户修改或创建无权的机构和用户) // 递归禁用没权限的机构(防止用户修改或创建无权的机构和用户)
HandlerOrgTree(orgTree, userOrgIdList); HandlerOrgTree(orgTree, userOrgIdList);
} }
@ -119,7 +134,7 @@ public class SysOrgService : IDynamicApiController, ITransient
DeleteAllUserOrgCache(pOrg.Id, pOrg.Pid); DeleteAllUserOrgCache(pOrg.Id, pOrg.Pid);
else if (input.Pid == 0) else if (input.Pid == 0)
DeleteAllUserOrgCache(0, 0); DeleteAllUserOrgCache(0, 0);
input.ServiceIds = input.Services?.Select(u => u.Id).ToArray();
var newOrg = await _sysOrgRep.AsInsertable(input.Adapt<SysOrg>()).ExecuteReturnEntityAsync(); var newOrg = await _sysOrgRep.AsInsertable(input.Adapt<SysOrg>()).ExecuteReturnEntityAsync();
return newOrg.Id; return newOrg.Id;
} }
@ -397,193 +412,4 @@ public class SysOrgService : IDynamicApiController, ITransient
var orgTreeList = await _sysOrgRep.AsQueryable().ToChildListAsync(u => u.Pid, pid, true); var orgTreeList = await _sysOrgRep.AsQueryable().ToChildListAsync(u => u.Pid, pid, true);
return orgTreeList.Select(u => u.Id).ToList(); return orgTreeList.Select(u => u.Id).ToList();
} }
/// <summary>
/// 增加区域
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "AddArea"), HttpPost]
[DisplayName("增加区域")]
public async Task<long> AddArea(AddAreaInput input)
{
if (!_userManager.SuperAdmin && input.Pid == 0)
throw Oops.Oh(ErrorCodeEnum.D2009);
if (await _sysOrgRep.IsAnyAsync(u => u.Name == input.Name && u.Code == input.Code))
throw Oops.Oh(ErrorCodeEnum.D2002);
if (!_userManager.SuperAdmin && input.Pid != 0)
{
// 新增机构父Id不是0,则进行权限校验
var orgIdList = await GetUserOrgIdList();
// 新增机构的父机构不在自己的数据范围内
if (orgIdList.Count < 1 || !orgIdList.Contains(input.Pid))
throw Oops.Oh(ErrorCodeEnum.D2003);
}
// 删除与此父机构有关的用户机构缓存
var pOrg = await _sysOrgRep.GetFirstAsync(u => u.Id == input.Pid);
if (pOrg != null)
DeleteAllUserOrgCache(pOrg.Id, pOrg.Pid);
else if (input.Pid == 0)
DeleteAllUserOrgCache(0, 0);
var newOrg = await _sysOrgRep.AsInsertable(new SysOrg()
{
Pid = input.Pid,
Status = StatusEnum.Enable,
CreateUserId = _userManager.UserId,
CreateUserName = _userManager.Account,
Name = input.Name,
Code = input.Code,
Type = "Area",
Remark = input.Remark,
DirectorId = input.DirectorId
}).ExecuteReturnEntityAsync();
return newOrg.Id;
}
// public async Task<List<AreaOutput>> GetUserAreaList(QueryAreaInput input)
// {
// var userOrgIdList = await GetUserOrgIdList();
// var iSugarQueryable = _sysOrgRep.AsQueryable().OrderBy(u => u.OrderNo)
// .Where(a => a.Type == "Area");
// var orgTree = new List<SysOrg>();
// if (_userManager.SuperAdmin)
// {
// orgTree = await iSugarQueryable.ToTreeAsync(u => u.Children, u => u.Pid, input.Id);
// }
// else
// {
// orgTree = await iSugarQueryable.ToTreeAsync(u => u.Children, u => u.Pid, input.Id,
// userOrgIdList.Select(d => (object)d).ToArray());
// // 递归禁用没权限的机构(防止用户修改或创建无权的机构和用户)
// HandlerOrgTree(orgTree, userOrgIdList);
// }
//
// var sysOrg = await _sysOrgRep.GetSingleAsync(u => u.Id == input.Id);
// if (sysOrg != null)
// {
// sysOrg.Children = orgTree;
// orgTree = new List<SysOrg> { sysOrg };
// }
//
// return orgTree;
// if (!string.IsNullOrWhiteSpace(input.Name) || !string.IsNullOrWhiteSpace(input.Code))
// {
// return await iSugarQueryable.WhereIF(userOrgIdList.Count > 0, u => userOrgIdList.Contains(u.Id))
// .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name))
// .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code == input.Code)
// .Select(a => a.Adapt<AreaOutput>())
// .Mapper(a =>
// {
// a.Factories = a.Children.Where(c => c.Type == "Factory").Select(s => s.Adapt<FactoryOutput>())
// .Select(t =>
// {
// t.Stations = t.Children.Where(c => c.Type == "Station")
// .Select(s => s.Adapt<StationOutput>()).ToList();
// return t;
// })
// .ToList();
// })
// .ToListAsync();
// }
// }
/// <summary>
/// 增加基地
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "AddFactory"), HttpPost]
[DisplayName("增加基地")]
public async Task<long> AddFactory(AddFactoryInput input)
{
if (!_userManager.SuperAdmin && input.Pid == 0)
throw Oops.Oh(ErrorCodeEnum.D2009);
if (await _sysOrgRep.IsAnyAsync(u => u.Name == input.Name && u.Code == input.Code))
throw Oops.Oh(ErrorCodeEnum.D2002);
if (!_userManager.SuperAdmin && input.Pid != 0)
{
// 新增机构父Id不是0,则进行权限校验
var orgIdList = await GetUserOrgIdList();
// 新增机构的父机构不在自己的数据范围内
if (orgIdList.Count < 1 || !orgIdList.Contains(input.Pid))
throw Oops.Oh(ErrorCodeEnum.D2003);
}
// 删除与此父机构有关的用户机构缓存
var pOrg = await _sysOrgRep.GetFirstAsync(u => u.Id == input.Pid);
if (pOrg != null)
DeleteAllUserOrgCache(pOrg.Id, pOrg.Pid);
else if (input.Pid == 0)
DeleteAllUserOrgCache(0, 0);
var newOrg = await _sysOrgRep.AsInsertable(new SysOrg()
{
Pid = input.Pid,
Status = StatusEnum.Enable,
CreateUserId = _userManager.UserId,
CreateUserName = _userManager.Account,
Name = input.Name,
Code = input.Code,
Type = "Factory",
Remark = input.Remark,
DirectorId = input.DirectorId,
Position = input.Position
}).ExecuteReturnEntityAsync();
return newOrg.Id;
}
/// <summary>
/// 增加工作站
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "AddStation"), HttpPost]
[DisplayName("增加工作站")]
public async Task<long> AddStation(AddStationInput input)
{
if (!_userManager.SuperAdmin && input.Pid == 0)
throw Oops.Oh(ErrorCodeEnum.D2009);
if (await _sysOrgRep.IsAnyAsync(u => u.Name == input.Name && u.Code == input.Code))
throw Oops.Oh(ErrorCodeEnum.D2002);
if (!_userManager.SuperAdmin && input.Pid != 0)
{
// 新增机构父Id不是0,则进行权限校验
var orgIdList = await GetUserOrgIdList();
// 新增机构的父机构不在自己的数据范围内
if (orgIdList.Count < 1 || !orgIdList.Contains(input.Pid))
throw Oops.Oh(ErrorCodeEnum.D2003);
}
// 删除与此父机构有关的用户机构缓存
var pOrg = await _sysOrgRep.GetFirstAsync(u => u.Id == input.Pid);
if (pOrg != null)
DeleteAllUserOrgCache(pOrg.Id, pOrg.Pid);
else if (input.Pid == 0)
DeleteAllUserOrgCache(0, 0);
var ids = input.Services?.Select(s => s.Id).ToArray();
var newOrg = await _sysOrgRep.AsInsertable(new SysOrg()
{
Pid = input.Pid,
Status = StatusEnum.Enable,
CreateUserId = _userManager.UserId,
CreateUserName = _userManager.Account,
Name = input.Name,
Code = input.Code,
Type = "Station",
Remark = input.Remark,
DirectorId = input.DirectorId,
ServiceIds = ids?.ToList(),
}).ExecuteReturnEntityAsync();
return newOrg.Id;
}
} }

3
Admin.NET.Core/SqlSugar/SqlSugarRepository.cs

@ -1,4 +1,6 @@
using Org.BouncyCastle.Asn1.X509.Qualified;
namespace Admin.NET.Core; namespace Admin.NET.Core;
/// <summary> /// <summary>
@ -40,4 +42,5 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
if (sqlSugarScopeProviderTenant == null) return; if (sqlSugarScopeProviderTenant == null) return;
base.Context = sqlSugarScopeProviderTenant; base.Context = sqlSugarScopeProviderTenant;
} }
} }

62
Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@ -1,4 +1,3 @@
using System.Text.Json; using System.Text.Json;
namespace Admin.NET.Core; namespace Admin.NET.Core;
@ -21,10 +20,7 @@ public static class SqlSugarSetup
// 自定义 SqlSugar 雪花ID算法 // 自定义 SqlSugar 雪花ID算法
SnowFlakeSingle.WorkId = snowIdOpt.WorkerId; SnowFlakeSingle.WorkId = snowIdOpt.WorkerId;
StaticConfig.CustomSnowFlakeFunc = () => StaticConfig.CustomSnowFlakeFunc = () => { return YitIdHelper.NextId(); };
{
return YitIdHelper.NextId();
};
var dbOptions = App.GetConfig<DbConnectionOptions>("DbConnection", true); var dbOptions = App.GetConfig<DbConnectionOptions>("DbConnection", true);
dbOptions.ConnectionConfigs.ForEach(SetDbConfig); dbOptions.ConnectionConfigs.ForEach(SetDbConfig);
@ -44,10 +40,7 @@ public static class SqlSugarSetup
services.AddUnitOfWork<SqlSugarUnitOfWork>(); // 事务与工作单元注册 services.AddUnitOfWork<SqlSugarUnitOfWork>(); // 事务与工作单元注册
// 初始化数据库表结构及种子数据 // 初始化数据库表结构及种子数据
dbOptions.ConnectionConfigs.ForEach(config => dbOptions.ConnectionConfigs.ForEach(config => { InitDatabase(sqlSugar, config); });
{
InitDatabase(sqlSugar, config);
});
} }
/// <summary> /// <summary>
@ -110,7 +103,8 @@ public static class SqlSugarSetup
var originColor = Console.ForegroundColor; var originColor = Console.ForegroundColor;
if (sql.StartsWith("SELECT", StringComparison.OrdinalIgnoreCase)) if (sql.StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
Console.ForegroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.Green;
if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase)) if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) ||
sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase))
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase)) if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase))
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
@ -121,7 +115,8 @@ public static class SqlSugarSetup
db.Aop.OnError = ex => db.Aop.OnError = ex =>
{ {
if (ex.Parametres == null) return; if (ex.Parametres == null) return;
var log = $"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n"; var log =
$"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
var originColor = Console.ForegroundColor; var originColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(log); Console.WriteLine(log);
@ -136,7 +131,9 @@ public static class SqlSugarSetup
var fileName = db.Ado.SqlStackTrace.FirstFileName; // 文件名 var fileName = db.Ado.SqlStackTrace.FirstFileName; // 文件名
var fileLine = db.Ado.SqlStackTrace.FirstLine; // 行号 var fileLine = db.Ado.SqlStackTrace.FirstLine; // 行号
var firstMethodName = db.Ado.SqlStackTrace.FirstMethodName; // 方法名 var firstMethodName = db.Ado.SqlStackTrace.FirstMethodName; // 方法名
var log = $"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}"; var log =
$"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" +
$"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
var originColor = Console.ForegroundColor; var originColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkYellow; Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(log); Console.WriteLine(log);
@ -145,18 +142,21 @@ public static class SqlSugarSetup
} }
}; };
} }
// 数据审计 // 数据审计
db.Aop.DataExecuting = (oldValue, entityInfo) => db.Aop.DataExecuting = (oldValue, entityInfo) =>
{ {
if (entityInfo.OperationType == DataFilterType.InsertByObject) if (entityInfo.OperationType == DataFilterType.InsertByObject)
{ {
// 主键(long类型)且没有值的---赋值雪花Id // 主键(long类型)且没有值的---赋值雪花Id
if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long)) if (entityInfo.EntityColumnInfo.IsPrimarykey &&
entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
{ {
var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue); var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
if (id == null || (long)id == 0) if (id == null || (long)id == 0)
entityInfo.SetValue(YitIdHelper.NextId()); entityInfo.SetValue(YitIdHelper.NextId());
} }
if (entityInfo.PropertyName == nameof(EntityBase.CreateTime)) if (entityInfo.PropertyName == nameof(EntityBase.CreateTime))
entityInfo.SetValue(DateTime.Now); entityInfo.SetValue(DateTime.Now);
if (App.User != null) if (App.User != null)
@ -193,6 +193,7 @@ public static class SqlSugarSetup
} }
} }
} }
if (entityInfo.OperationType == DataFilterType.UpdateByObject) if (entityInfo.OperationType == DataFilterType.UpdateByObject)
{ {
if (entityInfo.PropertyName == nameof(EntityBase.UpdateTime)) if (entityInfo.PropertyName == nameof(EntityBase.UpdateTime))
@ -250,7 +251,8 @@ public static class SqlSugarSetup
}; };
await db.CopyNew().Insertable(logDiff).ExecuteCommandAsync(); await db.CopyNew().Insertable(logDiff).ExecuteCommandAsync();
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(DateTime.Now + $"\r\n*****开始差异日志*****\r\n{Environment.NewLine}{JSON.Serialize(logDiff)}{Environment.NewLine}*****结束差异日志*****\r\n"); Console.WriteLine(DateTime.Now +
$"\r\n*****开始差异日志*****\r\n{Environment.NewLine}{JSON.Serialize(logDiff)}{Environment.NewLine}*****结束差异日志*****\r\n");
}; };
} }
@ -273,15 +275,22 @@ public static class SqlSugarSetup
// 初始化表结构 // 初始化表结构
if (config.TableSettings.EnableInitTable) if (config.TableSettings.EnableInitTable)
{ {
var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false)) var entityTypes = App.EffectiveTypes.Where(u =>
.WhereIF(config.TableSettings.EnableIncreTable, u => u.IsDefined(typeof(IncreTableAttribute), false)).ToList(); !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false))
.WhereIF(config.TableSettings.EnableIncreTable, u => u.IsDefined(typeof(IncreTableAttribute), false))
.ToList();
if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) // 默认库(有系统表特性、没有日志表和租户表特性) if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) // 默认库(有系统表特性、没有日志表和租户表特性)
entityTypes = entityTypes.Where(u => u.GetCustomAttributes<SysTableAttribute>().Any() || (!u.GetCustomAttributes<LogTableAttribute>().Any() && !u.GetCustomAttributes<TenantAttribute>().Any())).ToList(); entityTypes = entityTypes.Where(u =>
u.GetCustomAttributes<SysTableAttribute>().Any() ||
(!u.GetCustomAttributes<LogTableAttribute>().Any() &&
!u.GetCustomAttributes<TenantAttribute>().Any())).ToList();
else if (config.ConfigId.ToString() == SqlSugarConst.LogConfigId) // 日志库 else if (config.ConfigId.ToString() == SqlSugarConst.LogConfigId) // 日志库
entityTypes = entityTypes.Where(u => u.GetCustomAttributes<LogTableAttribute>().Any()).ToList(); entityTypes = entityTypes.Where(u => u.GetCustomAttributes<LogTableAttribute>().Any()).ToList();
else else
entityTypes = entityTypes.Where(u => u.GetCustomAttribute<TenantAttribute>()?.configId.ToString() == config.ConfigId.ToString()).ToList(); // 自定义的库 entityTypes = entityTypes.Where(u =>
u.GetCustomAttribute<TenantAttribute>()?.configId.ToString() == config.ConfigId.ToString())
.ToList(); // 自定义的库
foreach (var entityType in entityTypes) foreach (var entityType in entityTypes)
{ {
@ -295,15 +304,20 @@ public static class SqlSugarSetup
// 初始化种子数据 // 初始化种子数据
if (config.SeedSettings.EnableInitSeed) if (config.SeedSettings.EnableInitSeed)
{ {
var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>)))) var seedDataTypes = App.EffectiveTypes.Where(u =>
.WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false)).ToList(); !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces()
.Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
.WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false))
.ToList();
foreach (var seedType in seedDataTypes) foreach (var seedType in seedDataTypes)
{ {
var entityType = seedType.GetInterfaces().First().GetGenericArguments().First(); var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();
if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) // 默认库(有系统表特性、没有日志表和租户表特性) if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) // 默认库(有系统表特性、没有日志表和租户表特性)
{ {
if (entityType.GetCustomAttribute<SysTableAttribute>() == null && (entityType.GetCustomAttribute<LogTableAttribute>() != null || entityType.GetCustomAttribute<TenantAttribute>() != null)) if (entityType.GetCustomAttribute<SysTableAttribute>() == null &&
(entityType.GetCustomAttribute<LogTableAttribute>() != null ||
entityType.GetCustomAttribute<TenantAttribute>() != null))
continue; continue;
} }
else if (config.ConfigId.ToString() == SqlSugarConst.LogConfigId) // 日志库 else if (config.ConfigId.ToString() == SqlSugarConst.LogConfigId) // 日志库
@ -355,8 +369,10 @@ public static class SqlSugarSetup
db.DbMaintenance.CreateDatabase(); db.DbMaintenance.CreateDatabase();
// 获取所有业务表-初始化租户库表结构(排除系统表、日志表、特定库表) // 获取所有业务表-初始化租户库表结构(排除系统表、日志表、特定库表)
var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false) && var entityTypes = App.EffectiveTypes.Where(u =>
!u.IsDefined(typeof(SysTableAttribute), false) && !u.IsDefined(typeof(LogTableAttribute), false) && !u.IsDefined(typeof(TenantAttribute), false)).ToList(); !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false) &&
!u.IsDefined(typeof(SysTableAttribute), false) && !u.IsDefined(typeof(LogTableAttribute), false) &&
!u.IsDefined(typeof(TenantAttribute), false)).ToList();
if (!entityTypes.Any()) return; if (!entityTypes.Any()) return;
foreach (var entityType in entityTypes) foreach (var entityType in entityTypes)

17
Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj

@ -40,16 +40,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Admin.Bodk.Device\Admin.Bodk.Device.csproj" />
<ProjectReference Include="..\Admin.NET.Bodk.Cells\Admin.NET.Bodk.Cells.csproj" />
<ProjectReference Include="..\Admin.NET.Bodk.Customer\Admin.NET.Bodk.Customer.csproj" />
<ProjectReference Include="..\Admin.NET.Bodk.Device\Admin.NET.Bodk.Device.csproj" />
<ProjectReference Include="..\Admin.NET.Bodk.Genetic\Admin.NET.Bodk.Genetic.csproj" />
<ProjectReference Include="..\Admin.NET.Bodk.Project\Admin.NET.Bodk.Project.csproj" />
<ProjectReference Include="..\Admin.NET.Web.Core\Admin.NET.Web.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\Template\data.data.ts.vm"> <Content Update="wwwroot\Template\data.data.ts.vm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -88,4 +78,11 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Application\Admin.NET.Application.csproj" />
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
<ProjectReference Include="..\Admin.NET.Web.Core\Admin.NET.Web.Core.csproj" />
<ProjectReference Include="..\Bodk.NET.Project\Bodk.NET.Project.csproj" />
</ItemGroup>
</Project> </Project>

BIN
Admin.NET.Web.Entry/Admin.NET.db

Binary file not shown.

37
Admin.NET.sln

@ -42,6 +42,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Cells", "Adm
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Core", "Admin.NET.Bodk.Core\Admin.NET.Bodk.Core.csproj", "{0273F0C6-A22B-494D-AA0B-30628C537FEA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Core", "Admin.NET.Bodk.Core\Admin.NET.Bodk.Core.csproj", "{0273F0C6-A22B-494D-AA0B-30628C537FEA}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bodk", "Bodk", "{1B5D6CD4-1BAD-4F3C-9476-24376811BB56}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bodk.NET.Core", "Bodk.NET.Core\Bodk.NET.Core.csproj", "{CE8BF7BE-451F-4421-9C0C-346FC13EBC94}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bodk.NET.Project", "Bodk.NET.Project\Bodk.NET.Project.csproj", "{3964C5ED-A766-4FEB-987A-EC54EADFFAA0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bodk.NET.LocalServer", "Bodk.NET.LocalServer\Bodk.NET.LocalServer.csproj", "{8603F2EA-02DB-4B0D-B65C-B2B436F456DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bodk.NET.Device", "Bodk.NET.Device\Bodk.NET.Device.csproj", "{C31BB5C0-BA31-4283-9FC4-CD3626B95A2F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bodk.NET.Customer", "Bodk.NET.Customer\Bodk.NET.Customer.csproj", "{E00395A2-E491-4788-8C51-58761D705192}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -112,6 +124,26 @@ Global
{0273F0C6-A22B-494D-AA0B-30628C537FEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {0273F0C6-A22B-494D-AA0B-30628C537FEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0273F0C6-A22B-494D-AA0B-30628C537FEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {0273F0C6-A22B-494D-AA0B-30628C537FEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0273F0C6-A22B-494D-AA0B-30628C537FEA}.Release|Any CPU.Build.0 = Release|Any CPU {0273F0C6-A22B-494D-AA0B-30628C537FEA}.Release|Any CPU.Build.0 = Release|Any CPU
{CE8BF7BE-451F-4421-9C0C-346FC13EBC94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE8BF7BE-451F-4421-9C0C-346FC13EBC94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE8BF7BE-451F-4421-9C0C-346FC13EBC94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE8BF7BE-451F-4421-9C0C-346FC13EBC94}.Release|Any CPU.Build.0 = Release|Any CPU
{3964C5ED-A766-4FEB-987A-EC54EADFFAA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3964C5ED-A766-4FEB-987A-EC54EADFFAA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3964C5ED-A766-4FEB-987A-EC54EADFFAA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3964C5ED-A766-4FEB-987A-EC54EADFFAA0}.Release|Any CPU.Build.0 = Release|Any CPU
{8603F2EA-02DB-4B0D-B65C-B2B436F456DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8603F2EA-02DB-4B0D-B65C-B2B436F456DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8603F2EA-02DB-4B0D-B65C-B2B436F456DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8603F2EA-02DB-4B0D-B65C-B2B436F456DD}.Release|Any CPU.Build.0 = Release|Any CPU
{C31BB5C0-BA31-4283-9FC4-CD3626B95A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C31BB5C0-BA31-4283-9FC4-CD3626B95A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C31BB5C0-BA31-4283-9FC4-CD3626B95A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C31BB5C0-BA31-4283-9FC4-CD3626B95A2F}.Release|Any CPU.Build.0 = Release|Any CPU
{E00395A2-E491-4788-8C51-58761D705192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E00395A2-E491-4788-8C51-58761D705192}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E00395A2-E491-4788-8C51-58761D705192}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E00395A2-E491-4788-8C51-58761D705192}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -119,6 +151,11 @@ Global
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{C4A288D5-0FAA-4F43-9072-B97635D7871D} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {C4A288D5-0FAA-4F43-9072-B97635D7871D} = {76F70D22-8D53-468E-A3B6-1704666A1D71}
{48EFC3A6-BDC0-4D05-819A-B1FB927FA4C8} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {48EFC3A6-BDC0-4D05-819A-B1FB927FA4C8} = {76F70D22-8D53-468E-A3B6-1704666A1D71}
{CE8BF7BE-451F-4421-9C0C-346FC13EBC94} = {1B5D6CD4-1BAD-4F3C-9476-24376811BB56}
{3964C5ED-A766-4FEB-987A-EC54EADFFAA0} = {1B5D6CD4-1BAD-4F3C-9476-24376811BB56}
{8603F2EA-02DB-4B0D-B65C-B2B436F456DD} = {1B5D6CD4-1BAD-4F3C-9476-24376811BB56}
{C31BB5C0-BA31-4283-9FC4-CD3626B95A2F} = {1B5D6CD4-1BAD-4F3C-9476-24376811BB56}
{E00395A2-E491-4788-8C51-58761D705192} = {1B5D6CD4-1BAD-4F3C-9476-24376811BB56}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5CD801D7-984A-4F5C-8FA2-211B7A5EA9F3} SolutionGuid = {5CD801D7-984A-4F5C-8FA2-211B7A5EA9F3}

2
Admin.NET.sln.DotSettings

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Genotyping/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

13
Bodk.NET.Core/Bodk.NET.Core.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
</ItemGroup>
</Project>

13
Bodk.NET.Customer/Bodk.NET.Customer.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
</ItemGroup>
</Project>

31
Bodk.NET.Customer/Entities/BodkCustomer.cs

@ -0,0 +1,31 @@
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
using Admin.NET.Core;
using SqlSugar;
namespace Bodk.NET.Customer.Entities;
[SugarTable("bodk_base_customer", "客户表")]
public class BodkCustomer : EntityBase
{
[SugarColumn(IsNullable = false, ColumnDescription = "客户名称")]
public virtual string Name { get; set; }
[SugarColumn(IsNullable = false, ColumnDescription = "身份证号码")]
public virtual string IdCard { get; set; }
[SugarColumn(IsNullable = false, ColumnDescription = "手机号码")]
public virtual string Phone { get; set; }
[SugarColumn(IsNullable = false, ColumnDescription = "性别")]
public virtual bool IsMale { get; set; }
[SugarColumn(IsJson = true, ColumnDescription = "客户从属的机构列表", IsNullable = true)]
public virtual List<long>? OrgIds { get; set; }
[SugarColumn(IsNullable = true)] public string? ImageUrl { get; set; }
[SugarColumn(IsNullable = true)] public string? VoiceUrl { get; set; }
}

85
Bodk.NET.Customer/Models/Customer.cs

@ -0,0 +1,85 @@
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
using System.ComponentModel.DataAnnotations;
using Admin.NET.Core;
using Bodk.NET.Customer.Entities;
namespace Bodk.NET.Customer.Models;
/// <summary>
/// 新增客户ID入参
/// </summary>
public class AddCustomerInput : BodkCustomer
{
private new long Id { get; set; }
/// <summary>
/// 客户姓名
/// </summary>
[Required(ErrorMessage = "客户姓名不能为空")]
public override string Name { get; set; }
/// <summary>
/// 客户身份证号
/// </summary>
[Required(ErrorMessage = "客户身份证号不能为空")]
public override string IdCard { get; set; }
/// <summary>
/// 客户性别
/// </summary>
[Required(ErrorMessage = "客户性别不能为空")]
public override bool IsMale { get; set; }
/// <summary>
/// 客户手机号
/// </summary>
[Required(ErrorMessage = "客户手机号不能为空")]
public override string Phone { get; set; }
}
/// <summary>
/// 更新客户ID入参
/// </summary>
public class UpdateCustomerInput : BodkCustomer
{
/// <summary>
/// 客户Id
/// </summary>
[Required(ErrorMessage = "客户Id不能为空")]
public override long Id { get; set; }
}
/// <summary>
/// 分页获取客户列表入参
/// </summary>
public class PageCustomerInput : BasePageInput
{
/// <summary>
/// 组织机构Id列表
/// </summary>
public long[]? OrgIds { get; set; }
}
/// <summary>
/// 查询单个客户入参
/// </summary>
public class SingleCustomerInput
{
/// <summary>
/// 名称
/// </summary>
public string? Name { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string? IdCard { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string? Phone { get; set; }
}

86
Bodk.NET.Customer/Services/CustomerService.cs

@ -0,0 +1,86 @@
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
using System.ComponentModel;
using Admin.NET.Core;
using Bodk.NET.Customer.Entities;
using Bodk.NET.Customer.Models;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bodk.NET.Customer.Services;
/// <summary>
/// 客户接口控制器
/// </summary>
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "Customer", Description = "客户接口")]
public class CustomerService(SqlSugarRepository<BodkCustomer> repository) : IDynamicApiController, ITransient
{
/// <summary>
/// 新增客户
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "Add"), HttpPost]
[DisplayName("Add")]
[Authorize(AuthenticationSchemes =
JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
public async Task<long> AddCustomer(AddCustomerInput input)
{
var entity = input.Adapt<BodkCustomer>();
bool exist = await CheckCustomerExist(entity);
if (exist)
throw Oops.Oh("该用户已存在");
return await repository.InsertReturnSnowflakeIdAsync(entity);
}
/// <summary>
/// 更新客户
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "Update"), HttpPost]
[DisplayName("Update")]
[Authorize(AuthenticationSchemes =
JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
public async Task UpdateCustomer(UpdateCustomerInput input)
{
var entity = input.Adapt<BodkCustomer>();
bool exist = await CheckCustomerExist(input.Id);
if (!exist)
throw Oops.Oh("该用户不存在");
await repository.UpdateAsync(entity);
}
/// <summary>
/// 获取客户列表
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "Update"), HttpPost]
[DisplayName("Update")]
[Authorize(AuthenticationSchemes =
JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
public async Task PageCustomer(UpdateCustomerInput input)
{
var entity = input.Adapt<BodkCustomer>();
bool exist = await CheckCustomerExist(input.Id);
if (!exist)
throw Oops.Oh("该用户不存在");
await repository.UpdateAsync(entity);
}
private async Task<bool> CheckCustomerExist(BodkCustomer entity)
{
return await repository.AsQueryable().AnyAsync(u => u.IdCard == entity.IdCard)
|| await repository.AsQueryable().AnyAsync(u => u.Phone == entity.Phone);
}
private Task<bool> CheckCustomerExist(long id)
{
return repository.AsQueryable().AnyAsync(u => u.Id == id);
}
}

9
Bodk.NET.Device/Bodk.NET.Device.csproj

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

13
Bodk.NET.LocalServer/Bodk.NET.LocalServer.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
</ItemGroup>
</Project>

22
Bodk.NET.Project/Bodk.NET.Project.csproj

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>obj\Debug\Bodk.NET.Project.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
<ProjectReference Include="..\Bodk.NET.Core\Bodk.NET.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Entities\" />
</ItemGroup>
</Project>
Loading…
Cancel
Save