清除common.props
This commit is contained in:
@@ -6,12 +6,18 @@
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class VmodelSettingAttribute : Attribute
|
||||
{
|
||||
public string Area { get; set; }
|
||||
public string? Id { get; set; }
|
||||
public string? Area { get; set; }
|
||||
public string? Code { get; set; }
|
||||
|
||||
public VmodelSettingAttribute(string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public VmodelSettingAttribute(string area, string? code = null)
|
||||
{
|
||||
Area = area;
|
||||
Code = code;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using SqlSugar;
|
||||
using Tnb.Core;
|
||||
using Tnb.Vengine.Domain;
|
||||
@@ -17,6 +18,7 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
{
|
||||
private const int MAX_PAGE_SIZE = 1000;
|
||||
private static ISqlSugarClient? _db;
|
||||
private readonly ICacheManager _cache;
|
||||
|
||||
protected ISqlSugarClient Db
|
||||
{
|
||||
@@ -43,9 +45,10 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
/// <summary>
|
||||
/// 构造
|
||||
/// </summary>
|
||||
public DataAccess(IUserManager currentUser)
|
||||
public DataAccess(IUserManager currentUser, ICacheManager cache)
|
||||
{
|
||||
_user = currentUser;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -116,11 +119,17 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
/// </summary>
|
||||
public async Task<Vmodel> GetVmodelAsync(string id, bool loadNavigate = false)
|
||||
{
|
||||
Vmodel vm = await Db.Queryable<Vmodel>().FirstAsync(a => a.id == id && a.deleted == 0);
|
||||
ThrowIf.IsNull(vm, $"找不到id={id}的模型");
|
||||
if (loadNavigate)
|
||||
var key = $"tnb.vmodel:{id}";
|
||||
var vm = await _cache.GetAsync<Vmodel>(key);
|
||||
if (vm == null)
|
||||
{
|
||||
await LoadVmodelNavigateAsync(vm);
|
||||
vm = await Db.Queryable<Vmodel>().FirstAsync(a => a.id == id && a.deleted == 0);
|
||||
ThrowIf.IsNull(vm, $"找不到id={id}的模型");
|
||||
if (loadNavigate)
|
||||
{
|
||||
await LoadVmodelNavigateAsync(vm);
|
||||
}
|
||||
await _cache.SetAsync(id, vm, TimeSpan.FromMinutes(10));
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
Reference in New Issue
Block a user