Compare commits
No commits in common. "c1e0665826a7a8464e772265be7b3a8fa7dc5938" and "73134b736a18fe294c7b9183bc1aa9333ea631c1" have entirely different histories.
c1e0665826
...
73134b736a
|
@ -1,37 +1,57 @@
|
|||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using BZPT.Api.Middleware;
|
||||
using BZPT.Domains.IRepositories;
|
||||
using BZPT.Repositories;
|
||||
using IGeekFan.AspNetCore.Knife4jUI;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Newtonsoft.Json;
|
||||
using NPlatform.API;
|
||||
using NPlatform.Infrastructure.Config;
|
||||
//using Hangfire;
|
||||
//using Hangfire.Redis.StackExchange;
|
||||
//using Hangfire.Dashboard.BasicAuthorization;
|
||||
using NPlatform.Infrastructure.IdGenerators;
|
||||
using NPlatform.Middleware;
|
||||
using NPlatform.Repositories;
|
||||
using Serilog;
|
||||
using Serilog.Context;
|
||||
using ServiceStack;
|
||||
using SqlSugar;
|
||||
using StackExchange.Redis;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NPlatform.Infrastructure.Config;
|
||||
using NPlatform.Middleware;
|
||||
using NPlatform.API;
|
||||
using NPlatform.DI;
|
||||
using NPlatform.Repositories;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
using IGeekFan.AspNetCore.Knife4jUI;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using IdentityServer4.Configuration;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using BZPT.Repositories;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using NPlatform.Infrastructure.Config.Section;
|
||||
using ServiceStack;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Hangfire;
|
||||
using Hangfire.Redis.StackExchange;
|
||||
using Hangfire.Dashboard.BasicAuthorization;
|
||||
using BZPT.Domains.Application;
|
||||
using System.Security.Claims;
|
||||
using NPlatform.Infrastructure.IdGenerators;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using StackExchange.Redis;
|
||||
using BZPT.Api.Middleware;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog.Context;
|
||||
using Serilog;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using BZPT.Domains.IRepositories;
|
||||
using BZPT.Domains.IService.Sys;
|
||||
using BZPT.Api;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var serviceConfig = builder.Configuration.GetServiceConfig();
|
||||
|
@ -50,20 +70,20 @@ var redisConfig = builder.Configuration.GetRedisConfig();
|
|||
//从配置获取 Redis 连接字符串
|
||||
var redisConn = $"{redisConfig.Connections?.FirstOrDefault()},password={redisConfig.Password}";
|
||||
Console.WriteLine("redis 连接:" + redisConn);
|
||||
//// 配置 Hangfire
|
||||
//builder.Services.AddHangfire(x =>
|
||||
//{
|
||||
// x.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||
// .UseSimpleAssemblyNameTypeSerializer()
|
||||
// .UseRecommendedSerializerSettings()
|
||||
// .UseRedisStorage(redisConn, new RedisStorageOptions
|
||||
// {
|
||||
// Db = 11,
|
||||
// Prefix = "Hangfire:"
|
||||
// });
|
||||
//});
|
||||
// 配置 Hangfire
|
||||
builder.Services.AddHangfire(x =>
|
||||
{
|
||||
x.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||
.UseSimpleAssemblyNameTypeSerializer()
|
||||
.UseRecommendedSerializerSettings()
|
||||
.UseRedisStorage(redisConn, new RedisStorageOptions
|
||||
{
|
||||
Db = 11,
|
||||
Prefix = "Hangfire:"
|
||||
});
|
||||
});
|
||||
|
||||
//builder.Services.AddHangfireServer();
|
||||
builder.Services.AddHangfireServer();
|
||||
|
||||
// 连接到 Redis
|
||||
var connectionMultiplexer = ConnectionMultiplexer.Connect(redisConn);
|
||||
|
@ -194,7 +214,7 @@ builder.Services.AddAuthentication(options =>
|
|||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateAudience = true, // 验证 Audience
|
||||
ValidAudiences = new string[] { serviceConfig.ServiceID }, // 或者 "api.BZPT",取决于你的 API 需要验证哪个 Audience
|
||||
ValidAudiences =new string[] { serviceConfig.ServiceID }, // 或者 "api.BZPT",取决于你的 API 需要验证哪个 Audience
|
||||
ValidateIssuer = true, // 验证 Issuer
|
||||
ValidIssuer = builder.Configuration["AuthorityServer"], // 确保与 IdentityServer4 的 Issuer 配置一致
|
||||
ValidateLifetime = true,
|
||||
|
|
|
@ -41,6 +41,13 @@
|
|||
"CERT_PASSWORD": "ydl825913",
|
||||
"ConsulServer": "http://localhost:8500",
|
||||
"AllowedOrigins": "http://localhost:19901,http://192.168.0.100:40000",
|
||||
"AuthorityServer": "https://192.168.1.100:19902",
|
||||
"AllowedHosts": "*",
|
||||
"Urls": "http://0.0.0.0:19901",
|
||||
"RedisConfig": {
|
||||
"RedisType": "Normal",
|
||||
"Connections": [ "redismy:6379" ],
|
||||
"dbNum": 10,
|
||||
"Password": "redis&&!123"
|
||||
}
|
||||
}
|
|
@ -33,5 +33,6 @@
|
|||
"AllowedOrigins": "http://localhost:19901,http://localhost:3000,http://localhost:5173",
|
||||
"AllowedHosts": "*",
|
||||
"RetryCount": 10,
|
||||
"AuthorityServer": "https://106.52.199.114:8001",
|
||||
"SystemHome": "https://106.52.199.114:8000/"
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
"Url": "http://*:19901"
|
||||
},
|
||||
"Https": {
|
||||
"Url": "https://*:19902"
|
||||
"Url": "https://*:8001"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -46,10 +46,7 @@
|
|||
"AllowedOrigins": "http://localhost:19901,http://localhost:3000,http://localhost:5173",
|
||||
"AllowedHosts": "*",
|
||||
"RetryCount": 10,
|
||||
"REDIS_HOST": "localhost",
|
||||
"REDIS_PASSWORD": "redis&&!123",
|
||||
"REDIS_DBNUM": "1",
|
||||
"AuthorityServer": "https://localhost:19901/",
|
||||
"AuthorityServer": "https://106.52.199.114:8001/",
|
||||
"SystemHome": "https://106.52.199.114:8000/",
|
||||
"Hangfire": {
|
||||
"AdminPassword": "HNjt123~"
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
using BZPT.Repositories;
|
||||
using BZPT.Domains.IRepositories.Sys;
|
||||
using BZPT.Dto.Sys;
|
||||
using BZPT.Repositories;
|
||||
using Consul.Filtering;
|
||||
using DevExtreme.AspNet.Data;
|
||||
using NetTaste;
|
||||
using NPlatform.Domains.Entity;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using ServiceStack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BZPT.Domains.Services
|
||||
{
|
||||
public class SugarServiceBase<TEntity, TDto> : BaseService where TDto : BaseDto where TEntity : EntityBase<string>
|
||||
public class SugarServiceBase<TEntity,TDto> :BaseService where TDto : BaseDto where TEntity:EntityBase<string>
|
||||
{
|
||||
#region CUD
|
||||
[Autowired]
|
||||
|
@ -44,16 +56,16 @@ namespace BZPT.Domains.Services
|
|||
|
||||
public virtual async Task<INPResult> Delete(string id)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
if(string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
return new FailResult<TEntity>($"id 参数不能为空");
|
||||
}
|
||||
var rstCount = await this.Repository.RemoveAsync(t => t.Id == id);
|
||||
var rstCount = await this.Repository.RemoveAsync(t=>t.Id== id);
|
||||
return new SuccessResult<int>(rstCount);
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task<INPResult> Delete(Expression<Func<TEntity, bool>> deleteWhere)
|
||||
public virtual async Task<INPResult> Delete(Expression< Func<TEntity,bool>> deleteWhere)
|
||||
{
|
||||
var rstCount = await this.Repository.RemoveAsync(deleteWhere);
|
||||
return new SuccessResult<int>(rstCount);
|
||||
|
@ -115,12 +127,6 @@ namespace BZPT.Domains.Services
|
|||
{
|
||||
loadOptionsexp.Sort = new SortingInfo[] { new SortingInfo() { Selector = "CreateTime", Desc = true } };
|
||||
}
|
||||
|
||||
if (loadOptionsexp.Filter == null)
|
||||
{
|
||||
loadOptionsexp.Filter = new List<object>();
|
||||
}
|
||||
|
||||
Type type = typeof(TEntity);
|
||||
// 检查是否存在指定名称的接口
|
||||
Type interfaceType = type.GetInterface("ILogicDelete");
|
||||
|
@ -140,15 +146,10 @@ namespace BZPT.Domains.Services
|
|||
{
|
||||
loadOptionsexp.Sort = new SortingInfo[] { new SortingInfo() { Selector = "CreateTime", Desc = true } };
|
||||
}
|
||||
if (loadOptionsexp.Filter == null)
|
||||
{
|
||||
loadOptionsexp.Filter = new List<object>();
|
||||
}
|
||||
|
||||
Type type = typeof(TEntity);
|
||||
// 检查是否存在指定名称的接口
|
||||
Type interfaceType = type.GetInterface("ILogicDelete");
|
||||
if (interfaceType != null && !loadOptionsexp.Filter.Contains("IsDeleted"))
|
||||
if (interfaceType != null&&!loadOptionsexp.Filter.Contains("IsDeleted"))
|
||||
{
|
||||
loadOptionsexp.And(new List<object>(){
|
||||
"IsDeleted","=",false });
|
||||
|
|
Loading…
Reference in New Issue