修复租户库插入无默认数据问题

master
ZR20090193-陈敬勇 9 months ago
parent 737bd7dd06
commit 8058ba1cc0

@ -17,11 +17,6 @@ public interface ISaasDbService
/// <returns></returns>
public ISqlSugarClient GetMasterDb();
/// <summary>
/// 主库根据Id获取业务库
/// </summary>
/// <returns></returns>
public ISqlSugarClient GetBizDbById(object configId);
/// <summary>
/// 主库根据Id获取业务库Scope

@ -1,3 +1,4 @@
using DS.Module.Core.Data;
using DS.Module.UserModule;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
@ -61,26 +62,7 @@ public class SaasDbService : ISaasDbService
return db.GetConnection("1288018625843826688");
}
/// <summary>
/// 主库根据Id获取业务库
/// </summary>
/// <returns></returns>
public ISqlSugarClient GetBizDbById(object configId)
{
if(!db.IsAnyConnection(configId))
{
var connInfo = GetMasterDb().Queryable<SysTenantLink>().First(x => x.TenantId == Convert.ToInt64(configId));
//用非默认ConfigId进行测试
//添加业务库只在当前上下文有效原理SqlSugarScope模式入门文档去看
db.AddConnection(new ConnectionConfig() {
ConfigId = configId,
ConnectionString = connInfo.Connection,
DbType = connInfo.DbType,
IsAutoCloseConnection = true });
}
return db.GetConnection(configId);
}
/// <summary>
/// 主库根据Id获取业务库Scope
/// </summary>
@ -93,15 +75,43 @@ public class SaasDbService : ISaasDbService
var connInfo = GetMasterDb().Queryable<SysTenantLink>().First(x => x.TenantId == Convert.ToInt64(configId));
//用非默认ConfigId进行测试
//添加业务库只在当前上下文有效原理SqlSugarScope模式入门文档去看
db.AddConnection(new ConnectionConfig() {
db.AddConnection(new ConnectionConfig()
{
ConfigId = configId,
ConnectionString = connInfo.Connection,
DbType = connInfo.DbType,
IsAutoCloseConnection = true });
IsAutoCloseConnection = true
});
var dbProvider = db.GetConnectionScope(configId);
dbProvider.Ado.CommandTimeOut = 30;
dbProvider.Aop.OnLogExecuting = (sql, pars) =>
{
//执行前事件
//Logger.Log(LogLevel.Info,
// DateTime.Now.ToString() + "\r\n" +
// UtilMethods.GetSqlString(c.DbType, sql, pars));
Console.WriteLine("执行的sql:" + sql);
};
//数据处理事件
dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
{
// 新增操作
SqlsugarHelper.InsertByObjectForSqlsugar(entityInfo, user);
// 更新操作
SqlsugarHelper.UpdateByObjectForSqlsugar(entityInfo, user);
};
dbProvider.Aop.OnDiffLogEvent = (it) => { };
//全局过滤机构Id
dbProvider.QueryFilter.AddTableFilter<IOrgId>(m => m.OrgId == user.GetOrgId());
//全局软删除过滤
dbProvider.QueryFilter.AddTableFilter<IDeleted>(m => m.Deleted == false);
}
return db.GetConnectionScope(configId);
}
public SqlSugarScopeProvider GetMasterDbScope()
{
return db.GetConnectionScope("1288018625843826688");

@ -78,7 +78,7 @@ public class CodeCountryService:ICodeCountryService
public DataResult<List<CodeCountryRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeCountry>()
@ -89,7 +89,7 @@ public class CodeCountryService:ICodeCountryService
public DataResult EditClientCodeCountry(CodeCountryReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeCountryService:ICodeCountryService
public DataResult<CodeCountryRes> GetClientCodeCountryInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeCountry>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeCountryRes>()
@ -137,7 +137,7 @@ public class CodeCountryService:ICodeCountryService
public DataResult ImportCodeCountry(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeCountry>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodeCountryService:ICodeCountryService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeCountryList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeCountry>()
.Select(n=>n.Id.ToString())
.ToList();

@ -78,7 +78,7 @@ public class CodeCtnService:ICodeCtnService
public DataResult<List<CodeCtnRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeCtn>()
@ -89,7 +89,7 @@ public class CodeCtnService:ICodeCtnService
public DataResult EditClientCodeCtn(CodeCtnReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeCtnService:ICodeCtnService
public DataResult<CodeCtnRes> GetClientCodeCtnInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeCtn>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeCtnRes>()
@ -137,7 +137,7 @@ public class CodeCtnService:ICodeCtnService
public DataResult ImportCodeCtn(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeCtn>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodeCtnService:ICodeCtnService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeCtnList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeCtn>()
.Select(n=>n.Id.ToString())
.ToList();

@ -79,7 +79,7 @@ public class CodeGoodsService:ICodeGoodsService
public DataResult<List<CodeGoodsRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeGoods>()
@ -91,7 +91,7 @@ public class CodeGoodsService:ICodeGoodsService
public DataResult EditClientCodeGoods(CodeGoodsReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -119,7 +119,7 @@ public class CodeGoodsService:ICodeGoodsService
public DataResult<CodeGoodsRes> GetClientCodeGoodsInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeGoods>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeGoodsRes>()
@ -140,7 +140,7 @@ public class CodeGoodsService:ICodeGoodsService
public DataResult ImportCodeGoods(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeGoods>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -162,7 +162,7 @@ public class CodeGoodsService:ICodeGoodsService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeGoodsList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeGoods>()
.LeftJoin<CodeGoodsType>((a, b) => a.GoodsTypeId == b.Id)
.Select(n=>n.Id.ToString())

@ -78,7 +78,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
public DataResult<List<CodeGoodsTypeRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeGoodsType>()
@ -89,7 +89,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
public DataResult EditClientCodeGoodsType(CodeGoodsTypeReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
public DataResult<CodeGoodsTypeRes> GetClientCodeGoodsTypeInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeGoodsType>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeGoodsTypeRes>()
@ -137,7 +137,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
public DataResult ImportCodeGoodsType(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeGoodsType>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeGoodsTypeList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeGoodsType>()
.Select(n=>n.Id.ToString())
.ToList();

@ -78,7 +78,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
public DataResult<List<CodeIssueTypeRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeIssueType>()
@ -89,7 +89,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
public DataResult EditClientCodeIssueType(CodeIssueTypeReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
public DataResult<CodeIssueTypeRes> GetClientCodeIssueTypeInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeIssueType>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeIssueTypeRes>()
@ -137,7 +137,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
public DataResult ImportCodeIssueType(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeIssueType>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeIssueTypeList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeIssueType>()
.Select(n=>n.Id.ToString())
.ToList();

@ -78,7 +78,7 @@ public class CodePackageService:ICodePackageService
public DataResult<List<CodePackageRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodePackage>()
@ -89,7 +89,7 @@ public class CodePackageService:ICodePackageService
public DataResult EditClientCodePackage(CodePackageReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodePackageService:ICodePackageService
public DataResult<CodePackageRes> GetClientCodePackageInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodePackage>()
.Where(a => a.Id == long.Parse(id))
.Select<CodePackageRes>()
@ -137,7 +137,7 @@ public class CodePackageService:ICodePackageService
public DataResult ImportCodePackage(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodePackage>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodePackageService:ICodePackageService
/// <returns></returns>
public DataResult<List<string>> GetExistCodePackageList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodePackage>()
.Select(n=>n.Id.ToString())
.ToList();

@ -78,7 +78,7 @@ public class CodePortService:ICodePortService
public DataResult<List<CodePortRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodePort>()
@ -89,7 +89,7 @@ public class CodePortService:ICodePortService
public DataResult EditClientCodePort(CodePortReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodePortService:ICodePortService
public DataResult<CodePortRes> GetClientCodePortInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodePort>()
.Where(a => a.Id == long.Parse(id))
.Select<CodePortRes>()
@ -137,7 +137,7 @@ public class CodePortService:ICodePortService
public DataResult ImportCodePort(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodePort>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodePortService:ICodePortService
/// <returns></returns>
public DataResult<List<string>> GetExistCodePortList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodePort>()
.Select(n=>n.Id.ToString())
.ToList();

@ -78,7 +78,7 @@ public class CodeSourceDetailService:ICodeSourceDetailService
public DataResult<List<CodeSourceDetailRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeSourceDetail>()
@ -89,7 +89,7 @@ public class CodeSourceDetailService:ICodeSourceDetailService
public DataResult EditClientCodeSourceDetail(CodeSourceDetailReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeSourceDetailService:ICodeSourceDetailService
public DataResult<CodeSourceDetailRes> GetClientCodeSourceDetailInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeSourceDetail>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeSourceDetailRes>()

@ -78,7 +78,7 @@ public class CodeSourceService:ICodeSourceService
public DataResult<List<CodeSourceRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeSource>()
@ -89,7 +89,7 @@ public class CodeSourceService:ICodeSourceService
public DataResult EditClientCodeSource(CodeSourceReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeSourceService:ICodeSourceService
public DataResult<CodeSourceRes> GetClientCodeSourceInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeSource>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeSourceRes>()
@ -137,7 +137,7 @@ public class CodeSourceService:ICodeSourceService
public DataResult ImportCodeSource(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeSource>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -164,7 +164,7 @@ public class CodeSourceService:ICodeSourceService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeSourceList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeSource>()
.Select(n=>n.Id.ToString())
.ToList();

@ -78,7 +78,7 @@ public class CodeVesselService:ICodeVesselService
public DataResult<List<CodeVesselRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeVessel>()
@ -89,7 +89,7 @@ public class CodeVesselService:ICodeVesselService
public DataResult EditClientCodeVessel(CodeVesselReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -117,7 +117,7 @@ public class CodeVesselService:ICodeVesselService
public DataResult<CodeVesselRes> GetClientCodeVesselInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeVessel>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeVesselRes>()
@ -137,7 +137,7 @@ public class CodeVesselService:ICodeVesselService
public DataResult ImportCodeVessel(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeVessel>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -159,7 +159,7 @@ public class CodeVesselService:ICodeVesselService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeVesselList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeVessel>()
.Select(n=>n.Id.ToString())
.ToList();

@ -79,7 +79,7 @@ public class CodeVoynoService:ICodeVoynoService
public DataResult<List<CodeVoynoRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeVoyno>()
@ -91,7 +91,7 @@ public class CodeVoynoService:ICodeVoynoService
public DataResult EditClientCodeVoyno(CodeVoynoReq req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
@ -119,7 +119,7 @@ public class CodeVoynoService:ICodeVoynoService
public DataResult<CodeVoynoRes> GetClientCodeVoynoInfo(string id)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeVoyno>()
.LeftJoin<CodeVessel>((a,b)=>a.VesselId==b.Id)
.Where(a => a.Id == long.Parse(id))
@ -141,7 +141,7 @@ public class CodeVoynoService:ICodeVoynoService
public DataResult ImportCodeVoyno(IdModel req)
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeVoyno>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
@ -163,7 +163,7 @@ public class CodeVoynoService:ICodeVoynoService
/// <returns></returns>
public DataResult<List<string>> GetExistCodeVoynoList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeVoyno>()
.LeftJoin<CodeVessel>((a,b)=>a.VesselId==b.Id)
.Select(n=>n.Id.ToString())

@ -0,0 +1,85 @@
using DS.Module.Core;
using FluentValidation;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 数据权限请求实体
/// </summary>
public class SysSequenceReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 权限ID
/// </summary>
public long PermissionId { get; set; }
/// <summary>
/// 权限实体
/// </summary>
public string PermissionEntity { get; set; }= "";
/// <summary>
/// 名称
/// </summary>
public string SequenceName { get; set; }= "";
/// <summary>
/// 分隔符
/// </summary>
public string SequenceDelimiter { get; set; }= "";
/// <summary>
/// 序号重置规则
/// </summary>
public string SequenceReset { get; set; } = "";
/// <summary>
/// 步长
/// </summary>
public int Step { get; set; } = 0;
/// <summary>
/// 当前值
/// </summary>
public int CurrentNo { get; set; }= 0;
/// <summary>
/// 当前编码
/// </summary>
public string CurrentCode { get; set; }= "";
/// <summary>
/// 当前重置依赖,即最后一次获取编码的日期
/// </summary>
public string CurrentReset { get; set; }= "";
/// <summary>
/// 排序
/// </summary>
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
}
/// <summary>
/// 验证
/// </summary>
public class SysSequenceReqValidator : AbstractValidator<SysSequenceReq>
{
/// <summary>
/// 构造函数
/// </summary>
public SysSequenceReqValidator()
{
this.RuleFor(o => o.PermissionId)
.NotEmpty().WithName("权限模块Id");
this.RuleFor(o => o.SequenceName)
.NotEmpty().WithName("名称");
}
}

@ -0,0 +1,71 @@
using DS.Module.Core;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 数据权限返回实体
/// </summary>
public class SysSequenceRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 权限ID
/// </summary>
public long PermissionId { get; set; }
/// <summary>
/// 权限实体
/// </summary>
public string PermissionEntity { get; set; }= "";
/// <summary>
/// 名称
/// </summary>
public string SequenceName { get; set; }= "";
/// <summary>
/// 分隔符
/// </summary>
public string SequenceDelimiter { get; set; }= "";
/// <summary>
/// 序号重置规则
/// </summary>
public string SequenceReset { get; set; } = "";
/// <summary>
/// 步长
/// </summary>
public int Step { get; set; } = 0;
/// <summary>
/// 当前值
/// </summary>
public int CurrentNo { get; set; }= 0;
/// <summary>
/// 当前编码
/// </summary>
public string CurrentCode { get; set; }= "";
/// <summary>
/// 当前重置依赖,即最后一次获取编码的日期
/// </summary>
public string CurrentReset { get; set; }= "";
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 排序
/// </summary>
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}

@ -0,0 +1,58 @@
using DS.Module.Core;
using DS.Module.Core.Data;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 系统编码表
/// </summary>
[SqlSugar.SugarTable("sys_sequence","系统编码表")]
public class SysSequence : BaseTenantModel<long>
{
/// <summary>
/// 权限ID
/// </summary>
public long PermissionId { get; set; }
/// <summary>
/// 权限实体
/// </summary>
public string PermissionEntity { get; set; }
/// <summary>
/// 名称
/// </summary>
public string SequenceName { get; set; }
/// <summary>
/// 分隔符
/// </summary>
public string SequenceDelimiter { get; set; }
/// <summary>
/// 序号重置规则
/// </summary>
public string SequenceReset { get; set; }
/// <summary>
/// 步长
/// </summary>
public int Step { get; set; }
/// <summary>
/// 当前值
/// </summary>
public int CurrentNo { get; set; }
/// <summary>
/// 当前编码
/// </summary>
public string CurrentCode { get; set; }
/// <summary>
/// 当前重置依赖,即最后一次获取编码的日期
/// </summary>
public string CurrentReset { get; set; }
/// <summary>
/// 状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "状态")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 排序号
/// </summary>
public string OrderNo { get; set; }
}

@ -0,0 +1,51 @@
using DS.Module.Core;
using DS.Module.Core.Data;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 系统编码规则表
/// </summary>
[SqlSugar.SugarTable("sys_sequence_rule","系统编码表")]
public class SysSequenceRule : BaseTenantModel<long>
{
/// <summary>
/// 权限ID
/// </summary>
public long PermissionId { get; set; }
/// <summary>
/// 单据Id
/// </summary>
public long SequenceId { get; set; }
/// <summary>
/// 取规则类别timestamp、const、number
/// </summary>
public string RuleType { get; set; }
/// <summary>
/// 规则参数,如 YYMMDD
/// </summary>
public string RuleValue { get; set; }
/// <summary>
/// 补齐方向left或right
/// </summary>
public string PaddingSide { get; set; }
/// <summary>
/// 补齐宽度
/// </summary>
public int PaddingWidth { get; set; }
/// <summary>
/// 填充字符
/// </summary>
public string PaddingChar { get; set; }
/// <summary>
/// 状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "状态")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 排序号
/// </summary>
public string OrderNo { get; set; }
}

@ -805,7 +805,7 @@ public class CommonService : ICommonService
/// <returns></returns>
public DataResult<List<ApiSelectViewModel>> GetClientGoodsTypeList()
{
var tenantDb = saasService.GetBizDbById(user.TenantId);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<CodeGoodsType>()
.Select(a => new ApiSelectViewModel
{

@ -279,7 +279,7 @@ public class TenantApplyService : ITenantApplyService
DbType = link.DbType,
IsAutoCloseConnection = true });
}
var tenantDb = saasService.GetBizDbById(tenant.Id);
var tenantDb = saasService.GetBizDbScopeById(tenant.Id);
StaticConfig.CodeFirst_MySqlCollate="utf8mb4_0900_ai_ci";//较高版本支持
//初始化数库
tenantDb.DbMaintenance.CreateDatabase();

Loading…
Cancel
Save