mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:13:26 +08:00
添加项目文件。
This commit is contained in:
20
.gitee/ISSUE_TEMPLATE.zh-CN.md
Normal file
20
.gitee/ISSUE_TEMPLATE.zh-CN.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
## 请详细填写以下内容:
|
||||||
|
|
||||||
|
### 遇到问题的原因:
|
||||||
|
|
||||||
|
|
||||||
|
### 开发环境:
|
||||||
|
|
||||||
|
|
||||||
|
### 复显步骤:
|
||||||
|
|
||||||
|
|
||||||
|
### 期望达到的效果:
|
||||||
|
|
||||||
|
|
||||||
|
### 多张全屏大图:
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
如需上传图片,可直接截图后此处粘贴即可,不需要点击上传按钮上传。
|
||||||
14
.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
Normal file
14
.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## 该Pull Request关联的Issue:
|
||||||
|
|
||||||
|
### 修改描述:
|
||||||
|
|
||||||
|
|
||||||
|
### 测试用例:
|
||||||
|
|
||||||
|
|
||||||
|
### 修复效果的截屏:
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
如需上传图片,可直接截图后此处粘贴即可,不需要点击上传按钮上传。
|
||||||
246
CoreCms.Net.Auth/AuthorizationSetup.cs
Normal file
246
CoreCms.Net.Auth/AuthorizationSetup.cs
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Auth.Policys;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Db 启动服务
|
||||||
|
/// </summary>
|
||||||
|
public static class AuthorizationSetup
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 后台管理员jwt初始化设置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
public static void AddAuthorizationSetupForAdmin(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
#region 参数
|
||||||
|
//读取配置文件
|
||||||
|
var symmetricKeyAsBase64 = AppSettingsConstVars.JwtConfigSecretKey;
|
||||||
|
var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64);
|
||||||
|
var signingKey = new SymmetricSecurityKey(keyByteArray);
|
||||||
|
var issuer = AppSettingsConstVars.JwtConfigIssuer;
|
||||||
|
var audience = AppSettingsConstVars.JwtConfigAudience;
|
||||||
|
|
||||||
|
var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256);
|
||||||
|
|
||||||
|
// 如果要数据库动态绑定,这里先留个空,后边处理器里动态赋值
|
||||||
|
var permission = new List<PermissionItem>();
|
||||||
|
|
||||||
|
// 角色与接口的权限要求参数
|
||||||
|
var permissionRequirement = new PermissionRequirement(
|
||||||
|
"/api/denied",// 拒绝授权的跳转地址(目前无用)
|
||||||
|
permission,
|
||||||
|
ClaimTypes.Role,//基于角色的授权
|
||||||
|
issuer,//发行人
|
||||||
|
audience,//听众
|
||||||
|
signingCredentials,//签名凭据
|
||||||
|
expiration: TimeSpan.FromSeconds(60 * 60 * 24)//接口的过期时间
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// 复杂的策略授权
|
||||||
|
services.AddAuthorization(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy(Permissions.Name,
|
||||||
|
policy => policy.Requirements.Add(permissionRequirement));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 令牌验证参数
|
||||||
|
var tokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateIssuerSigningKey = true, //是否验证SecurityKey
|
||||||
|
IssuerSigningKey = signingKey, //拿到SecurityKey
|
||||||
|
ValidateIssuer = true, //是否验证Issuer
|
||||||
|
ValidIssuer = issuer,//发行人 //Issuer,这两项和前面签发jwt的设置一致
|
||||||
|
ValidateAudience = true, //是否验证Audience
|
||||||
|
ValidAudience = audience,//订阅人
|
||||||
|
ValidateLifetime = true,//是否验证失效时间
|
||||||
|
ClockSkew = TimeSpan.FromSeconds(60),
|
||||||
|
RequireExpirationTime = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
// core自带官方JWT认证,开启Bearer认证
|
||||||
|
services.AddAuthentication(o =>
|
||||||
|
{
|
||||||
|
o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
o.DefaultChallengeScheme = nameof(ApiResponseForAdminHandler);
|
||||||
|
o.DefaultForbidScheme = nameof(ApiResponseForAdminHandler);
|
||||||
|
})
|
||||||
|
// 添加JwtBearer服务
|
||||||
|
.AddJwtBearer(o =>
|
||||||
|
{
|
||||||
|
o.TokenValidationParameters = tokenValidationParameters;
|
||||||
|
o.Events = new JwtBearerEvents
|
||||||
|
{
|
||||||
|
OnChallenge = context =>
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Error", context.ErrorDescription);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
},
|
||||||
|
OnAuthenticationFailed = context =>
|
||||||
|
{
|
||||||
|
var token = context.Request.Headers["Authorization"].ObjectToString().Replace("Bearer ", "");
|
||||||
|
var jwtToken = (new JwtSecurityTokenHandler()).ReadJwtToken(token);
|
||||||
|
|
||||||
|
if (jwtToken.Issuer != issuer)
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Error-Iss", "issuer is wrong!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jwtToken.Audiences.FirstOrDefault() != audience)
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Error-Aud", "Audience is wrong!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果过期,则把<是否过期>添加到,返回头信息中
|
||||||
|
if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Expired", "true");
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.AddScheme<AuthenticationSchemeOptions, ApiResponseForAdminHandler>(nameof(ApiResponseForAdminHandler), o => { });
|
||||||
|
|
||||||
|
|
||||||
|
// 注入权限处理器
|
||||||
|
services.AddScoped<IAuthorizationHandler, PermissionForAdminHandler>();
|
||||||
|
services.AddSingleton(permissionRequirement);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 前端客户jwt初始化设置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
public static void AddAuthorizationSetupForClient(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
#region 参数
|
||||||
|
//读取配置文件
|
||||||
|
var symmetricKeyAsBase64 = AppSettingsConstVars.JwtConfigSecretKey;
|
||||||
|
var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64);
|
||||||
|
var signingKey = new SymmetricSecurityKey(keyByteArray);
|
||||||
|
var issuer = AppSettingsConstVars.JwtConfigIssuer;
|
||||||
|
var audience = AppSettingsConstVars.JwtConfigAudience;
|
||||||
|
|
||||||
|
var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256);
|
||||||
|
|
||||||
|
// 如果要数据库动态绑定,这里先留个空,后边处理器里动态赋值
|
||||||
|
var permission = new List<PermissionItem>();
|
||||||
|
|
||||||
|
// 角色与接口的权限要求参数
|
||||||
|
var permissionRequirement = new PermissionRequirement(
|
||||||
|
"/api/denied",// 拒绝授权的跳转地址(目前无用)
|
||||||
|
permission,
|
||||||
|
ClaimTypes.Role,//基于角色的授权
|
||||||
|
issuer,//发行人
|
||||||
|
audience,//听众
|
||||||
|
signingCredentials,//签名凭据
|
||||||
|
expiration: TimeSpan.FromSeconds(60 * 60 * 24)//接口的过期时间
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// 复杂的策略授权
|
||||||
|
services.AddAuthorization(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy(Permissions.Name, policy => policy.Requirements.Add(permissionRequirement));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 令牌验证参数
|
||||||
|
var tokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateIssuerSigningKey = true, //是否验证SecurityKey
|
||||||
|
IssuerSigningKey = signingKey, //拿到SecurityKey
|
||||||
|
ValidateIssuer = true, //是否验证Issuer
|
||||||
|
ValidIssuer = issuer,//发行人
|
||||||
|
ValidateAudience = true, //是否验证Audience
|
||||||
|
ValidAudience = audience,//订阅人
|
||||||
|
ValidateLifetime = true, //是否验证失效时间
|
||||||
|
ClockSkew = TimeSpan.FromSeconds(60),
|
||||||
|
RequireExpirationTime = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
// core自带官方JWT认证,开启Bearer认证
|
||||||
|
services.AddAuthentication(o =>
|
||||||
|
{
|
||||||
|
o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
o.DefaultChallengeScheme = nameof(ApiResponseForClientHandler);
|
||||||
|
o.DefaultForbidScheme = nameof(ApiResponseForClientHandler);
|
||||||
|
})
|
||||||
|
// 添加JwtBearer服务
|
||||||
|
.AddJwtBearer(o =>
|
||||||
|
{
|
||||||
|
o.TokenValidationParameters = tokenValidationParameters;
|
||||||
|
o.Events = new JwtBearerEvents
|
||||||
|
{
|
||||||
|
OnChallenge = context =>
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Error", context.ErrorDescription);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
},
|
||||||
|
OnAuthenticationFailed = context =>
|
||||||
|
{
|
||||||
|
var token = context.Request.Headers["Authorization"].ObjectToString().Replace("Bearer ", "");
|
||||||
|
var jwtToken = (new JwtSecurityTokenHandler()).ReadJwtToken(token);
|
||||||
|
|
||||||
|
if (jwtToken.Issuer != issuer)
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Error-Iss", "issuer is wrong!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jwtToken.Audiences.FirstOrDefault() != audience)
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Error-Aud", "Audience is wrong!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果过期,则把<是否过期>添加到,返回头信息中
|
||||||
|
if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add("Token-Expired", "true");
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.AddScheme<AuthenticationSchemeOptions, ApiResponseForClientHandler>(nameof(ApiResponseForClientHandler), o => { });
|
||||||
|
|
||||||
|
|
||||||
|
// 注入权限处理器
|
||||||
|
services.AddScoped<IAuthorizationHandler, PermissionForClientHandler>();
|
||||||
|
services.AddSingleton(permissionRequirement);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
20
CoreCms.Net.Auth/CoreCms.Net.Auth.csproj
Normal file
20
CoreCms.Net.Auth/CoreCms.Net.Auth.csproj
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.13.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Configuration\CoreCms.Net.Configuration.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.IRepository\CoreCms.Net.IRepository.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.IServices\CoreCms.Net.IServices.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
33
CoreCms.Net.Auth/HttpContextSetup.cs
Normal file
33
CoreCms.Net.Auth/HttpContextSetup.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using CoreCms.Net.Auth.HttpContextUser;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 上下文启动
|
||||||
|
/// </summary>
|
||||||
|
public static class HttpContextSetup
|
||||||
|
{
|
||||||
|
public static void AddHttpContextSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
services.AddScoped<IHttpContextUser, AspNetUser>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
75
CoreCms.Net.Auth/HttpContextUser/AspNetUser.cs
Normal file
75
CoreCms.Net.Auth/HttpContextUser/AspNetUser.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.HttpContextUser
|
||||||
|
{
|
||||||
|
public class AspNetUser : IHttpContextUser
|
||||||
|
{
|
||||||
|
private readonly IHttpContextAccessor _accessor;
|
||||||
|
|
||||||
|
public AspNetUser(IHttpContextAccessor accessor)
|
||||||
|
{
|
||||||
|
_accessor = accessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name => _accessor.HttpContext.User.Identity.Name;
|
||||||
|
public int ID => GetClaimValueByType("jti").FirstOrDefault().ObjectToInt();
|
||||||
|
|
||||||
|
public bool IsAuthenticated()
|
||||||
|
{
|
||||||
|
return _accessor.HttpContext.User.Identity.IsAuthenticated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetToken()
|
||||||
|
{
|
||||||
|
return _accessor.HttpContext.Request.Headers["Authorization"].ObjectToString().Replace("Bearer ", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> GetUserInfoFromToken(string ClaimType)
|
||||||
|
{
|
||||||
|
|
||||||
|
var jwtHandler = new JwtSecurityTokenHandler();
|
||||||
|
if (!string.IsNullOrEmpty(GetToken()))
|
||||||
|
{
|
||||||
|
JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(GetToken());
|
||||||
|
|
||||||
|
return (from item in jwtToken.Claims
|
||||||
|
where item.Type == ClaimType
|
||||||
|
select item.Value).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new List<string>() { };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Claim> GetClaimsIdentity()
|
||||||
|
{
|
||||||
|
return _accessor.HttpContext.User.Claims;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> GetClaimValueByType(string ClaimType)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (from item in GetClaimsIdentity()
|
||||||
|
where item.Type == ClaimType
|
||||||
|
select item.Value).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
CoreCms.Net.Auth/HttpContextUser/IHttpContextUser.cs
Normal file
29
CoreCms.Net.Auth/HttpContextUser/IHttpContextUser.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.HttpContextUser
|
||||||
|
{
|
||||||
|
public interface IHttpContextUser
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
int ID { get; }
|
||||||
|
bool IsAuthenticated();
|
||||||
|
IEnumerable<Claim> GetClaimsIdentity();
|
||||||
|
List<string> GetClaimValueByType(string ClaimType);
|
||||||
|
|
||||||
|
string GetToken();
|
||||||
|
List<string> GetUserInfoFromToken(string ClaimType);
|
||||||
|
}
|
||||||
|
}
|
||||||
125
CoreCms.Net.Auth/OverWrite/JwtHelper.cs
Normal file
125
CoreCms.Net.Auth/OverWrite/JwtHelper.cs
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.OverWrite
|
||||||
|
{
|
||||||
|
public class JwtHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 颁发JWT字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tokenModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string IssueJwt(TokenModelJwt tokenModel)
|
||||||
|
{
|
||||||
|
string iss = AppSettingsConstVars.JwtConfigIssuer;
|
||||||
|
string aud = AppSettingsConstVars.JwtConfigAudience;
|
||||||
|
string secret = AppSettingsConstVars.JwtConfigSecretKey;
|
||||||
|
|
||||||
|
//var claims = new Claim[] //old
|
||||||
|
var claims = new List<Claim>
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 特别重要:
|
||||||
|
1、这里将用户的部分信息,比如 uid 存到了Claim 中,如果你想知道如何在其他地方将这个 uid从 Token 中取出来,请看下边的SerializeJwt() 方法,或者在整个解决方案,搜索这个方法,看哪里使用了!
|
||||||
|
2、你也可以研究下 HttpContext.User.Claims ,具体的你可以看看 Policys/PermissionHandler.cs 类中是如何使用的。
|
||||||
|
*/
|
||||||
|
|
||||||
|
new Claim(JwtRegisteredClaimNames.Jti, tokenModel.Uid.ToString()),
|
||||||
|
new Claim(JwtRegisteredClaimNames.Iat, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"),
|
||||||
|
new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
|
||||||
|
//这个就是过期时间,目前是过期1000秒,可自定义,注意JWT有自己的缓冲过期时间
|
||||||
|
new Claim (JwtRegisteredClaimNames.Exp,$"{new DateTimeOffset(DateTime.Now.AddSeconds(1000)).ToUnixTimeSeconds()}"),
|
||||||
|
new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(1000).ToString()),
|
||||||
|
new Claim(JwtRegisteredClaimNames.Iss,iss),
|
||||||
|
new Claim(JwtRegisteredClaimNames.Aud,aud)
|
||||||
|
|
||||||
|
//new Claim(ClaimTypes.Role,tokenModel.Role),//为了解决一个用户多个角色(比如:Admin,System),用下边的方法
|
||||||
|
};
|
||||||
|
|
||||||
|
// 可以将一个用户的多个角色全部赋予;
|
||||||
|
// 作者:DX 提供技术支持;
|
||||||
|
claims.AddRange(tokenModel.Role.Split(',').Select(s => new Claim(ClaimTypes.Role, s)));
|
||||||
|
|
||||||
|
//秘钥 (SymmetricSecurityKey 对安全性的要求,密钥的长度太短会报出异常)
|
||||||
|
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret));
|
||||||
|
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||||
|
|
||||||
|
var jwt = new JwtSecurityToken(
|
||||||
|
issuer: iss,
|
||||||
|
claims: claims,
|
||||||
|
signingCredentials: creds);
|
||||||
|
|
||||||
|
var jwtHandler = new JwtSecurityTokenHandler();
|
||||||
|
var encodedJwt = jwtHandler.WriteToken(jwt);
|
||||||
|
|
||||||
|
return encodedJwt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jwtStr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static TokenModelJwt SerializeJwt(string jwtStr)
|
||||||
|
{
|
||||||
|
var jwtHandler = new JwtSecurityTokenHandler();
|
||||||
|
JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(jwtStr);
|
||||||
|
object role;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jwtToken.Payload.TryGetValue(ClaimTypes.Role, out role);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
var tm = new TokenModelJwt
|
||||||
|
{
|
||||||
|
Uid = (jwtToken.Id).ObjectToInt(),
|
||||||
|
Role = role != null ? role.ObjectToString() : ""
|
||||||
|
};
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 令牌
|
||||||
|
/// </summary>
|
||||||
|
public class TokenModelJwt
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id
|
||||||
|
/// </summary>
|
||||||
|
public long Uid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 角色
|
||||||
|
/// </summary>
|
||||||
|
public string Role { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 职能
|
||||||
|
/// </summary>
|
||||||
|
public string Work { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
96
CoreCms.Net.Auth/OverWrite/JwtTokenAuth.cs
Normal file
96
CoreCms.Net.Auth/OverWrite/JwtTokenAuth.cs
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.OverWrite
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 中间件
|
||||||
|
/// 原做为自定义授权中间件
|
||||||
|
/// 先做检查 header token的使用
|
||||||
|
/// </summary>
|
||||||
|
public class JwtTokenAuth
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
private readonly RequestDelegate _next;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="next"></param>
|
||||||
|
public JwtTokenAuth(RequestDelegate next)
|
||||||
|
{
|
||||||
|
_next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void PreProceed(HttpContext next)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"{DateTime.Now} middleware invoke preproceed");
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
private void PostProceed(HttpContext next)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"{DateTime.Now} middleware invoke postproceed");
|
||||||
|
//....
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpContext"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task Invoke(HttpContext httpContext)
|
||||||
|
{
|
||||||
|
PreProceed(httpContext);
|
||||||
|
|
||||||
|
//检测是否包含'Authorization'请求头
|
||||||
|
if (!httpContext.Request.Headers.ContainsKey("Authorization"))
|
||||||
|
{
|
||||||
|
PostProceed(httpContext);
|
||||||
|
|
||||||
|
return _next(httpContext);
|
||||||
|
}
|
||||||
|
//var tokenHeader = httpContext.Request.Headers["Authorization"].ToString();
|
||||||
|
var tokenHeader = httpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (tokenHeader.Length >= 128)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"{DateTime.Now} token :{tokenHeader}");
|
||||||
|
TokenModelJwt tm = JwtHelper.SerializeJwt(tokenHeader);
|
||||||
|
//授权
|
||||||
|
//var claimList = new List<Claim>();
|
||||||
|
//var claim = new Claim(ClaimTypes.Role, tm.Role);
|
||||||
|
//claimList.Add(claim);
|
||||||
|
//var identity = new ClaimsIdentity(claimList);
|
||||||
|
//var principal = new ClaimsPrincipal(identity);
|
||||||
|
//httpContext.User = principal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{DateTime.Now} middleware wrong:{e.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
PostProceed(httpContext);
|
||||||
|
return _next(httpContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
56
CoreCms.Net.Auth/Policys/ApiResponse.cs
Normal file
56
CoreCms.Net.Auth/Policys/ApiResponse.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
public class ApiResponse
|
||||||
|
{
|
||||||
|
public int Status { get; set; } = 404;
|
||||||
|
public object Value { get; set; } = "No Found";
|
||||||
|
|
||||||
|
public ApiResponse(StatusCode apiCode, object msg = null)
|
||||||
|
{
|
||||||
|
switch (apiCode)
|
||||||
|
{
|
||||||
|
case StatusCode.CODE401:
|
||||||
|
{
|
||||||
|
Status = 401;
|
||||||
|
Value = "很抱歉,您无权访问该接口,请确保已经登录!";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case StatusCode.CODE403:
|
||||||
|
{
|
||||||
|
Status = 403;
|
||||||
|
Value = "很抱歉,您的访问权限等级不够,联系管理员!";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case StatusCode.CODE500:
|
||||||
|
{
|
||||||
|
Status = 500;
|
||||||
|
Value = msg;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum StatusCode
|
||||||
|
{
|
||||||
|
CODE401,
|
||||||
|
CODE403,
|
||||||
|
CODE404,
|
||||||
|
CODE500
|
||||||
|
}
|
||||||
|
}
|
||||||
62
CoreCms.Net.Auth/Policys/ApiResponseForAdminHandler.cs
Normal file
62
CoreCms.Net.Auth/Policys/ApiResponseForAdminHandler.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
public class ApiResponseForAdminHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||||
|
{
|
||||||
|
public ApiResponseForAdminHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
protected override async Task HandleChallengeAsync(AuthenticationProperties properties)
|
||||||
|
{
|
||||||
|
Response.ContentType = "application/json";
|
||||||
|
//Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||||
|
//await Response.WriteAsync(JsonConvert.SerializeObject(new ApiResponse(StatusCode.CODE401)));
|
||||||
|
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
jm.code = 401;
|
||||||
|
jm.data = 401;
|
||||||
|
jm.msg = "很抱歉,您无权访问该接口,请确保已经登录!";
|
||||||
|
await Response.WriteAsync(JsonConvert.SerializeObject(jm));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task HandleForbiddenAsync(AuthenticationProperties properties)
|
||||||
|
{
|
||||||
|
Response.ContentType = "application/json";
|
||||||
|
//Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||||
|
//await Response.WriteAsync(JsonConvert.SerializeObject(new ApiResponse(StatusCode.CODE403)));
|
||||||
|
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
jm.code = 403;
|
||||||
|
jm.msg = "很抱歉,您的访问权限等级不够,联系管理员!!";
|
||||||
|
await Response.WriteAsync(JsonConvert.SerializeObject(jm));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
65
CoreCms.Net.Auth/Policys/ApiResponseForClientHandler.cs
Normal file
65
CoreCms.Net.Auth/Policys/ApiResponseForClientHandler.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
public class ApiResponseForClientHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||||
|
{
|
||||||
|
public ApiResponseForClientHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
protected override async Task HandleChallengeAsync(AuthenticationProperties properties)
|
||||||
|
{
|
||||||
|
Response.ContentType = "application/json";
|
||||||
|
//Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||||
|
//await Response.WriteAsync(JsonConvert.SerializeObject(new ApiResponse(StatusCode.CODE401)));
|
||||||
|
|
||||||
|
var jm = new WebApiCallBack();
|
||||||
|
jm.status = false;
|
||||||
|
jm.code = 14007;
|
||||||
|
jm.data = 14007;
|
||||||
|
jm.msg = "很抱歉,授权失效,请重新登录!";
|
||||||
|
await Response.WriteAsync(JsonConvert.SerializeObject(jm));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task HandleForbiddenAsync(AuthenticationProperties properties)
|
||||||
|
{
|
||||||
|
Response.ContentType = "application/json";
|
||||||
|
//Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||||
|
//await Response.WriteAsync(JsonConvert.SerializeObject(new ApiResponse(StatusCode.CODE403)));
|
||||||
|
|
||||||
|
var jm = new WebApiCallBack();
|
||||||
|
jm.status = false;
|
||||||
|
jm.code = 14007;
|
||||||
|
jm.data = 14007;
|
||||||
|
jm.msg = "很抱歉,授权失效,请重新登录!";
|
||||||
|
await Response.WriteAsync(JsonConvert.SerializeObject(jm));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
56
CoreCms.Net.Auth/Policys/JwtToken.cs
Normal file
56
CoreCms.Net.Auth/Policys/JwtToken.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// JWTToken生成类
|
||||||
|
/// </summary>
|
||||||
|
public class JwtToken
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取基于JWT的Token
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="claims">需要在登陆的时候配置</param>
|
||||||
|
/// <param name="permissionRequirement">在startup中定义的参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static dynamic BuildJwtToken(Claim[] claims, PermissionRequirement permissionRequirement)
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
// 实例化JwtSecurityToken
|
||||||
|
var jwt = new JwtSecurityToken(
|
||||||
|
issuer: permissionRequirement.Issuer,
|
||||||
|
audience: permissionRequirement.Audience,
|
||||||
|
claims: claims,
|
||||||
|
notBefore: now,
|
||||||
|
expires: now.Add(permissionRequirement.Expiration),
|
||||||
|
signingCredentials: permissionRequirement.SigningCredentials
|
||||||
|
);
|
||||||
|
// 生成 Token
|
||||||
|
var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt);
|
||||||
|
|
||||||
|
//打包返回前台
|
||||||
|
var responseJson = new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
token = encodedJwt,
|
||||||
|
expires_in = permissionRequirement.Expiration.TotalSeconds,
|
||||||
|
token_type = "Bearer"
|
||||||
|
};
|
||||||
|
return responseJson;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
210
CoreCms.Net.Auth/Policys/PermissionForAdminHandler.cs
Normal file
210
CoreCms.Net.Auth/Policys/PermissionForAdminHandler.cs
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using CoreCms.Net.Utility.Helper;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 权限授权处理器
|
||||||
|
/// </summary>
|
||||||
|
public class PermissionForAdminHandler : AuthorizationHandler<PermissionRequirement>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 验证方案提供对象
|
||||||
|
/// </summary>
|
||||||
|
public IAuthenticationSchemeProvider Schemes { get; set; }
|
||||||
|
private readonly ISysRoleMenuServices _sysRoleMenuServices;
|
||||||
|
private readonly IHttpContextAccessor _accessor;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数注入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="schemes"></param>
|
||||||
|
/// <param name="navigationRepository"></param>
|
||||||
|
/// <param name="accessor"></param>
|
||||||
|
public PermissionForAdminHandler(IAuthenticationSchemeProvider schemes
|
||||||
|
, ISysRoleMenuServices sysRoleMenuServices
|
||||||
|
, IHttpContextAccessor accessor)
|
||||||
|
{
|
||||||
|
_accessor = accessor;
|
||||||
|
Schemes = schemes;
|
||||||
|
_sysRoleMenuServices = sysRoleMenuServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重写异步处理程序
|
||||||
|
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
|
||||||
|
{
|
||||||
|
|
||||||
|
var httpContext = _accessor.HttpContext;
|
||||||
|
|
||||||
|
if (!requirement.Permissions.Any())
|
||||||
|
{
|
||||||
|
var data = await _sysRoleMenuServices.RoleModuleMaps();
|
||||||
|
var list = new List<PermissionItem>();
|
||||||
|
|
||||||
|
if (Permissions.IsUseIds4)
|
||||||
|
{
|
||||||
|
list = (from item in data
|
||||||
|
orderby item.id
|
||||||
|
select new PermissionItem
|
||||||
|
{
|
||||||
|
Url = item.menu?.component,
|
||||||
|
RouteUrl = item.menu?.path,
|
||||||
|
Authority = item.menu?.authority,
|
||||||
|
Role = item.role?.id.ObjectToString(),
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list = (from item in data
|
||||||
|
orderby item.id
|
||||||
|
select new PermissionItem
|
||||||
|
{
|
||||||
|
Url = item.menu?.component,
|
||||||
|
RouteUrl = item.menu?.path,
|
||||||
|
Authority = item.menu?.authority,
|
||||||
|
Role = item.role?.roleCode,
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
requirement.Permissions = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//请求Url
|
||||||
|
if (httpContext != null)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var questUrl = httpContext.Request.Path.Value.ToLower();
|
||||||
|
//判断请求是否停止
|
||||||
|
var handlers = httpContext.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>();
|
||||||
|
foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync())
|
||||||
|
{
|
||||||
|
if (await handlers.GetHandlerAsync(httpContext, scheme.Name) is IAuthenticationRequestHandler handler && await handler.HandleRequestAsync())
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断请求是否拥有凭据,即有没有登录
|
||||||
|
var defaultAuthenticate = await Schemes.GetDefaultAuthenticateSchemeAsync();
|
||||||
|
if (defaultAuthenticate != null)
|
||||||
|
{
|
||||||
|
var result = await httpContext.AuthenticateAsync(defaultAuthenticate.Name);
|
||||||
|
//result?.Principal不为空即登录成功
|
||||||
|
if (result?.Principal != null)
|
||||||
|
{
|
||||||
|
httpContext.User = result.Principal;
|
||||||
|
|
||||||
|
// 获取当前用户的角色信息
|
||||||
|
var currentUserRoles = new List<string>();
|
||||||
|
|
||||||
|
// ids4和jwt切换
|
||||||
|
// ids4
|
||||||
|
if (Permissions.IsUseIds4)
|
||||||
|
{
|
||||||
|
currentUserRoles = (from item in httpContext.User.Claims
|
||||||
|
where item.Type == "role"
|
||||||
|
select item.Value).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// jwt
|
||||||
|
currentUserRoles = (from item in httpContext.User.Claims
|
||||||
|
where item.Type == requirement.ClaimType
|
||||||
|
select item.Value).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
var isMatchRole = false;
|
||||||
|
var permisssionRoles = requirement.Permissions.Where(w => currentUserRoles.Contains(w.Role));
|
||||||
|
foreach (var item in permisssionRoles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//权限中是否存在请求的url
|
||||||
|
if (Regex.Match(questUrl, item.Url.ObjectToString().ToLower()).Value == questUrl)
|
||||||
|
{
|
||||||
|
isMatchRole = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证权限
|
||||||
|
if (currentUserRoles.Count <= 0 || !isMatchRole)
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var isExp = false;
|
||||||
|
|
||||||
|
// ids4和jwt切换
|
||||||
|
// ids4
|
||||||
|
if (Permissions.IsUseIds4)
|
||||||
|
{
|
||||||
|
isExp = (httpContext.User.Claims.SingleOrDefault(s => s.Type == "exp")?.Value) != null && DateHelper.StampToDateTime(httpContext.User.Claims.SingleOrDefault(s => s.Type == "exp")?.Value) >= DateTime.Now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// jwt
|
||||||
|
isExp = (httpContext.User.Claims.SingleOrDefault(s => s.Type == ClaimTypes.Expiration)?.Value) != null && DateTime.Parse(httpContext.User.Claims.SingleOrDefault(s => s.Type == ClaimTypes.Expiration)?.Value) >= DateTime.Now;
|
||||||
|
}
|
||||||
|
if (isExp)
|
||||||
|
{
|
||||||
|
context.Succeed(requirement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//判断没有登录时,是否访问登录的url,并且是Post请求,并且是form表单提交类型,否则为失败
|
||||||
|
//if (!questUrl.Equals(requirement.LoginPath.ToLower(), StringComparison.Ordinal) && (!httpContext.Request.Method.Equals("POST") || !httpContext.Request.HasJsonContentType()))
|
||||||
|
//{
|
||||||
|
// context.Fail();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Succeed(requirement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
182
CoreCms.Net.Auth/Policys/PermissionForClientHandler.cs
Normal file
182
CoreCms.Net.Auth/Policys/PermissionForClientHandler.cs
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 权限授权处理器
|
||||||
|
/// </summary>
|
||||||
|
public class PermissionForClientHandler : AuthorizationHandler<PermissionRequirement>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 验证方案提供对象
|
||||||
|
/// </summary>
|
||||||
|
public IAuthenticationSchemeProvider Schemes { get; set; }
|
||||||
|
private readonly IHttpContextAccessor _accessor;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数注入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="schemes"></param>
|
||||||
|
/// <param name="navigationRepository"></param>
|
||||||
|
/// <param name="accessor"></param>
|
||||||
|
public PermissionForClientHandler(IAuthenticationSchemeProvider schemes, IHttpContextAccessor accessor)
|
||||||
|
{
|
||||||
|
_accessor = accessor;
|
||||||
|
Schemes = schemes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重写异步处理程序
|
||||||
|
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
|
||||||
|
{
|
||||||
|
|
||||||
|
var httpContext = _accessor.HttpContext;
|
||||||
|
|
||||||
|
if (!requirement.Permissions.Any())
|
||||||
|
{
|
||||||
|
//var data = await _navigationRepository.QueryAsync();
|
||||||
|
//var list = (from item in data
|
||||||
|
// where item.isLock == false
|
||||||
|
// orderby item.id
|
||||||
|
// select new PermissionItem
|
||||||
|
// {
|
||||||
|
// Url = item.linkUrl,
|
||||||
|
// Role = item.identificationCode,
|
||||||
|
// }).ToList();
|
||||||
|
//requirement.Permissions = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//请求Url
|
||||||
|
if (httpContext != null)
|
||||||
|
{
|
||||||
|
var questUrl = httpContext.Request.Path.Value.ToLower();
|
||||||
|
//判断请求是否停止
|
||||||
|
var handlers = httpContext.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>();
|
||||||
|
foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync())
|
||||||
|
{
|
||||||
|
if (await handlers.GetHandlerAsync(httpContext, scheme.Name) is IAuthenticationRequestHandler handler && await handler.HandleRequestAsync())
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断请求是否拥有凭据,即有没有登录
|
||||||
|
var defaultAuthenticate = await Schemes.GetDefaultAuthenticateSchemeAsync();
|
||||||
|
if (defaultAuthenticate != null)
|
||||||
|
{
|
||||||
|
var result = await httpContext.AuthenticateAsync(defaultAuthenticate.Name);
|
||||||
|
//result?.Principal不为空即登录成功
|
||||||
|
if (result?.Principal != null)
|
||||||
|
{
|
||||||
|
// 将最新的角色和接口列表更新
|
||||||
|
|
||||||
|
// 这里暂时把代码移动到了Login获取token的api里,这样就不用每次都请求数据库,造成压力.
|
||||||
|
// 但是这样有个问题,就是如果修改了某一个角色的菜单权限,不会立刻更新,
|
||||||
|
// 需要让用户退出重新登录,如果你想实时更新,请把下边的注释打开即可.
|
||||||
|
|
||||||
|
//var data = await _roleModulePermissionServices.RoleModuleMaps();
|
||||||
|
//var list = (from item in data
|
||||||
|
// where item.IsDeleted == false
|
||||||
|
// orderby item.Id
|
||||||
|
// select new PermissionItem
|
||||||
|
// {
|
||||||
|
// Url = item.Module?.LinkUrl,
|
||||||
|
// Role = item.Role?.Name,
|
||||||
|
// }).ToList();
|
||||||
|
//requirement.Permissions = list;
|
||||||
|
|
||||||
|
httpContext.User = result.Principal;
|
||||||
|
|
||||||
|
//权限中是否存在请求的url
|
||||||
|
//if (requirement.Permissions.GroupBy(g => g.Url).Where(w => w.Key?.ToLower() == questUrl).Count() > 0)
|
||||||
|
//if (isMatchUrl)
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
// 获取当前用户的角色信息
|
||||||
|
var currentUserRoles = (from item in httpContext.User.Claims
|
||||||
|
where item.Type == requirement.ClaimType
|
||||||
|
select item.Value).ToList();
|
||||||
|
|
||||||
|
var isMatchRole = false;
|
||||||
|
var permisssionRoles = requirement.Permissions.Where(w => currentUserRoles.Contains(w.Role));
|
||||||
|
foreach (var item in permisssionRoles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Regex.Match(questUrl, item.Url?.ObjectToString().ToLower())?.Value == questUrl)
|
||||||
|
{
|
||||||
|
isMatchRole = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证权限
|
||||||
|
//if (currentUserRoles.Count <= 0 || requirement.Permissions.Where(w => currentUserRoles.Contains(w.Role) && w.Url.ToLower() == questUrl).Count() <= 0)
|
||||||
|
if (currentUserRoles.Count <= 0 || !isMatchRole)
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断过期时间(这里仅仅是最坏验证原则,你可以不要这个if else的判断,因为我们使用的官方验证,Token过期后上边的result?.Principal 就为 null 了,进不到这里了,因此这里其实可以不用验证过期时间,只是做最后严谨判断)
|
||||||
|
if ((httpContext.User.Claims.SingleOrDefault(s => s.Type == ClaimTypes.Expiration)?.Value) != null && DateTime.Parse(httpContext.User.Claims.SingleOrDefault(s => s.Type == ClaimTypes.Expiration)?.Value) >= DateTime.Now)
|
||||||
|
{
|
||||||
|
context.Succeed(requirement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//判断没有登录时,是否访问登录的url,并且是Post请求,并且是form表单提交类型,否则为失败
|
||||||
|
//if (!questUrl.Equals(requirement.LoginPath.ToLower(), StringComparison.Ordinal) && (!httpContext.Request.Method.Equals("POST") || !httpContext.Request.HasJsonContentType()))
|
||||||
|
//{
|
||||||
|
// context.Fail();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Succeed(requirement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
CoreCms.Net.Auth/Policys/PermissionItem.cs
Normal file
40
CoreCms.Net.Auth/Policys/PermissionItem.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户或角色或其他凭据实体
|
||||||
|
/// </summary>
|
||||||
|
public class PermissionItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户或角色或其他凭据名称
|
||||||
|
/// </summary>
|
||||||
|
public virtual string Role { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 请求Url
|
||||||
|
/// </summary>
|
||||||
|
public virtual string Url { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 权限标识
|
||||||
|
/// </summary>
|
||||||
|
public virtual string Authority { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 路由标识Url
|
||||||
|
/// </summary>
|
||||||
|
public virtual string RouteUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
83
CoreCms.Net.Auth/Policys/PermissionRequirement.cs
Normal file
83
CoreCms.Net.Auth/Policys/PermissionRequirement.cs
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth.Policys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必要参数类
|
||||||
|
/// 继承 IAuthorizationRequirement,用于设计自定义权限处理器PermissionHandler
|
||||||
|
/// 因为AuthorizationHandler 中的泛型参数 TRequirement 必须继承 IAuthorizationRequirement
|
||||||
|
/// </summary>
|
||||||
|
public class PermissionRequirement : IAuthorizationRequirement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户权限集合,一个订单包含了很多详情,
|
||||||
|
/// 同理,一个网站的认证发行中,也有很多权限详情(这里是Role和URL的关系)
|
||||||
|
/// </summary>
|
||||||
|
public List<PermissionItem> Permissions { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 无权限action
|
||||||
|
/// </summary>
|
||||||
|
public string DeniedAction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 认证授权类型
|
||||||
|
/// </summary>
|
||||||
|
public string ClaimType { internal get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 请求路径
|
||||||
|
/// </summary>
|
||||||
|
public string LoginPath { get; set; } = "/Api/Login";
|
||||||
|
/// <summary>
|
||||||
|
/// 发行人
|
||||||
|
/// </summary>
|
||||||
|
public string Issuer { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 订阅人
|
||||||
|
/// </summary>
|
||||||
|
public string Audience { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 过期时间
|
||||||
|
/// </summary>
|
||||||
|
public TimeSpan Expiration { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 签名验证
|
||||||
|
/// </summary>
|
||||||
|
public SigningCredentials SigningCredentials { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deniedAction">拒约请求的url</param>
|
||||||
|
/// <param name="permissions">权限集合</param>
|
||||||
|
/// <param name="claimType">声明类型</param>
|
||||||
|
/// <param name="issuer">发行人</param>
|
||||||
|
/// <param name="audience">订阅人</param>
|
||||||
|
/// <param name="signingCredentials">签名验证实体</param>
|
||||||
|
/// <param name="expiration">过期时间</param>
|
||||||
|
public PermissionRequirement(string deniedAction, List<PermissionItem> permissions, string claimType, string issuer, string audience, SigningCredentials signingCredentials, TimeSpan expiration)
|
||||||
|
{
|
||||||
|
ClaimType = claimType;
|
||||||
|
DeniedAction = deniedAction;
|
||||||
|
Permissions = permissions;
|
||||||
|
Issuer = issuer;
|
||||||
|
Audience = audience;
|
||||||
|
Expiration = expiration;
|
||||||
|
SigningCredentials = signingCredentials;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
131
CoreCms.Net.Auth/TokenHelper.cs
Normal file
131
CoreCms.Net.Auth/TokenHelper.cs
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Auth
|
||||||
|
{
|
||||||
|
public class TokenHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Use the below code to generate symmetric Secret Key
|
||||||
|
/// var hmac = new HMACSHA256();
|
||||||
|
/// var key = Convert.ToBase64String(hmac.Key);
|
||||||
|
/// </summary>
|
||||||
|
private const string Secret = "db3OIsj+BXE9NZDy0t8W3TcNekrF+2d/1sFnWG4HnV8TZY30iTOdtVWJG8abWvB1GlOgJuQZdcF2Luqm/hccMw==";
|
||||||
|
public static string GenerateToken(string username, int expireMinutes = 120)
|
||||||
|
{ // 此方法用来生成 Token
|
||||||
|
var symmetricKey = Convert.FromBase64String(Secret); // 生成二进制字节数组
|
||||||
|
var tokenHandler = new JwtSecurityTokenHandler(); // 创建一个JwtSecurityTokenHandler类用来生成Token
|
||||||
|
var now = DateTime.UtcNow; // 获取当前时间
|
||||||
|
var tokenDescriptor = new SecurityTokenDescriptor // 创建一个 Token 的原始对象
|
||||||
|
{
|
||||||
|
Subject = new ClaimsIdentity(new[] // Token的身份证,类似一个人可以有身份证,户口本
|
||||||
|
{
|
||||||
|
new Claim(ClaimTypes.Name, username) // 可以创建多个
|
||||||
|
}),
|
||||||
|
|
||||||
|
Expires = now.AddMinutes(Convert.ToInt32(expireMinutes)), // Token 有效期
|
||||||
|
|
||||||
|
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey), SecurityAlgorithms.HmacSha256)
|
||||||
|
// 生成一个Token证书,第一个参数是根据预先的二进制字节数组生成一个安全秘钥,说白了就是密码,第二个参数是编码方式
|
||||||
|
};
|
||||||
|
var stoken = tokenHandler.CreateToken(tokenDescriptor); // 生成一个编码后的token对象实例
|
||||||
|
var token = tokenHandler.WriteToken(stoken); // 生成token字符串,给前端使用
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
public static ClaimsPrincipal GetPrincipal(string token)
|
||||||
|
{ // 此方法用解码字符串token,并返回秘钥的信息对象
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tokenHandler = new JwtSecurityTokenHandler(); // 创建一个JwtSecurityTokenHandler类,用来后续操作
|
||||||
|
var jwtToken = tokenHandler.ReadToken(token) as JwtSecurityToken; // 将字符串token解码成token对象
|
||||||
|
if (jwtToken == null)
|
||||||
|
return null;
|
||||||
|
var symmetricKey = Convert.FromBase64String(Secret); // 生成编码对应的字节数组
|
||||||
|
var validationParameters = new TokenValidationParameters() // 生成验证token的参数
|
||||||
|
{
|
||||||
|
RequireExpirationTime = true, // token是否包含有效期
|
||||||
|
ValidateIssuer = false, // 验证秘钥发行人,如果要验证在这里指定发行人字符串即可
|
||||||
|
ValidateAudience = false, // 验证秘钥的接受人,如果要验证在这里提供接收人字符串即可
|
||||||
|
IssuerSigningKey = new SymmetricSecurityKey(symmetricKey) // 生成token时的安全秘钥
|
||||||
|
};
|
||||||
|
SecurityToken securityToken; // 接受解码后的token对象
|
||||||
|
var principal = tokenHandler.ValidateToken(token, validationParameters, out securityToken);
|
||||||
|
return principal; // 返回秘钥的主体对象,包含秘钥的所有相关信息
|
||||||
|
}
|
||||||
|
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 此方法用解码字符串token,并返回秘钥的信息对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetUserIdBySecurityToken(string token)
|
||||||
|
{
|
||||||
|
//读取配置文件
|
||||||
|
var symmetricKeyAsBase64 = AppSettingsConstVars.JwtConfigSecretKey;
|
||||||
|
var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64);
|
||||||
|
var signingKey = new SymmetricSecurityKey(keyByteArray);
|
||||||
|
var issuer = AppSettingsConstVars.JwtConfigIssuer;
|
||||||
|
var audience = AppSettingsConstVars.JwtConfigAudience;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tokenHandler = new JwtSecurityTokenHandler(); // 创建一个JwtSecurityTokenHandler类,用来后续操作
|
||||||
|
var jwtToken = tokenHandler.ReadToken(token) as JwtSecurityToken; // 将字符串token解码成token对象
|
||||||
|
if (jwtToken == null)
|
||||||
|
return 0;
|
||||||
|
var validationParameters = new TokenValidationParameters() // 生成验证token的参数
|
||||||
|
{
|
||||||
|
ValidateIssuerSigningKey = true, //是否验证SecurityKey
|
||||||
|
IssuerSigningKey = signingKey, //拿到SecurityKey
|
||||||
|
ValidateIssuer = true, //是否验证Issuer
|
||||||
|
ValidIssuer = issuer,//发行人 //Issuer,这两项和前面签发jwt的设置一致
|
||||||
|
ValidateAudience = true, //是否验证Audience
|
||||||
|
ValidAudience = audience,//订阅人
|
||||||
|
ValidateLifetime = true,//是否验证失效时间
|
||||||
|
ClockSkew = TimeSpan.FromSeconds(60),
|
||||||
|
RequireExpirationTime = true,
|
||||||
|
};
|
||||||
|
SecurityToken securityToken; // 接受解码后的token对象
|
||||||
|
var principal = tokenHandler.ValidateToken(token, validationParameters, out securityToken);
|
||||||
|
|
||||||
|
if (securityToken == null || string.IsNullOrEmpty(securityToken.Id))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return Convert.ToInt32(securityToken.Id); // 返回秘钥的主体对象,包含秘钥的所有相关信息
|
||||||
|
}
|
||||||
|
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/7/13 21:58:04
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Caching.Manual;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.AccressToken
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 微信帮助类
|
||||||
|
/// </summary>
|
||||||
|
public static class WeChatCacheAccessTokenHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取微信小程序accessToken
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetWxOpenAccessToken()
|
||||||
|
{
|
||||||
|
//获取小程序AccessToken
|
||||||
|
var cacheAccessToken = ManualDataCache.Instance.Get<WeChatAccessToken>(GlobalEnumVars.AccessTokenEnum.WxOpenAccessToken.ToString());
|
||||||
|
return cacheAccessToken?.accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取微信公众号accessToken
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetWeChatAccessToken()
|
||||||
|
{
|
||||||
|
//获取微信AccessToken
|
||||||
|
var cacheAccessToken = ManualDataCache.Instance.Get<WeChatAccessToken>(GlobalEnumVars.AccessTokenEnum.WeiXinAccessToken.ToString());
|
||||||
|
return cacheAccessToken?.accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
CoreCms.Net.Caching/AutoMate/MemoryCache/ICachingProvider.cs
Normal file
12
CoreCms.Net.Caching/AutoMate/MemoryCache/ICachingProvider.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace CoreCms.Net.Caching.AutoMate.MemoryCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 简单的缓存接口,只有查询和添加,以后会进行扩展
|
||||||
|
/// </summary>
|
||||||
|
public interface ICachingProvider
|
||||||
|
{
|
||||||
|
object Get(string cacheKey);
|
||||||
|
|
||||||
|
void Set(string cacheKey, object cacheValue, int timeSpan);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
CoreCms.Net.Caching/AutoMate/MemoryCache/MemoryCaching.cs
Normal file
30
CoreCms.Net.Caching/AutoMate/MemoryCache/MemoryCaching.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.AutoMate.MemoryCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 实例化缓存接口ICaching
|
||||||
|
/// </summary>
|
||||||
|
public class MemoryCaching : ICachingProvider
|
||||||
|
{
|
||||||
|
//引用Microsoft.Extensions.Caching.Memory;这个和.net 还是不一样,没有了Httpruntime了
|
||||||
|
private readonly IMemoryCache _cache;
|
||||||
|
//还是通过构造函数的方法,获取
|
||||||
|
public MemoryCaching(IMemoryCache cache)
|
||||||
|
{
|
||||||
|
_cache = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Get(string cacheKey)
|
||||||
|
{
|
||||||
|
return _cache.Get(cacheKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(string cacheKey, object cacheValue, int timeSpan)
|
||||||
|
{
|
||||||
|
_cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(timeSpan * 60));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.AutoMate.RedisCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Redis缓存接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IRedisOperationRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
//获取 Reids 缓存值
|
||||||
|
Task<string> Get(string key);
|
||||||
|
|
||||||
|
//获取值,并序列化
|
||||||
|
Task<TEntity> Get<TEntity>(string key);
|
||||||
|
|
||||||
|
//保存
|
||||||
|
Task Set(string key, object value, TimeSpan cacheTime);
|
||||||
|
|
||||||
|
//判断是否存在
|
||||||
|
Task<bool> Exist(string key);
|
||||||
|
|
||||||
|
//移除某一个缓存值
|
||||||
|
Task Remove(string key);
|
||||||
|
|
||||||
|
//全部清除
|
||||||
|
Task Clear();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据key获取RedisValue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<RedisValue[]> ListRangeAsync(string redisKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在列表头部插入值。如果键不存在,先创建再插入值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<long> ListLeftPushAsync(string redisKey, string redisValue);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在列表尾部插入值。如果键不存在,先创建再插入值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<long> ListRightPushAsync(string redisKey, string redisValue);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在列表尾部插入数组集合。如果键不存在,先创建再插入值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<long> ListRightPushAsync(string redisKey, IEnumerable<string> redisValue);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的第一个元素 反序列化
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<T> ListLeftPopAsync<T>(string redisKey) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的最后一个元素 反序列化
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<T> ListRightPopAsync<T>(string redisKey) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的第一个元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> ListLeftPopAsync(string redisKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的最后一个元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> ListRightPopAsync(string redisKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 列表长度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<long> ListLengthAsync(string redisKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回在该列表上键所对应的元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="db"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<string>> ListRangeAsync(string redisKey, int db = -1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据索引获取指定位置数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="start"></param>
|
||||||
|
/// <param name="stop"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<string>> ListRangeAsync(string redisKey, int start, int stop);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除List中的元素 并返回删除的个数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<long> ListDelRangeAsync(string redisKey, string redisValue, long type = 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空List
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task ListClearAsync(string redisKey);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 有序集合/定时任务延迟队列用的多
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey">key</param>
|
||||||
|
/// <param name="redisValue">元素</param>
|
||||||
|
/// <param name="score">分数</param>
|
||||||
|
Task SortedSetAddAsync(string redisKey, string redisValue, double score);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,243 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.AutoMate.RedisCache
|
||||||
|
{
|
||||||
|
public class RedisOperationRepository : IRedisOperationRepository
|
||||||
|
{
|
||||||
|
private readonly ILogger<RedisOperationRepository> _logger;
|
||||||
|
private readonly ConnectionMultiplexer _redis;
|
||||||
|
private readonly IDatabase _database;
|
||||||
|
|
||||||
|
public RedisOperationRepository(ILogger<RedisOperationRepository> logger, ConnectionMultiplexer redis)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_redis = redis;
|
||||||
|
_database = redis.GetDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IServer GetServer()
|
||||||
|
{
|
||||||
|
var endpoint = _redis.GetEndPoints();
|
||||||
|
return _redis.GetServer(endpoint.First());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Clear()
|
||||||
|
{
|
||||||
|
foreach (var endPoint in _redis.GetEndPoints())
|
||||||
|
{
|
||||||
|
var server = GetServer();
|
||||||
|
foreach (var key in server.Keys())
|
||||||
|
{
|
||||||
|
await _database.KeyDeleteAsync(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exist(string key)
|
||||||
|
{
|
||||||
|
return await _database.KeyExistsAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> Get(string key)
|
||||||
|
{
|
||||||
|
return await _database.StringGetAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Remove(string key)
|
||||||
|
{
|
||||||
|
await _database.KeyDeleteAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Set(string key, object value, TimeSpan cacheTime)
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
//序列化,将object值生成RedisValue
|
||||||
|
await _database.StringSetAsync(key, JsonConvert.SerializeObject(value), cacheTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TEntity> Get<TEntity>(string key)
|
||||||
|
{
|
||||||
|
var value = await _database.StringGetAsync(key);
|
||||||
|
if (value.HasValue)
|
||||||
|
{
|
||||||
|
//需要用的反序列化,将Redis存储的Byte[],进行反序列化
|
||||||
|
return JsonConvert.DeserializeObject<TEntity>(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据key获取RedisValue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<RedisValue[]> ListRangeAsync(string redisKey)
|
||||||
|
{
|
||||||
|
return await _database.ListRangeAsync(redisKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在列表头部插入值。如果键不存在,先创建再插入值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<long> ListLeftPushAsync(string redisKey, string redisValue)
|
||||||
|
{
|
||||||
|
return await _database.ListLeftPushAsync(redisKey, redisValue);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 在列表尾部插入值。如果键不存在,先创建再插入值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<long> ListRightPushAsync(string redisKey, string redisValue)
|
||||||
|
{
|
||||||
|
return await _database.ListRightPushAsync(redisKey, redisValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在列表尾部插入数组集合。如果键不存在,先创建再插入值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<long> ListRightPushAsync(string redisKey, IEnumerable<string> redisValue)
|
||||||
|
{
|
||||||
|
var redislist = new List<RedisValue>();
|
||||||
|
foreach (var item in redisValue)
|
||||||
|
{
|
||||||
|
redislist.Add(item);
|
||||||
|
}
|
||||||
|
return await _database.ListRightPushAsync(redisKey, redislist.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的第一个元素 反序列化
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<T> ListLeftPopAsync<T>(string redisKey) where T : class
|
||||||
|
{
|
||||||
|
var cacheValue = await _database.ListLeftPopAsync(redisKey);
|
||||||
|
if (string.IsNullOrEmpty(cacheValue)) return null;
|
||||||
|
var res = JsonConvert.DeserializeObject<T>(cacheValue);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的最后一个元素 反序列化
|
||||||
|
/// 只能是对象集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<T> ListRightPopAsync<T>(string redisKey) where T : class
|
||||||
|
{
|
||||||
|
var cacheValue = await _database.ListRightPopAsync(redisKey);
|
||||||
|
if (string.IsNullOrEmpty(cacheValue)) return null;
|
||||||
|
var res = JsonConvert.DeserializeObject<T>(cacheValue);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的第一个元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> ListLeftPopAsync(string redisKey)
|
||||||
|
{
|
||||||
|
return await _database.ListLeftPopAsync(redisKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除并返回存储在该键列表的最后一个元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> ListRightPopAsync(string redisKey)
|
||||||
|
{
|
||||||
|
return await _database.ListRightPopAsync(redisKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 列表长度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<long> ListLengthAsync(string redisKey)
|
||||||
|
{
|
||||||
|
return await _database.ListLengthAsync(redisKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回在该列表上键所对应的元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<string>> ListRangeAsync(string redisKey, int db = -1)
|
||||||
|
{
|
||||||
|
var result = await _database.ListRangeAsync(redisKey);
|
||||||
|
return result.Select(o => o.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据索引获取指定位置数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
/// <param name="start"></param>
|
||||||
|
/// <param name="stop"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<string>> ListRangeAsync(string redisKey, int start, int stop)
|
||||||
|
{
|
||||||
|
var result = await _database.ListRangeAsync(redisKey, start, stop);
|
||||||
|
return result.Select(o => o.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除List中的元素 并返回删除的个数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey">key</param>
|
||||||
|
/// <param name="redisValue">元素</param>
|
||||||
|
/// <param name="type">大于零 : 从表头开始向表尾搜索,小于零 : 从表尾开始向表头搜索,等于零:移除表中所有与 VALUE 相等的值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<long> ListDelRangeAsync(string redisKey, string redisValue, long type = 0)
|
||||||
|
{
|
||||||
|
return await _database.ListRemoveAsync(redisKey, redisValue, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空List
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey"></param>
|
||||||
|
public async Task ListClearAsync(string redisKey)
|
||||||
|
{
|
||||||
|
await _database.ListTrimAsync(redisKey, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 有序集合/定时任务延迟队列用的多
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="redisKey">key</param>
|
||||||
|
/// <param name="redisValue">元素</param>
|
||||||
|
/// <param name="score">分数</param>
|
||||||
|
public async Task SortedSetAddAsync(string redisKey, string redisValue, double score)
|
||||||
|
{
|
||||||
|
await _database.SortedSetAddAsync(redisKey, redisValue, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
18
CoreCms.Net.Caching/CoreCms.Net.Caching.csproj
Normal file
18
CoreCms.Net.Caching/CoreCms.Net.Caching.csproj
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
||||||
|
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="1.9.0" />
|
||||||
|
<PackageReference Include="StackExchange.Redis" Version="2.2.50" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Configuration\CoreCms.Net.Configuration.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
88
CoreCms.Net.Caching/Manual/IManualCacheManager.cs
Normal file
88
CoreCms.Net.Caching/Manual/IManualCacheManager.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.Manual
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 手动缓存操作接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IManualCacheManager
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证缓存项是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool Exists(string key);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="expiresIn">缓存时长(分钟)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool Set(string key, object value, int expiresIn = 0);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
void Remove(string key);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
void RemoveAll(IEnumerable<string> keys);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
T Get<T>(string key);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
object Get(string key);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keys">缓存Key集合</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IDictionary<string, object> GetAll(IEnumerable<string> keys);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除所有缓存
|
||||||
|
/// </summary>
|
||||||
|
void RemoveCacheAll();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除匹配到的缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
void RemoveCacheRegex(string pattern);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索 匹配到的缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IList<string> SearchCacheRegex(string pattern);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
51
CoreCms.Net.Caching/Manual/ManualDataCache.cs
Normal file
51
CoreCms.Net.Caching/Manual/ManualDataCache.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-02 14:43:16
|
||||||
|
* NameSpace: CoreCms.Net.Framework.Caching
|
||||||
|
* FileName: DataCache
|
||||||
|
* ClassDescription:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using CoreCms.Net.Caching.MemoryCache;
|
||||||
|
using CoreCms.Net.Caching.Redis;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.Manual
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 手动缓存调用
|
||||||
|
/// </summary>
|
||||||
|
public static partial class ManualDataCache
|
||||||
|
{
|
||||||
|
private static IManualCacheManager _instance = null;
|
||||||
|
/// <summary>
|
||||||
|
/// 静态实例,外部可直接调用
|
||||||
|
/// </summary>
|
||||||
|
public static IManualCacheManager Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_instance == null)
|
||||||
|
{
|
||||||
|
if (AppSettingsConstVars.RedisUseCache)
|
||||||
|
{
|
||||||
|
_instance = new RedisCacheManager();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_instance = new MemoryCacheManager();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
181
CoreCms.Net.Caching/Manual/MemoryCacheManager.cs
Normal file
181
CoreCms.Net.Caching/Manual/MemoryCacheManager.cs
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using CoreCms.Net.Caching.Manual;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.MemoryCache
|
||||||
|
{
|
||||||
|
public class MemoryCacheManager : IManualCacheManager
|
||||||
|
{
|
||||||
|
private static volatile Microsoft.Extensions.Caching.Memory.MemoryCache _memoryCache = new Microsoft.Extensions.Caching.Memory.MemoryCache((IOptions<MemoryCacheOptions>)new MemoryCacheOptions());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证缓存项是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Exists(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
return _memoryCache.TryGetValue(key, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="expiresIn">缓存时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Set(string key, object value, int expiresIn = 0)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
if (value == null)
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
if (expiresIn > 0)
|
||||||
|
{
|
||||||
|
_memoryCache.Set(key, value,
|
||||||
|
new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(120))
|
||||||
|
.SetAbsoluteExpiration(TimeSpan.FromMinutes(expiresIn)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_memoryCache.Set(key, value,
|
||||||
|
new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(120))
|
||||||
|
.SetAbsoluteExpiration(TimeSpan.FromMinutes(1440)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Exists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
|
||||||
|
_memoryCache.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void RemoveAll(IEnumerable<string> keys)
|
||||||
|
{
|
||||||
|
if (keys == null)
|
||||||
|
throw new ArgumentNullException(nameof(keys));
|
||||||
|
|
||||||
|
keys.ToList().ForEach(item => _memoryCache.Remove(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Get<T>(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
|
||||||
|
return _memoryCache.Get<T>(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public object Get(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
|
||||||
|
return _memoryCache.Get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keys">缓存Key集合</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IDictionary<string, object> GetAll(IEnumerable<string> keys)
|
||||||
|
{
|
||||||
|
if (keys == null)
|
||||||
|
throw new ArgumentNullException(nameof(keys));
|
||||||
|
|
||||||
|
var dict = new Dictionary<string, object>();
|
||||||
|
keys.ToList().ForEach(item => dict.Add(item, _memoryCache.Get(item)));
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除所有缓存
|
||||||
|
/// </summary>
|
||||||
|
public void RemoveCacheAll()
|
||||||
|
{
|
||||||
|
var l = GetCacheKeys();
|
||||||
|
foreach (var s in l)
|
||||||
|
{
|
||||||
|
Remove(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除匹配到的缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void RemoveCacheRegex(string pattern)
|
||||||
|
{
|
||||||
|
IList<string> l = SearchCacheRegex(pattern);
|
||||||
|
foreach (var s in l)
|
||||||
|
{
|
||||||
|
Remove(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索 匹配到的缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IList<string> SearchCacheRegex(string pattern)
|
||||||
|
{
|
||||||
|
var cacheKeys = GetCacheKeys();
|
||||||
|
var l = cacheKeys.Where(k => Regex.IsMatch(k, pattern)).ToList();
|
||||||
|
return l.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有缓存键
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string> GetCacheKeys()
|
||||||
|
{
|
||||||
|
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||||
|
var entries = _memoryCache.GetType().GetField("_entries", flags).GetValue(_memoryCache);
|
||||||
|
var cacheItems = entries as IDictionary;
|
||||||
|
var keys = new List<string>();
|
||||||
|
if (cacheItems == null) return keys;
|
||||||
|
foreach (DictionaryEntry cacheItem in cacheItems)
|
||||||
|
{
|
||||||
|
keys.Add(cacheItem.Key.ToString());
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
209
CoreCms.Net.Caching/Manual/RedisCacheManager.cs
Normal file
209
CoreCms.Net.Caching/Manual/RedisCacheManager.cs
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-02 14:09:33
|
||||||
|
* ClassDescription:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using CoreCms.Net.Caching.Manual;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.Redis
|
||||||
|
{
|
||||||
|
public class RedisCacheManager : IManualCacheManager
|
||||||
|
{
|
||||||
|
private readonly string _redisConnenctionString;
|
||||||
|
|
||||||
|
public volatile ConnectionMultiplexer RedisConnection;
|
||||||
|
|
||||||
|
private readonly object _redisConnectionLock = new object();
|
||||||
|
|
||||||
|
public RedisCacheManager()
|
||||||
|
{
|
||||||
|
string redisConfiguration = AppSettingsConstVars.RedisConfigConnectionString;//获取连接字符串
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(redisConfiguration))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("redis config is empty", nameof(redisConfiguration));
|
||||||
|
}
|
||||||
|
_redisConnenctionString = redisConfiguration;
|
||||||
|
|
||||||
|
RedisConnection = GetRedisConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 核心代码,获取连接实例
|
||||||
|
/// 通过双if 夹lock的方式,实现单例模式
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private ConnectionMultiplexer GetRedisConnection()
|
||||||
|
{
|
||||||
|
//如果已经连接实例,直接返回
|
||||||
|
if (RedisConnection != null && RedisConnection.IsConnected)
|
||||||
|
{
|
||||||
|
return RedisConnection;
|
||||||
|
}
|
||||||
|
//加锁,防止异步编程中,出现单例无效的问题
|
||||||
|
lock (_redisConnectionLock)
|
||||||
|
{
|
||||||
|
if (RedisConnection != null)
|
||||||
|
{
|
||||||
|
//释放redis连接
|
||||||
|
RedisConnection.Dispose();
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RedisConnection = ConnectionMultiplexer.Connect(_redisConnenctionString);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw new Exception("Redis服务未启用,请开启该服务,并且请注意端口号,Redis默认使用6379端口号。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RedisConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断key是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Exists(string key)
|
||||||
|
{
|
||||||
|
return RedisConnection.GetDatabase().KeyExists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="expiresIn">缓存时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Set(string key, object value, int expiresIn = 0)
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
//序列化,将object值生成RedisValue
|
||||||
|
if (expiresIn > 0)
|
||||||
|
{
|
||||||
|
return RedisConnection.GetDatabase().StringSet(key, SerializeExtensions.Serialize(value), TimeSpan.FromMinutes(expiresIn));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RedisConnection.GetDatabase().StringSet(key, SerializeExtensions.Serialize(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
RedisConnection.GetDatabase().KeyDelete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void RemoveAll(IEnumerable<string> keys)
|
||||||
|
{
|
||||||
|
foreach (var key in keys)
|
||||||
|
{
|
||||||
|
RedisConnection.GetDatabase().KeyDelete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Get<T>(string key)
|
||||||
|
{
|
||||||
|
var value = RedisConnection.GetDatabase().StringGet(key);
|
||||||
|
if (value.HasValue)
|
||||||
|
{
|
||||||
|
//需要用的反序列化,将Redis存储的Byte[],进行反序列化
|
||||||
|
return SerializeExtensions.Deserialize<T>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Get(string key)
|
||||||
|
{
|
||||||
|
return RedisConnection.GetDatabase().StringGet(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDictionary<string, object> GetAll(IEnumerable<string> keys)
|
||||||
|
{
|
||||||
|
if (keys == null)
|
||||||
|
throw new ArgumentNullException(nameof(keys));
|
||||||
|
var dict = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
keys.ToList().ForEach(item => dict.Add(item, RedisConnection.GetDatabase().StringGet(item)));
|
||||||
|
return dict;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveCacheAll()
|
||||||
|
{
|
||||||
|
foreach (var endPoint in GetRedisConnection().GetEndPoints())
|
||||||
|
{
|
||||||
|
var server = GetRedisConnection().GetServer(endPoint);
|
||||||
|
foreach (var key in server.Keys())
|
||||||
|
{
|
||||||
|
RedisConnection.GetDatabase().KeyDelete(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveCacheRegex(string pattern)
|
||||||
|
{
|
||||||
|
var script = "return redis.call('keys',@pattern)";
|
||||||
|
var prepared = LuaScript.Prepare(script);
|
||||||
|
var redisResult = RedisConnection.GetDatabase().ScriptEvaluate(prepared, new { pattern });
|
||||||
|
if (!redisResult.IsNull)
|
||||||
|
{
|
||||||
|
RedisConnection.GetDatabase().KeyDelete((RedisKey[])redisResult); //删除一组key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<string> SearchCacheRegex(string pattern)
|
||||||
|
{
|
||||||
|
var list = new List<String>();
|
||||||
|
var script = "return redis.call('keys',@pattern)";
|
||||||
|
var prepared = LuaScript.Prepare(script);
|
||||||
|
var redisResult = RedisConnection.GetDatabase().ScriptEvaluate(prepared, new { pattern });
|
||||||
|
if (!redisResult.IsNull)
|
||||||
|
{
|
||||||
|
foreach (var key in (RedisKey[])redisResult)
|
||||||
|
{
|
||||||
|
list.Add(RedisConnection.GetDatabase().StringGet(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
282
CoreCms.Net.Caching/SqlSugar/SqlSugarMemoryCache.cs
Normal file
282
CoreCms.Net.Caching/SqlSugar/SqlSugarMemoryCache.cs
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.SqlSugar
|
||||||
|
{
|
||||||
|
public class SqlSugarMemoryCache : ICacheService
|
||||||
|
{
|
||||||
|
MemoryCacheHelper cache = new MemoryCacheHelper();
|
||||||
|
public void Add<V>(string key, V value)
|
||||||
|
{
|
||||||
|
cache.Set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add<V>(string key, V value, int cacheDurationInSeconds)
|
||||||
|
{
|
||||||
|
cache.Set(key, value, cacheDurationInSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey<V>(string key)
|
||||||
|
{
|
||||||
|
return cache.Exists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public V Get<V>(string key)
|
||||||
|
{
|
||||||
|
return cache.Get<V>(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAllKey<V>()
|
||||||
|
{
|
||||||
|
return cache.GetCacheKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
public V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue)
|
||||||
|
{
|
||||||
|
if (cache.Exists(cacheKey))
|
||||||
|
{
|
||||||
|
return cache.Get<V>(cacheKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = create();
|
||||||
|
cache.Set(cacheKey, result, cacheDurationInSeconds);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove<V>(string key)
|
||||||
|
{
|
||||||
|
cache.Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class MemoryCacheHelper
|
||||||
|
{
|
||||||
|
private static readonly Microsoft.Extensions.Caching.Memory.MemoryCache Cache = new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptions());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证缓存项是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Exists(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
return Cache.TryGetValue(key, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
|
||||||
|
/// <param name="expiressAbsoulte">绝对过期时长</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Set(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
if (value == null)
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
Cache.Set(key, value,
|
||||||
|
new MemoryCacheEntryOptions().SetSlidingExpiration(expiresSliding)
|
||||||
|
.SetAbsoluteExpiration(expiressAbsoulte));
|
||||||
|
return Exists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="expiresIn">缓存时长</param>
|
||||||
|
/// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Set(string key, object value, TimeSpan expiresIn, bool isSliding = false)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
if (value == null)
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
Cache.Set(key, value,
|
||||||
|
isSliding
|
||||||
|
? new MemoryCacheEntryOptions().SetSlidingExpiration(expiresIn)
|
||||||
|
: new MemoryCacheEntryOptions().SetAbsoluteExpiration(expiresIn));
|
||||||
|
|
||||||
|
return Exists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void Set(string key, object value)
|
||||||
|
{
|
||||||
|
Set(key, value, TimeSpan.FromDays(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="ts"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void Set(string key, object value, TimeSpan ts)
|
||||||
|
{
|
||||||
|
Set(key, value, ts, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <param name="value">缓存Value</param>
|
||||||
|
/// <param name="ts"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void Set(string key, object value, int seconds)
|
||||||
|
{
|
||||||
|
var ts = TimeSpan.FromSeconds(seconds);
|
||||||
|
Set(key, value, ts, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
Cache.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void RemoveAll(IEnumerable<string> keys)
|
||||||
|
{
|
||||||
|
if (keys == null)
|
||||||
|
throw new ArgumentNullException(nameof(keys));
|
||||||
|
|
||||||
|
keys.ToList().ForEach(item => Cache.Remove(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取缓存
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Get<T>(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
|
||||||
|
return Cache.Get<T>(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public object Get(string key)
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
|
||||||
|
return Cache.Get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keys">缓存Key集合</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IDictionary<string, object> GetAll(IEnumerable<string> keys)
|
||||||
|
{
|
||||||
|
if (keys == null)
|
||||||
|
throw new ArgumentNullException(nameof(keys));
|
||||||
|
|
||||||
|
var dict = new Dictionary<string, object>();
|
||||||
|
keys.ToList().ForEach(item => dict.Add(item, Cache.Get(item)));
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除所有缓存
|
||||||
|
/// </summary>
|
||||||
|
public void RemoveCacheAll()
|
||||||
|
{
|
||||||
|
var l = GetCacheKeys();
|
||||||
|
foreach (var s in l)
|
||||||
|
{
|
||||||
|
Remove(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除匹配到的缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void RemoveCacheRegex(string pattern)
|
||||||
|
{
|
||||||
|
IList<string> l = SearchCacheRegex(pattern);
|
||||||
|
foreach (var s in l)
|
||||||
|
{
|
||||||
|
Remove(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索 匹配到的缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IList<string> SearchCacheRegex(string pattern)
|
||||||
|
{
|
||||||
|
var cacheKeys = GetCacheKeys();
|
||||||
|
var l = cacheKeys.Where(k => Regex.IsMatch(k, pattern)).ToList();
|
||||||
|
return l.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有缓存键
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string> GetCacheKeys()
|
||||||
|
{
|
||||||
|
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||||
|
var entries = Cache.GetType().GetField("_entries", flags).GetValue(Cache);
|
||||||
|
var cacheItems = entries as IDictionary;
|
||||||
|
var keys = new List<string>();
|
||||||
|
if (cacheItems == null) return keys;
|
||||||
|
foreach (DictionaryEntry cacheItem in cacheItems)
|
||||||
|
{
|
||||||
|
keys.Add(cacheItem.Key.ToString());
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
CoreCms.Net.Caching/SqlSugar/SqlSugarRedisCache.cs
Normal file
68
CoreCms.Net.Caching/SqlSugar/SqlSugarRedisCache.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Caching.Redis;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Caching.SqlSugar
|
||||||
|
{
|
||||||
|
public class SqlSugarRedisCache : ICacheService
|
||||||
|
{
|
||||||
|
readonly RedisCacheManager _service = null;
|
||||||
|
|
||||||
|
public SqlSugarRedisCache()
|
||||||
|
{
|
||||||
|
_service = new RedisCacheManager(); ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add<TV>(string key, TV value)
|
||||||
|
{
|
||||||
|
_service.Set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add<TV>(string key, TV value, int cacheDurationInSeconds)
|
||||||
|
{
|
||||||
|
_service.Set(key, value, cacheDurationInSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey<TV>(string key)
|
||||||
|
{
|
||||||
|
return _service.Exists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TV Get<TV>(string key)
|
||||||
|
{
|
||||||
|
return _service.Get<TV>(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAllKey<TV>()
|
||||||
|
{
|
||||||
|
|
||||||
|
return _service.SearchCacheRegex("SqlSugarDataCache.*");
|
||||||
|
}
|
||||||
|
|
||||||
|
public TV GetOrCreate<TV>(string cacheKey, Func<TV> create, int cacheDurationInSeconds = int.MaxValue)
|
||||||
|
{
|
||||||
|
if (this.ContainsKey<TV>(cacheKey))
|
||||||
|
{
|
||||||
|
return this.Get<TV>(cacheKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = create();
|
||||||
|
this.Add(cacheKey, result, cacheDurationInSeconds);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove<TV>(string key)
|
||||||
|
{
|
||||||
|
_service.Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
29
CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj
Normal file
29
CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="CrudTemplete\Controllers\Controller.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\DbModel\Model.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\Repositories\IRepository.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\Repositories\Repository.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\Services\IServices.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\Services\Services.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\View\Create.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\View\Details.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\View\Edit.tpl" />
|
||||||
|
<EmbeddedResource Include="CrudTemplete\View\Index.tpl" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DotLiquid" Version="2.2.548" />
|
||||||
|
<PackageReference Include="sqlSugarCore" Version="5.0.4.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,513 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: {{ModelCreateTime}}
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.Entities.Expression;
|
||||||
|
using CoreCms.Net.Model.FromBody;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using CoreCms.Net.Filter;
|
||||||
|
using CoreCms.Net.Loging;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
|
using CoreCms.Net.Utility.Helper;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.HSSF.UserModel;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// {{ModelDescription}}
|
||||||
|
///</summary>
|
||||||
|
[Description("{{ModelDescription}}")]
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
[RequiredErrorForAdmin]
|
||||||
|
[Authorize]
|
||||||
|
public class {{ModelClassName}}Controller : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
private readonly I{{ModelClassName}}Services _{{ModelClassName}}Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
///</summary>
|
||||||
|
public {{ModelClassName}}Controller(IWebHostEnvironment webHostEnvironment
|
||||||
|
,I{{ModelClassName}}Services {{ModelClassName}}Services
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
_{{ModelClassName}}Services = {{ModelClassName}}Services;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 获取列表============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/GetPageList
|
||||||
|
/// <summary>
|
||||||
|
/// 获取列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("获取列表")]
|
||||||
|
public async Task<AdminUiCallBack> GetPageList()
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||||
|
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||||
|
var where = PredicateBuilder.True<{{ModelClassName}}>();
|
||||||
|
//获取排序字段
|
||||||
|
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||||
|
|
||||||
|
Expression<Func<{{ModelClassName}}, object>> orderEx = orderField switch
|
||||||
|
{
|
||||||
|
{% for field in ModelFields %}"{{field.DbColumnName}}" => p => p.{{field.DbColumnName}},{% endfor %}
|
||||||
|
_ => p => p.id
|
||||||
|
};
|
||||||
|
|
||||||
|
//设置排序方式
|
||||||
|
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||||
|
var orderBy = orderDirection switch
|
||||||
|
{
|
||||||
|
"asc" => OrderByType.Asc,
|
||||||
|
"desc" => OrderByType.Desc,
|
||||||
|
_ => OrderByType.Desc
|
||||||
|
};
|
||||||
|
//查询筛选
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'nvarchar' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}}.Contains({{field.DbColumnName}}));
|
||||||
|
}{% elsif field.DataType == 'int' or field.DataType == 'bigint' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault().ObjectToInt(0);
|
||||||
|
if ({{field.DbColumnName}} > 0)
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == {{field.DbColumnName}});
|
||||||
|
}{% elsif field.DataType == 'decimal' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault().ObjectToDecimal(0);
|
||||||
|
if ({{field.DbColumnName}} > 0)
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == {{field.DbColumnName}});
|
||||||
|
}{% elsif field.DataType == 'datetime' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}))
|
||||||
|
{
|
||||||
|
if ({{field.DbColumnName}}.Contains("到"))
|
||||||
|
{
|
||||||
|
var dts = {{field.DbColumnName}}.Split("到");
|
||||||
|
var dtStart = dts[0].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} > dtStart);
|
||||||
|
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} < dtEnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dt = {{field.DbColumnName}}.ObjectToDate();
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} > dt);
|
||||||
|
}
|
||||||
|
}{% elsif field.DataType == 'bit' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}) && {{field.DbColumnName}}.ToLowerInvariant() == "true")
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == true);
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty({{field.DbColumnName}}) && {{field.DbColumnName}}.ToLowerInvariant() == "false")
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == false);
|
||||||
|
}{% else %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}}.Contains({{field.DbColumnName}}));
|
||||||
|
}{% endif %}{% endfor %}
|
||||||
|
//获取数据
|
||||||
|
var list = await _{{ModelClassName}}Services.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||||
|
//返回数据
|
||||||
|
jm.data = list;
|
||||||
|
jm.code = 0;
|
||||||
|
jm.count = list.TotalCount;
|
||||||
|
jm.msg = "数据调用成功!";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 首页数据============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/GetIndex
|
||||||
|
/// <summary>
|
||||||
|
/// 首页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("首页数据")]
|
||||||
|
public AdminUiCallBack GetIndex()
|
||||||
|
{
|
||||||
|
//返回数据
|
||||||
|
var jm = new AdminUiCallBack { code = 0 };
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 创建数据============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/GetCreate
|
||||||
|
/// <summary>
|
||||||
|
/// 创建数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("创建数据")]
|
||||||
|
public AdminUiCallBack GetCreate()
|
||||||
|
{
|
||||||
|
//返回数据
|
||||||
|
var jm = new AdminUiCallBack { code = 0 };
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 创建提交============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/DoCreate
|
||||||
|
/// <summary>
|
||||||
|
/// 创建提交
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("创建提交")]
|
||||||
|
public async Task<AdminUiCallBack> DoCreate([FromBody]{{ModelClassName}} entity)
|
||||||
|
{
|
||||||
|
var jm = await _{{ModelClassName}}Services.InsertAsync(entity);
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 编辑数据============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/GetEdit
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("编辑数据")]
|
||||||
|
public async Task<AdminUiCallBack> GetEdit([FromBody]FMIntId entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var model = await _{{ModelClassName}}Services.QueryByIdAsync(entity.id, false);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
jm.code = 0;
|
||||||
|
jm.data = model;
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 编辑提交============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/Edit
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑提交
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("编辑提交")]
|
||||||
|
public async Task<AdminUiCallBack> DoEdit([FromBody]{{ModelClassName}} entity)
|
||||||
|
{
|
||||||
|
var jm = await _{{ModelClassName}}Services.UpdateAsync(entity);
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 删除数据============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/DoDelete/10
|
||||||
|
/// <summary>
|
||||||
|
/// 单选删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("单选删除")]
|
||||||
|
public async Task<AdminUiCallBack> DoDelete([FromBody]FMIntId entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var model = await _{{ModelClassName}}Services.ExistsAsync(p => p.id == entity.id, true);
|
||||||
|
if (!model)
|
||||||
|
{
|
||||||
|
jm.msg = GlobalConstVars.DataisNo;
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
jm = await _{{ModelClassName}}Services.DeleteByIdAsync(entity.id);
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 批量删除============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/DoBatchDelete/10,11,20
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("批量删除")]
|
||||||
|
public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayIntIds entity)
|
||||||
|
{
|
||||||
|
var jm = await _{{ModelClassName}}Services.DeleteByIdsAsync(entity.id);
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 预览数据============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/GetDetails/10
|
||||||
|
/// <summary>
|
||||||
|
/// 预览数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("预览数据")]
|
||||||
|
public async Task<AdminUiCallBack> GetDetails([FromBody]FMIntId entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var model = await _{{ModelClassName}}Services.QueryByIdAsync(entity.id, false);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
jm.code = 0;
|
||||||
|
jm.data = model;
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 选择导出============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/SelectExportExcel/10
|
||||||
|
/// <summary>
|
||||||
|
/// 选择导出
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("选择导出")]
|
||||||
|
public async Task<AdminUiCallBack> SelectExportExcel([FromBody]FMArrayIntIds entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
//创建Excel文件的对象
|
||||||
|
var book = new HSSFWorkbook();
|
||||||
|
//添加一个sheet
|
||||||
|
var mySheet = book.CreateSheet("Sheet1");
|
||||||
|
//获取list数据
|
||||||
|
var listModel = await _{{ModelClassName}}Services.QueryListByClauseAsync(p => entity.id.Contains(p.id), p => p.id, OrderByType.Asc, true);
|
||||||
|
//给sheet1添加第一行的头部标题
|
||||||
|
var headerRow = mySheet.CreateRow(0);
|
||||||
|
var headerStyle = ExcelHelper.GetHeaderStyle(book);
|
||||||
|
{% for field in ModelFields %}
|
||||||
|
var cell{{ forloop.index0 }} = headerRow.CreateCell({{ forloop.index0 }});
|
||||||
|
cell{{ forloop.index0 }}.SetCellValue("{{field.ColumnDescription}}");
|
||||||
|
cell{{ forloop.index0 }}.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth({{ forloop.index0 }}, 10 * 256);
|
||||||
|
{% endfor %}
|
||||||
|
headerRow.Height = 30 * 20;
|
||||||
|
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
||||||
|
|
||||||
|
//将数据逐步写入sheet1各个行
|
||||||
|
for (var i = 0; i < listModel.Count; i++)
|
||||||
|
{
|
||||||
|
var rowTemp = mySheet.CreateRow(i + 1);
|
||||||
|
{% for field in ModelFields %}
|
||||||
|
var rowTemp{{ forloop.index0 }} = rowTemp.CreateCell({{ forloop.index0 }});
|
||||||
|
rowTemp{{ forloop.index0 }}.SetCellValue(listModel[i].{{field.DbColumnName}}.ToString());
|
||||||
|
rowTemp{{ forloop.index0 }}.CellStyle = commonCellStyle;
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
// 导出excel
|
||||||
|
string webRootPath = _webHostEnvironment.WebRootPath;
|
||||||
|
string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
|
||||||
|
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-{{ModelClassName}}导出(选择结果).xls";
|
||||||
|
string filePath = webRootPath + tpath;
|
||||||
|
DirectoryInfo di = new DirectoryInfo(filePath);
|
||||||
|
if (!di.Exists)
|
||||||
|
{
|
||||||
|
di.Create();
|
||||||
|
}
|
||||||
|
FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create);
|
||||||
|
book.Write(fileHssf);
|
||||||
|
fileHssf.Close();
|
||||||
|
|
||||||
|
jm.code = 0;
|
||||||
|
jm.msg = GlobalConstVars.ExcelExportSuccess;
|
||||||
|
jm.data = tpath + fileName;
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 查询导出============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/QueryExportExcel/10
|
||||||
|
/// <summary>
|
||||||
|
/// 查询导出
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("查询导出")]
|
||||||
|
public async Task<AdminUiCallBack> QueryExportExcel()
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var where = PredicateBuilder.True<{{ModelClassName}}>();
|
||||||
|
//查询筛选
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'nvarchar' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}}.Contains({{field.DbColumnName}}));
|
||||||
|
}{% elsif field.DataType == 'int' or field.DataType == 'bigint' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault().ObjectToInt(0);
|
||||||
|
if ({{field.DbColumnName}} > 0)
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == {{field.DbColumnName}});
|
||||||
|
}{% elsif field.DataType == 'datetime' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}))
|
||||||
|
{
|
||||||
|
var dt = {{field.DbColumnName}}.ObjectToDate();
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} > dt);
|
||||||
|
}{% elsif field.DataType == 'bit' %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}) && {{field.DbColumnName}}.ToLowerInvariant() == "true")
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == true);
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty({{field.DbColumnName}}) && {{field.DbColumnName}}.ToLowerInvariant() == "false")
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}} == false);
|
||||||
|
}{% else %}
|
||||||
|
//{{field.ColumnDescription}} {{field.DataType}}
|
||||||
|
var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty({{field.DbColumnName}}))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.{{field.DbColumnName}}.Contains({{field.DbColumnName}}));
|
||||||
|
}{% endif %}{% endfor %}
|
||||||
|
//获取数据
|
||||||
|
//创建Excel文件的对象
|
||||||
|
var book = new HSSFWorkbook();
|
||||||
|
//添加一个sheet
|
||||||
|
var mySheet = book.CreateSheet("Sheet1");
|
||||||
|
//获取list数据
|
||||||
|
var listModel = await _{{ModelClassName}}Services.QueryListByClauseAsync(where, p => p.id, OrderByType.Asc, true);
|
||||||
|
//给sheet1添加第一行的头部标题
|
||||||
|
var headerRow = mySheet.CreateRow(0);
|
||||||
|
var headerStyle = ExcelHelper.GetHeaderStyle(book);
|
||||||
|
{% for field in ModelFields %}
|
||||||
|
var cell{{ forloop.index0 }} = headerRow.CreateCell({{ forloop.index0 }});
|
||||||
|
cell{{ forloop.index0 }}.SetCellValue("{{field.ColumnDescription}}");
|
||||||
|
cell{{ forloop.index0 }}.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth({{ forloop.index0 }}, 10 * 256);
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
headerRow.Height = 30 * 20;
|
||||||
|
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
||||||
|
|
||||||
|
//将数据逐步写入sheet1各个行
|
||||||
|
for (var i = 0; i < listModel.Count; i++)
|
||||||
|
{
|
||||||
|
var rowTemp = mySheet.CreateRow(i + 1);
|
||||||
|
{% for field in ModelFields %}
|
||||||
|
|
||||||
|
var rowTemp{{ forloop.index0 }} = rowTemp.CreateCell({{ forloop.index0 }});
|
||||||
|
rowTemp{{ forloop.index0 }}.SetCellValue(listModel[i].{{field.DbColumnName}}.ToString());
|
||||||
|
rowTemp{{ forloop.index0 }}.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
// 写入到excel
|
||||||
|
string webRootPath = _webHostEnvironment.WebRootPath;
|
||||||
|
string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
|
||||||
|
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-{{ModelClassName}}导出(查询结果).xls";
|
||||||
|
string filePath = webRootPath + tpath;
|
||||||
|
DirectoryInfo di = new DirectoryInfo(filePath);
|
||||||
|
if (!di.Exists)
|
||||||
|
{
|
||||||
|
di.Create();
|
||||||
|
}
|
||||||
|
FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create);
|
||||||
|
book.Write(fileHssf);
|
||||||
|
fileHssf.Close();
|
||||||
|
|
||||||
|
jm.code = 0;
|
||||||
|
jm.msg = GlobalConstVars.ExcelExportSuccess;
|
||||||
|
jm.data = tpath + fileName;
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'bit' %}
|
||||||
|
#region 设置{{field.ColumnDescription}}============================================================
|
||||||
|
// POST: Api/{{ModelClassName}}/DoSet{{field.DbColumnName}}/10
|
||||||
|
/// <summary>
|
||||||
|
/// 设置{{field.ColumnDescription}}
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("设置{{field.ColumnDescription}}")]
|
||||||
|
public async Task<AdminUiCallBack> DoSet{{field.DbColumnName}}([FromBody]FMUpdateBoolDataByIntId entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var oldModel = await _{{ModelClassName}}Services.QueryByIdAsync(entity.id, false);
|
||||||
|
if (oldModel == null)
|
||||||
|
{
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
oldModel.{{field.DbColumnName}} = (bool)entity.data;
|
||||||
|
|
||||||
|
var bl = await _{{ModelClassName}}Services.UpdateAsync(p => new {{ModelClassName}}() { {{field.DbColumnName}} = oldModel.{{field.DbColumnName}} }, p => p.id == oldModel.id);
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
85
CoreCms.Net.CodeGenerator/CrudTemplete/DbModel/Model.tpl
Normal file
85
CoreCms.Net.CodeGenerator/CrudTemplete/DbModel/Model.tpl
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: {{ModelCreateTime}}
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using SqlSugar;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Model.Entities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// {{ModelDescription}}
|
||||||
|
/// </summary>
|
||||||
|
public partial class {{ModelClassName}}
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
/// </summary>
|
||||||
|
public {{ModelClassName}}()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
{% for field in ModelFields %}
|
||||||
|
/// <summary>
|
||||||
|
/// {{field.ColumnDescription}}
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "{{field.ColumnDescription}}")]
|
||||||
|
{% if field.IsIdentity == true and field.IsPrimarykey == true %}
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
{% elsif field.IsIdentity == true and field.IsPrimarykey == false %}
|
||||||
|
[SugarColumn(IsIdentity = true)]
|
||||||
|
{% elsif field.IsIdentity == false and field.IsPrimarykey == true %}
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
{% else %}{% endif %}
|
||||||
|
{% if field.IsNullable == false %}[Required(ErrorMessage = "请输入{0}")]{% endif %}
|
||||||
|
{% if field.DataType == 'nvarchar' and field.Length > 0 %}[StringLength(maximumLength:{{field.Length}},ErrorMessage = "{0}不能超过{1}字")]{% endif %}
|
||||||
|
{% if field.DataType == 'varchar' and field.Length > 0 %}[StringLength(maximumLength:{{field.Length}},ErrorMessage = "{0}不能超过{1}字")]{% endif %}
|
||||||
|
{% if field.DataType == 'nvarchar' or field.DataType == 'varchar' or field.DataType == 'text' %}
|
||||||
|
public System.String {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'int' and field.IsNullable == false %}
|
||||||
|
public System.Int32 {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'int' and field.IsNullable == true %}
|
||||||
|
public System.Int32? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'bigint' and field.IsNullable == false %}
|
||||||
|
public System.Int64 {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'bigint' and field.IsNullable == true %}
|
||||||
|
public System.Int64? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'float' and field.IsNullable == false %}
|
||||||
|
public float {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'float' and field.IsNullable == true %}
|
||||||
|
public float? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'bit' and field.IsNullable == false %}
|
||||||
|
public System.Boolean {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'bit' and field.IsNullable == true %}
|
||||||
|
public System.Boolean? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'datetime' and field.IsNullable == false %}
|
||||||
|
public System.DateTime {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'datetime' and field.IsNullable == true %}
|
||||||
|
public System.DateTime? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'date' and field.IsNullable == false %}
|
||||||
|
public System.DateTime {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'date' and field.IsNullable == true %}
|
||||||
|
public System.DateTime? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'uniqueidentifier' and field.IsNullable == false %}
|
||||||
|
public System.Guid {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'uniqueidentifier' and field.IsNullable == true %}
|
||||||
|
public System.Guid? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'decimal' and field.IsNullable == false %}
|
||||||
|
public System.Decimal {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'decimal' and field.IsNullable == true %}
|
||||||
|
public System.Decimal? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'numeric' and field.IsNullable == false %}
|
||||||
|
public System.Decimal {{field.DbColumnName}} { get; set; }
|
||||||
|
{% elsif field.DataType == 'numeric' and field.IsNullable == true %}
|
||||||
|
public System.Decimal? {{field.DbColumnName}} { get; set; }
|
||||||
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: {{ModelCreateTime}}
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// {{ModelDescription}} 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface I{{ModelClassName}}Repository : IBaseRepository<{{ModelClassName}}>
|
||||||
|
{
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync({{ModelClassName}} entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync({{ModelClassName}} entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<{{ModelClassName}}> entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<{{ModelClassName}}>> GetCaChe();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
Task<List<{{ModelClassName}}>> UpdateCaChe();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<{{ModelClassName}}>> QueryPageAsync(
|
||||||
|
Expression<Func<{{ModelClassName}}, bool>> predicate,
|
||||||
|
Expression<Func<{{ModelClassName}}, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: {{ModelCreateTime}}
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Caching.Manual;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.IRepository;
|
||||||
|
using CoreCms.Net.IRepository.UnitOfWork;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Repository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// {{ModelDescription}} 接口实现
|
||||||
|
/// </summary>
|
||||||
|
public class {{ModelClassName}}Repository : BaseRepository<{{ModelClassName}}>, I{{ModelClassName}}Repository
|
||||||
|
{
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
public {{ModelClassName}}Repository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||||
|
{
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 实现重写增删改查操作==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">实体数据</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> InsertAsync({{ModelClassName}} entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||||
|
if (bl)
|
||||||
|
{
|
||||||
|
await UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> UpdateAsync({{ModelClassName}} entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var oldModel = await DbClient.Queryable<{{ModelClassName}}>().In(entity.id).SingleAsync();
|
||||||
|
if (oldModel == null)
|
||||||
|
{
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
//事物处理过程开始
|
||||||
|
{% for field in ModelFields %}oldModel.{{field.DbColumnName}} = entity.{{field.DbColumnName}};
|
||||||
|
{% endfor %}
|
||||||
|
//事物处理过程结束
|
||||||
|
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||||
|
if (bl)
|
||||||
|
{
|
||||||
|
await UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> UpdateAsync(List<{{ModelClassName}}> entity)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync();
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||||
|
if (bl)
|
||||||
|
{
|
||||||
|
await UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var bl = await DbClient.Deleteable<{{ModelClassName}}>(id).ExecuteCommandHasChangeAsync();
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||||
|
if (bl)
|
||||||
|
{
|
||||||
|
await UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||||
|
{
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
|
||||||
|
var bl = await DbClient.Deleteable<{{ModelClassName}}>().In(ids).ExecuteCommandHasChangeAsync();
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||||
|
if (bl)
|
||||||
|
{
|
||||||
|
await UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<{{ModelClassName}}>> GetCaChe()
|
||||||
|
{
|
||||||
|
var cache = ManualDataCache.Instance.Get<List<{{ModelClassName}}>>(GlobalConstVars.Cache{{ModelClassName}});
|
||||||
|
if (cache != null)
|
||||||
|
{
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
return await UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
public async Task<List<{{ModelClassName}}>> UpdateCaChe()
|
||||||
|
{
|
||||||
|
var list = await DbClient.Queryable<{{ModelClassName}}>().With(SqlWith.NoLock).ToListAsync();
|
||||||
|
ManualDataCache.Instance.Set(GlobalConstVars.Cache{{ModelClassName}}, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 重写根据条件查询分页数据
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<IPageList<{{ModelClassName}}>> QueryPageAsync(Expression<Func<{{ModelClassName}}, bool>> predicate,
|
||||||
|
Expression<Func<{{ModelClassName}}, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false)
|
||||||
|
{
|
||||||
|
RefAsync<int> totalCount = 0;
|
||||||
|
List<{{ModelClassName}}> page;
|
||||||
|
if (blUseNoLock)
|
||||||
|
{
|
||||||
|
page = await DbClient.Queryable<{{ModelClassName}}>()
|
||||||
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||||
|
.WhereIF(predicate != null, predicate).Select(p => new {{ModelClassName}}
|
||||||
|
{
|
||||||
|
{% for field in ModelFields %}{{field.DbColumnName}} = p.{{field.DbColumnName}},
|
||||||
|
{% endfor %}
|
||||||
|
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
page = await DbClient.Queryable<{{ModelClassName}}>()
|
||||||
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||||
|
.WhereIF(predicate != null, predicate).Select(p => new {{ModelClassName}}
|
||||||
|
{
|
||||||
|
{% for field in ModelFields %}{{field.DbColumnName}} = p.{{field.DbColumnName}},
|
||||||
|
{% endfor %}
|
||||||
|
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||||
|
}
|
||||||
|
var list = new PageList<{{ModelClassName}}>(page, pageIndex, pageSize, totalCount);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: {{ModelCreateTime}}
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// {{ModelDescription}} 服务工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface I{{ModelClassName}}Services : IBaseServices<{{ModelClassName}}>
|
||||||
|
{
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync({{ModelClassName}} entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync({{ModelClassName}} entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<{{ModelClassName}}> entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<{{ModelClassName}}>> GetCaChe();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
Task<List<{{ModelClassName}}>> UpdateCaChe();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 重写根据条件查询分页数据
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<{{ModelClassName}}>> QueryPageAsync(
|
||||||
|
Expression<Func<{{ModelClassName}}, bool>> predicate,
|
||||||
|
Expression<Func<{{ModelClassName}}, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
137
CoreCms.Net.CodeGenerator/CrudTemplete/Services/Services.tpl
Normal file
137
CoreCms.Net.CodeGenerator/CrudTemplete/Services/Services.tpl
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: {{ModelCreateTime}}
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.IRepository;
|
||||||
|
using CoreCms.Net.IRepository.UnitOfWork;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// {{ModelDescription}} 接口实现
|
||||||
|
/// </summary>
|
||||||
|
public class {{ModelClassName}}Services : BaseServices<{{ModelClassName}}>, I{{ModelClassName}}Services
|
||||||
|
{
|
||||||
|
private readonly I{{ModelClassName}}Repository _dal;
|
||||||
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
public {{ModelClassName}}Services(IUnitOfWork unitOfWork, I{{ModelClassName}}Repository dal)
|
||||||
|
{
|
||||||
|
this._dal = dal;
|
||||||
|
base.BaseDal = dal;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 实现重写增删改查操作==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">实体数据</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> InsertAsync({{ModelClassName}} entity)
|
||||||
|
{
|
||||||
|
return await _dal.InsertAsync(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> UpdateAsync({{ModelClassName}} entity)
|
||||||
|
{
|
||||||
|
return await _dal.UpdateAsync(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> UpdateAsync(List<{{ModelClassName}}> entity)
|
||||||
|
{
|
||||||
|
return await _dal.UpdateAsync(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||||
|
{
|
||||||
|
return await _dal.DeleteByIdAsync(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||||
|
{
|
||||||
|
return await _dal.DeleteByIdsAsync(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<{{ModelClassName}}>> GetCaChe()
|
||||||
|
{
|
||||||
|
return await _dal.GetCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
public async Task<List<{{ModelClassName}}>> UpdateCaChe()
|
||||||
|
{
|
||||||
|
return await _dal.UpdateCaChe();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 重写根据条件查询分页数据
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public new async Task<IPageList<{{ModelClassName}}>> QueryPageAsync(Expression<Func<{{ModelClassName}}, bool>> predicate,
|
||||||
|
Expression<Func<{{ModelClassName}}, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false)
|
||||||
|
{
|
||||||
|
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
99
CoreCms.Net.CodeGenerator/CrudTemplete/View/Create.tpl
Normal file
99
CoreCms.Net.CodeGenerator/CrudTemplete/View/Create.tpl
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
|
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-{{ModelClassName}}-createForm" id="LAY-app-{{ModelClassName}}-createForm">
|
||||||
|
{% for field in ModelFields %}{% if field.DbColumnName contains 'Image' or field.DbColumnName contains 'image' or field.DbColumnName contains 'thumbnail' or field.DbColumnName contains 'Thumbnail' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input name="{{field.DbColumnName}}" id="{{field.DbColumnName}}Input" lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请上传{{field.ColumnDescription}}" lay-reqText="请上传{{field.ColumnDescription}}" />
|
||||||
|
</div>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<img class="coreshop-upload-img" id="viewImgBox{{field.DbColumnName}}" src="{% raw %}{{{% endraw %} layui.setter.noImagePicUrl {% raw %}}}{% endraw %}">
|
||||||
|
<button type="button" class="layui-btn" id="upBtn{{field.DbColumnName}}" lay-active="doCropperImg">上传图片</button>
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'nvarchar' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{% if field.Length >0 %}<input name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required|verify{{field.DbColumnName}}" class="layui-input" lay-reqText="请输入{{field.ColumnDescription}}" placeholder="请输入{{field.ColumnDescription}}"/>{% else %}<input name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required" class="layui-input" lay-reqText="请输入{{field.ColumnDescription}}" placeholder="请输入{{field.ColumnDescription}}" />{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'int' or field.DataType == 'bigint' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" min="0" max="999999" name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required|number" class="layui-input" value="1" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}并为数字" />
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'datetime' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="{{field.DbColumnName}}" id="createTime-{{ModelClassName}}-{{field.DbColumnName}}" type="text" lay-verType="tips" lay-verify="required|datetime" class="layui-input" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}" />
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'bit' %}
|
||||||
|
<div class="layui-form-item" pane>
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="checkbox" lay-filter="switch" name="{{field.DbColumnName}}" lay-skin="switch" lay-text="开启|关闭">
|
||||||
|
</div>
|
||||||
|
</div>{% else %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}" />
|
||||||
|
</div>
|
||||||
|
</div>{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
<div class="layui-form-item text-right core-hidden">
|
||||||
|
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-{{ModelClassName}}-createForm-submit" id="LAY-app-{{ModelClassName}}-createForm-submit" value="确认添加">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var debug= layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d.params.data); }
|
||||||
|
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
|
||||||
|
function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, form = layui.form
|
||||||
|
, admin = layui.admin
|
||||||
|
, laydate = layui.laydate
|
||||||
|
, upload = layui.upload
|
||||||
|
, cropperImg = layui.cropperImg
|
||||||
|
, coreHelper = layui.coreHelper;
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'datetime' %}
|
||||||
|
laydate.render({
|
||||||
|
elem: '#createTime-{{ModelClassName}}-{{field.DbColumnName}}',
|
||||||
|
type: 'datetime'
|
||||||
|
});{% endif %}{% if field.DbColumnName contains 'Image' or field.DbColumnName contains 'image' or field.DbColumnName contains 'thumbnail' or field.DbColumnName contains 'Thumbnail' %}
|
||||||
|
//{{field.ColumnDescription}}图片裁剪上传
|
||||||
|
$('#upBtn{{field.DbColumnName}}').click(function () {
|
||||||
|
cropperImg.cropImg({
|
||||||
|
aspectRatio: 1 / 1,
|
||||||
|
imgSrc: $('#viewImgBox{{field.DbColumnName}}').attr('src'),
|
||||||
|
onCrop: function (data) {
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
|
||||||
|
if (0 === res.code) {
|
||||||
|
$('#viewImgBox{{field.DbColumnName}}').attr('src', res.data.fileUrl);
|
||||||
|
$("#{{field.DbColumnName}}Input").val(res.data.fileUrl);
|
||||||
|
layer.msg(res.msg);
|
||||||
|
layer.close(loadIndex);
|
||||||
|
} else {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
layer.msg(res.msg, { icon: 2, anim: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
{% endif %}{% endfor %}
|
||||||
|
form.verify({
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'nvarchar' and field.Length > 0 %}
|
||||||
|
verify{{field.DbColumnName}}: [/^.{0,{{field.Length}}}$/,'{{field.ColumnDescription}}最大只允许输入{{field.Length}}位字符'],{% endif %}{% endfor %}
|
||||||
|
});
|
||||||
|
//重载form
|
||||||
|
form.render(null, 'LAY-app-{{ModelClassName}}-createForm');
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
36
CoreCms.Net.CodeGenerator/CrudTemplete/View/Details.tpl
Normal file
36
CoreCms.Net.CodeGenerator/CrudTemplete/View/Details.tpl
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
|
<table class="layui-table layui-form" lay-filter="LAY-app-{{ModelClassName}}-detailsForm" id="LAY-app-{{ModelClassName}}-detailsForm">
|
||||||
|
<colgroup>
|
||||||
|
<col width="100">
|
||||||
|
<col>
|
||||||
|
</colgroup>
|
||||||
|
<tbody>
|
||||||
|
{% for field in ModelFields %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="{{field.DbColumnName}}">{{field.ColumnDescription}}</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if field.DataType == 'bit' %}<input type="checkbox" disabled name="{{field.DbColumnName}}" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}}{% raw %}}}{% endraw %}" lay-skin="switch" lay-text="开启|关闭" lay-filter="{{field.DbColumnName}}" {% raw %}{{{% endraw %} d.params.data.{{field.DbColumnName}} ? 'checked' : '' {% raw %}}}{% endraw %}>{% else %}{% raw %}{{{% endraw %} d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var debug= layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d.params.data); }
|
||||||
|
|
||||||
|
layui.use(['admin', 'form', 'coreHelper'], function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, setter = layui.setter
|
||||||
|
, admin = layui.admin
|
||||||
|
, coreHelper = layui.coreHelper
|
||||||
|
, form = layui.form;
|
||||||
|
form.render(null, 'LAY-app-{{ModelClassName}}-detailsForm');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
100
CoreCms.Net.CodeGenerator/CrudTemplete/View/Edit.tpl
Normal file
100
CoreCms.Net.CodeGenerator/CrudTemplete/View/Edit.tpl
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<script type="text/html" template lay-done="layui.data.sendParams(d);">
|
||||||
|
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-{{ModelClassName}}-editForm" id="LAY-app-{{ModelClassName}}-editForm">
|
||||||
|
{% for field in ModelFields %}{% if field.IsIdentity == true and field.IsPrimarykey == true %}<input type="hidden" name="{{field.DbColumnName}}" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}" />{% endif %}{% if field.DbColumnName contains 'Image' or field.DbColumnName contains 'image' or field.DbColumnName contains 'thumbnail' or field.DbColumnName contains 'Thumbnail' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input name="{{field.DbColumnName}}" id="{{field.DbColumnName}}Input" lay-verType="tips" lay-verify="required" class="layui-input" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}" placeholder="请上传{{field.ColumnDescription}}" lay-reqText="请上传{{field.ColumnDescription}}" />
|
||||||
|
</div>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<img class="coreshop-upload-img" id="viewImgBox{{field.DbColumnName}}" src="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || layui.setter.noImagePicUrl {% raw %}}}{% endraw %}">
|
||||||
|
<button type="button" class="layui-btn" id="upBtn{{field.DbColumnName}}" lay-active="doCropperImg">上传图片</button>
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'nvarchar' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{% if field.Length >0 %}<input name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required|verify{{field.DbColumnName}}" class="layui-input" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}" />{% else %}<input name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}" />
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'int' or field.DataType == 'bigint' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" min="0" max="999999" name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required|number" class="layui-input" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}并为数字" />
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'datetime' %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="{{field.DbColumnName}}" id="editTime-{{ModelClassName}}-{{field.DbColumnName}}" type="text" lay-verType="tips" lay-verify="required|datetime" class="layui-input" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}"/>
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'bit' %}
|
||||||
|
<div class="layui-form-item" pane>
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="checkbox" lay-filter="switch" name="{{field.DbColumnName}}" {% raw %}{{{% endraw %} d.params.data.{{field.DbColumnName}} ? 'checked' : '' {% raw %}}}{% endraw %} lay-skin="switch" lay-text="开启|关闭">
|
||||||
|
</div>
|
||||||
|
</div>{% else %}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="{{field.DbColumnName}}" class="layui-form-label layui-form-required">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="{{field.DbColumnName}}" lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入{{field.ColumnDescription}}" lay-reqText="请输入{{field.ColumnDescription}}" value="{% raw %}{{{% endraw %}d.params.data.{{field.DbColumnName}} || '' {% raw %}}}{% endraw %}" />
|
||||||
|
</div>
|
||||||
|
</div>{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
<div class="layui-form-item text-right core-hidden">
|
||||||
|
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-{{ModelClassName}}-editForm-submit" id="LAY-app-{{ModelClassName}}-editForm-submit" value="确认编辑">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var debug= layui.setter.debug;
|
||||||
|
layui.data.sendParams = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d.params.data); }
|
||||||
|
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
|
||||||
|
function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, form = layui.form
|
||||||
|
, admin = layui.admin
|
||||||
|
, laydate = layui.laydate
|
||||||
|
, upload = layui.upload
|
||||||
|
, cropperImg = layui.cropperImg
|
||||||
|
, coreHelper = layui.coreHelper;
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'datetime' %}
|
||||||
|
laydate.render({
|
||||||
|
elem: '#editTime-{{ModelClassName}}-{{field.DbColumnName}}',
|
||||||
|
type: 'datetime'
|
||||||
|
});{% endif %}{% if field.DbColumnName contains 'Image' or field.DbColumnName contains 'image' or field.DbColumnName contains 'thumbnail' or field.DbColumnName contains 'Thumbnail' %}
|
||||||
|
//{{field.ColumnDescription}}图片裁剪上传
|
||||||
|
$('#upBtn{{field.DbColumnName}}').click(function () {
|
||||||
|
cropperImg.cropImg({
|
||||||
|
aspectRatio: 1 / 1,
|
||||||
|
imgSrc: $('#viewImgBox{{field.DbColumnName}}').attr('src'),
|
||||||
|
onCrop: function (data) {
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
|
||||||
|
if (0 === res.code) {
|
||||||
|
$('#viewImgBox{{field.DbColumnName}}').attr('src', res.data.fileUrl);
|
||||||
|
$("#{{field.DbColumnName}}Input").val(res.data.fileUrl);
|
||||||
|
layer.msg(res.msg);
|
||||||
|
layer.close(loadIndex);
|
||||||
|
} else {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
layer.msg(res.msg, { icon: 2, anim: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
{% endif %}{% endfor %}
|
||||||
|
form.verify({
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'nvarchar' and field.Length > 0 %}
|
||||||
|
verify{{field.DbColumnName}}: [/^.{0,{{field.Length}}}$/,'{{field.ColumnDescription}}最大只允许输入{{field.Length}}位字符'],{% endif %}{% endfor %}
|
||||||
|
});
|
||||||
|
//重载form
|
||||||
|
form.render(null, 'LAY-app-{{ModelClassName}}-editForm');
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
395
CoreCms.Net.CodeGenerator/CrudTemplete/View/Index.tpl
Normal file
395
CoreCms.Net.CodeGenerator/CrudTemplete/View/Index.tpl
Normal file
@@ -0,0 +1,395 @@
|
|||||||
|
<title>{{ModelDescription}}</title>
|
||||||
|
<!--当前位置开始-->
|
||||||
|
<div class="layui-card layadmin-header">
|
||||||
|
<div class="layui-breadcrumb" lay-filter="breadcrumb">
|
||||||
|
<script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--当前位置结束-->
|
||||||
|
<style>
|
||||||
|
/* 重写样式 */
|
||||||
|
</style>
|
||||||
|
<script type="text/html" template lay-type="Post" lay-url="{{ layui.setter.apiUrl }}Api/{{ModelClassName}}/GetIndex" lay-done="layui.data.done(d);">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<div class="table-body">
|
||||||
|
<table id="LAY-app-{{ModelClassName}}-tableBox" lay-filter="LAY-app-{{ModelClassName}}-tableBox"></table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/html" id="LAY-app-{{ModelClassName}}-toolbar">
|
||||||
|
<div class="layui-form coreshop-toolbar-search-form">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'bit' %}
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="{{field.DbColumnName}}">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<select name="{{field.DbColumnName}}">
|
||||||
|
<option value="">请选择</option>
|
||||||
|
<option value="True">是</option>
|
||||||
|
<option value="False">否</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>{% elsif field.DataType == 'datetime' %}
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="{{field.DbColumnName}}">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-inline" style="width: 260px;">
|
||||||
|
<input type="text" name="{{field.DbColumnName}}" id="searchTime-{{ModelClassName}}-{{field.DbColumnName}}" placeholder="请输入{{field.ColumnDescription}}" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>{% else %}
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="{{field.DbColumnName}}">{{field.ColumnDescription}}</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="{{field.DbColumnName}}" placeholder="请输入{{field.ColumnDescription}}" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>{% endif %}{% endfor %}
|
||||||
|
<div class="layui-inline">
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-{{ModelClassName}}-search"><i class="layui-icon layui-icon-search"></i>筛选</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="LAY-app-{{ModelClassName}}-pagebar">
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="addData"><i class="layui-icon layui-icon-add-1"></i>添加数据</button>
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="batchDelete"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="selectExportExcel"><i class="layui-icon layui-icon-add-circle"></i>选择导出</button>
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="queryExportExcel"><i class="layui-icon layui-icon-download-circle"></i>查询导出</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="LAY-app-{{ModelClassName}}-tableBox-bar">
|
||||||
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
||||||
|
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||||
|
<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#{{ModelClassName}}TbDelDrop{% raw %}{{d.LAY_INDEX}}{% endraw %}" no-shade="true">删除</a>
|
||||||
|
<div class="dropdown-menu-nav dropdown-popconfirm dropdown-top-right layui-hide" id="{{ModelClassName}}TbDelDrop{% raw %}{{d.LAY_INDEX}}{% endraw %}"
|
||||||
|
style="max-width: 200px;white-space: normal;min-width: auto;margin-left: 10px;">
|
||||||
|
<div class="dropdown-anchor"></div>
|
||||||
|
<div class="dropdown-popconfirm-title">
|
||||||
|
<i class="layui-icon layui-icon-help"></i>
|
||||||
|
确定要删除吗?
|
||||||
|
</div>
|
||||||
|
<div class="dropdown-popconfirm-btn">
|
||||||
|
<a class="layui-btn layui-btn-primary cursor" btn-cancel>取消</a>
|
||||||
|
<a class="layui-btn layui-btn-normal cursor" lay-event="del">确定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var indexData;
|
||||||
|
var debug= layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d); }
|
||||||
|
|
||||||
|
indexData = d.data;
|
||||||
|
layui.use(['index', 'table', 'laydate', 'util', 'coredropdown', 'coreHelper'],
|
||||||
|
function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, admin = layui.admin
|
||||||
|
, table = layui.table
|
||||||
|
, form = layui.form
|
||||||
|
, laydate = layui.laydate
|
||||||
|
, setter = layui.setter
|
||||||
|
, coreHelper = layui.coreHelper
|
||||||
|
, util = layui.util
|
||||||
|
, view = layui.view;
|
||||||
|
|
||||||
|
var searchwhere;
|
||||||
|
//监听搜索
|
||||||
|
form.on('submit(LAY-app-{{ModelClassName}}-search)',
|
||||||
|
function(data) {
|
||||||
|
var field = data.field;
|
||||||
|
searchwhere = field;
|
||||||
|
//执行重载
|
||||||
|
table.reloadData('LAY-app-{{ModelClassName}}-tableBox',{ where: field });
|
||||||
|
});
|
||||||
|
//数据绑定
|
||||||
|
table.render({
|
||||||
|
elem: '#LAY-app-{{ModelClassName}}-tableBox',
|
||||||
|
url: layui.setter.apiUrl + 'Api/{{ModelClassName}}/GetPageList',
|
||||||
|
method: 'POST',
|
||||||
|
toolbar: '#LAY-app-{{ModelClassName}}-toolbar',
|
||||||
|
pagebar: '#LAY-app-{{ModelClassName}}-pagebar',
|
||||||
|
className: 'pagebarbox',
|
||||||
|
defaultToolbar: ['filter', 'print', 'exports'],
|
||||||
|
height: 'full-127',//面包屑142px,搜索框4行172,3行137,2行102,1行67
|
||||||
|
page: true,
|
||||||
|
limit: 30,
|
||||||
|
limits: [10, 15, 20, 25, 30, 50, 100, 200],
|
||||||
|
text: {none: '暂无相关数据'},
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{ type: "checkbox", fixed: "left" },{% for field in ModelFields %}{% if field.IsIdentity == true and field.IsPrimarykey == true %}
|
||||||
|
{ field: '{{field.DbColumnName}}', title: '{{field.ColumnDescription}}', width: 60, sort: false},{% elsif field.DataType == 'datetime' %}
|
||||||
|
{ field: '{{field.DbColumnName}}', title: '{{field.ColumnDescription}}', width: 130, sort: false},{% elsif field.DataType == 'bit' %}
|
||||||
|
{ field: '{{field.DbColumnName}}', title: '{{field.ColumnDescription}}', width: 95, templet: '#switch_{{field.DbColumnName}}', sort: false , unresize: true},{% elsif field.DbColumnName contains 'Image' or field.DbColumnName contains 'image' or field.DbColumnName contains 'thumbnail' or field.DbColumnName contains 'thumbnail'%}
|
||||||
|
{ field: '{{field.DbColumnName}}', title: '{{field.ColumnDescription}}', width: 100, sort: false,
|
||||||
|
templet: function (d) {
|
||||||
|
if (d.{{field.DbColumnName}}) {
|
||||||
|
return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + d.{{field.DbColumnName}} + '")><image style="max-width:28px;max-height:28px;" src="' + d.{{field.DbColumnName}} + '"/></a>';
|
||||||
|
} else {
|
||||||
|
return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + setter.noImagePicUrl + '")><image style="max-width:30px;max-height:30px;" src="' + setter.noImagePicUrl + '"/></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},{% else %}
|
||||||
|
{ field: '{{field.DbColumnName}}', title: '{{field.ColumnDescription}}', sort: false,width: 105 },{% endif %}{% endfor %}
|
||||||
|
{ width: 162, align: 'center', title:'操作', fixed: 'right', toolbar: '#LAY-app-{{ModelClassName}}-tableBox-bar' }
|
||||||
|
]
|
||||||
|
]
|
||||||
|
});
|
||||||
|
//监听排序事件
|
||||||
|
table.on('sort(LAY-app-{{ModelClassName}}-tableBox)', function(obj){
|
||||||
|
table.reloadData('LAY-app-{{ModelClassName}}-tableBox', {
|
||||||
|
initSort: obj, //记录初始排序,如果不设的话,将无法标记表头的排序状态。
|
||||||
|
where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
|
||||||
|
orderField: obj.field, //排序字段
|
||||||
|
orderDirection: obj.type //排序方式
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//监听行双击事件
|
||||||
|
table.on('rowDouble(LAY-app-{{ModelClassName}}-tableBox)', function (obj) {
|
||||||
|
//查看详情
|
||||||
|
doDetails(obj);
|
||||||
|
});
|
||||||
|
//头工具栏事件
|
||||||
|
table.on('pagebar(LAY-app-{{ModelClassName}}-tableBox)', function (obj) {
|
||||||
|
var checkStatus = table.checkStatus(obj.config.id);
|
||||||
|
switch (obj.event) {
|
||||||
|
case 'addData':
|
||||||
|
doCreate();
|
||||||
|
break;
|
||||||
|
case 'batchDelete':
|
||||||
|
doBatchDelete(checkStatus);
|
||||||
|
break;
|
||||||
|
case 'selectExportExcel':
|
||||||
|
doSelectExportExcel(checkStatus);
|
||||||
|
break;
|
||||||
|
case 'queryExportExcel':
|
||||||
|
doQueryExportexcel();
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
//监听工具条
|
||||||
|
table.on('tool(LAY-app-{{ModelClassName}}-tableBox)',
|
||||||
|
function(obj) {
|
||||||
|
if (obj.event === 'detail') {
|
||||||
|
doDetails(obj);
|
||||||
|
} else if (obj.event === 'del') {
|
||||||
|
doDelete(obj);
|
||||||
|
} else if (obj.event === 'edit') {
|
||||||
|
doEdit(obj)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//执行创建操作
|
||||||
|
function doCreate(){
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/GetCreate", null, function (e) {
|
||||||
|
if (e.code === 0) {
|
||||||
|
admin.popup({
|
||||||
|
shadeClose: false,
|
||||||
|
title: '创建数据',
|
||||||
|
area: ['1200px', '90%'],
|
||||||
|
id: 'LAY-popup-{{ModelClassName}}-create',
|
||||||
|
success: function (layero, index) {
|
||||||
|
view(this.id).render('base/{{ModelClassName}}/create', { data: e.data }).done(function () {
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(LAY-app-{{ModelClassName}}-createForm-submit)',
|
||||||
|
function(data) {
|
||||||
|
var field = data.field; //获取提交的字段
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'bit' %}
|
||||||
|
field.{{field.DbColumnName}} = field.{{field.DbColumnName}} == 'on';{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
if (debug) { console.log(field); } //开启调试返回数据
|
||||||
|
//提交 Ajax 成功后,关闭当前弹层并重载表格
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/DoCreate", field, function (e) {
|
||||||
|
console.log(e)
|
||||||
|
if (e.code === 0) {
|
||||||
|
layui.table.reloadData('LAY-app-{{ModelClassName}}-tableBox'); //重载表格
|
||||||
|
layer.close(index); //再执行关闭
|
||||||
|
layer.msg(e.msg);
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// 禁止弹窗出现滚动条
|
||||||
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
||||||
|
}
|
||||||
|
, btn: ['确定', '取消']
|
||||||
|
, yes: function (index, layero) {
|
||||||
|
layero.contents().find("#LAY-app-{{ModelClassName}}-createForm-submit").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行编辑操作
|
||||||
|
function doEdit(obj){
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/GetEdit", {id:obj.data.id}, function (e) {
|
||||||
|
if (e.code === 0) {
|
||||||
|
admin.popup({
|
||||||
|
shadeClose: false,
|
||||||
|
title: '编辑数据',
|
||||||
|
area: ['1200px', '90%'],
|
||||||
|
id: 'LAY-popup-{{ModelClassName}}-edit',
|
||||||
|
success: function (layero, index) {
|
||||||
|
view(this.id).render('base/{{ModelClassName}}/edit', { data: e.data }).done(function () {
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(LAY-app-{{ModelClassName}}-editForm-submit)',
|
||||||
|
function(data) {
|
||||||
|
var field = data.field; //获取提交的字段
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'bit' %}
|
||||||
|
field.{{field.DbColumnName}} = field.{{field.DbColumnName}} == 'on';{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
if (debug) { console.log(field); } //开启调试返回数据
|
||||||
|
//提交 Ajax 成功后,关闭当前弹层并重载表格
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/DoEdit", field, function (e) {
|
||||||
|
console.log(e)
|
||||||
|
if (e.code === 0) {
|
||||||
|
layui.table.reloadData('LAY-app-{{ModelClassName}}-tableBox'); //重载表格
|
||||||
|
layer.close(index); //再执行关闭
|
||||||
|
layer.msg(e.msg);
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
// 禁止弹窗出现滚动条
|
||||||
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
||||||
|
}
|
||||||
|
, btn: ['确定', '取消']
|
||||||
|
, yes: function (index, layero) {
|
||||||
|
layero.contents().find("#LAY-app-{{ModelClassName}}-editForm-submit").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行预览操作
|
||||||
|
function doDetails(obj) {
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/GetDetails", { id: obj.data.id }, function (e) {
|
||||||
|
if (e.code === 0) {
|
||||||
|
admin.popup({
|
||||||
|
shadeClose: false,
|
||||||
|
title: '查看详情',
|
||||||
|
area: ['1200px', '90%'],
|
||||||
|
id: 'LAY-popup-{{ModelClassName}}-details',
|
||||||
|
success: function (layero, index) {
|
||||||
|
view(this.id).render('base/{{ModelClassName}}/details', { data: e.data }).done(function () {
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
// 禁止弹窗出现滚动条
|
||||||
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行单个删除
|
||||||
|
function doDelete(obj){
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/DoDelete", { id: obj.data.id }, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
table.reloadData('LAY-app-{{ModelClassName}}-tableBox');
|
||||||
|
layer.msg(e.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行批量删除
|
||||||
|
function doBatchDelete(checkStatus){
|
||||||
|
var checkData = checkStatus.data;
|
||||||
|
if (checkData.length === 0) {
|
||||||
|
return layer.msg('请选择要删除的数据');
|
||||||
|
}
|
||||||
|
layer.confirm('确定删除吗?删除后将无法恢复。',
|
||||||
|
function(index) {
|
||||||
|
var delidsStr = [];
|
||||||
|
layui.each(checkData,
|
||||||
|
function(index, item) {
|
||||||
|
delidsStr.push(item.id);
|
||||||
|
});
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/DoBatchDelete", { id: delidsStr }, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
table.reloadData('LAY-app-{{ModelClassName}}-tableBox');
|
||||||
|
layer.msg(e.msg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行查询条件导出excel
|
||||||
|
function doQueryExportexcel(){
|
||||||
|
layer.confirm('确定根据当前的查询条件导出数据吗?',
|
||||||
|
function(index) {
|
||||||
|
var field = searchwhere;
|
||||||
|
coreHelper.PostForm("Api/{{ModelClassName}}/QueryExportExcel", field, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
if (e.code === 0) {
|
||||||
|
window.open(e.data);
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//执行选择目录导出数据
|
||||||
|
function doSelectExportExcel(checkStatus){
|
||||||
|
var checkData = checkStatus.data;
|
||||||
|
if (checkData.length === 0) {
|
||||||
|
return layer.msg('请选择您要导出的数据');
|
||||||
|
}
|
||||||
|
layer.confirm('确定导出选择的内容吗?',
|
||||||
|
function(index) {
|
||||||
|
var delidsStr = [];
|
||||||
|
layui.each(checkData,
|
||||||
|
function(index, item) {
|
||||||
|
delidsStr.push(item.id);
|
||||||
|
});
|
||||||
|
layer.close(index);
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/SelectExportExcel", { id: delidsStr }, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
if (e.code === 0) {
|
||||||
|
window.open(e.data);
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'datetime' %}
|
||||||
|
laydate.render({
|
||||||
|
elem: '#searchTime-{{ModelClassName}}-{{field.DbColumnName}}',
|
||||||
|
type: 'datetime',
|
||||||
|
range: '到',
|
||||||
|
});{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
//监听 表格复选框操作
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'bit' %}
|
||||||
|
layui.form.on('switch(switch_{{field.DbColumnName}})', function (obj) {
|
||||||
|
coreHelper.Post("Api/{{ModelClassName}}/DoSet{{field.DbColumnName}}", { id: this.value, data: obj.elem.checked }, function (e) {
|
||||||
|
if (debug) { console.log(e); } //开启调试返回数据
|
||||||
|
//table.reloadData('LAY-app-{{ModelClassName}}-tableBox');
|
||||||
|
layer.msg(e.msg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
//重载form
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
{% for field in ModelFields %}{% if field.DataType == 'bit' %}
|
||||||
|
<!--设置{{field.ColumnDescription}}-->
|
||||||
|
<script type="text/html" id="switch_{{field.DbColumnName}}">
|
||||||
|
<input type="checkbox" name="switch_{{field.DbColumnName}}" value="{% raw %}{{d.id}}{% endraw %}" lay-skin="switch" lay-text="开启|关闭" lay-filter="switch_{{field.DbColumnName}}" {% raw %}{{{% endraw %} d.{{field.DbColumnName}} ? 'checked' : '' {% raw %}}}{% endraw %}>
|
||||||
|
</script>
|
||||||
|
{% endif %}{% endfor %}
|
||||||
629
CoreCms.Net.CodeGenerator/GeneratorCodeHelper.cs
Normal file
629
CoreCms.Net.CodeGenerator/GeneratorCodeHelper.cs
Normal file
@@ -0,0 +1,629 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using DotLiquid;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.CodeGenerator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自动生成代码
|
||||||
|
/// </summary>
|
||||||
|
public static class GeneratorCodeHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单表生成对应数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tableName">表名称</param>
|
||||||
|
/// <param name="tableDescription">表说明</param>
|
||||||
|
/// <param name="columns">表字段</param>
|
||||||
|
public static byte[] CodeGenerator(string tableName, string tableDescription, List<DbColumnInfo> columns, string fileType)
|
||||||
|
{
|
||||||
|
//ModelClassName
|
||||||
|
//ModelName
|
||||||
|
//ModelFields Name Comment
|
||||||
|
var dt = DateTime.Now;
|
||||||
|
byte[] data;
|
||||||
|
var obj = new
|
||||||
|
{
|
||||||
|
ModelCreateTime= dt,
|
||||||
|
ModelName = tableName,
|
||||||
|
ModelDescription = tableDescription,
|
||||||
|
ModelClassName = tableName,
|
||||||
|
ModelFields = columns.Select(r => new
|
||||||
|
{
|
||||||
|
r.DbColumnName,
|
||||||
|
r.ColumnDescription,
|
||||||
|
r.DataType,
|
||||||
|
r.DecimalDigits,
|
||||||
|
r.DefaultValue,
|
||||||
|
r.IsIdentity,
|
||||||
|
r.IsNullable,
|
||||||
|
r.IsPrimarykey,
|
||||||
|
//Length = (r.DataType == "nvarchar" && r.Length > 0) ? r.Length / 2 : r.Length,
|
||||||
|
r.Length,
|
||||||
|
r.PropertyName,
|
||||||
|
r.PropertyType,
|
||||||
|
r.Scale,
|
||||||
|
r.TableId,
|
||||||
|
r.TableName,
|
||||||
|
r.Value
|
||||||
|
}).ToArray()
|
||||||
|
};
|
||||||
|
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(GeneratorCodeHelper)).Assembly;
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (ZipArchive zip = new ZipArchive(ms, ZipArchiveMode.Create, false))
|
||||||
|
{
|
||||||
|
string file;
|
||||||
|
string result;
|
||||||
|
Template template;
|
||||||
|
|
||||||
|
switch (fileType)
|
||||||
|
{
|
||||||
|
case "AllFiles":
|
||||||
|
//Controller
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Controllers.Controller.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry4 = zip.CreateEntry("Controller/" + tableName + "Controller.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry4.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//IRespository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.IRepository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IRepository/I" + tableName + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Respository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.Repository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Repository/" + tableName + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IServices
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.IServices.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IServices/I" + tableName + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Services
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.Services.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Services/" + tableName + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Model
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.DbModel.Model.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Entity/" + tableName + ".cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CreateHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Create.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/create.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//EditHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Edit.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/edit.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//DetailsHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Details.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/details.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IndexHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Index.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/index.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "EntityFiles":
|
||||||
|
//Model
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.DbModel.Model.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Entity/" + tableName + ".cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "ServicesFiles":
|
||||||
|
//IServices
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.IServices.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IServices/I" + tableName + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Services
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.Services.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Services/" + tableName + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "ViewFiles":
|
||||||
|
//CreateHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Create.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/create.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//EditHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Edit.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/edit.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//DetailsHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Details.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/details.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IndexHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Index.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + tableName.ToLower().ToLower() + "/index.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "InterFaceFiles":
|
||||||
|
//IRespository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.IRepository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IRepository/I" + tableName + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Respository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.Repository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Repository/" + tableName + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data = ms.ToArray();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成整个数据库文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tableName">表名称</param>
|
||||||
|
/// <param name="tableDescription">表说明</param>
|
||||||
|
/// <param name="columns">表字段</param>
|
||||||
|
public static byte[] CodeGeneratorAll(List<DbTableInfoAndColumns> dbModels, string fileType)
|
||||||
|
{
|
||||||
|
//ModelClassName
|
||||||
|
//ModelName
|
||||||
|
//ModelFields Name Comment
|
||||||
|
byte[] data;
|
||||||
|
|
||||||
|
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(GeneratorCodeHelper)).Assembly;
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (ZipArchive zip = new ZipArchive(ms, ZipArchiveMode.Create, false))
|
||||||
|
{
|
||||||
|
string file;
|
||||||
|
string result;
|
||||||
|
Template template;
|
||||||
|
|
||||||
|
foreach (var item in dbModels)
|
||||||
|
{
|
||||||
|
var obj = new
|
||||||
|
{
|
||||||
|
ModelName = item.Name,
|
||||||
|
ModelDescription = item.Description,
|
||||||
|
ModelClassName = item.Name,
|
||||||
|
ModelFields = item.columns.Select(r => new
|
||||||
|
{
|
||||||
|
r.DbColumnName,
|
||||||
|
r.ColumnDescription,
|
||||||
|
r.DataType,
|
||||||
|
r.DecimalDigits,
|
||||||
|
r.DefaultValue,
|
||||||
|
r.IsIdentity,
|
||||||
|
r.IsNullable,
|
||||||
|
r.IsPrimarykey,
|
||||||
|
Length = (r.DataType == "nvarchar" && r.Length > 0) ? r.Length / 2 : r.Length,
|
||||||
|
r.PropertyName,
|
||||||
|
r.PropertyType,
|
||||||
|
r.Scale,
|
||||||
|
r.TableId,
|
||||||
|
r.TableName,
|
||||||
|
r.Value
|
||||||
|
}).ToArray()
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (fileType)
|
||||||
|
{
|
||||||
|
case "AllFiles":
|
||||||
|
//Controller
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Controllers.Controller.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry4 = zip.CreateEntry("Controller/" + item.Name + "Controller.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry4.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//IRespository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.IRepository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IRepository/I" + item.Name + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Respository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.Repository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Repository/" + item.Name + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IServices
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.IServices.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IServices/I" + item.Name + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Services
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.Services.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Services/" + item.Name + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Model
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.DbModel.Model.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Entity/" + item.Name + ".cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CreateHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Create.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/create.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//EditHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Edit.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/edit.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//DetailsHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Details.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/details.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IndexHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Index.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/index.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "EntityFiles":
|
||||||
|
//Model
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.DbModel.Model.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Entity/" + item.Name + ".cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "ServicesFiles":
|
||||||
|
//IServices
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.IServices.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IServices/I" + item.Name + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Services
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Services.Services.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Services/" + item.Name + "Services.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "ViewFiles":
|
||||||
|
//CreateHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Create.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/create.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//EditHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Edit.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/edit.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//DetailsHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Details.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/details.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IndexHtml
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.View.Index.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Html/" + item.Name.ToLower().ToLower() + "/index.html");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "InterFaceFiles":
|
||||||
|
//IRespository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.IRepository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry3 = zip.CreateEntry("IRepository/I" + item.Name + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry3.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Respository
|
||||||
|
using (var reader = new StreamReader(assembly.GetManifestResourceStream("CoreCms.Net.CodeGenerator.CrudTemplete.Repositories.Repository.tpl"), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
file = reader.ReadToEnd();
|
||||||
|
template = Template.Parse(file);
|
||||||
|
result = template.Render(Hash.FromAnonymousObject(obj));
|
||||||
|
ZipArchiveEntry entry1 = zip.CreateEntry("Repository/" + item.Name + "Repository.cs");
|
||||||
|
using (StreamWriter entryStream = new StreamWriter(entry1.Open()))
|
||||||
|
{
|
||||||
|
entryStream.Write(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
data = ms.ToArray();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
164
CoreCms.Net.Configuration/AppSettingsConstVars.cs
Normal file
164
CoreCms.Net.Configuration/AppSettingsConstVars.cs
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SqlSugar.Extensions;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置文件格式化
|
||||||
|
/// </summary>
|
||||||
|
public class AppSettingsConstVars
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 全局地址================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 系统后端地址
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string AppConfigAppUrl = AppSettingsHelper.GetContent("AppConfig", "AppUrl");
|
||||||
|
/// <summary>
|
||||||
|
/// 系统接口地址
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string AppConfigAppInterFaceUrl = AppSettingsHelper.GetContent("AppConfig", "AppInterFaceUrl");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 数据库================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据库连接字符串
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DbSqlConnection = AppSettingsHelper.GetContent("ConnectionStrings", "SqlConnection");
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据库类型
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DbDbType = AppSettingsHelper.GetContent("ConnectionStrings", "DbType");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region redis================================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取redis连接字符串
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string RedisConfigConnectionString = AppSettingsHelper.GetContent("RedisConfig", "ConnectionString");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用redis作为缓存选择
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool RedisUseCache = AppSettingsHelper.GetContent("RedisConfig", "UseCache").ObjToBool();
|
||||||
|
/// <summary>
|
||||||
|
/// 启用redis作为定时任务
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool RedisUseTimedTask = AppSettingsHelper.GetContent("RedisConfig", "UseTimedTask").ObjToBool();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region AOP================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 事务切面开关
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool TranAopEnabled = AppSettingsHelper.GetContent("TranAOP", "Enabled").ObjToBool();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Jwt授权配置================================================================================
|
||||||
|
|
||||||
|
public static readonly string JwtConfigSecretKey = AppSettingsHelper.GetContent("JwtConfig", "SecretKey");
|
||||||
|
public static readonly string JwtConfigIssuer = AppSettingsHelper.GetContent("JwtConfig", "Issuer");
|
||||||
|
public static readonly string JwtConfigAudience = AppSettingsHelper.GetContent("JwtConfig", "Audience");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Cors跨域设置================================================================================
|
||||||
|
public static readonly string CorsPolicyName = AppSettingsHelper.GetContent("Cors", "PolicyName");
|
||||||
|
public static readonly bool CorsEnableAllIPs = AppSettingsHelper.GetContent("Cors", "EnableAllIPs").ObjToBool();
|
||||||
|
public static readonly string CorsIPs = AppSettingsHelper.GetContent("Cors", "IPs");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Middleware中间件================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Ip限流
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool MiddlewareIpLogEnabled = AppSettingsHelper.GetContent("Middleware", "IPLog", "Enabled").ObjToBool();
|
||||||
|
/// <summary>
|
||||||
|
/// 记录请求与返回数据
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool MiddlewareRequestResponseLogEnabled = AppSettingsHelper.GetContent("Middleware", "RequestResponseLog", "Enabled").ObjToBool();
|
||||||
|
/// <summary>
|
||||||
|
/// 用户访问记录-是否开启
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool MiddlewareRecordAccessLogsEnabled = AppSettingsHelper.GetContent("Middleware", "RecordAccessLogs", "Enabled").ObjToBool();
|
||||||
|
/// <summary>
|
||||||
|
/// 用户访问记录-过滤ip
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string MiddlewareRecordAccessLogsIgnoreApis = AppSettingsHelper.GetContent("Middleware", "RecordAccessLogs", "IgnoreApis");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 支付================================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 微信支付回调
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PayCallBackWeChatPayUrl = AppSettingsHelper.GetContent("PayCallBack", "WeChatPayUrl");
|
||||||
|
/// <summary>
|
||||||
|
/// 微信退款回调
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PayCallBackWeChatRefundUrl = AppSettingsHelper.GetContent("PayCallBack", "WeChatRefundUrl");
|
||||||
|
/// <summary>
|
||||||
|
/// 支付宝支付回调
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PayCallBackAlipayUrl = AppSettingsHelper.GetContent("PayCallBack", "AlipayUrl");
|
||||||
|
/// <summary>
|
||||||
|
/// 支付宝退款回调
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PayCallBackAlipayRefundUrl = AppSettingsHelper.GetContent("PayCallBack", "AlipayRefundUrl");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 易联云打印机================================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool YiLianYunConfigEnabled = AppSettingsHelper.GetContent("YiLianYunConfig", "Enabled").ObjToBool();
|
||||||
|
/// <summary>
|
||||||
|
/// 应用ID
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string YiLianYunConfigClientId = AppSettingsHelper.GetContent("YiLianYunConfig", "ClientId");
|
||||||
|
/// <summary>
|
||||||
|
/// 应用密钥
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string YiLianYunConfigClientSecret = AppSettingsHelper.GetContent("YiLianYunConfig", "ClientSecret");
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机设备号
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string YiLianYunConfigMachineCode = AppSettingsHelper.GetContent("YiLianYunConfig", "MachineCode");
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机终端密钥
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string YiLianYunConfigMsign = AppSettingsHelper.GetContent("YiLianYunConfig", "Msign");
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机名称
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string YiLianYunConfigPrinterName = AppSettingsHelper.GetContent("YiLianYunConfig", "PrinterName");
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机设置联系方式
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string YiLianYunConfigPhone = AppSettingsHelper.GetContent("YiLianYunConfig", "Phone");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region HangFire定时任务================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 登录账号
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string HangFireLogin = AppSettingsHelper.GetContent("HangFire", "Login");
|
||||||
|
/// <summary>
|
||||||
|
/// 登录密码
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string HangFirePassWord = AppSettingsHelper.GetContent("HangFire", "PassWord");
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
46
CoreCms.Net.Configuration/AppSettingsHelper.cs
Normal file
46
CoreCms.Net.Configuration/AppSettingsHelper.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using SqlSugar.Extensions;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <20><>ȡAppsettings<67><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
/// </summary>
|
||||||
|
public class AppSettingsHelper
|
||||||
|
{
|
||||||
|
static IConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
|
public AppSettingsHelper(string contentPath)
|
||||||
|
{
|
||||||
|
string Path = "appsettings.json";
|
||||||
|
Configuration = new ConfigurationBuilder().SetBasePath(contentPath).Add(new JsonConfigurationSource { Path = Path, Optional = false, ReloadOnChange = true }).Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <20><>װҪ<D7B0><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||||||
|
/// AppSettingsHelper.GetContent(new string[] { "JwtConfig", "SecretKey" });
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sections"><3E>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetContent(params string[] sections)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
if (sections.Any())
|
||||||
|
{
|
||||||
|
return Configuration[string.Join(":", sections)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
17
CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj
Normal file
17
CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoMapper" Version="10.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
398
CoreCms.Net.Configuration/GlobalConstVars.cs
Normal file
398
CoreCms.Net.Configuration/GlobalConstVars.cs
Normal file
@@ -0,0 +1,398 @@
|
|||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
public class GlobalConstVars
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据删除成功
|
||||||
|
/// </summary>
|
||||||
|
public const string DeleteSuccess = "数据删除成功";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据删除失败
|
||||||
|
/// </summary>
|
||||||
|
public const string DeleteFailure = "数据删除失败";
|
||||||
|
/// <summary>
|
||||||
|
/// 系统禁止删除此数据
|
||||||
|
/// </summary>
|
||||||
|
public const string DeleteProhibitDelete = "系统禁止删除此数据";
|
||||||
|
/// <summary>
|
||||||
|
/// 此数据含有子类信息,禁止删除
|
||||||
|
/// </summary>
|
||||||
|
public const string DeleteIsHaveChildren = "此数据含有子类信息,禁止删除";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据处理异常
|
||||||
|
/// </summary>
|
||||||
|
public const string DataHandleEx = "数据接口出现异常";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据添加成功
|
||||||
|
/// </summary>
|
||||||
|
public const string CreateSuccess = "数据添加成功";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据添加失败
|
||||||
|
/// </summary>
|
||||||
|
public const string CreateFailure = "数据添加失败";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据移动成功
|
||||||
|
/// </summary>
|
||||||
|
public const string MoveSuccess = "数据移动成功";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据移动失败
|
||||||
|
/// </summary>
|
||||||
|
public const string MoveFailure = "数据移动失败";
|
||||||
|
/// <summary>
|
||||||
|
/// 系统禁止添加数据
|
||||||
|
/// </summary>
|
||||||
|
public const string CreateProhibitCreate = "系统禁止添加数据";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据编辑成功
|
||||||
|
/// </summary>
|
||||||
|
public const string EditSuccess = "数据编辑成功";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据编辑失败
|
||||||
|
/// </summary>
|
||||||
|
public const string EditFailure = "数据编辑失败";
|
||||||
|
/// <summary>
|
||||||
|
/// 系统禁止编辑此数据
|
||||||
|
/// </summary>
|
||||||
|
public const string EditProhibitEdit = "系统禁止编辑此数据";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据已存在
|
||||||
|
/// </summary>
|
||||||
|
public const string DataIsHave = "数据已存在";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据不存在
|
||||||
|
/// </summary>
|
||||||
|
public const string DataisNo = "数据不存在";
|
||||||
|
/// <summary>
|
||||||
|
/// 请提交必要的参数
|
||||||
|
/// </summary>
|
||||||
|
public const string DataParameterError = "请提交必要的参数";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据插入成功
|
||||||
|
/// </summary>
|
||||||
|
public const string InsertSuccess = "数据插入成功!";
|
||||||
|
/// <summary>
|
||||||
|
/// 数据插入失败
|
||||||
|
/// </summary>
|
||||||
|
public const string InsertFailure = "数据插入失败!";
|
||||||
|
/// <summary>
|
||||||
|
/// Excel导出失败
|
||||||
|
/// </summary>
|
||||||
|
public const string ExcelExportFailure = "Excel导出失败";
|
||||||
|
/// <summary>
|
||||||
|
/// Excel导出成功
|
||||||
|
/// </summary>
|
||||||
|
public const string ExcelExportSuccess = "Excel导出成功";
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据成功
|
||||||
|
/// </summary>
|
||||||
|
public const string GetDataSuccess = "获取数据成功!";
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据异常
|
||||||
|
/// </summary>
|
||||||
|
public const string GetDataException = "获取数据异常!";
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据失败
|
||||||
|
/// </summary>
|
||||||
|
public const string GetDataFailure = "获取数据失败!";
|
||||||
|
/// <summary>
|
||||||
|
/// 设置数据成功
|
||||||
|
/// </summary>
|
||||||
|
public const string SetDataSuccess = "设置数据成功!";
|
||||||
|
/// <summary>
|
||||||
|
/// 设置数据异常
|
||||||
|
/// </summary>
|
||||||
|
public const string SetDataException = "设置数据异常!";
|
||||||
|
/// <summary>
|
||||||
|
/// 设置数据失败
|
||||||
|
/// </summary>
|
||||||
|
public const string SetDataFailure = "设置数据失败!";
|
||||||
|
|
||||||
|
//缓存数据
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存已经排序后台导航
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheFindNavSortList = "CacheFindNavSortList";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存未排序后台导航
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheFindNavNoSortList = "CacheFindNavNoSortList";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存角色列表
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheManagerRoleList = "CacheManagerRoleList";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存单页分类
|
||||||
|
/// </summary>
|
||||||
|
public const string CachePageCategoryList = "CachePageCategoryList";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存角色详细信息
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheRoleValues = "CacheRoleValues";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存用户组
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheUserCategoryList = "CacheUserCategoryList";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存业务
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheJobDirectoryList = "CacheJobDirectoryList";
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存无序区域业务
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheAreaList = "CacheArea";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存配置信息
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheCoreCmsSettingList = "CacheCoreCmsSettingList";
|
||||||
|
|
||||||
|
public const string CacheCoreCmsSettingByComparison = "CacheCoreCmsSettingByComparison";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CookieOpenid
|
||||||
|
/// </summary>
|
||||||
|
public const string CookieOpenId = "CookieOpenId";
|
||||||
|
/// <summary>
|
||||||
|
/// SessionOpenId
|
||||||
|
/// </summary>
|
||||||
|
public const string SessionOpenId = "SessionOpenId";
|
||||||
|
/// <summary>
|
||||||
|
/// 用户AccessToken有效期
|
||||||
|
/// </summary>
|
||||||
|
public const string CookieOAuthAccessTokenEndTime = "CookieOAuthAccessTokenEndTime";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 广告表
|
||||||
|
/// </summary>
|
||||||
|
public const string CacheCoreCmsAdvertisement = "CacheCoreCmsAdvertisement";
|
||||||
|
public const string CacheCoreCmsAdvertPosition = "CacheCoreCmsAdvertPosition"; //广告位置表
|
||||||
|
public const string CacheCoreCmsArea = "CacheCoreCmsArea"; // 地区表
|
||||||
|
public const string CacheCoreCmsArticle = "CacheCoreCmsArticle"; //文章表
|
||||||
|
public const string CacheCoreCmsArticleType = "CacheCoreCmsArticleType"; // 文章分类表
|
||||||
|
public const string CacheCoreCmsBillAftersales = "CacheCoreCmsBillAftersales"; // 退货单表
|
||||||
|
public const string CacheCoreCmsBillAftersalesImages = "CacheCoreCmsBillAftersalesImages"; // 商品图片关联表
|
||||||
|
public const string CacheCoreCmsBillAftersalesItem = "CacheCoreCmsBillAftersalesItem"; // 售后单明细表
|
||||||
|
public const string CacheCoreCmsBillDelivery = "CacheCoreCmsBillDelivery"; //发货单表
|
||||||
|
public const string CacheCoreCmsBillDeliveryItem = "CacheCoreCmsBillDeliveryItem"; // 发货单详情表
|
||||||
|
public const string CacheCoreCmsBillDeliveryOrderRel = "CacheCoreCmsBillDeliveryOrderRel"; // 发货单订单关联表
|
||||||
|
public const string CacheCoreCmsBillLading = "CacheCoreCmsBillLading"; // 提货单表
|
||||||
|
public const string CacheCoreCmsBillPayments = "CacheCoreCmsBillPayments"; //支付单表
|
||||||
|
public const string CacheCoreCmsBillPaymentsRel = "CacheCoreCmsBillPaymentsRel"; //支付单明细表
|
||||||
|
public const string CacheCoreCmsBillRefund = "CacheCoreCmsBillRefund"; //退款单表
|
||||||
|
public const string CacheCoreCmsBillReship = "CacheCoreCmsBillReship"; //退货单表
|
||||||
|
public const string CacheCoreCmsBillReshipItem = "CacheCoreCmsBillReshipItem"; // 退货单明细表
|
||||||
|
public const string CacheCoreCmsBrand = "CacheCoreCmsBrand"; //品牌表
|
||||||
|
public const string CacheCoreCmsCart = "CacheCoreCmsCart"; // 购物车表
|
||||||
|
public const string CacheCoreCmsClerk = "CacheCoreCmsClerk"; //店铺店员关联表
|
||||||
|
public const string CacheCoreCmsCoupon = "CacheCoreCmsCoupon"; // 优惠券表
|
||||||
|
public const string CacheCoreCmsDistribution = "CacheCoreCmsDistribution"; // 分销商表
|
||||||
|
public const string CacheCoreCmsDistributionCondition = "CacheCoreCmsDistributionCondition"; //分销商等级升级条件
|
||||||
|
public const string CacheCoreCmsDistributionGrade = "CacheCoreCmsDistributionGrade"; // 分销商等级设置表
|
||||||
|
public const string CacheCoreCmsDistributionOrder = "CacheCoreCmsDistributionOrder"; //分销商订单记录表
|
||||||
|
public const string CacheCoreCmsDistributionResult = "CacheCoreCmsDistributionResult"; // 等级佣金表
|
||||||
|
public const string CacheCoreCmsErrorMessageLog = "CacheCoreCmsErrorMessageLog"; //后台异常错误表
|
||||||
|
public const string CacheCoreCmsForm = "CacheCoreCmsForm"; //表单
|
||||||
|
public const string CacheCoreCmsFormItem = "CacheCoreCmsFormItem"; // 表单项表
|
||||||
|
public const string CacheCoreCmsFormSubmit = "CacheCoreCmsFormSubmit"; // 用户对表的提交记录
|
||||||
|
public const string CacheCoreCmsFormSubmitDetail = "CacheCoreCmsFormSubmitDetail"; //提交表单保存大文本值表
|
||||||
|
public const string CacheCoreCmsGoods = "CacheCoreCmsGoods"; // 商品表
|
||||||
|
public const string CacheCoreCmsGoodsBrowsing = "CacheCoreCmsGoodsBrowsing"; // 商品浏览记录表
|
||||||
|
public const string CacheCoreCmsGoodsCategory = "CacheCoreCmsGoodsCategory"; // 商品分类
|
||||||
|
public const string CacheCoreCmsGoodsCategoryExtend = "CacheCoreCmsGoodsCategoryExtend"; //商品分类扩展表
|
||||||
|
public const string CacheCoreCmsGoodsCollection = "CacheCoreCmsGoodsCollection"; //商品收藏表
|
||||||
|
public const string CacheCoreCmsGoodsComment = "CacheCoreCmsGoodsComment"; //商品评价表
|
||||||
|
public const string CacheCoreCmsGoodsGrade = "CacheCoreCmsGoodsGrade"; //商品会员价表
|
||||||
|
public const string CacheCoreCmsGoodsImages = "CacheCoreCmsGoodsImages"; // 商品图片关联表
|
||||||
|
public const string CacheCoreCmsGoodsParams = "CacheCoreCmsGoodsParams"; // 商品参数表
|
||||||
|
public const string CacheCoreCmsGoodsType = "CacheCoreCmsGoodsType"; // 商品类型
|
||||||
|
public const string CacheCoreCmsGoodsTypeParams = "CacheCoreCmsGoodsTypeParams"; // 商品参数类型关系表
|
||||||
|
public const string CacheCoreCmsGoodsTypeSpec = "CacheCoreCmsGoodsTypeSpec"; //商品类型属性表
|
||||||
|
public const string CacheCoreCmsGoodsTypeSpecRel = "CacheCoreCmsGoodsTypeSpecRel"; //商品类型和属性关联表
|
||||||
|
public const string CacheCoreCmsGoodsTypeSpecValue = "CacheCoreCmsGoodsTypeSpecValue"; // 商品类型属性值表
|
||||||
|
public const string CacheCoreCmsImages = "CacheCoreCmsImages"; // 图片表
|
||||||
|
public const string CacheCoreCmsInvoice = "CacheCoreCmsInvoice"; // 发票表
|
||||||
|
public const string CacheCoreCmsInvoiceRecord = "CacheCoreCmsInvoiceRecord"; //发票信息记录
|
||||||
|
public const string CacheCoreCmsJobs = "CacheCoreCmsJobs"; // 队列表
|
||||||
|
public const string CacheCoreCmsLabel = "CacheCoreCmsLabel"; //标签表
|
||||||
|
public const string CacheCoreCmsLoginLog = "CacheCoreCmsLoginLog"; // 登录日志
|
||||||
|
public const string CacheCoreCmsLogistics = "CacheCoreCmsLogistics"; // 物流公司表
|
||||||
|
public const string CacheCoreCmsMessage = "CacheCoreCmsMessage"; //消息发送表
|
||||||
|
public const string CacheCoreCmsMessageCenter = "CacheCoreCmsMessageCenter"; // 消息配置表
|
||||||
|
public const string CacheCoreCmsNotice = "CacheCoreCmsNotice"; //公告表
|
||||||
|
public const string CacheCoreCmsOrder = "CacheCoreCmsOrder"; //订单表
|
||||||
|
public const string CacheCoreCmsOrderItem = "CacheCoreCmsOrderItem"; //订单明细表
|
||||||
|
public const string CacheCoreCmsOrderLog = "CacheCoreCmsOrderLog"; //订单记录表
|
||||||
|
public const string CacheCoreCmsPages = "CacheCoreCmsPages"; // 单页
|
||||||
|
public const string CacheCoreCmsPagesItems = "CacheCoreCmsPagesItems"; //单页内容
|
||||||
|
public const string CacheCoreCmsPayments = "CacheCoreCmsPayments"; // 支付方式表
|
||||||
|
public const string CacheCoreCmsPinTuanGoods = "CacheCoreCmsPinTuanGoods"; //拼团商品表
|
||||||
|
public const string CacheCoreCmsPinTuanRecord = "CacheCoreCmsPinTuanRecord"; //拼团记录表
|
||||||
|
public const string CacheCoreCmsPinTuanRule = "CacheCoreCmsPinTuanRule"; //拼团规则表
|
||||||
|
public const string CacheCoreCmsProducts = "CacheCoreCmsProducts"; //货品表
|
||||||
|
public const string CacheCoreCmsPromotion = "CacheCoreCmsPromotion"; // 促销表
|
||||||
|
public const string CacheCoreCmsPromotionCondition = "CacheCoreCmsPromotionCondition"; // 促销条件表
|
||||||
|
public const string CacheCoreCmsPromotionResult = "CacheCoreCmsPromotionResult"; //促销结果表
|
||||||
|
public const string CacheCoreCmsSetting = "CacheCoreCmsSetting"; //店铺设置表
|
||||||
|
public const string CacheCoreCmsShip = "CacheCoreCmsShip"; //配送方式表
|
||||||
|
public const string CacheCoreCmsSms = "CacheCoreCmsSms"; // 短信发送日志
|
||||||
|
public const string CacheCoreCmsStore = "CacheCoreCmsStore"; // 门店表
|
||||||
|
public const string CacheCoreCmsTemplate = "CacheCoreCmsTemplate"; //模板列表
|
||||||
|
public const string CacheCoreCmsTemplateMessage = "CacheCoreCmsTemplateMessage"; //模板消息
|
||||||
|
public const string CacheCoreCmsTemplateOrder = "CacheCoreCmsTemplateOrder"; //模板订购记录表
|
||||||
|
public const string CacheCoreCmsUser = "CacheCoreCmsUser"; //用户表
|
||||||
|
public const string CacheCoreCmsUserBalance = "CacheCoreCmsUserBalance"; //用户余额表
|
||||||
|
public const string CacheCoreCmsUserBankCard = "CacheCoreCmsUserBankCard"; //银行卡信息
|
||||||
|
public const string CacheCoreCmsUserGrade = "CacheCoreCmsUserGrade"; // 用户等级表
|
||||||
|
public const string CacheCoreCmsUserLog = "CacheCoreCmsUserLog"; // 用户日志
|
||||||
|
public const string CacheCoreCmsUserPointLog = "CacheCoreCmsUserPointLog"; //用户积分记录表
|
||||||
|
public const string CacheCoreCmsUserShip = "CacheCoreCmsUserShip"; //用户地址表
|
||||||
|
public const string CacheCoreCmsUserTocash = "CacheCoreCmsUserTocash"; //用户提现记录表
|
||||||
|
public const string CacheCoreCmsUserToken = "CacheCoreCmsUserToken"; // 用户token
|
||||||
|
public const string CacheCoreCmsUserWeChatInfo = "CacheCoreCmsUserWeChatInfo"; //用户表
|
||||||
|
public const string CacheCoreCmsUserWeChatMsgSubscription = "CacheCoreCmsUserWeChatMsgSubscription"; // 微信订阅消息存储表
|
||||||
|
public const string CacheCoreCmsUserWeChatMsgSubscriptionSwitch = "CacheCoreCmsUserWeChatMsgSubscriptionSwitch"; // 用户订阅提醒状态
|
||||||
|
public const string CacheCoreCmsUserWeChatMsgTemplate = "CacheCoreCmsUserWeChatMsgTemplate"; // 微信小程序消息模板
|
||||||
|
public const string CacheCoreCmsWeixinAuthor = "CacheCoreCmsWeixinAuthor"; // 获取授权方的帐号基本信息表
|
||||||
|
public const string CacheCoreCmsWeixinMediaMessage = "CacheCoreCmsWeixinMediaMessage"; //微信图文消息表
|
||||||
|
public const string CacheCoreCmsWeixinMenu = "CacheCoreCmsWeixinMenu"; //微信公众号菜单表
|
||||||
|
public const string CacheCoreCmsWeixinMessage = "CacheCoreCmsWeixinMessage"; //微信消息表
|
||||||
|
public const string CacheCoreCmsWeixinPublish = "CacheCoreCmsWeixinPublish"; //小程序发布审核表
|
||||||
|
public const string CacheCoreCmsWorkSheet = "CacheCoreCmsWorkSheet"; //工作工单表
|
||||||
|
public const string CacheSysDictionary = "CacheSysDictionary"; //数据字典表
|
||||||
|
public const string CacheSysDictionaryData = "CacheSysDictionaryData"; //数据字典项表
|
||||||
|
public const string CacheSysLoginRecord = "CacheSysLoginRecord"; //登录日志表
|
||||||
|
public const string CacheSysMenu = "CacheSysMenu"; // 菜单表
|
||||||
|
public const string CacheSysOperRecord = "CacheSysOperRecord"; // 操作日志表
|
||||||
|
public const string CacheSysOrganization = "CacheSysOrganization"; // 组织机构表
|
||||||
|
public const string CacheSysRole = "CacheSysRole"; //角色表
|
||||||
|
public const string CacheSysRoleMenu = "CacheSysRoleMenu"; //角色菜单关联表
|
||||||
|
public const string CacheSysUser = "CacheSysUser"; //用户表
|
||||||
|
public const string CacheSysUserRole = "CacheSysUserRole"; //用户角色关联表
|
||||||
|
public const string CacheViewStoreClerk = "CacheViewStoreClerk"; //店员视图表
|
||||||
|
public const string CacheCoreCmsProductsDistribution = "CacheCoreCmsProductsDistribution"; //货品三级佣金表
|
||||||
|
public const string CacheCoreCmsServiceDescription = "CacheCoreCmsServiceDescription";
|
||||||
|
public const string CacheCoreCmsAgentGrade = "CacheCoreCmsAgentGrade";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tools工具常量
|
||||||
|
/// </summary>
|
||||||
|
public static class ToolsVars
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const string IllegalWordsCahceName = "IllegalWordsCahce";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 权限变量配置
|
||||||
|
/// </summary>
|
||||||
|
public static class Permissions
|
||||||
|
{
|
||||||
|
public const string Name = "Permission";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前项目是否启用IDS4权限方案
|
||||||
|
/// true:表示启动IDS4
|
||||||
|
/// false:表示使用JWT
|
||||||
|
public static bool IsUseIds4 = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 路由变量前缀配置
|
||||||
|
/// </summary>
|
||||||
|
public static class RoutePrefix
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 前缀名
|
||||||
|
/// 如果不需要,尽量留空,不要修改
|
||||||
|
/// 除非一定要在所有的 api 前统一加上特定前缀
|
||||||
|
/// </summary>
|
||||||
|
public const string Name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 银行卡相关常量定义
|
||||||
|
/// </summary>
|
||||||
|
public static class BankConst
|
||||||
|
{
|
||||||
|
public const string BankLogoUrl = "https://apimg.alipay.com/combo.png?d=cashier&t=";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RedisMqKey队列
|
||||||
|
/// </summary>
|
||||||
|
public static class RedisMessageQueueKey
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 微信支付成功后推送到接口进行数据处理
|
||||||
|
/// </summary>
|
||||||
|
public const string WeChatPayNotice = "WeChatPayNoticeQueue";
|
||||||
|
/// <summary>
|
||||||
|
/// 微信模板消息
|
||||||
|
/// </summary>
|
||||||
|
public const string SendWxTemplateMessage = "SendWxTemplateMessage";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单完结后走代理或分销商提成处理
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderAgentOrDistribution = "OrderAgentOrDistributionQueue";
|
||||||
|
/// <summary>
|
||||||
|
/// 订单完成时,结算该订单
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderFinishCommand = "OrderFinishCommandQueue";
|
||||||
|
/// <summary>
|
||||||
|
/// 订单完成时,门店订单自动发货
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderAutomaticDelivery = "OrderAutomaticDeliveryQueue";
|
||||||
|
/// <summary>
|
||||||
|
/// 订单完结后走打印模块
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderPrint = "OrderPrintQueue";
|
||||||
|
/// <summary>
|
||||||
|
/// 售后审核通过后处理
|
||||||
|
/// </summary>
|
||||||
|
public const string AfterSalesReview = "AfterSalesReview";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 日志队列
|
||||||
|
/// </summary>
|
||||||
|
public const string LogingQueue = "LogingQueue";
|
||||||
|
/// <summary>
|
||||||
|
/// 短信发送队列
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsQueue = "SmsQueue";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//用户相关
|
||||||
|
|
||||||
|
//订单支付成功后,用户升级处理
|
||||||
|
public const string UserUpGrade = "UserUpGradeQueue";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
2772
CoreCms.Net.Configuration/GlobalEnumVars.cs
Normal file
2772
CoreCms.Net.Configuration/GlobalEnumVars.cs
Normal file
File diff suppressed because it is too large
Load Diff
573
CoreCms.Net.Configuration/GlobalErrorCodeVars.cs
Normal file
573
CoreCms.Net.Configuration/GlobalErrorCodeVars.cs
Normal file
@@ -0,0 +1,573 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-03-28 23:22:14
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据接口错误编码返回
|
||||||
|
/// 11000 用户
|
||||||
|
/// 12000 商品
|
||||||
|
/// 13000 订单
|
||||||
|
/// 14000 api
|
||||||
|
/// 15000 促销&优惠券
|
||||||
|
/// </summary>
|
||||||
|
public class GlobalErrorCodeVars
|
||||||
|
{
|
||||||
|
|
||||||
|
public const string Code10000 = "未定义的错误信息";
|
||||||
|
public const string Code10002 = "没有找到此记录";
|
||||||
|
public const string Code10003 = "参数不正确";
|
||||||
|
public const string Code10004 = "保存失败";
|
||||||
|
public const string Code10005 = "用户信息没有修改";
|
||||||
|
public const string Code10006 = "图片超过限定张数";
|
||||||
|
public const string Code10007 = "删除失败";
|
||||||
|
public const string Code10008 = "没有此配置参数";
|
||||||
|
public const string Code10009 = "没有此消息编码,请确认";
|
||||||
|
public const string Code10010 = "您没有该操作权限";
|
||||||
|
public const string Code10011 = "请选择商户";
|
||||||
|
public const string Code10012 = "验证码错误";
|
||||||
|
public const string Code10013 = "请输入验证码";
|
||||||
|
public const string Code10014 = "没有此推荐人";
|
||||||
|
public const string Code10015 = "商户公众号未配置";
|
||||||
|
public const string Code10016 = "编辑失败";
|
||||||
|
public const string Code10018 = "操作失败";
|
||||||
|
public const string Code10019 = "新增失败";
|
||||||
|
public const string Code10020 = "出了点小状况,请刷新重试~";
|
||||||
|
public const string Code10021 = "更新失败";
|
||||||
|
public const string Code10022 = "非法操作";
|
||||||
|
public const string Code10023 = "删除失败";
|
||||||
|
public const string Code10024 = "修改失败";
|
||||||
|
public const string Code10025 = "获取失败";
|
||||||
|
public const string Code10026 = "创建失败";
|
||||||
|
public const string Code10027 = "查询失败";
|
||||||
|
public const string Code10028 = "有非法查询字段";
|
||||||
|
public const string Code10029 = "查询字段错误";
|
||||||
|
public const string Code10030 = "字段校检通过";
|
||||||
|
public const string Code10031 = "排序错误";
|
||||||
|
public const string Code10032 = "排序校检通过";
|
||||||
|
public const string Code10033 = "无参数相关信息";
|
||||||
|
public const string Code10034 = "删除消息失败";
|
||||||
|
public const string Code10035 = "上传失败";
|
||||||
|
public const string Code10036 = "没有符合的数据";
|
||||||
|
public const string Code10037 = "失败";
|
||||||
|
public const string Code10038 = "添加失败";
|
||||||
|
public const string Code10039 = "导出执行失败";
|
||||||
|
public const string Code10040 = "导出执行成功";
|
||||||
|
public const string Code10041 = "导入执行失败";
|
||||||
|
public const string Code10042 = "图片保存失败";
|
||||||
|
public const string Code10043 = "请先上传图片";
|
||||||
|
public const string Code10045 = "请输入任务名称,防止混淆";
|
||||||
|
public const string Code10046 = "导出任务加入成功,请到任务列表中下载文件";
|
||||||
|
public const string Code10047 = "导入任务加入成功,请到任务列表中查看进度";
|
||||||
|
public const string Code10048 = "请求地址出错";
|
||||||
|
public const string Code10049 = "callback参数不合法";
|
||||||
|
|
||||||
|
|
||||||
|
public const string Code10050 = "此支付方式未启用";
|
||||||
|
public const string Code10051 = "缺少参数,请确认";
|
||||||
|
public const string Code10052 = "此支付方式未启用,或不是一个有效的支付方式";
|
||||||
|
public const string Code10053 = "已开启过此支付方式,不需要重复开启";
|
||||||
|
public const string Code10054 = "没有此支付类型,请确认";
|
||||||
|
public const string Code10055 = "请选择支付方式";
|
||||||
|
public const string Code10056 = "请输入支付单号";
|
||||||
|
public const string Code10057 = "没有此支付方式";
|
||||||
|
public const string Code10058 = "没有此支付方式,或此支付方式未启用";
|
||||||
|
public const string Code10059 = "支付单金额为0,直接支付成功";
|
||||||
|
public const string Code10060 = "没有找到此支付单";
|
||||||
|
public const string Code10061 = "不需要获取openid";
|
||||||
|
public const string Code10062 = "请用户先进行微信登陆或绑定";
|
||||||
|
public const string Code10063 = "请用户先进行支付宝登陆或绑定";
|
||||||
|
public const string Code10064 = "请先选择标签";
|
||||||
|
public const string Code10065 = "发送失败";
|
||||||
|
public const string Code10066 = "msg里的值就是跳转的url"; //微信公众号静默登陆
|
||||||
|
public const string Code10067 = "公众号支付必须传url参数";
|
||||||
|
public const string Code10068 = "code必传";
|
||||||
|
public const string Code10069 = "后台小程序配置的APPID和APPSECRET错误,无法生成海报";
|
||||||
|
public const string Code10070 = "iv参数缺失";
|
||||||
|
public const string Code10071 = "加密参数缺失";
|
||||||
|
public const string Code10072 = "地址库不存在,请重新生成";
|
||||||
|
public const string Code10073 = "未查询到授权信息";
|
||||||
|
public const string Code10074 = "清除缓存成功";
|
||||||
|
public const string Code10075 = "后台操作日志默认不让删除";
|
||||||
|
public const string Code10076 = "时间段格式不正确";
|
||||||
|
public const string Code10077 = "没有此时间维度";
|
||||||
|
public const string Code10078 = "开始时间必须小于结束时间";
|
||||||
|
public const string Code10079 = "没有此时间粒度";
|
||||||
|
public const string Code10080 = "无此业务类型";
|
||||||
|
public const string Code10081 = "设置失败";
|
||||||
|
public const string Code10082 = "已超时或重复提交,请重试或刷新页面";
|
||||||
|
public const string Code10083 = "无可导出数据";
|
||||||
|
public const string Code10084 = "平台名称不能为空";
|
||||||
|
public const string Code10085 = "联系方式号码格式错误";
|
||||||
|
public const string Code10099 = "暂无消息";
|
||||||
|
public const string Code10100 = "没有此消息编码";
|
||||||
|
|
||||||
|
|
||||||
|
//文章等
|
||||||
|
public const string Code10800 = "文章分类";
|
||||||
|
public const string Code10801 = "文章不存在或已删除";
|
||||||
|
public const string Code10802 = "无法选择自己和自己的子级为父级";
|
||||||
|
//广告位
|
||||||
|
public const string Code10820 = "该广告位模板已经添加";
|
||||||
|
public const string Code10821 = "该广告位下有广告,删除失败";
|
||||||
|
|
||||||
|
public const string Code10840 = "该地区下存在关联地区,无法删除";
|
||||||
|
|
||||||
|
public const string Code11001 = "用户未登录";
|
||||||
|
public const string Code11002 = "此微信用户未登录或当前账号未绑定微信账号";
|
||||||
|
public const string Code11003 = "请选择头像";
|
||||||
|
public const string Code11004 = "没有找到此用户";
|
||||||
|
public const string Code11005 = "此用户没有绑定手机号码,所以发送短信失败";
|
||||||
|
public const string Code11006 = "此用户以停用,请联系总管理员";
|
||||||
|
public const string Code11007 = "余额不足";
|
||||||
|
public const string Code11008 = "请输入用户名,长度6-20位";
|
||||||
|
public const string Code11009 = "请输入密码,长度为6-16位";
|
||||||
|
public const string Code11010 = "没有找到此管理员";
|
||||||
|
public const string Code11011 = "用户名重复";
|
||||||
|
public const string Code11012 = "请输入旧密码";
|
||||||
|
public const string Code11013 = "请输入新密码";
|
||||||
|
public const string Code11014 = "请输入确认密码";
|
||||||
|
public const string Code11015 = "用户余额不足";
|
||||||
|
public const string Code11016 = "没有找到此提现银行卡";
|
||||||
|
public const string Code11017 = "请输入银行卡号";
|
||||||
|
public const string Code11018 = "请输入提现金额";
|
||||||
|
public const string Code11019 = "已注册过,请直接登陆";
|
||||||
|
public const string Code11020 = "请输入正确的充值金额";
|
||||||
|
public const string Code11021 = "请检查银行卡号是否有误";
|
||||||
|
public const string Code11022 = "账号已停用";
|
||||||
|
public const string Code11023 = "超级管理员,就不要编辑了吧?";
|
||||||
|
public const string Code11024 = "超级管理员,就不要删除了把?";
|
||||||
|
public const string Code11025 = "两次密码输入不一致";
|
||||||
|
public const string Code11026 = "密码过期了";
|
||||||
|
public const string Code11027 = "请选择出生日期";
|
||||||
|
public const string Code11028 = "请输入昵称";
|
||||||
|
public const string Code11029 = "请设置出生日期";
|
||||||
|
|
||||||
|
public const string Code11030 = "没有此用户等级";
|
||||||
|
public const string Code11031 = "请输入手机号码或者密码";
|
||||||
|
public const string Code11032 = "没有找到此账号";
|
||||||
|
public const string Code11033 = "密码错误,请重试";
|
||||||
|
public const string Code11044 = "新密码和旧密码一致";
|
||||||
|
public const string Code11045 = "旧密码不正确";
|
||||||
|
public const string Code11046 = "短信验证码错误";
|
||||||
|
public const string Code11047 = "此账号已经注册过,请直接登陆";
|
||||||
|
public const string Code11048 = "填写邀请码失败";
|
||||||
|
public const string Code11049 = "自己不能邀请自己";
|
||||||
|
public const string Code11050 = "没有此收货地址信息";
|
||||||
|
public const string Code11051 = "请输入手机号码";
|
||||||
|
public const string Code11052 = "邀请码不存在";
|
||||||
|
public const string Code11053 = "已有上级邀请,不能绑定其他的邀请";
|
||||||
|
public const string Code11054 = "不能关联这个邀请人,因为他是你的下级或者下下级";
|
||||||
|
public const string Code11055 = "请选择自提门店";
|
||||||
|
public const string Code11056 = "用户暂无收货地址";
|
||||||
|
public const string Code11057 = "请输入正确的手机号";
|
||||||
|
public const string Code11058 = "手机号已经存在,请更换手机号重新添加";
|
||||||
|
public const string Code11059 = "用户名已经存在,请确认";
|
||||||
|
public const string Code11060 = "该卡片已经添加";
|
||||||
|
public const string Code11061 = "该银行卡不存在";
|
||||||
|
public const string Code11062 = "该地址不存在";
|
||||||
|
public const string Code11063 = "提现最低不能少于{str1}元";
|
||||||
|
public const string Code11064 = "每日提现不能超过{str1}元";
|
||||||
|
public const string Code11065 = "提现失败";
|
||||||
|
public const string Code11066 = "没有此记录或不是待审核状态";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const string Code11070 = "请输入角色名称";
|
||||||
|
public const string Code11071 = "没有此角色信息";
|
||||||
|
public const string Code11072 = "没有选择权限信息";
|
||||||
|
|
||||||
|
public const string Code11080 = "请输入管理员的手机号码";
|
||||||
|
public const string Code11081 = "没有找到此用户";
|
||||||
|
public const string Code11082 = "目前一个账号只能绑定一个店铺,此手机号码已注册过店铺,如果是未审核通过的店铺可以联系平台删除对应的店铺,然后再次添加此管理员";
|
||||||
|
public const string Code11083 = "手机号码和用户id两者最少写一个";
|
||||||
|
public const string Code11084 = "此账号已经是店铺管理员了,请勿重新设置";
|
||||||
|
public const string Code11085 = "此账号是超级管理员,不需要添加";
|
||||||
|
public const string Code11086 = "您不是管理员,请先成为商户管理员或者创建自己的店铺";
|
||||||
|
public const string Code11087 = "用户绑定了多个商户平台,系统不知道你想登陆哪一个,需要用户去选择"; //严格意义上来说这个不是错误信息
|
||||||
|
public const string Code11088 = "没有找到控制器,请联系平台管理员";
|
||||||
|
public const string Code11089 = "没有找到此方法,请联系平台管理员";
|
||||||
|
public const string Code11090 = "没有找到此方法所对应的关联方法,请联系平台管理员";
|
||||||
|
public const string Code11091 = "请先清空下级节点";
|
||||||
|
public const string Code11092 = "核心参数不能为空";
|
||||||
|
public const string Code11093 = "父节点是模块,当前类型就必须是控制器";
|
||||||
|
public const string Code11094 = "父节点是控制器,当前类型就必须是方法";
|
||||||
|
public const string Code11095 = "父节点是根节点,当前类型就必须是模块";
|
||||||
|
public const string Code11096 = "当前节点已经存在,请勿重复提交";
|
||||||
|
public const string Code11097 = "设置的父节点可能会陷入死循环";
|
||||||
|
public const string Code11098 = "设置的父菜单可能陷入死循环";
|
||||||
|
public const string Code11099 = "如果是控制器节点,菜单节点必须和父节点保持一致";
|
||||||
|
|
||||||
|
public const string Code11100 = "购物车商品不能为空,或不是有效的商品";
|
||||||
|
public const string Code11101 = "父节点可能会陷入死循环";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const string Code11500 = "店铺不存在,请确认";
|
||||||
|
public const string Code11501 = "店铺现在处于非正常状态"; //未审核通过或者是到期了
|
||||||
|
public const string Code11502 = "这个手机号没有对应的店铺用户";
|
||||||
|
public const string Code11503 = "已经存在这个店员,无需重复添加";
|
||||||
|
public const string Code11504 = "不是店员";
|
||||||
|
|
||||||
|
|
||||||
|
//积分
|
||||||
|
public const string Code11600 = "积分不足,无法使用积分";
|
||||||
|
public const string Code11601 = "积分超过订单可使用的积分数量";
|
||||||
|
public const string Code11602 = "今天已经签到,无需重复签到";
|
||||||
|
public const string Code11603 = "今天还没有签到";
|
||||||
|
//商品
|
||||||
|
//分类
|
||||||
|
public const string Code12001 = "获取顶级分类失败";
|
||||||
|
public const string Code12002 = "商品数据保存失败";
|
||||||
|
public const string Code12003 = "货品数据保存失败";
|
||||||
|
public const string Code12004 = "请选择默认货品";
|
||||||
|
public const string Code12005 = "会员价保存失败";
|
||||||
|
public const string Code12006 = "商品图片保存失败";
|
||||||
|
public const string Code12007 = "扩展分类保存失败";
|
||||||
|
public const string Code12008 = "总库存更新失败";
|
||||||
|
public const string Code12009 = "商品ID不能为空";
|
||||||
|
public const string Code12010 = "存在下级分类,不允许删除";
|
||||||
|
public const string Code12011 = "属性值不能为空";
|
||||||
|
public const string Code12012 = "属性值删除失败";
|
||||||
|
public const string Code12013 = "属性值保存失败";
|
||||||
|
public const string Code12014 = "商品: {str1} 已在未结束的活动{str2}中,请勿重复添加!";
|
||||||
|
// public const string Code12015="上架";
|
||||||
|
// public const string Code12016="下架";
|
||||||
|
public const string Code12017 = "没有找到此商品分类";
|
||||||
|
|
||||||
|
|
||||||
|
//品牌
|
||||||
|
public const string Code12101 = "";
|
||||||
|
//类型
|
||||||
|
public const string Code12301 = "";
|
||||||
|
//属性
|
||||||
|
public const string Code12401 = "";
|
||||||
|
//货品
|
||||||
|
public const string Code12501 = "货品不存在";
|
||||||
|
|
||||||
|
//商品
|
||||||
|
public const string Code12700 = "商品不存在";
|
||||||
|
public const string Code12701 = "无此规格信息";
|
||||||
|
public const string Code12702 = "库存不足";
|
||||||
|
public const string Code12703 = "库存更新失败";
|
||||||
|
public const string Code12704 = "商品删除失败";
|
||||||
|
public const string Code12705 = "获取促销商品失败";
|
||||||
|
public const string Code12706 = "商品已下架";
|
||||||
|
|
||||||
|
//订单
|
||||||
|
public const string Code13001 = "请选择收货地址";
|
||||||
|
public const string Code13002 = "取消订单成功";
|
||||||
|
public const string Code13003 = "取消订单失败";
|
||||||
|
public const string Code13004 = "暂未设置配送方式";
|
||||||
|
public const string Code13005 = "下单成功";
|
||||||
|
public const string Code13006 = "下单失败";
|
||||||
|
public const string Code13007 = "订单支付失败";
|
||||||
|
public const string Code13008 = "订单支付失败,该订单已支付";
|
||||||
|
public const string Code13009 = "订单不存在";
|
||||||
|
public const string Code13010 = "备注失败";
|
||||||
|
|
||||||
|
public const string Code13100 = "请输入订单编号";
|
||||||
|
public const string Code13101 = "没有找到此订单信息,或者您没有权限查看此信息";
|
||||||
|
public const string Code13102 = "已有售后,请联系客服";
|
||||||
|
public const string Code13103 = "订单类型不能为空";
|
||||||
|
|
||||||
|
//订单售后
|
||||||
|
public const string Code13200 = "订单不是可售后状态";
|
||||||
|
public const string Code13201 = "退货的数量超过可退的数量";
|
||||||
|
public const string Code13202 = "退货商品不正确,请确认";
|
||||||
|
public const string Code13203 = "订单状态不可退款";
|
||||||
|
public const string Code13204 = "订单状态不可退货";
|
||||||
|
public const string Code13205 = "请选择退货商品";
|
||||||
|
public const string Code13206 = "总退款金额超过已支付金额";
|
||||||
|
public const string Code13207 = "售后单不是待审核状态,或者没有找到此售后单";
|
||||||
|
public const string Code13208 = "退款单金额为0,不需要退款";
|
||||||
|
public const string Code13209 = "退货数量为空,不需要生成退货单";
|
||||||
|
public const string Code13210 = "退款单已退或没权限进行操作";
|
||||||
|
public const string Code13211 = "退货单已退或没权限进行操作";
|
||||||
|
public const string Code13212 = "请输入退货单编号";
|
||||||
|
public const string Code13213 = "请选择物流公司";
|
||||||
|
public const string Code13214 = "请输入物流编码";
|
||||||
|
public const string Code13215 = "请输入退款单号";
|
||||||
|
public const string Code13216 = "请输入退款金额";
|
||||||
|
public const string Code13217 = "请输入售后单号";
|
||||||
|
public const string Code13218 = "没有找到此售后单";
|
||||||
|
public const string Code13219 = "没有找到此退款单或此退款单状态不是未待退款状态";
|
||||||
|
public const string Code13220 = "请输入退货单号";
|
||||||
|
public const string Code13221 = "没有找到此退货单";
|
||||||
|
public const string Code13222 = "请输入售后单号";
|
||||||
|
public const string Code13223 = "没有找到此售后单号";
|
||||||
|
public const string Code13224 = "没有找到此退款单或此退款单状态不是退款失败状态";
|
||||||
|
public const string Code13225 = "缺少物流查询参数";
|
||||||
|
public const string Code13226 = "x轴最多1000个节点,请减少时间范围,或者修改粒度";
|
||||||
|
public const string Code13227 = "还没发货呢,怎么能收到货呢?";
|
||||||
|
public const string Code13228 = "请选择审核状态";
|
||||||
|
public const string Code13229 = "快递公司编码不能为空";
|
||||||
|
public const string Code13230 = "确认收货失败";
|
||||||
|
public const string Code13231 = "砍价活动订单更新失败";
|
||||||
|
public const string Code13232 = "物流公司不存在";
|
||||||
|
|
||||||
|
|
||||||
|
//订单发货
|
||||||
|
public const string Code13300 = "订单已完成或取消不能发货";
|
||||||
|
public const string Code13301 = "订单未付款不能发货";
|
||||||
|
public const string Code13302 = "订单已发货不能再发货";
|
||||||
|
public const string Code13303 = "订单中不存在要发货的商品";
|
||||||
|
public const string Code13304 = "发货数量大于订单中商品的数量";
|
||||||
|
public const string Code13305 = "发货单生成出现未知错误";
|
||||||
|
public const string Code13306 = "发货失败,该货品已不存在";
|
||||||
|
public const string Code13307 = "发货失败,商品数量不足";
|
||||||
|
public const string Code13308 = "发货明细里包含订单之外的商品";
|
||||||
|
|
||||||
|
public const string Code13309 = "收货地址信息不全";
|
||||||
|
public const string Code13310 = "{str1}发超了";
|
||||||
|
public const string Code13311 = "请至少发生一件商品!";
|
||||||
|
public const string Code13312 = "提货单不存在";
|
||||||
|
public const string Code13313 = "未提货的提货单不能删除";
|
||||||
|
public const string Code13314 = "你无权删除该提货单";
|
||||||
|
public const string Code13315 = "没有可提货的订单";
|
||||||
|
public const string Code13316 = "请选择配送地区";
|
||||||
|
public const string Code13317 = "请选择订单";
|
||||||
|
public const string Code13318 = "门店自提订单和普通订单不能混合发货。";
|
||||||
|
public const string Code13319 = "订单号:{str1}非正常状态不能发货。<br />";
|
||||||
|
public const string Code13320 = "订单号:{str1} 未支付不能发货。<br />";
|
||||||
|
public const string Code13321 = "订单号:{str1} 不是待发货和部分发货状态不能发货。<br />";
|
||||||
|
public const string Code13322 = "订单号:{str1}有未审核的售后单,请先处理掉才能发货。";
|
||||||
|
public const string Code13323 = "多个用户订单,";
|
||||||
|
public const string Code13324 = "多个收货地址,";
|
||||||
|
public const string Code13325 = "请注意!合并发货订单中存在:{str1}。确定发货吗?";
|
||||||
|
public const string Code13326 = "{str1}的{str2}发超了";
|
||||||
|
|
||||||
|
|
||||||
|
//评价
|
||||||
|
public const string Code13400 = "评价缺少商品信息";
|
||||||
|
public const string Code13401 = "评价缺少订单号";
|
||||||
|
public const string Code13402 = "评价缺少商家店铺评价信息";
|
||||||
|
public const string Code13403 = "缺少商品ID参数";
|
||||||
|
public const string Code13404 = "评价失败:{str1}";
|
||||||
|
public const string Code13405 = "订单状态存在问题,不能评价";
|
||||||
|
|
||||||
|
//支付
|
||||||
|
public const string Code13500 = "没有找到此未支付的支付单号";
|
||||||
|
public const string Code13501 = "订单号:{str1}没有找到,或不是未支付状态";
|
||||||
|
public const string Code13502 = "请输入正确的充值金额";
|
||||||
|
public const string Code13503 = "表单:{str1}没有找到,或不是未支付状态";
|
||||||
|
public const string Code13504 = "没有找到此支付记录";
|
||||||
|
|
||||||
|
public const string Code13550 = "没有找到支付成功的支付单号";
|
||||||
|
public const string Code13551 = "退款单退款方式和支付方式不一样,原路退还失败";
|
||||||
|
public const string Code13552 = "";
|
||||||
|
|
||||||
|
//售后
|
||||||
|
public const string Code13600 = "aftersale_level值类型不对";
|
||||||
|
public const string Code13601 = "未发货商品-{str1}{str2}最多能退{str3}个";
|
||||||
|
public const string Code13602 = "已发货商品-{str1}{str2}最多能退{str3}个";
|
||||||
|
|
||||||
|
|
||||||
|
public const string Code14001 = "";
|
||||||
|
public const string Code14002 = "method参数结构错误";
|
||||||
|
public const string Code14003 = "method参数1不存在";
|
||||||
|
public const string Code14004 = "method参数2不存在";
|
||||||
|
public const string Code14006 = "请先登录";
|
||||||
|
public const string Code14007 = "用户身份过期请重新登录";
|
||||||
|
public const string Code14008 = "操作失败,请重试1";
|
||||||
|
public const string Code14009 = "操作失败,请重试2";
|
||||||
|
public const string Code14011 = "请输入货品id";
|
||||||
|
public const string Code14012 = "请输入货品数量";
|
||||||
|
public const string Code14013 = "移除购物车成功";
|
||||||
|
public const string Code14014 = "移除购物车失败";
|
||||||
|
public const string Code14015 = "生成token失败";
|
||||||
|
public const string Code14016 = "不是有效的token";
|
||||||
|
|
||||||
|
|
||||||
|
//促销,优惠券
|
||||||
|
public const string Code15001 = "请输入促销名称";
|
||||||
|
public const string Code15002 = "请输入起止时间";
|
||||||
|
public const string Code15003 = "请选择促销条件";
|
||||||
|
public const string Code15004 = "没有找到此促销条件";
|
||||||
|
public const string Code15005 = "没有找到此促销结果";
|
||||||
|
public const string Code15006 = "请输入促销ID参数";
|
||||||
|
public const string Code15007 = "该优惠券不存在或状态不可领取";
|
||||||
|
public const string Code15008 = "你已领取过了,勿重复领取";
|
||||||
|
public const string Code15009 = "优惠券号码不存在";
|
||||||
|
public const string Code15010 = "优惠券还没有到开始时间";
|
||||||
|
public const string Code15011 = "优惠券已经过期";
|
||||||
|
public const string Code15012 = "优惠券禁用了,请联系客服";
|
||||||
|
public const string Code15013 = "优惠券已经使用过了";
|
||||||
|
public const string Code15014 = "优惠券不符合使用规则";
|
||||||
|
public const string Code15015 = "同一类优惠券,只能使用一张";
|
||||||
|
public const string Code15016 = "团购或秒杀只能应用一种促销结果";
|
||||||
|
public const string Code15017 = "同一个商品只能同时存在一个团购秒杀";
|
||||||
|
public const string Code15018 = "已超出领取限额";
|
||||||
|
public const string Code15019 = "优惠券信息获取失败";
|
||||||
|
public const string Code15020 = "优惠券号码不存在";
|
||||||
|
public const string Code15021 = "领取失败";
|
||||||
|
public const string Code15022 = "核销使用优惠券失败";
|
||||||
|
public const string Code15023 = "一次最多可以生成5000张";
|
||||||
|
public const string Code15024 = "一张都没生成";
|
||||||
|
public const string Code15025 = "该优惠券已被使用";
|
||||||
|
public const string Code15026 = "该优惠券已被其他人领取";
|
||||||
|
public const string Code15027 = "绑定失败";
|
||||||
|
public const string Code15028 = "优惠券超过最大领取数量";
|
||||||
|
|
||||||
|
//拼团
|
||||||
|
public const string Code15600 = "活动已结束";
|
||||||
|
public const string Code15601 = "还没有到时间";
|
||||||
|
public const string Code15602 = "已经结束了";
|
||||||
|
public const string Code15603 = "没有找到此拼团商品";
|
||||||
|
public const string Code15604 = "请传拼团id";
|
||||||
|
public const string Code15605 = "请传商品id";
|
||||||
|
public const string Code15606 = "请传入订单id或者teamId";
|
||||||
|
public const string Code15607 = "没有此拼团记录,或不是已经结束";
|
||||||
|
public const string Code15608 = "参加拼团的商品和下单商品不一致";
|
||||||
|
public const string Code15609 = "没有找到拼团发起人";
|
||||||
|
public const string Code15610 = "该商品已超过当前活动最大购买量";
|
||||||
|
public const string Code15611 = "您已超过该活动最大购买量";
|
||||||
|
public const string Code15612 = "货品折扣后价格已经小于0元";
|
||||||
|
public const string Code15613 = "您不能参加自己的开团";
|
||||||
|
|
||||||
|
//微信消息
|
||||||
|
public const string Code16001 = "请输入标题";
|
||||||
|
public const string Code16002 = "请先填写内容";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const string Code17001 = "商品数据不存在";
|
||||||
|
public const string Code17002 = "收藏成功";
|
||||||
|
public const string Code17003 = "取消收藏成功!";
|
||||||
|
|
||||||
|
//砍价
|
||||||
|
public const string Code17601 = "砍价活动暂未开始";
|
||||||
|
public const string Code17602 = "砍价活动已结束";
|
||||||
|
public const string Code17603 = "没有找到此砍价商品";
|
||||||
|
public const string Code17604 = "请传砍价id";
|
||||||
|
// public const string Code17605="请传商品id";
|
||||||
|
// public const string Code17610="该商品已超过当前活动最大购买量";
|
||||||
|
public const string Code17611 = "您已超过该活动最大购买量";
|
||||||
|
public const string Code17612 = "砍价活动不存在";
|
||||||
|
public const string Code17613 = "您参与的活动已下单,请勿重复下单";
|
||||||
|
public const string Code17614 = "您参与的活动已结束";
|
||||||
|
public const string Code17615 = "您参与的活动已取消";
|
||||||
|
public const string Code17616 = "该砍价已成功,请先支付后再继续参与活动";
|
||||||
|
public const string Code17618 = "发起砍价活动失败";
|
||||||
|
|
||||||
|
public const string Code17620 = "请输入活动名称";
|
||||||
|
public const string Code17621 = "请输入活动简介";
|
||||||
|
public const string Code17622 = "请选择单规格商品";
|
||||||
|
public const string Code17623 = "砍价活动状态错误";
|
||||||
|
public const string Code17624 = "请选择活动时间";
|
||||||
|
public const string Code17625 = "请输入起始金额";
|
||||||
|
public const string Code17626 = "请输入成交金额";
|
||||||
|
public const string Code17627 = "请输入最大价";
|
||||||
|
public const string Code17628 = "请输入最小价";
|
||||||
|
public const string Code17629 = "请输入有效时长";
|
||||||
|
public const string Code17630 = "请输入砍价次数";
|
||||||
|
public const string Code17631 = "砍价总次数必须大于0";
|
||||||
|
public const string Code17632 = "商品:{str1} 参加过砍价了";
|
||||||
|
public const string Code17633 = "砍价记录不存在,请先参加活动";
|
||||||
|
public const string Code17634 = "此商品只能砍价{str1}次";
|
||||||
|
public const string Code17635 = "此商品已经砍到最底价了";
|
||||||
|
public const string Code17636 = "您已超过该活动最大参加次数,看看别的活动吧~";
|
||||||
|
public const string Code17637 = "您有正在进行中的砍价,请勿重复参加";
|
||||||
|
public const string Code17638 = "活动数量已满,请看看其它活动吧";
|
||||||
|
public const string Code17639 = "活动不存在";
|
||||||
|
|
||||||
|
|
||||||
|
//表单
|
||||||
|
public const string Code18001 = "表单不存在";
|
||||||
|
public const string Code18002 = "表单已过期";
|
||||||
|
public const string Code18003 = "您已达到最大提交次数,请忽继续提交。";
|
||||||
|
public const string Code18004 = "格式错误,请重新输入";
|
||||||
|
public const string Code18005 = "提交失败,请重试";
|
||||||
|
public const string Code18006 = "请输入";
|
||||||
|
public const string Code18007 = "表单明细提交失败,请重试";
|
||||||
|
public const string Code18008 = "暂无表单";
|
||||||
|
public const string Code18009 = "请先删除该表单下用户的提交记录";
|
||||||
|
public const string Code18010 = "请先添加表单项";
|
||||||
|
public const string Code18011 = "无此提交";
|
||||||
|
public const string Code18012 = "此表单需要登录后操作";
|
||||||
|
public const string Code18020 = "未提交任何数据";
|
||||||
|
|
||||||
|
//通用 -21000
|
||||||
|
public const string Code20000 = "请选择";
|
||||||
|
public const string Code20001 = "请选择日期";
|
||||||
|
public const string Code20002 = "请选择广告位";
|
||||||
|
public const string Code20003 = "请选择广告商品";
|
||||||
|
public const string Code20004 = "请选择广告文章";
|
||||||
|
public const string Code20005 = "请选择文章分类";
|
||||||
|
public const string Code20006 = "请选择更新时间段";
|
||||||
|
public const string Code20007 = "请选择市";
|
||||||
|
public const string Code20008 = "请选择县/区";
|
||||||
|
public const string Code20009 = "请选择地区";
|
||||||
|
public const string Code20010 = "请选择单规格商品";
|
||||||
|
public const string Code20011 = "请选择智能表单";
|
||||||
|
public const string Code20012 = "请选择待核销订单";
|
||||||
|
public const string Code20013 = "请选择品牌";
|
||||||
|
public const string Code20014 = "请选择分类";
|
||||||
|
public const string Code20015 = "请选择类型";
|
||||||
|
public const string Code20016 = "请选择属性";
|
||||||
|
public const string Code20017 = "";
|
||||||
|
public const string Code20018 = "";
|
||||||
|
public const string Code20019 = "";
|
||||||
|
public const string Code20020 = "";
|
||||||
|
public const string Code20021 = "";
|
||||||
|
public const string Code20022 = "";
|
||||||
|
public const string Code20023 = "";
|
||||||
|
public const string Code20024 = "";
|
||||||
|
public const string Code20025 = "";
|
||||||
|
public const string Code20026 = "";
|
||||||
|
public const string Code20027 = "";
|
||||||
|
public const string Code20028 = "";
|
||||||
|
public const string Code20029 = "";
|
||||||
|
public const string Code20030 = "";
|
||||||
|
public const string Code20031 = "";
|
||||||
|
public const string Code20032 = "";
|
||||||
|
public const string Code20033 = "";
|
||||||
|
public const string Code20034 = "";
|
||||||
|
public const string Code20035 = "";
|
||||||
|
public const string Code20036 = "";
|
||||||
|
public const string Code20037 = "";
|
||||||
|
public const string Code20038 = "";
|
||||||
|
public const string Code20039 = "";
|
||||||
|
public const string Code20040 = "";
|
||||||
|
|
||||||
|
//会员管理 -21000
|
||||||
|
|
||||||
|
//商品管理 -22000
|
||||||
|
|
||||||
|
//订单管理 -23000
|
||||||
|
|
||||||
|
//运营管理 -24000
|
||||||
|
|
||||||
|
//促销管理 -25000
|
||||||
|
|
||||||
|
//财务管理 -26000
|
||||||
|
|
||||||
|
//控制面板 -27000
|
||||||
|
|
||||||
|
|
||||||
|
//30000 前台
|
||||||
|
|
||||||
|
//会员管理 -31000
|
||||||
|
|
||||||
|
//商品管理 -32000
|
||||||
|
|
||||||
|
//订单管理 -33000
|
||||||
|
|
||||||
|
//运营管理 -34000
|
||||||
|
|
||||||
|
//促销管理 -35000
|
||||||
|
|
||||||
|
//财务管理 -36000
|
||||||
|
|
||||||
|
//控制面板 -37000
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
62
CoreCms.Net.Configuration/GlobalStatusCodes.cs
Normal file
62
CoreCms.Net.Configuration/GlobalStatusCodes.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-03-14 16:30:32
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// HTTP 返回格式状态码
|
||||||
|
/// </summary>
|
||||||
|
public static class GlobalStatusCodes
|
||||||
|
{
|
||||||
|
public const int Status100Continue = 100;
|
||||||
|
public const int Status101SwitchingProtocols = 101;
|
||||||
|
public const int Status102Processing = 102;
|
||||||
|
public const int Status200Ok = 200;
|
||||||
|
|
||||||
|
// 等等等等
|
||||||
|
|
||||||
|
public const int Status400BadRequest = 400;
|
||||||
|
public const int Status401Unauthorized = 401;
|
||||||
|
public const int Status402PaymentRequired = 402;
|
||||||
|
public const int Status403Forbidden = 403;
|
||||||
|
public const int Status404NotFound = 404;
|
||||||
|
public const int Status405MethodNotAllowed = 405;
|
||||||
|
public const int Status406NotAcceptable = 406;
|
||||||
|
|
||||||
|
public const int Status414RequestUriTooLong = 414;
|
||||||
|
public const int Status414UriTooLong = 414;
|
||||||
|
public const int Status415UnsupportedMediaType = 415;
|
||||||
|
public const int Status416RangeNotSatisfiable = 416;
|
||||||
|
public const int Status416RequestedRangeNotSatisfiable = 416;
|
||||||
|
public const int Status417ExpectationFailed = 417;
|
||||||
|
public const int Status418ImATeapot = 418;
|
||||||
|
public const int Status419AuthenticationTimeout = 419;
|
||||||
|
public const int Status421MisdirectedRequest = 421;
|
||||||
|
public const int Status422UnprocessableEntity = 422;
|
||||||
|
public const int Status423Locked = 423;
|
||||||
|
public const int Status424FailedDependency = 424;
|
||||||
|
|
||||||
|
// 等等等等
|
||||||
|
|
||||||
|
public const int Status500InternalServerError = 500;
|
||||||
|
public const int Status501NotImplemented = 501;
|
||||||
|
public const int Status502BadGateway = 502;
|
||||||
|
public const int Status503ServiceUnavailable = 503;
|
||||||
|
public const int Status504GatewayTimeout = 504;
|
||||||
|
public const int Status505HttpVersionNotsupported = 505;
|
||||||
|
public const int Status506VariantAlsoNegotiates = 506;
|
||||||
|
public const int Status507InsufficientStorage = 507;
|
||||||
|
public const int Status508LoopDetected = 508;
|
||||||
|
public const int Status510NotExtended = 510;
|
||||||
|
public const int Status511NetworkAuthenticationRequired = 511;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
715
CoreCms.Net.Configuration/SystemSettingConstVars.cs
Normal file
715
CoreCms.Net.Configuration/SystemSettingConstVars.cs
Normal file
@@ -0,0 +1,715 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-03-03 3:24:15
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台设置字段缓存名称定义
|
||||||
|
/// </summary>
|
||||||
|
public static class SystemSettingConstVars
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台名称
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopName = "shopName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平台描述
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopDesc = "shopDesc";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平台地址
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopAddress = "shopAddress";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备案信息
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopBeiAn = "shopBeiAn";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平台logo
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopLogo = "shopLogo";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Favicon图标
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopFavicon = "shopFavicon";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认图
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopDefaultImage = "shopDefaultImage";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商家手机号
|
||||||
|
/// </summary>
|
||||||
|
public const string ShopMobile = "shopMobile";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开启门店自提
|
||||||
|
/// </summary>
|
||||||
|
public const string StoreSwitch = "storeSwitch";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分类样式
|
||||||
|
/// </summary>
|
||||||
|
public const string CateStyle = "cateStyle";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// H5分类样式
|
||||||
|
/// </summary>
|
||||||
|
public const string CateType = "cateType";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单取消时间
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderCancelTime = "orderCancelTime";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单完成时间
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderCompleteTime = "orderCompleteTime";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单确认收货时间
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderAutoSignTime = "orderAutoSignTime";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单自动评价时间
|
||||||
|
/// </summary>
|
||||||
|
public const string OrderAutoEvalTime = "orderAutoEvalTime";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单提醒付款时间
|
||||||
|
/// </summary>
|
||||||
|
public const string RemindOrderTime = "remindOrderTime";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 门店订单自动发货
|
||||||
|
/// </summary>
|
||||||
|
public const string StoreOrderAutomaticDelivery = "storeOrderAutomaticDelivery";
|
||||||
|
|
||||||
|
//分销功能(老分销)=============================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启分销
|
||||||
|
/// </summary>
|
||||||
|
public const string OpenDistribution = "openDistribution";
|
||||||
|
/// <summary>
|
||||||
|
/// 用户须知:成为分销商后,可以获取佣金,用户只可被推荐一次,越早推荐越返利越多哦。
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionNotes = "distributionNotes";
|
||||||
|
/// <summary>
|
||||||
|
/// 分销协议
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionAgreement = "distributionAgreement";
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启店铺
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionStore = "distributionStore";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示邀请人信息
|
||||||
|
/// </summary>
|
||||||
|
public const string ShowInviterInfo = "showInviterInfo";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分销层级1,2层
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionLevel = "distributionLevel";
|
||||||
|
/// <summary>
|
||||||
|
/// 成为分销商条件:1无条件(需要审核),2申请(需要审核),3无条件
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionType = "distributionType";
|
||||||
|
/// <summary>
|
||||||
|
/// 消费自动成为分销商:元
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionMoney = "distributionMoney";
|
||||||
|
/// <summary>
|
||||||
|
/// 购买商品成为分销商:1关闭,2任意商品,3指定商品
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionGoods = "distributionGoods";
|
||||||
|
/// <summary>
|
||||||
|
/// 购买商品成为分销商指定商品序列号
|
||||||
|
/// </summary>
|
||||||
|
public const string DistributionGoodsId = "distributionGoodsId";
|
||||||
|
/// <summary>
|
||||||
|
/// 佣金类型:1百分比,2固定金额
|
||||||
|
/// </summary>
|
||||||
|
public const string CommissionType = "commissionType";
|
||||||
|
/// <summary>
|
||||||
|
/// 一级佣金
|
||||||
|
/// </summary>
|
||||||
|
public const string CommissionFirst = "commissionFirst";
|
||||||
|
/// <summary>
|
||||||
|
/// 二级佣金
|
||||||
|
/// </summary>
|
||||||
|
public const string CommissionSecond = "commissionSecond";
|
||||||
|
/// <summary>
|
||||||
|
/// 三级佣金
|
||||||
|
/// </summary>
|
||||||
|
public const string CommissionThird = "commissionThird";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存警报数量
|
||||||
|
/// </summary>
|
||||||
|
public const string GoodsStocksWarn = "goodsStocksWarn";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退货联系人
|
||||||
|
/// </summary>
|
||||||
|
public const string ReshipName = "reshipName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退货联系方式
|
||||||
|
/// </summary>
|
||||||
|
public const string ReshipMobile = "reshipMobile";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退货区域
|
||||||
|
/// </summary>
|
||||||
|
public const string ReshipAreaId = "reshipAreaId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退货详细地址
|
||||||
|
/// </summary>
|
||||||
|
public const string ReshipAddress = "reshipAddress";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退货坐标
|
||||||
|
/// </summary>
|
||||||
|
public const string ReshipCoordinate = "reshipCoordinate";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 签到奖励类型
|
||||||
|
/// </summary>
|
||||||
|
public const string SignPointType = "signPointType";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 随机奖励积分最小值
|
||||||
|
/// </summary>
|
||||||
|
public const string SignRandomMin = "signRandomMin";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 随机奖励积分最大值
|
||||||
|
/// </summary>
|
||||||
|
public const string SignRandomMax = "signRandomMax";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首次奖励积分
|
||||||
|
/// </summary>
|
||||||
|
public const string FirstSignPoint = "firstSignPoint";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连续签到追加
|
||||||
|
/// </summary>
|
||||||
|
public const string ContinuitySignAdditional = "continuitySignAdditional";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单日最大奖励
|
||||||
|
/// </summary>
|
||||||
|
public const string SignMostPoint = "signMostPoint";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开启积分功能
|
||||||
|
/// </summary>
|
||||||
|
public const string PointSwitch = "pointSwitch";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单积分折现比例
|
||||||
|
/// </summary>
|
||||||
|
public const string PointDiscountedProportion = "pointDiscountedProportion";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单积分使用比例
|
||||||
|
/// </summary>
|
||||||
|
public const string OrdersPointProportion = "ordersPointProportion";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单积分奖励比例
|
||||||
|
/// </summary>
|
||||||
|
public const string OrdersRewardProportion = "ordersRewardProportion";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定特殊日期状态
|
||||||
|
/// </summary>
|
||||||
|
public const string SignAppointDateStatus = "signAppointDateStatus";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定特殊日期
|
||||||
|
/// </summary>
|
||||||
|
public const string SignAppointDate = "signAppointDate";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定日期奖励类型
|
||||||
|
/// </summary>
|
||||||
|
public const string SignAppointDataType = "signAppointDataType";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定日期倍率
|
||||||
|
/// </summary>
|
||||||
|
public const string SignAppointDateRate = "signAppointDateRate";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定日期追加
|
||||||
|
/// </summary>
|
||||||
|
public const string SignAppointDateAdditional = "signAppointDateAdditional";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//小程序设置============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序部署URL
|
||||||
|
/// </summary>
|
||||||
|
public const string WxUrl = "wxUrl";
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序名称
|
||||||
|
/// </summary>
|
||||||
|
public const string WxNickName = "wxNickName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序AppId
|
||||||
|
/// </summary>
|
||||||
|
public const string WxAppid = "wxAppid";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序AppSecret
|
||||||
|
/// </summary>
|
||||||
|
public const string WxAppSecret = "wxAppSecret";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序TOKEN
|
||||||
|
/// </summary>
|
||||||
|
public const string WxToken = "wxToken";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小程序EncodingAESKey
|
||||||
|
/// </summary>
|
||||||
|
public const string WxEncodeaeskey = "wxEncodeaeskey";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原始Id
|
||||||
|
/// </summary>
|
||||||
|
public const string WxUserName = "wxUserName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主体信息
|
||||||
|
/// </summary>
|
||||||
|
public const string WxPrincipalName = "wxPrincipalName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 简介
|
||||||
|
/// </summary>
|
||||||
|
public const string WxSignature = "wxSignature";
|
||||||
|
|
||||||
|
|
||||||
|
//公众号设置============================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公众号部署URL
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialUrl = "wxOfficialUrl";
|
||||||
|
/// <summary>
|
||||||
|
/// 公众号名称
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialName = "wxOfficialName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 微信号
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialId = "wxOfficialId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AppId
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialAppid = "wxOfficialAppid";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AppSecret
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialAppSecret = "wxOfficialAppSecret";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公众号原始ID
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialSourceId = "wxOfficialSourceId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 微信验证TOKEN
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialToken = "wxOfficialToken";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EncodingAESKey
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialEncodeaeskey = "wxOfficialEncodeaeskey";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公众号类型
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialType = "wxOfficialType";
|
||||||
|
/// <summary>
|
||||||
|
/// 公众号二维码
|
||||||
|
/// </summary>
|
||||||
|
public const string WxOfficialQrCode = "wxOfficialQrCode";
|
||||||
|
|
||||||
|
|
||||||
|
// 提现设置============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 最低提现金额
|
||||||
|
/// </summary>
|
||||||
|
public const string TocashMoneyLow = "tocashMoneyLow";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 提现服务费率
|
||||||
|
/// </summary>
|
||||||
|
public const string TocashMoneyRate = "tocashMoneyRate";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每日提现上限
|
||||||
|
/// </summary>
|
||||||
|
public const string TocashMoneyLimit = "tocashMoneyLimit";
|
||||||
|
|
||||||
|
|
||||||
|
//其他设置============================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 腾讯地图key
|
||||||
|
/// </summary>
|
||||||
|
public const string QqMapKey = "qqMapKey";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公司编号
|
||||||
|
/// </summary>
|
||||||
|
public const string Kuaidi100Customer = "kuaidi100Customer";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 授权key
|
||||||
|
/// </summary>
|
||||||
|
public const string Kuaidi100Key = "kuaidi100Key";
|
||||||
|
|
||||||
|
|
||||||
|
//搜索发现关键字============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索发现关键词
|
||||||
|
/// </summary>
|
||||||
|
public const string RecommendKeys = "recommendKeys";
|
||||||
|
|
||||||
|
|
||||||
|
//统计代码============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 百度统计代码
|
||||||
|
/// </summary>
|
||||||
|
public const string StatisticsCode = "statisticsCode";
|
||||||
|
|
||||||
|
|
||||||
|
//发票开关============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 发票功能
|
||||||
|
/// </summary>
|
||||||
|
public const string InvoiceSwitch = "invoiceSwitch";
|
||||||
|
|
||||||
|
|
||||||
|
//第三方的登陆的时候,是否需要绑定手机号码,强烈建议用户开启,除非只在微信小程序内使用============================================================================
|
||||||
|
//1绑定,2不绑定
|
||||||
|
/// <summary>
|
||||||
|
/// 绑定手机号码
|
||||||
|
/// </summary>
|
||||||
|
public const string IsBindMobile = "isBindMobile";
|
||||||
|
|
||||||
|
//支付宝小程序appid============================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付宝小程序appid
|
||||||
|
/// </summary>
|
||||||
|
public const string MpAlipayAppid = "mpAlipayAppid";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分享图片
|
||||||
|
/// </summary>
|
||||||
|
public const string ShareImage = "shareImage";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分享标题
|
||||||
|
/// </summary>
|
||||||
|
public const string ShareTitle = "shareTitle";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分享描述
|
||||||
|
/// </summary>
|
||||||
|
public const string ShareDesc = "shareDesc";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关于我们文章
|
||||||
|
/// </summary>
|
||||||
|
public const string AboutArticleId = "aboutArticleId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关于我们文章
|
||||||
|
/// </summary>
|
||||||
|
public const string AboutArticle = "aboutArticle";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客服ID
|
||||||
|
/// </summary>
|
||||||
|
public const string EntId = "entId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户协议
|
||||||
|
/// </summary>
|
||||||
|
public const string UserAgreementId = "userAgreementId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户协议
|
||||||
|
/// </summary>
|
||||||
|
public const string UserAgreement = "userAgreement";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 隐私政策
|
||||||
|
/// </summary>
|
||||||
|
public const string PrivacyPolicyId = "privacyPolicyId";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 隐私政策
|
||||||
|
/// </summary>
|
||||||
|
public const string PrivacyPolicy = "privacyPolicy";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示门店列表
|
||||||
|
/// </summary>
|
||||||
|
public const string ShowStoresSwitch = "showStoresSwitch";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示充值功能
|
||||||
|
/// </summary>
|
||||||
|
public const string ShowStoreBalanceRechargeSwitch = "showStoreBalanceRechargeSwitch";
|
||||||
|
|
||||||
|
//第三方接口============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 易源接口授权key
|
||||||
|
/// </summary>
|
||||||
|
public const string ShowApiAppid = "showApiAppid";
|
||||||
|
/// <summary>
|
||||||
|
/// 易源接口授权密钥
|
||||||
|
/// </summary>
|
||||||
|
public const string ShowApiSecret = "showApiSecret";
|
||||||
|
|
||||||
|
|
||||||
|
//短信平台============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启短信
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsEnabled = "smsEnabled";
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsUserId = "smsUserId";
|
||||||
|
/// <summary>
|
||||||
|
/// 用户账号
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsAccount = "smsAccount";
|
||||||
|
/// <summary>
|
||||||
|
/// 用户密码
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsPassword = "smsPassword";
|
||||||
|
/// <summary>
|
||||||
|
/// 短信api地址
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsApiUrl = "smsApiUrl";
|
||||||
|
/// <summary>
|
||||||
|
/// 短信签名
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsSignature = "smsSignature";
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 账户注册-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForReg = "smsTplForReg";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 账户登录-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForLogin = "smsTplForLogin";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证验证码-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForVeri = "smsTplForVeri";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下单成功时-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForCreateOrder = "smsTplForCreateOrder";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单支付成功时-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForOrderPayed = "smsTplForOrderPayed";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单催付提醒-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForRemindOrderPay = "smsTplForRemindOrderPay";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单发货通知-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForDeliveryNotice = "smsTplForDeliveryNotice";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 售后确认通过-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForAfterSalesPass = "smsTplForAfterSalesPass";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户退款成功通知-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForRefundSuccess = "smsTplForRefundSuccess";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单付款成功平台通知-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForSellerOrderNotice = "smsTplForSellerOrderNotice";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通用类型-短信内容模板
|
||||||
|
/// </summary>
|
||||||
|
public const string SmsTplForCommon = "smsTplForCommon";
|
||||||
|
|
||||||
|
//网络打印机============================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterEnabled = "netWorkPrinterEnabled";
|
||||||
|
/// <summary>
|
||||||
|
/// 应用ID
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterClientId = "netWorkPrinterClientId";
|
||||||
|
/// <summary>
|
||||||
|
/// 应用密钥
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterClientSecret = "netWorkPrinterClientSecret";
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机设备号
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterMachineCode = "netWorkPrinterMachineCode";
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机终端密钥
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterMsign = "netWorkPrinterMsign";
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机名称
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterPrinterName = "netWorkPrinterPrinterName";
|
||||||
|
/// <summary>
|
||||||
|
/// 打印机设置联系方式
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NetWorkPrinterPhone = "netWorkPrinterPhone";
|
||||||
|
|
||||||
|
//代理模块============================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启代理模块
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string IsOpenAgent = "isOpenAgent";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示代理模块申请及管理入口
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string IsShowAgentPortal = "isShowAgentPortal";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户须知:
|
||||||
|
/// </summary>
|
||||||
|
public const string AgentNotes = "agentNotes";
|
||||||
|
/// <summary>
|
||||||
|
/// 分销协议:
|
||||||
|
/// </summary>
|
||||||
|
public const string AgentAgreement = "agentAgreement";
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许代理代购服务
|
||||||
|
/// </summary>
|
||||||
|
public const string IsAllowProcurementService = "isAllowProcurementService";
|
||||||
|
|
||||||
|
|
||||||
|
//附件存储============================================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存储方式
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageType = "filesStorageType";
|
||||||
|
/// <summary>
|
||||||
|
/// 存储路径
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStoragePath = "filesStoragePath";
|
||||||
|
/// <summary>
|
||||||
|
/// 文件后缀类型
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageFileSuffix = "filesStorageFileSuffix";
|
||||||
|
/// <summary>
|
||||||
|
/// 文件最大大小M
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageFileMaxSize = "filesStorageFileMaxSize";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 云存储绑定域名
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageBucketBindUrl = "filesStorageBucketBindUrl";
|
||||||
|
/// <summary>
|
||||||
|
/// 云存储授权账户
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageAccessKeyId = "filesStorageAccessKeyId";
|
||||||
|
/// <summary>
|
||||||
|
/// 云存储授权密钥
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageAccessKeySecret = "filesStorageAccessKeySecret";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 腾讯云账户标识
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageTencentAccountId = "filesStorageTencentAccountId";
|
||||||
|
/// <summary>
|
||||||
|
/// 腾讯云存储桶地域
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageTencentCosRegion = "filesStorageTencentCosRegion";
|
||||||
|
/// <summary>
|
||||||
|
/// 腾讯云存储桶名称
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageTencentBucketName = "filesStorageTencentBucketName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 阿里云节点
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageAliYunEndpoint = "filesStorageAliYunEndpoint";
|
||||||
|
/// <summary>
|
||||||
|
/// 阿里云桶名称
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageAliYunBucketName = "filesStorageAliYunBucketName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 七牛云桶名称
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string FilesStorageQiNiuBucketName = "filesStorageQiNiuBucketName";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
270
CoreCms.Net.Configuration/SystemSettingDictionary.cs
Normal file
270
CoreCms.Net.Configuration/SystemSettingDictionary.cs
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* Projectname= 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-03-02 23:52:48
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 全局基础配置字典类型
|
||||||
|
/// </summary>
|
||||||
|
public static class SystemSettingDictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取系统配置字典,不匹配数据库(1是2否)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Dictionary<string, DictionaryKeyValues> GetConfig()
|
||||||
|
{
|
||||||
|
Dictionary<string, DictionaryKeyValues> di = new Dictionary<string, DictionaryKeyValues>();
|
||||||
|
//平台设置
|
||||||
|
di.Add(SystemSettingConstVars.ShopName, new DictionaryKeyValues() { sKey = "平台名称", sValue = "核心内容管理系统" });
|
||||||
|
di.Add(SystemSettingConstVars.ShopDesc, new DictionaryKeyValues() { sKey = "平台描述", sValue = "平台描述会展示在前台及微信分享描述" });
|
||||||
|
di.Add(SystemSettingConstVars.ShopAddress, new DictionaryKeyValues() { sKey = "平台地址", sValue = "我的平台地址" });
|
||||||
|
di.Add(SystemSettingConstVars.ShopBeiAn, new DictionaryKeyValues() { sKey = "备案信息", sValue = "网站备案信息" });
|
||||||
|
di.Add(SystemSettingConstVars.ShopLogo, new DictionaryKeyValues() { sKey = "平台logo", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ShopFavicon, new DictionaryKeyValues() { sKey = "Favicon图标", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ShopDefaultImage, new DictionaryKeyValues() { sKey = "默认图", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.StoreSwitch, new DictionaryKeyValues() { sKey = "开启门店自提", sValue = "2" });
|
||||||
|
di.Add(SystemSettingConstVars.CateStyle, new DictionaryKeyValues() { sKey = "分类样式", sValue = "3" });
|
||||||
|
di.Add(SystemSettingConstVars.CateType, new DictionaryKeyValues() { sKey = "H5分类样式", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.AboutArticleId, new DictionaryKeyValues() { sKey = "关于我们文章", sValue = "2" });
|
||||||
|
di.Add(SystemSettingConstVars.AboutArticle, new DictionaryKeyValues() { sKey = "关于我们文章", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.UserAgreementId, new DictionaryKeyValues() { sKey = "用户协议", sValue = "3" });
|
||||||
|
di.Add(SystemSettingConstVars.UserAgreement, new DictionaryKeyValues() { sKey = "用户协议", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.PrivacyPolicyId, new DictionaryKeyValues() { sKey = "隐私政策", sValue = "4" });
|
||||||
|
di.Add(SystemSettingConstVars.PrivacyPolicy, new DictionaryKeyValues() { sKey = "隐私政策", sValue = "" });
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.ShowStoresSwitch, new DictionaryKeyValues() { sKey = "显示门店列表", sValue = "2" });
|
||||||
|
di.Add(SystemSettingConstVars.ShowStoreBalanceRechargeSwitch, new DictionaryKeyValues() { sKey = "显示充值功能", sValue = "2" });
|
||||||
|
|
||||||
|
//搜索发现关键字
|
||||||
|
di.Add(SystemSettingConstVars.RecommendKeys, new DictionaryKeyValues() { sKey = "搜索发现关键词", sValue = "核心,内容,管理,系统" });
|
||||||
|
//分享设置
|
||||||
|
di.Add(SystemSettingConstVars.ShareImage, new DictionaryKeyValues() { sKey = "分享图片", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ShareTitle, new DictionaryKeyValues() { sKey = "分享标题", sValue = "优质好店邀您共享" });
|
||||||
|
di.Add(SystemSettingConstVars.ShareDesc, new DictionaryKeyValues() { sKey = "分享描述", sValue = "" });
|
||||||
|
//会员设置
|
||||||
|
di.Add(SystemSettingConstVars.ShopMobile, new DictionaryKeyValues() { sKey = "商家手机号", sValue = "" });
|
||||||
|
//1绑定,2不绑定-第三方的登陆的时候,是否需要绑定手机号码,强烈建议用户开启,除非只在微信小程序内使用
|
||||||
|
di.Add(SystemSettingConstVars.IsBindMobile, new DictionaryKeyValues() { sKey = "绑定手机号码", sValue = "1" });
|
||||||
|
//商品设置
|
||||||
|
di.Add(SystemSettingConstVars.GoodsStocksWarn, new DictionaryKeyValues() { sKey = "库存警报数量", sValue = "10" });
|
||||||
|
|
||||||
|
//订单管理
|
||||||
|
di.Add(SystemSettingConstVars.OrderCancelTime, new DictionaryKeyValues() { sKey = "订单取消时间", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.OrderCompleteTime, new DictionaryKeyValues() { sKey = "订单完成时间", sValue = "30" });
|
||||||
|
di.Add(SystemSettingConstVars.OrderAutoSignTime, new DictionaryKeyValues() { sKey = "订单确认收货时间", sValue = "20" });
|
||||||
|
di.Add(SystemSettingConstVars.OrderAutoEvalTime, new DictionaryKeyValues() { sKey = "订单自动评价时间", sValue = "30" });
|
||||||
|
di.Add(SystemSettingConstVars.RemindOrderTime, new DictionaryKeyValues() { sKey = "订单提醒付款时间", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.ReshipName, new DictionaryKeyValues() { sKey = "退货联系人", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ReshipMobile, new DictionaryKeyValues() { sKey = "退货联系方式", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ReshipAreaId, new DictionaryKeyValues() { sKey = "退货区域", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ReshipAddress, new DictionaryKeyValues() { sKey = "退货详细地址", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ReshipCoordinate, new DictionaryKeyValues() { sKey = "退货坐标", sValue = "" });
|
||||||
|
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.StoreOrderAutomaticDelivery, new DictionaryKeyValues() { sKey = "门店自提自动发货", sValue = "2" });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//分销功能
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.OpenDistribution, new DictionaryKeyValues() { sKey = "是否开启三级分销", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionNotes, new DictionaryKeyValues() { sKey = "用户须知", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionAgreement, new DictionaryKeyValues() { sKey = "分销协议", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionStore, new DictionaryKeyValues() { sKey = "是否开启店铺", sValue = "2" });
|
||||||
|
//di.Add(GlobalSettingConstVars.FirstPushAward, new DictionaryKeyValues() { sKey = "直推奖励", sValue = "0" });
|
||||||
|
//di.Add(GlobalSettingConstVars.SecondPushAward, new DictionaryKeyValues() { sKey = "次推奖励", sValue = "0" });
|
||||||
|
di.Add(SystemSettingConstVars.ShowInviterInfo, new DictionaryKeyValues() { sKey = "是否显示邀请人信息", sValue = "2" });
|
||||||
|
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.DistributionLevel, new DictionaryKeyValues() { sKey = "分销层级", sValue = "2" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionType, new DictionaryKeyValues() { sKey = "成为分销商条件", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionMoney, new DictionaryKeyValues() { sKey = "消费自动成为分销商", sValue = "100" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionGoods, new DictionaryKeyValues() { sKey = "购买商品成为分销商", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.DistributionGoodsId, new DictionaryKeyValues() { sKey = "购买商品成为分销商指定商品序列号", sValue = "0" });
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.CommissionType, new DictionaryKeyValues() { sKey = "佣金类型", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.CommissionFirst, new DictionaryKeyValues() { sKey = "一级佣金", sValue = "0" });
|
||||||
|
di.Add(SystemSettingConstVars.CommissionSecond, new DictionaryKeyValues() { sKey = "二级佣金", sValue = "0" });
|
||||||
|
di.Add(SystemSettingConstVars.CommissionThird, new DictionaryKeyValues() { sKey = "三级佣金", sValue = "0" });
|
||||||
|
|
||||||
|
//代理功能
|
||||||
|
di.Add(SystemSettingConstVars.IsOpenAgent, new DictionaryKeyValues() { sKey = "是否开启代理模块", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.IsShowAgentPortal, new DictionaryKeyValues() { sKey = "前端显示入口", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.AgentNotes, new DictionaryKeyValues() { sKey = "用户须知", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.AgentAgreement, new DictionaryKeyValues() { sKey = "代理协议", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.IsAllowProcurementService, new DictionaryKeyValues() { sKey = "是否允许代理代购服务", sValue = "1" });
|
||||||
|
|
||||||
|
//积分设置
|
||||||
|
di.Add(SystemSettingConstVars.SignPointType, new DictionaryKeyValues() { sKey = "签到奖励类型", sValue = "2" });
|
||||||
|
di.Add(SystemSettingConstVars.SignRandomMin, new DictionaryKeyValues() { sKey = "随机奖励积分最小值", sValue = "1", });
|
||||||
|
di.Add(SystemSettingConstVars.SignRandomMax, new DictionaryKeyValues() { sKey = "随机奖励积分最大值", sValue = "10" });
|
||||||
|
di.Add(SystemSettingConstVars.FirstSignPoint, new DictionaryKeyValues() { sKey = "首次奖励积分", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.ContinuitySignAdditional, new DictionaryKeyValues() { sKey = "连续签到追加", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.SignMostPoint, new DictionaryKeyValues() { sKey = "单日最大奖励", sValue = "10" });
|
||||||
|
di.Add(SystemSettingConstVars.PointSwitch, new DictionaryKeyValues() { sKey = "开启积分功能", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.PointDiscountedProportion, new DictionaryKeyValues() { sKey = "订单积分折现比例", sValue = "100" });
|
||||||
|
di.Add(SystemSettingConstVars.OrdersPointProportion, new DictionaryKeyValues() { sKey = "订单积分使用比例", sValue = "10" });
|
||||||
|
di.Add(SystemSettingConstVars.OrdersRewardProportion, new DictionaryKeyValues() { sKey = "订单积分奖励比例", sValue = "1" });
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.SignAppointDateStatus, new DictionaryKeyValues() { sKey = "指定特殊日期状态", sValue = "false" });
|
||||||
|
di.Add(SystemSettingConstVars.SignAppointDate, new DictionaryKeyValues() { sKey = "指定特殊日期", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.SignAppointDataType, new DictionaryKeyValues() { sKey = "指定日期奖励类型", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.SignAppointDateRate, new DictionaryKeyValues() { sKey = "指定日期倍率", sValue = "2" });
|
||||||
|
di.Add(SystemSettingConstVars.SignAppointDateAdditional, new DictionaryKeyValues() { sKey = "指定日期追加", sValue = "10" });
|
||||||
|
|
||||||
|
// 提现设置
|
||||||
|
di.Add(SystemSettingConstVars.TocashMoneyLow, new DictionaryKeyValues() { sKey = "最低提现金额", sValue = "0.01" });
|
||||||
|
di.Add(SystemSettingConstVars.TocashMoneyRate, new DictionaryKeyValues() { sKey = "提现服务费率", sValue = "0" });
|
||||||
|
di.Add(SystemSettingConstVars.TocashMoneyLimit, new DictionaryKeyValues() { sKey = "每日提现上限", sValue = "0" });
|
||||||
|
|
||||||
|
//小程序设置
|
||||||
|
di.Add(SystemSettingConstVars.WxUrl, new DictionaryKeyValues() { sKey = "小程序部署URL", sValue = "https://", });
|
||||||
|
di.Add(SystemSettingConstVars.WxNickName, new DictionaryKeyValues() { sKey = "小程序名称", sValue = "CoreShop", });
|
||||||
|
di.Add(SystemSettingConstVars.WxAppid, new DictionaryKeyValues() { sKey = "AppId", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxAppSecret, new DictionaryKeyValues() { sKey = "AppSecret", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.WxToken, new DictionaryKeyValues() { sKey = "小程序验证TOKEN", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxEncodeaeskey, new DictionaryKeyValues() { sKey = "小程序EncodingAESKey", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.WxUserName, new DictionaryKeyValues() { sKey = "原始Id", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxPrincipalName, new DictionaryKeyValues() { sKey = "主体信息", sValue = "核心内容管理系统", });
|
||||||
|
di.Add(SystemSettingConstVars.WxSignature, new DictionaryKeyValues() { sKey = "简介", sValue = "核心内容管理系统", });
|
||||||
|
|
||||||
|
//公众号设置
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialUrl, new DictionaryKeyValues() { sKey = "公众号部署URL", sValue = "https://", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialName, new DictionaryKeyValues() { sKey = "公众号名称", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialId, new DictionaryKeyValues() { sKey = "微信号", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialAppid, new DictionaryKeyValues() { sKey = "AppId", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialAppSecret, new DictionaryKeyValues() { sKey = "AppSecret", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialSourceId, new DictionaryKeyValues() { sKey = "公众号原始ID", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialToken, new DictionaryKeyValues() { sKey = "微信验证TOKEN", sValue = "", });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialEncodeaeskey, new DictionaryKeyValues() { sKey = "EncodingAESKey", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialType, new DictionaryKeyValues() { sKey = "公众号类型", sValue = "service" });
|
||||||
|
di.Add(SystemSettingConstVars.WxOfficialQrCode, new DictionaryKeyValues() { sKey = "公众号二维码", sValue = "" });
|
||||||
|
|
||||||
|
//其他设置
|
||||||
|
di.Add(SystemSettingConstVars.QqMapKey, new DictionaryKeyValues() { sKey = "腾讯地图key", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.Kuaidi100Customer, new DictionaryKeyValues() { sKey = "公司编号", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.Kuaidi100Key, new DictionaryKeyValues() { sKey = "授权key", sValue = "" });
|
||||||
|
|
||||||
|
//统计代码
|
||||||
|
di.Add(SystemSettingConstVars.StatisticsCode, new DictionaryKeyValues() { sKey = "百度统计代码", sValue = "" });
|
||||||
|
//发票开关
|
||||||
|
di.Add(SystemSettingConstVars.InvoiceSwitch, new DictionaryKeyValues() { sKey = "发票功能", sValue = "1" });
|
||||||
|
//支付宝小程序appid
|
||||||
|
di.Add(SystemSettingConstVars.MpAlipayAppid, new DictionaryKeyValues() { sKey = "支付宝小程序appid", sValue = "" });
|
||||||
|
//客服ID
|
||||||
|
di.Add(SystemSettingConstVars.EntId, new DictionaryKeyValues() { sKey = "客服ID", sValue = "" });
|
||||||
|
//易源接口授权
|
||||||
|
di.Add(SystemSettingConstVars.ShowApiAppid, new DictionaryKeyValues() { sKey = "AppId", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.ShowApiSecret, new DictionaryKeyValues() { sKey = "授权Secret", sValue = "" });
|
||||||
|
|
||||||
|
//凯信通短信设置
|
||||||
|
di.Add(SystemSettingConstVars.SmsEnabled, new DictionaryKeyValues() { sKey = "是否开启短信", sValue = "1" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsUserId, new DictionaryKeyValues() { sKey = "用户ID", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsAccount, new DictionaryKeyValues() { sKey = "账号", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsPassword, new DictionaryKeyValues() { sKey = "密码", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsApiUrl, new DictionaryKeyValues() { sKey = "Api地址", sValue = "http://sms.corecms.net:9999/sms.aspx" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsSignature, new DictionaryKeyValues() { sKey = "短信签名", sValue = "" });
|
||||||
|
|
||||||
|
//附件存储
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageType, new DictionaryKeyValues() { sKey = "存储方式", sValue = "LocalStorage" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStoragePath, new DictionaryKeyValues() { sKey = "存储路径", sValue = "/upload/" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageFileSuffix, new DictionaryKeyValues() { sKey = "文件后缀类型", sValue = "gif,jpg,jpeg,png,bmp,xls,xlsx,doc,pdf,mp4,WebM,Ogv" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageFileMaxSize, new DictionaryKeyValues() { sKey = "文件最大大小", sValue = "10" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageBucketBindUrl, new DictionaryKeyValues() { sKey = "云存储绑定域名", sValue = "http://www.coreshop.cn/" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageAccessKeyId, new DictionaryKeyValues() { sKey = "云存储授权账户", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageAccessKeySecret, new DictionaryKeyValues() { sKey = "云存储授权密钥", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageTencentAccountId, new DictionaryKeyValues() { sKey = "腾讯云账户标识", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageTencentCosRegion, new DictionaryKeyValues() { sKey = "腾讯云桶地域", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageTencentBucketName, new DictionaryKeyValues() { sKey = "腾讯云桶名称", sValue = "" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageAliYunEndpoint, new DictionaryKeyValues() { sKey = "阿里云节点", sValue = "https://oss-cn-shenzhen.aliyuncs.com" });
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageAliYunBucketName, new DictionaryKeyValues() { sKey = "阿里云桶名称", sValue = "CoreShop" });
|
||||||
|
|
||||||
|
di.Add(SystemSettingConstVars.FilesStorageQiNiuBucketName, new DictionaryKeyValues() { sKey = "七牛云桶名称", sValue = "CoreShop" });
|
||||||
|
|
||||||
|
//短信发送内容模板
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForReg, new DictionaryKeyValues() { sKey = "账户注册", sValue = "您正在注册账号,验证码是{code},请勿告诉他人。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForLogin, new DictionaryKeyValues() { sKey = "账户登录", sValue = "您正在登陆账号,验证码是{code},请勿告诉他人。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForVeri, new DictionaryKeyValues() { sKey = "验证验证码", sValue = "您的验证码是{code},请勿告诉他人。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForCreateOrder, new DictionaryKeyValues() { sKey = "下单成功时", sValue = "恭喜您,订单创建成功,祝您购物愉快。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForOrderPayed, new DictionaryKeyValues() { sKey = "订单支付成功时", sValue = "恭喜您,订单支付成功,祝您购物愉快。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForRemindOrderPay, new DictionaryKeyValues() { sKey = "订单催付提醒", sValue = "您的订单还有1个小时就要取消了,请及时进行支付。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForDeliveryNotice, new DictionaryKeyValues() { sKey = "订单发货通知", sValue = "您好,您的订单已经发货。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForAfterSalesPass, new DictionaryKeyValues() { sKey = "售后确认通过", sValue = "您好,您的售后已经通过。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForRefundSuccess, new DictionaryKeyValues() { sKey = "用户退款成功通知", sValue = "用户您好,您的退款已经处理,请确认。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForSellerOrderNotice, new DictionaryKeyValues() { sKey = "订单付款成功平台通知", sValue = "您有新的订单了,请及时处理。" });
|
||||||
|
di.Add(SystemSettingConstVars.SmsTplForCommon, new DictionaryKeyValues() { sKey = "通用类型", sValue = "欢迎您访问我们的微信小程序,有问题请联系客服。" });
|
||||||
|
|
||||||
|
|
||||||
|
return di;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取促销添加参数类型字典
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<CommonKeyValues> GetPromotionConditionType()
|
||||||
|
{
|
||||||
|
var list = new List<CommonKeyValues>
|
||||||
|
{
|
||||||
|
new CommonKeyValues() {sDescription = "所有商品满足条件", sValue = "goods", sKey = "GOODS_ALL"},
|
||||||
|
new CommonKeyValues() {sDescription = "指定某些商品满足条件", sValue = "goods", sKey = "GOODS_IDS"},
|
||||||
|
new CommonKeyValues() {sDescription = "指定商品分类满足条件", sValue = "goods", sKey = "GOODS_CATS"},
|
||||||
|
new CommonKeyValues() {sDescription = "指定商品品牌满足条件", sValue = "goods", sKey = "GOODS_BRANDS"},
|
||||||
|
new CommonKeyValues() {sDescription = "订单满XX金额满足条件", sValue = "order", sKey = "ORDER_FULL"},
|
||||||
|
new CommonKeyValues() {sDescription = "用户符合指定等级", sValue = "user", sKey = "USER_GRADE"}
|
||||||
|
};
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取促销添加结果类型字典
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<CommonKeyValues> GetPromotionResultType()
|
||||||
|
{
|
||||||
|
var list = new List<CommonKeyValues>
|
||||||
|
{
|
||||||
|
new CommonKeyValues() {sDescription = "指定商品减固定金额", sValue = "goods", sKey = "GOODS_REDUCE"},
|
||||||
|
new CommonKeyValues() {sDescription = "指定商品打X折", sValue = "goods", sKey = "GOODS_DISCOUNT"},
|
||||||
|
new CommonKeyValues() {sDescription = "指定商品一口价", sValue = "goods", sKey = "GOODS_ONE_PRICE"},
|
||||||
|
new CommonKeyValues() {sDescription = "订单减指定金额", sValue = "order", sKey = "ORDER_REDUCE"},
|
||||||
|
new CommonKeyValues() {sDescription = "订单打X折", sValue = "order", sKey = "ORDER_DISCOUNT"},
|
||||||
|
new CommonKeyValues() {sDescription = "指定商品每第几件减指定金额", sValue = "goods", sKey = "GOODS_HALF_PRICE"}
|
||||||
|
};
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取系统默认发货物流方式
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<CommonKeyValues> GetSystemLogistics()
|
||||||
|
{
|
||||||
|
var list = new List<CommonKeyValues>
|
||||||
|
{
|
||||||
|
new CommonKeyValues() {sDescription = "本地同城配送", sValue = "无", sKey = "benditongcheng"},
|
||||||
|
new CommonKeyValues() {sDescription = "本地上门自提", sValue = "无", sKey = "shangmenziti"},
|
||||||
|
};
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
237
CoreCms.Net.Core/AOP/CacheAopBase.cs
Normal file
237
CoreCms.Net.Core/AOP/CacheAopBase.cs
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-05-08 23:28:44
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using Castle.DynamicProxy;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using CoreCms.Net.Utility.Helper;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.AOP
|
||||||
|
{
|
||||||
|
public abstract class CacheAopBase : IInterceptor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// AOP的拦截方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="invocation"></param>
|
||||||
|
public abstract void Intercept(IInvocation invocation);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义缓存的key
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="invocation"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected string CustomCacheKey(IInvocation invocation)
|
||||||
|
{
|
||||||
|
var typeName = invocation.TargetType.Name;
|
||||||
|
var methodName = invocation.Method.Name;
|
||||||
|
var methodArguments = invocation.Arguments.Select(GetArgumentValue).Take(3).ToList();//获取参数列表,最多三个
|
||||||
|
|
||||||
|
string key = $"{typeName}:{methodName}:";
|
||||||
|
foreach (var param in methodArguments)
|
||||||
|
{
|
||||||
|
key = $"{key}{param}:";
|
||||||
|
}
|
||||||
|
|
||||||
|
return key.TrimEnd(':');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// object 转 string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected static string GetArgumentValue(object arg)
|
||||||
|
{
|
||||||
|
if (arg is DateTime)
|
||||||
|
return ((DateTime)arg).ToString("yyyyMMddHHmmss");
|
||||||
|
|
||||||
|
if (arg is string || arg is ValueType)
|
||||||
|
return arg.ToString();
|
||||||
|
|
||||||
|
if (arg != null)
|
||||||
|
{
|
||||||
|
if (arg is Expression)
|
||||||
|
{
|
||||||
|
var obj = arg as Expression;
|
||||||
|
var result = Resolve(obj);
|
||||||
|
return CommonHelper.Md5For16(result);
|
||||||
|
}
|
||||||
|
else if (arg.GetType().IsClass)
|
||||||
|
{
|
||||||
|
return CommonHelper.Md5For16(Newtonsoft.Json.JsonConvert.SerializeObject(arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Resolve(Expression expression)
|
||||||
|
{
|
||||||
|
if (expression is LambdaExpression)
|
||||||
|
{
|
||||||
|
LambdaExpression lambda = expression as LambdaExpression;
|
||||||
|
expression = lambda.Body;
|
||||||
|
return Resolve(expression);
|
||||||
|
}
|
||||||
|
if (expression is BinaryExpression)
|
||||||
|
{
|
||||||
|
BinaryExpression binary = expression as BinaryExpression;
|
||||||
|
if (binary.Left is MemberExpression && binary.Right is ConstantExpression)//解析x=>x.Name=="123" x.Age==123这类
|
||||||
|
return ResolveFunc(binary.Left, binary.Right, binary.NodeType);
|
||||||
|
if (binary.Left is MethodCallExpression && binary.Right is ConstantExpression)//解析x=>x.Name.Contains("xxx")==false这类的
|
||||||
|
{
|
||||||
|
object value = (binary.Right as ConstantExpression).Value;
|
||||||
|
return ResolveLinqToObject(binary.Left, value, binary.NodeType);
|
||||||
|
}
|
||||||
|
if ((binary.Left is MemberExpression && binary.Right is MemberExpression)
|
||||||
|
|| (binary.Left is MemberExpression && binary.Right is UnaryExpression))//解析x=>x.Date==DateTime.Now这种
|
||||||
|
{
|
||||||
|
LambdaExpression lambda = Expression.Lambda(binary.Right);
|
||||||
|
Delegate fn = lambda.Compile();
|
||||||
|
ConstantExpression value = Expression.Constant(fn.DynamicInvoke(null), binary.Right.Type);
|
||||||
|
return ResolveFunc(binary.Left, value, binary.NodeType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (expression is UnaryExpression)
|
||||||
|
{
|
||||||
|
UnaryExpression unary = expression as UnaryExpression;
|
||||||
|
if (unary.Operand is MethodCallExpression)//解析!x=>x.Name.Contains("xxx")或!array.Contains(x.Name)这类
|
||||||
|
return ResolveLinqToObject(unary.Operand, false);
|
||||||
|
if (unary.Operand is MemberExpression && unary.NodeType == ExpressionType.Not)//解析x=>!x.isDeletion这样的
|
||||||
|
{
|
||||||
|
ConstantExpression constant = Expression.Constant(false);
|
||||||
|
return ResolveFunc(unary.Operand, constant, ExpressionType.Equal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (expression is MemberExpression && expression.NodeType == ExpressionType.MemberAccess)//解析x=>x.isDeletion这样的
|
||||||
|
{
|
||||||
|
MemberExpression member = expression as MemberExpression;
|
||||||
|
ConstantExpression constant = Expression.Constant(true);
|
||||||
|
return ResolveFunc(member, constant, ExpressionType.Equal);
|
||||||
|
}
|
||||||
|
if (expression is MethodCallExpression)//x=>x.Name.Contains("xxx")或array.Contains(x.Name)这类
|
||||||
|
{
|
||||||
|
MethodCallExpression methodcall = expression as MethodCallExpression;
|
||||||
|
return ResolveLinqToObject(methodcall, true);
|
||||||
|
}
|
||||||
|
var body = expression as BinaryExpression;
|
||||||
|
//已经修改过代码body应该不会是null值了
|
||||||
|
if (body == null)
|
||||||
|
return string.Empty;
|
||||||
|
var Operator = GetOperator(body.NodeType);
|
||||||
|
var Left = Resolve(body.Left);
|
||||||
|
var Right = Resolve(body.Right);
|
||||||
|
string Result = string.Format("({0} {1} {2})", Left, Operator, Right);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetOperator(ExpressionType expressiontype)
|
||||||
|
{
|
||||||
|
switch (expressiontype)
|
||||||
|
{
|
||||||
|
case ExpressionType.And:
|
||||||
|
return "and";
|
||||||
|
case ExpressionType.AndAlso:
|
||||||
|
return "and";
|
||||||
|
case ExpressionType.Or:
|
||||||
|
return "or";
|
||||||
|
case ExpressionType.OrElse:
|
||||||
|
return "or";
|
||||||
|
case ExpressionType.Equal:
|
||||||
|
return "=";
|
||||||
|
case ExpressionType.NotEqual:
|
||||||
|
return "<>";
|
||||||
|
case ExpressionType.LessThan:
|
||||||
|
return "<";
|
||||||
|
case ExpressionType.LessThanOrEqual:
|
||||||
|
return "<=";
|
||||||
|
case ExpressionType.GreaterThan:
|
||||||
|
return ">";
|
||||||
|
case ExpressionType.GreaterThanOrEqual:
|
||||||
|
return ">=";
|
||||||
|
default:
|
||||||
|
throw new Exception(string.Format("不支持{0}此种运算符查找!" + expressiontype));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ResolveFunc(Expression left, Expression right, ExpressionType expressiontype)
|
||||||
|
{
|
||||||
|
var Name = (left as MemberExpression).Member.Name;
|
||||||
|
var Value = (right as ConstantExpression).Value;
|
||||||
|
var Operator = GetOperator(expressiontype);
|
||||||
|
return Name + Operator + Value ?? "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ResolveLinqToObject(Expression expression, object value, ExpressionType? expressiontype = null)
|
||||||
|
{
|
||||||
|
var MethodCall = expression as MethodCallExpression;
|
||||||
|
var MethodName = MethodCall.Method.Name;
|
||||||
|
switch (MethodName)
|
||||||
|
{
|
||||||
|
case "Contains":
|
||||||
|
if (MethodCall.Object != null)
|
||||||
|
return Like(MethodCall);
|
||||||
|
return In(MethodCall, value);
|
||||||
|
case "Count":
|
||||||
|
return Len(MethodCall, value, expressiontype.Value);
|
||||||
|
case "LongCount":
|
||||||
|
return Len(MethodCall, value, expressiontype.Value);
|
||||||
|
default:
|
||||||
|
throw new Exception(string.Format("不支持{0}方法的查找!", MethodName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string In(MethodCallExpression expression, object isTrue)
|
||||||
|
{
|
||||||
|
var Argument1 = (expression.Arguments[0] as MemberExpression).Expression as ConstantExpression;
|
||||||
|
var Argument2 = expression.Arguments[1] as MemberExpression;
|
||||||
|
var Field_Array = Argument1.Value.GetType().GetFields().First();
|
||||||
|
object[] Array = Field_Array.GetValue(Argument1.Value) as object[];
|
||||||
|
List<string> SetInPara = new List<string>();
|
||||||
|
for (int i = 0; i < Array.Length; i++)
|
||||||
|
{
|
||||||
|
string Name_para = "InParameter" + i;
|
||||||
|
string Value = Array[i].ToString();
|
||||||
|
SetInPara.Add(Value);
|
||||||
|
}
|
||||||
|
string Name = Argument2.Member.Name;
|
||||||
|
string Operator = Convert.ToBoolean(isTrue) ? "in" : " not in";
|
||||||
|
string CompName = string.Join(",", SetInPara);
|
||||||
|
string Result = string.Format("{0} {1} ({2})", Name, Operator, CompName);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
private static string Like(MethodCallExpression expression)
|
||||||
|
{
|
||||||
|
|
||||||
|
var Temp = expression.Arguments[0];
|
||||||
|
LambdaExpression lambda = Expression.Lambda(Temp);
|
||||||
|
Delegate fn = lambda.Compile();
|
||||||
|
var tempValue = Expression.Constant(fn.DynamicInvoke(null), Temp.Type);
|
||||||
|
string Value = string.Format("%{0}%", tempValue);
|
||||||
|
string Name = (expression.Object as MemberExpression).Member.Name;
|
||||||
|
string Result = string.Format("{0} like {1}", Name, Value);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static string Len(MethodCallExpression expression, object value, ExpressionType expressiontype)
|
||||||
|
{
|
||||||
|
object Name = (expression.Arguments[0] as MemberExpression).Member.Name;
|
||||||
|
string Operator = GetOperator(expressiontype);
|
||||||
|
string Result = string.Format("len({0}){1}{2}", Name, Operator, value.ToString());
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
68
CoreCms.Net.Core/AOP/MemoryCacheAop.cs
Normal file
68
CoreCms.Net.Core/AOP/MemoryCacheAop.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-05-08 23:27:26
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Castle.DynamicProxy;
|
||||||
|
using CoreCms.Net.Caching.AutoMate.MemoryCache;
|
||||||
|
using CoreCms.Net.Core.Attribute;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.AOP
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 面向切换的内存缓存使用
|
||||||
|
/// </summary>
|
||||||
|
public class MemoryCacheAop : CacheAopBase
|
||||||
|
{
|
||||||
|
//通过注入的方式,把缓存操作接口通过构造函数注入
|
||||||
|
private readonly ICachingProvider _cache;
|
||||||
|
public MemoryCacheAop(ICachingProvider cache)
|
||||||
|
{
|
||||||
|
_cache = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Intercept方法是拦截的关键所在,也是IInterceptor接口中的唯一定义
|
||||||
|
public override void Intercept(IInvocation invocation)
|
||||||
|
{
|
||||||
|
var method = invocation.MethodInvocationTarget ?? invocation.Method;
|
||||||
|
//对当前方法的特性验证
|
||||||
|
//如果需要验证
|
||||||
|
var CachingAttribute = method.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(CachingAttribute));
|
||||||
|
if (CachingAttribute is CachingAttribute qCachingAttribute)
|
||||||
|
{
|
||||||
|
//获取自定义缓存键
|
||||||
|
var cacheKey = CustomCacheKey(invocation);
|
||||||
|
//根据key获取相应的缓存值
|
||||||
|
var cacheValue = _cache.Get(cacheKey);
|
||||||
|
if (cacheValue != null)
|
||||||
|
{
|
||||||
|
//将当前获取到的缓存值,赋值给当前执行方法
|
||||||
|
invocation.ReturnValue = cacheValue;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//去执行当前的方法
|
||||||
|
invocation.Proceed();
|
||||||
|
//存入缓存
|
||||||
|
if (!string.IsNullOrWhiteSpace(cacheKey))
|
||||||
|
{
|
||||||
|
_cache.Set(cacheKey, invocation.ReturnValue, qCachingAttribute.AbsoluteExpiration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
invocation.Proceed();//直接执行被拦截方法
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
91
CoreCms.Net.Core/AOP/RedisCacheAop.cs
Normal file
91
CoreCms.Net.Core/AOP/RedisCacheAop.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-05-09 0:13:52
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Castle.DynamicProxy;
|
||||||
|
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||||
|
using CoreCms.Net.Core.Attribute;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.AOP
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 面向切面的Redis缓存使用
|
||||||
|
/// </summary>
|
||||||
|
public class RedisCacheAop : CacheAopBase
|
||||||
|
{
|
||||||
|
//通过注入的方式,把缓存操作接口通过构造函数注入
|
||||||
|
private readonly IRedisOperationRepository _cache;
|
||||||
|
public RedisCacheAop(IRedisOperationRepository cache)
|
||||||
|
{
|
||||||
|
_cache = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Intercept方法是拦截的关键所在,也是IInterceptor接口中的唯一定义
|
||||||
|
public override void Intercept(IInvocation invocation)
|
||||||
|
{
|
||||||
|
var method = invocation.MethodInvocationTarget ?? invocation.Method;
|
||||||
|
if (method.ReturnType == typeof(void) || method.ReturnType == typeof(Task))
|
||||||
|
{
|
||||||
|
invocation.Proceed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//对当前方法的特性验证
|
||||||
|
if (method.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(CachingAttribute)) is CachingAttribute qCachingAttribute)
|
||||||
|
{
|
||||||
|
//获取自定义缓存键
|
||||||
|
var cacheKey = CustomCacheKey(invocation);
|
||||||
|
//注意是 string 类型,方法GetValue
|
||||||
|
var cacheValue = _cache.Get(cacheKey).Result;
|
||||||
|
if (cacheValue != null)
|
||||||
|
{
|
||||||
|
//将当前获取到的缓存值,赋值给当前执行方法
|
||||||
|
var returnType = typeof(Task).IsAssignableFrom(method.ReturnType) ? method.ReturnType.GenericTypeArguments.FirstOrDefault() : method.ReturnType;
|
||||||
|
|
||||||
|
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(cacheValue, returnType);
|
||||||
|
invocation.ReturnValue = (typeof(Task).IsAssignableFrom(method.ReturnType)) ? Task.FromResult(result) : result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//去执行当前的方法
|
||||||
|
invocation.Proceed();
|
||||||
|
|
||||||
|
//存入缓存
|
||||||
|
if (!string.IsNullOrWhiteSpace(cacheKey))
|
||||||
|
{
|
||||||
|
object response;
|
||||||
|
|
||||||
|
//Type type = invocation.ReturnValue?.GetType();
|
||||||
|
var type = invocation.Method.ReturnType;
|
||||||
|
if (typeof(Task).IsAssignableFrom(type))
|
||||||
|
{
|
||||||
|
var resultProperty = type.GetProperty("Result");
|
||||||
|
response = resultProperty.GetValue(invocation.ReturnValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response = invocation.ReturnValue;
|
||||||
|
}
|
||||||
|
response ??= string.Empty;
|
||||||
|
|
||||||
|
_cache.Set(cacheKey, response, TimeSpan.FromMinutes(qCachingAttribute.AbsoluteExpiration)).Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
invocation.Proceed();//直接执行被拦截方法
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
30
CoreCms.Net.Core/Attribute/CachingAttribute.cs
Normal file
30
CoreCms.Net.Core/Attribute/CachingAttribute.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-05-08 23:54:42
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 这个Attribute就是使用时候的验证,把它添加到要缓存数据的方法中,即可完成缓存的操作。
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
|
||||||
|
public class CachingAttribute : System.Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存绝对过期时间(分钟)
|
||||||
|
/// </summary>
|
||||||
|
public int AbsoluteExpiration { get; set; } = 30;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
26
CoreCms.Net.Core/Attribute/UseTranAttribute.cs
Normal file
26
CoreCms.Net.Core/Attribute/UseTranAttribute.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-05-08 23:55:07
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 这个Attribute就是使用时候的验证,把它添加到需要执行事务的方法中,即可完成事务的操作。
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
|
||||||
|
public class UseTranAttribute : System.Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
82
CoreCms.Net.Core/AutoFac/AutofacModuleRegister.cs
Normal file
82
CoreCms.Net.Core/AutoFac/AutofacModuleRegister.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using Autofac;
|
||||||
|
using Autofac.Extras.DynamicProxy;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Core.AOP;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.AutoFac
|
||||||
|
{
|
||||||
|
public class AutofacModuleRegister : Autofac.Module
|
||||||
|
{
|
||||||
|
protected override void Load(ContainerBuilder builder)
|
||||||
|
{
|
||||||
|
var basePath = AppContext.BaseDirectory;
|
||||||
|
|
||||||
|
#region 带有接口层的服务注入
|
||||||
|
|
||||||
|
var servicesDllFile = Path.Combine(basePath, "CoreCms.Net.Services.dll");
|
||||||
|
var repositoryDllFile = Path.Combine(basePath, "CoreCms.Net.Repository.dll");
|
||||||
|
|
||||||
|
if (!(File.Exists(servicesDllFile) && File.Exists(repositoryDllFile)))
|
||||||
|
{
|
||||||
|
var msg = "Repository.dll和Services.dll 丢失,因为项目解耦了,所以需要先F6编译,再F5运行,请检查 bin 文件夹,并拷贝。";
|
||||||
|
throw new Exception(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。
|
||||||
|
//var cacheType = new List<Type>();
|
||||||
|
//if (AppSettingsConstVars.RedisConfigEnabled)
|
||||||
|
//{
|
||||||
|
// builder.RegisterType<RedisCacheAop>();
|
||||||
|
// cacheType.Add(typeof(RedisCacheAop));
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// builder.RegisterType<MemoryCacheAop>();
|
||||||
|
// cacheType.Add(typeof(MemoryCacheAop));
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 获取 Service.dll 程序集服务,并注册
|
||||||
|
var assemblysServices = Assembly.LoadFrom(servicesDllFile);
|
||||||
|
//支持属性注入依赖重复
|
||||||
|
builder.RegisterAssemblyTypes(assemblysServices).AsImplementedInterfaces().InstancePerDependency()
|
||||||
|
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies);
|
||||||
|
|
||||||
|
// 获取 Repository.dll 程序集服务,并注册
|
||||||
|
var assemblysRepository = Assembly.LoadFrom(repositoryDllFile);
|
||||||
|
//支持属性注入依赖重复
|
||||||
|
builder.RegisterAssemblyTypes(assemblysRepository).AsImplementedInterfaces().InstancePerDependency()
|
||||||
|
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies);
|
||||||
|
|
||||||
|
|
||||||
|
// 获取 Service.dll 程序集服务,并注册
|
||||||
|
//var assemblysServices = Assembly.LoadFrom(servicesDllFile);
|
||||||
|
//builder.RegisterAssemblyTypes(assemblysServices)
|
||||||
|
// .AsImplementedInterfaces()
|
||||||
|
// .InstancePerDependency()
|
||||||
|
// .PropertiesAutowired()
|
||||||
|
// .EnableInterfaceInterceptors()//引用Autofac.Extras.DynamicProxy;
|
||||||
|
// .InterceptedBy(cacheType.ToArray());//允许将拦截器服务的列表分配给注册。
|
||||||
|
|
||||||
|
//// 获取 Repository.dll 程序集服务,并注册
|
||||||
|
//var assemblysRepository = Assembly.LoadFrom(repositoryDllFile);
|
||||||
|
//builder.RegisterAssemblyTypes(assemblysRepository)
|
||||||
|
// .AsImplementedInterfaces()
|
||||||
|
// .PropertiesAutowired()
|
||||||
|
// .InstancePerDependency();
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
CoreCms.Net.Core/Config/CorsSetup.cs
Normal file
56
CoreCms.Net.Core/Config/CorsSetup.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-03 22:49:41
|
||||||
|
* NameSpace: CoreCms.Net.Framework
|
||||||
|
* FileName: Cors
|
||||||
|
* ClassDescription:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置跨域(CORS)
|
||||||
|
/// </summary>
|
||||||
|
public static class CorsSetup
|
||||||
|
{
|
||||||
|
public static void AddCorsSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
services.AddCors(c =>
|
||||||
|
{
|
||||||
|
if (!AppSettingsConstVars.CorsEnableAllIPs)
|
||||||
|
{
|
||||||
|
c.AddPolicy(AppSettingsConstVars.CorsPolicyName, policy =>
|
||||||
|
{
|
||||||
|
policy.WithOrigins(AppSettingsConstVars.CorsIPs.Split(','));
|
||||||
|
policy.AllowAnyHeader();//Ensures that the policy allows any header.
|
||||||
|
policy.AllowAnyMethod();
|
||||||
|
policy.AllowCredentials();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//允许任意跨域请求
|
||||||
|
c.AddPolicy(AppSettingsConstVars.CorsPolicyName, policy =>
|
||||||
|
{
|
||||||
|
policy.SetIsOriginAllowed((host) => true)
|
||||||
|
.AllowAnyMethod()
|
||||||
|
.AllowAnyHeader()
|
||||||
|
.AllowCredentials();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
73
CoreCms.Net.Core/Config/HangFireSetup.cs
Normal file
73
CoreCms.Net.Core/Config/HangFireSetup.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-03 22:49:41
|
||||||
|
* ClassDescription:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Transactions;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using Hangfire;
|
||||||
|
using Hangfire.MySql;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 增加HangFire到单独配置
|
||||||
|
/// </summary>
|
||||||
|
public static class HangFireSetup
|
||||||
|
{
|
||||||
|
public static void AddHangFireSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
//注册Hangfire定时任务
|
||||||
|
var isEnabledRedis = AppSettingsConstVars.RedisUseTimedTask;
|
||||||
|
if (isEnabledRedis)
|
||||||
|
{
|
||||||
|
services.AddHangfire(x => x.UseRedisStorage(AppSettingsConstVars.RedisConfigConnectionString));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string dbTypeString = AppSettingsConstVars.DbDbType;
|
||||||
|
if (dbTypeString == DbType.MySql.ToString())
|
||||||
|
{
|
||||||
|
services.AddHangfire(x => x.UseStorage(new MySqlStorage(AppSettingsConstVars.DbSqlConnection, new MySqlStorageOptions
|
||||||
|
{
|
||||||
|
TransactionIsolationLevel = IsolationLevel.ReadCommitted, // 事务隔离级别。默认是读取已提交。
|
||||||
|
QueuePollInterval = TimeSpan.FromSeconds(15), //- 作业队列轮询间隔。默认值为15秒。
|
||||||
|
JobExpirationCheckInterval = TimeSpan.FromHours(1), //- 作业到期检查间隔(管理过期记录)。默认值为1小时。
|
||||||
|
CountersAggregateInterval = TimeSpan.FromMinutes(5), //- 聚合计数器的间隔。默认为5分钟。
|
||||||
|
PrepareSchemaIfNecessary = true, //- 如果设置为true,则创建数据库表。默认是true。
|
||||||
|
DashboardJobListLimit = 50000, //- 仪表板作业列表限制。默认值为50000。
|
||||||
|
TransactionTimeout = TimeSpan.FromMinutes(1), //- 交易超时。默认为1分钟。
|
||||||
|
TablesPrefix = "Hangfire" //- 数据库中表的前缀。默认为none
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
else if (dbTypeString == DbType.SqlServer.ToString())
|
||||||
|
{
|
||||||
|
services.AddHangfire(x => x.UseSqlServerStorage(AppSettingsConstVars.DbSqlConnection));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
services.AddHangfireServer(options =>
|
||||||
|
{
|
||||||
|
options.Queues = new[] { GlobalEnumVars.HangFireQueuesConfig.@default.ToString(), GlobalEnumVars.HangFireQueuesConfig.apis.ToString(), GlobalEnumVars.HangFireQueuesConfig.web.ToString(), GlobalEnumVars.HangFireQueuesConfig.recurring.ToString() };
|
||||||
|
options.ServerTimeout = TimeSpan.FromMinutes(4);
|
||||||
|
options.SchedulePollingInterval = TimeSpan.FromSeconds(15);//秒级任务需要配置短点,一般任务可以配置默认时间,默认15秒
|
||||||
|
options.ShutdownTimeout = TimeSpan.FromMinutes(30); //超时时间
|
||||||
|
options.WorkerCount = Math.Max(Environment.ProcessorCount, 20); //工作线程数,当前允许的最大线程,默认20
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
CoreCms.Net.Core/Config/MemoryCacheSetup.cs
Normal file
29
CoreCms.Net.Core/Config/MemoryCacheSetup.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Caching.AutoMate.MemoryCache;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Memory缓存 启动服务
|
||||||
|
/// </summary>
|
||||||
|
public static class MemoryCacheSetup
|
||||||
|
{
|
||||||
|
public static void AddMemoryCacheSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
services.AddScoped<ICachingProvider, MemoryCaching>();
|
||||||
|
services.AddSingleton<IMemoryCache>(factory =>
|
||||||
|
{
|
||||||
|
var cache = new MemoryCache(new MemoryCacheOptions());
|
||||||
|
return cache;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
CoreCms.Net.Core/Config/RedisCacheSetup.cs
Normal file
39
CoreCms.Net.Core/Config/RedisCacheSetup.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Redis缓存 启动服务
|
||||||
|
/// </summary>
|
||||||
|
public static class RedisCacheSetup
|
||||||
|
{
|
||||||
|
public static void AddRedisCacheSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
services.AddTransient<IRedisOperationRepository, RedisOperationRepository>();
|
||||||
|
|
||||||
|
// 配置启动Redis服务,虽然可能影响项目启动速度,但是不能在运行的时候报错,所以是合理的
|
||||||
|
services.AddSingleton<ConnectionMultiplexer>(sp =>
|
||||||
|
{
|
||||||
|
//获取连接字符串
|
||||||
|
string redisConfiguration = AppSettingsConstVars.RedisConfigConnectionString;
|
||||||
|
|
||||||
|
var configuration = ConfigurationOptions.Parse(redisConfiguration, true);
|
||||||
|
|
||||||
|
configuration.ResolveDns = true;
|
||||||
|
|
||||||
|
return ConnectionMultiplexer.Connect(configuration);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
48
CoreCms.Net.Core/Config/RedisMessageQueueSetup.cs
Normal file
48
CoreCms.Net.Core/Config/RedisMessageQueueSetup.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.RedisMQ.Subscribe;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using InitQ;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Redis 消息队列 启动服务
|
||||||
|
/// </summary>
|
||||||
|
public static class RedisMessageQueueSetup
|
||||||
|
{
|
||||||
|
public static void AddRedisMessageQueueSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
services.AddInitQ(m =>
|
||||||
|
{
|
||||||
|
//时间间隔
|
||||||
|
m.SuspendTime = 1000;
|
||||||
|
//redis服务器地址
|
||||||
|
m.ConnectionString = AppSettingsConstVars.RedisConfigConnectionString;
|
||||||
|
//对应的订阅者类,需要new一个实例对象,当然你也可以传参,比如日志对象
|
||||||
|
m.ListSubscribe = new List<Type>() {
|
||||||
|
typeof(OrderAgentOrDistributionSubscribe),
|
||||||
|
typeof(OrderAutomaticDeliverySubscribe),
|
||||||
|
typeof(OrderFinishCommandSubscribe),
|
||||||
|
typeof(OrderPrintSubscribe),
|
||||||
|
|
||||||
|
typeof(LogingSubscribe),
|
||||||
|
|
||||||
|
typeof(UserSubscribe),
|
||||||
|
typeof(WeChatPayNoticeSubscribe),
|
||||||
|
typeof(SendWxTemplateMessageSubscribe),
|
||||||
|
typeof(AfterSalesReviewSubscribe),
|
||||||
|
};
|
||||||
|
//显示日志
|
||||||
|
m.ShowLog = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
95
CoreCms.Net.Core/Config/SqlSugarSetup.cs
Normal file
95
CoreCms.Net.Core/Config/SqlSugarSetup.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-03 22:45:34
|
||||||
|
* FileName: SqlSugarSetup
|
||||||
|
* ClassDescription:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using CoreCms.Net.Caching.SqlSugar;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.Loging;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// SqlSugar 启动服务
|
||||||
|
/// </summary>
|
||||||
|
public static class SqlSugarSetup
|
||||||
|
{
|
||||||
|
public static void AddSqlSugarSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
string connectionString = AppSettingsConstVars.DbSqlConnection;
|
||||||
|
string dbTypeString = AppSettingsConstVars.DbDbType;
|
||||||
|
|
||||||
|
//获取数据类型
|
||||||
|
var dbType = dbTypeString == DbType.MySql.ToString() ? DbType.MySql : DbType.SqlServer;
|
||||||
|
//判断是否开启redis设置二级缓存方式
|
||||||
|
ICacheService myCache = AppSettingsConstVars.RedisUseCache
|
||||||
|
? (ICacheService)new SqlSugarRedisCache()
|
||||||
|
: new SqlSugarMemoryCache();
|
||||||
|
|
||||||
|
var connectionConfig = new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = connectionString, //必填
|
||||||
|
DbType = dbType, //必填
|
||||||
|
IsAutoCloseConnection = false,
|
||||||
|
InitKeyType = InitKeyType.Attribute,
|
||||||
|
|
||||||
|
ConfigureExternalServices = new ConfigureExternalServices()
|
||||||
|
{
|
||||||
|
DataInfoCacheService = myCache
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
services.AddScoped<ISqlSugarClient>(o =>
|
||||||
|
{
|
||||||
|
|
||||||
|
var db = new SqlSugarClient(connectionConfig); //默认SystemTable
|
||||||
|
|
||||||
|
//日志处理
|
||||||
|
////SQL执行前 可以修改SQL
|
||||||
|
//db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
//{
|
||||||
|
// //获取sql
|
||||||
|
// Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||||
|
// Console.WriteLine();
|
||||||
|
|
||||||
|
// //通过TempItems这个变量来算出这个SQL执行时间(1)
|
||||||
|
// if (db.TempItems == null) db.TempItems = new Dictionary<string, object>();
|
||||||
|
// db.TempItems.Add("logTime", DateTime.Now);
|
||||||
|
// //通过TempItems这个变量来算出这个SQL执行时间(2)
|
||||||
|
// var startingTime = db.TempItems["logTime"];
|
||||||
|
// db.TempItems.Remove("time");
|
||||||
|
// var completedTime = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
|
//};
|
||||||
|
//db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
||||||
|
//{
|
||||||
|
|
||||||
|
//};
|
||||||
|
//db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||||
|
//{
|
||||||
|
|
||||||
|
//};
|
||||||
|
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
||||||
|
{
|
||||||
|
NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Other, "SqlSugar", "执行SQL错误事件", exp);
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
132
CoreCms.Net.Core/Config/SwaggerSetup.cs
Normal file
132
CoreCms.Net.Core/Config/SwaggerSetup.cs
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-02 18:41:38
|
||||||
|
* FileName: SwaggerSetup
|
||||||
|
* ClassDescription:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using CoreCms.Net.Loging;
|
||||||
|
using CoreCms.Net.Swagger;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using Swashbuckle.AspNetCore.Filters;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
public static class SwaggerSetup
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void AddAdminSwaggerSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
var apiName = "核心商城系统管理端";
|
||||||
|
|
||||||
|
services.AddSwaggerGen((s) =>
|
||||||
|
{
|
||||||
|
//遍历出全部的版本,做文档信息展示
|
||||||
|
typeof(CustomApiVersion.ApiVersions).GetEnumNames().ToList().ForEach(version =>
|
||||||
|
{
|
||||||
|
s.SwaggerDoc(version, new OpenApiInfo
|
||||||
|
{
|
||||||
|
Version = version,
|
||||||
|
Title = $"{apiName} 接口文档",
|
||||||
|
Description = $"{apiName} HTTP API " + version,
|
||||||
|
Contact = new OpenApiContact { Name = apiName, Email = "JianWeie@163.com", Url = new Uri("https://CoreCms.Net") },
|
||||||
|
});
|
||||||
|
s.OrderActionsBy(o => o.RelativePath);
|
||||||
|
});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//生成API XML文档
|
||||||
|
var basePath = AppContext.BaseDirectory;
|
||||||
|
var xmlPath = Path.Combine(basePath, "doc.xml");
|
||||||
|
s.IncludeXmlComments(xmlPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Swagger, "Swagger", "Swagger生成失败,Doc.xml丢失,请检查并拷贝。", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开启加权小锁
|
||||||
|
s.OperationFilter<AddResponseHeadersFilter>();
|
||||||
|
s.OperationFilter<AppendAuthorizeToSummaryOperationFilter>();
|
||||||
|
|
||||||
|
// 在header中添加token,传递到后台
|
||||||
|
s.OperationFilter<SecurityRequirementsOperationFilter>();
|
||||||
|
|
||||||
|
// 必须是 oauth2
|
||||||
|
s.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = "JWT授权(数据将在请求头中进行传输) 直接在下框中输入Bearer {token}(注意两者之间是一个空格)\"",
|
||||||
|
Name = "Authorization",//jwt默认的参数名称
|
||||||
|
In = ParameterLocation.Header,//jwt默认存放Authorization信息的位置(请求头中)
|
||||||
|
Type = SecuritySchemeType.ApiKey
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void AddClientSwaggerSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
var apiName = "核心商城系统接口端";
|
||||||
|
|
||||||
|
services.AddSwaggerGen((s) =>
|
||||||
|
{
|
||||||
|
//遍历出全部的版本,做文档信息展示
|
||||||
|
typeof(CustomApiVersion.ApiVersions).GetEnumNames().ToList().ForEach(version =>
|
||||||
|
{
|
||||||
|
s.SwaggerDoc(version, new OpenApiInfo
|
||||||
|
{
|
||||||
|
Version = version,
|
||||||
|
Title = $"{apiName} 接口文档",
|
||||||
|
Description = $"{apiName} HTTP API " + version,
|
||||||
|
Contact = new OpenApiContact { Name = apiName, Email = "JianWeie@163.com", Url = new Uri("https://CoreCms.Net") },
|
||||||
|
});
|
||||||
|
s.OrderActionsBy(o => o.RelativePath);
|
||||||
|
});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//生成API XML文档
|
||||||
|
var basePath = AppContext.BaseDirectory;
|
||||||
|
var xmlPath = Path.Combine(basePath, "doc.xml");
|
||||||
|
s.IncludeXmlComments(xmlPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Swagger, "Swagger", "Swagger生成失败,Doc.xml丢失,请检查并拷贝。", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开启加权小锁
|
||||||
|
s.OperationFilter<AddResponseHeadersFilter>();
|
||||||
|
s.OperationFilter<AppendAuthorizeToSummaryOperationFilter>();
|
||||||
|
|
||||||
|
// 在header中添加token,传递到后台
|
||||||
|
s.OperationFilter<SecurityRequirementsOperationFilter>();
|
||||||
|
|
||||||
|
// 必须是 oauth2
|
||||||
|
s.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = "JWT授权(数据将在请求头中进行传输) 直接在下框中输入Bearer {token}(注意两者之间是一个空格)\"",
|
||||||
|
Name = "Authorization",//jwt默认的参数名称
|
||||||
|
In = ParameterLocation.Header,//jwt默认存放Authorization信息的位置(请求头中)
|
||||||
|
Type = SecuritySchemeType.ApiKey
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
34
CoreCms.Net.Core/Config/YiLianYunSetup.cs
Normal file
34
CoreCms.Net.Core/Config/YiLianYunSetup.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.RedisMQ.Subscribe;
|
||||||
|
using CoreCms.Net.Utility.Extensions;
|
||||||
|
using InitQ;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Qc.YilianyunSdk;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Core.Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 易联云打印机 启动服务
|
||||||
|
/// </summary>
|
||||||
|
public static class YiLianYunSetup
|
||||||
|
{
|
||||||
|
public static void AddYiLianYunSetup(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
services.AddYilianyunSdk<DefaultYilianyunSdkHook>(opt =>
|
||||||
|
{
|
||||||
|
// 应用ID请自行前往 dev.10ss.net 获取
|
||||||
|
opt.ClientId = AppSettingsConstVars.YiLianYunConfigClientId;
|
||||||
|
opt.ClientSecret = AppSettingsConstVars.YiLianYunConfigClientSecret;
|
||||||
|
opt.YilianyunClientType = YilianyunClientType.自有应用;
|
||||||
|
opt.SaveTokenDirPath = "./App_Data/YiLianYunLogs";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
CoreCms.Net.Core/CoreCms.Net.Core.csproj
Normal file
41
CoreCms.Net.Core/CoreCms.Net.Core.csproj
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Sms\**" />
|
||||||
|
<EmbeddedResource Remove="Sms\**" />
|
||||||
|
<None Remove="Sms\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
|
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Castle.Core" Version="4.4.1" />
|
||||||
|
<PackageReference Include="Hangfire" Version="1.7.25" />
|
||||||
|
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.25" />
|
||||||
|
<PackageReference Include="Hangfire.Core" Version="1.7.25" />
|
||||||
|
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
||||||
|
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
|
||||||
|
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.4" />
|
||||||
|
<PackageReference Include="InitQ" Version="1.0.0.7" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||||
|
<PackageReference Include="Qc.YilianyunSdk" Version="1.0.7" />
|
||||||
|
<PackageReference Include="sqlSugarCore" Version="5.0.4.2" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Caching\CoreCms.Net.Caching.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Configuration\CoreCms.Net.Configuration.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.IRepository\CoreCms.Net.IRepository.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.RedisMQ\CoreCms.Net.RedisMQ.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Swagger\CoreCms.Net.Swagger.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
156
CoreCms.Net.Filter/AdminsControllerPermission.cs
Normal file
156
CoreCms.Net.Filter/AdminsControllerPermission.cs
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-10-21 21:46:04
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Filter
|
||||||
|
{
|
||||||
|
public class AdminsControllerPermission
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 反射获取所有controller 和action
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<ControllerPermission> GetAllControllerAndActionByAssembly()
|
||||||
|
{
|
||||||
|
|
||||||
|
var result = new List<ControllerPermission>();
|
||||||
|
|
||||||
|
var types = Assembly.Load("CoreCms.Net.Web.Admin").GetTypes();
|
||||||
|
|
||||||
|
|
||||||
|
var noController = new[] { "ToolsController", "LoginController", "DemoController" };
|
||||||
|
|
||||||
|
var controllers = types.Where(p => p.Name.Contains("Controller") && !noController.Contains(p.Name));
|
||||||
|
foreach (var type in controllers)
|
||||||
|
{
|
||||||
|
if (type.Name.Length > 10 && type.BaseType.Name == "ControllerBase" && type.Name.EndsWith("Controller")) //如果是Controller
|
||||||
|
{
|
||||||
|
var members = type.GetMethods();
|
||||||
|
var cp = new ControllerPermission
|
||||||
|
{
|
||||||
|
name = type.Name.Substring(0, type.Name.Length - 10),
|
||||||
|
action = new List<ActionPermission>()
|
||||||
|
};
|
||||||
|
|
||||||
|
var objs = type.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||||
|
if (objs.Length > 0) cp.description = (objs[0] as DescriptionAttribute).Description;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(cp.description))
|
||||||
|
{
|
||||||
|
cp.name += "【" + cp.description + "】";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var newMembers = members.Where(p =>
|
||||||
|
p.ReturnType.FullName != null && (p.ReturnType.Name == "ActionResult" ||
|
||||||
|
p.ReturnType.Name == "FileResult" ||
|
||||||
|
p.ReturnType.Name == "JsonResult" ||
|
||||||
|
(p.ReturnType.GenericTypeArguments.Length > 0 && p.ReturnType.GenericTypeArguments[0].Name == "JsonResult") ||
|
||||||
|
p.ReturnType.Name == "AdminUiCallBack" ||
|
||||||
|
p.ReturnType.Name == "IActionResult" ||
|
||||||
|
p.ReturnType.FullName.Contains("CoreCms.Net.Model.ViewModels.UI.AdminUiCallBack"))
|
||||||
|
).ToList();
|
||||||
|
|
||||||
|
foreach (var member in newMembers)
|
||||||
|
{
|
||||||
|
if (member.Name == "ValidationProblem" || member.Name == "Json") continue;
|
||||||
|
|
||||||
|
//if (member.ReturnType.Name == "ActionResult" || member.ReturnType.Name == "FileResult" || member.ReturnType.Name == "JsonResult" || (member.ReturnType.GenericTypeArguments.Length > 0 && member.ReturnType.GenericTypeArguments[0].Name == "JsonResult")) //如果是Action
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
var ap = new ActionPermission
|
||||||
|
{
|
||||||
|
name = member.Name,
|
||||||
|
actionName = member.Name,
|
||||||
|
controllerName = member.DeclaringType.Name.Substring(0, member.DeclaringType.Name.Length - 10)
|
||||||
|
};
|
||||||
|
// 去掉“Controller”后缀
|
||||||
|
|
||||||
|
var attrs = member.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||||
|
if (attrs.Length > 0) ap.description = (attrs[0] as DescriptionAttribute).Description;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(ap.description))
|
||||||
|
{
|
||||||
|
ap.name += "【" + ap.description + "】";
|
||||||
|
}
|
||||||
|
cp.action.Add(ap);
|
||||||
|
|
||||||
|
}
|
||||||
|
cp.action = cp.action.Distinct(new ModelComparer()).ToList();
|
||||||
|
result.Add(cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModelComparer : IEqualityComparer<ActionPermission>
|
||||||
|
{
|
||||||
|
public bool Equals(ActionPermission x, ActionPermission y)
|
||||||
|
{
|
||||||
|
return x.name.ToUpper() == y.name.ToUpper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(ActionPermission obj)
|
||||||
|
{
|
||||||
|
return obj.name.ToUpper().GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class ActionPermission
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 请求地址
|
||||||
|
/// </summary>
|
||||||
|
public virtual string name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求地址
|
||||||
|
/// </summary>
|
||||||
|
public virtual string controllerName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求地址
|
||||||
|
/// </summary>
|
||||||
|
public virtual string actionName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public virtual string description { get; set; }
|
||||||
|
|
||||||
|
public virtual string type { get; set; } = "action";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ControllerPermission
|
||||||
|
{
|
||||||
|
public virtual string name { get; set; }
|
||||||
|
|
||||||
|
public virtual string description { get; set; }
|
||||||
|
|
||||||
|
public virtual IList<ActionPermission> action { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public virtual string type { get; set; } = "controller";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
38
CoreCms.Net.Filter/ApiExplorerIgnores.cs
Normal file
38
CoreCms.Net.Filter/ApiExplorerIgnores.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-03-15 20:42:29
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Filter
|
||||||
|
{
|
||||||
|
public class ApiExplorerIgnores : IActionModelConvention
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自带的Controller与swagger3.0冲突,在此排除扫描
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
public void Apply(ActionModel action)
|
||||||
|
{
|
||||||
|
//冲突的Ocelot.Raft.RaftController
|
||||||
|
if (action.Controller.ControllerName == ("WxOfficialOAuth") || action.Controller.ControllerName == ("WxOpenOAuth"))
|
||||||
|
action.ApiExplorer.IsVisible = false;
|
||||||
|
//Ocelot.Cache.OutputCacheController
|
||||||
|
if (action.Controller.ControllerName == ("AliPay"))
|
||||||
|
action.ApiExplorer.IsVisible = false;
|
||||||
|
|
||||||
|
if (action.Controller.ControllerName == ("WeChatPay"))
|
||||||
|
action.ApiExplorer.IsVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
CoreCms.Net.Filter/CoreCms.Net.Filter.csproj
Normal file
18
CoreCms.Net.Filter/CoreCms.Net.Filter.csproj
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
54
CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs
Normal file
54
CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-05 19:20:08
|
||||||
|
* Description:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using CoreCms.Net.Loging;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Filter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口全局异常错误日志
|
||||||
|
/// </summary>
|
||||||
|
public class GlobalExceptionsFilterForAdmin : IExceptionFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public void OnException(ExceptionContext context)
|
||||||
|
{
|
||||||
|
|
||||||
|
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", "全局捕获异常", context.Exception);
|
||||||
|
|
||||||
|
HttpStatusCode status = HttpStatusCode.InternalServerError;
|
||||||
|
|
||||||
|
//处理各种异常
|
||||||
|
var jm = new AdminUiCallBack();
|
||||||
|
jm.code = (int)status;
|
||||||
|
jm.msg = "系统异常,请查看错误描述并进行解决。";
|
||||||
|
jm.data = context.Exception;
|
||||||
|
context.ExceptionHandled = true;
|
||||||
|
context.Result = new ObjectResult(jm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
58
CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs
Normal file
58
CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* Versions: 1.0 *
|
||||||
|
* CreateTime: 2020-02-05 19:20:08
|
||||||
|
* Description:
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using CoreCms.Net.Loging;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Filter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口全局异常错误日志
|
||||||
|
/// </summary>
|
||||||
|
public class GlobalExceptionsFilterForClent : IExceptionFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public void OnException(ExceptionContext context)
|
||||||
|
{
|
||||||
|
|
||||||
|
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", "全局捕获异常", context.Exception);
|
||||||
|
|
||||||
|
|
||||||
|
HttpStatusCode status = HttpStatusCode.InternalServerError;
|
||||||
|
|
||||||
|
//处理各种异常
|
||||||
|
var jm = new WebApiCallBack
|
||||||
|
{
|
||||||
|
status = false,
|
||||||
|
code = (int)status,
|
||||||
|
msg = "系统返回异常,请联系管理员进行处理!",
|
||||||
|
data = context.Exception
|
||||||
|
};
|
||||||
|
context.ExceptionHandled = true;
|
||||||
|
context.Result = new ObjectResult(jm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
63
CoreCms.Net.Filter/RequiredErrorForAdmin.cs
Normal file
63
CoreCms.Net.Filter/RequiredErrorForAdmin.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-02-17 1:40:34
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Filter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 请求验证错误处理
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true)]
|
||||||
|
public class RequiredErrorForAdmin : ResultFilterAttribute
|
||||||
|
{
|
||||||
|
public override void OnResultExecuting(ResultExecutingContext actionContext)
|
||||||
|
{
|
||||||
|
//base.OnResultExecuting(actionContext);
|
||||||
|
var modelState = actionContext.ModelState;
|
||||||
|
List<ErrorView> errors = new List<ErrorView>();
|
||||||
|
if (!modelState.IsValid)
|
||||||
|
{
|
||||||
|
var baseResult = new AdminUiCallBack()
|
||||||
|
{
|
||||||
|
code = 1,
|
||||||
|
msg = "请提交必要的参数",
|
||||||
|
};
|
||||||
|
foreach (var key in modelState.Keys)
|
||||||
|
{
|
||||||
|
var state = modelState[key];
|
||||||
|
if (state.Errors.Any())
|
||||||
|
{
|
||||||
|
ErrorView errorView = new ErrorView();
|
||||||
|
errorView.ErrorName = key;
|
||||||
|
errorView.Error = state.Errors.First().ErrorMessage;
|
||||||
|
errors.Add(errorView);
|
||||||
|
baseResult.msg += errorView.ErrorName + "-" + errorView.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseResult.data = errors;
|
||||||
|
actionContext.Result = new ContentResult
|
||||||
|
{
|
||||||
|
Content = JsonConvert.SerializeObject(baseResult),
|
||||||
|
ContentType = "application/json"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
CoreCms.Net.Filter/RequiredErrorForClent.cs
Normal file
64
CoreCms.Net.Filter/RequiredErrorForClent.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms.Net *
|
||||||
|
* Web: https://CoreCms.Net *
|
||||||
|
* ProjectName: 核心内容管理系统 *
|
||||||
|
* Author: 大灰灰 *
|
||||||
|
* Email: JianWeie@163.com *
|
||||||
|
* CreateTime: 2020-02-17 1:40:34
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Filter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 请求验证错误处理
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true)]
|
||||||
|
public class RequiredErrorForClent : ResultFilterAttribute
|
||||||
|
{
|
||||||
|
public override void OnResultExecuting(ResultExecutingContext actionContext)
|
||||||
|
{
|
||||||
|
//base.OnResultExecuting(actionContext);
|
||||||
|
var modelState = actionContext.ModelState;
|
||||||
|
List<ErrorView> errors = new List<ErrorView>();
|
||||||
|
if (!modelState.IsValid)
|
||||||
|
{
|
||||||
|
var baseResult = new WebApiCallBack()
|
||||||
|
{
|
||||||
|
status = false,
|
||||||
|
code = 0,
|
||||||
|
msg = "请提交必要的参数",
|
||||||
|
};
|
||||||
|
foreach (var key in modelState.Keys)
|
||||||
|
{
|
||||||
|
var state = modelState[key];
|
||||||
|
if (state.Errors.Any())
|
||||||
|
{
|
||||||
|
ErrorView errorView = new ErrorView();
|
||||||
|
errorView.ErrorName = key;
|
||||||
|
errorView.Error = state.Errors.First().ErrorMessage;
|
||||||
|
errors.Add(errorView);
|
||||||
|
//baseResult.msg += errorView.ErrorName + "-" + errorView.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseResult.data = errors;
|
||||||
|
actionContext.Result = new ContentResult
|
||||||
|
{
|
||||||
|
Content = JsonConvert.SerializeObject(baseResult),
|
||||||
|
ContentType = "application/json"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 广告位置表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAdvertPositionRepository : IBaseRepository<CoreCmsAdvertPosition>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 广告表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAdvertisementRepository : IBaseRepository<CoreCmsAdvertisement>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代理商品池 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAgentGoodsRepository : IBaseRepository<CoreCmsAgentGoods>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsAgentGoods>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsAgentGoods, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsAgentGoods, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="products"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<AdminUiCallBack> InsertAsync(CoreCmsAgentGoods entity, List<CoreCmsAgentProducts> products);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="products"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<AdminUiCallBack> UpdateAsync(CoreCmsAgentGoods entity, List<CoreCmsAgentProducts> products);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsAgentGoods> entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<AdminUiCallBack> DeleteByIdAsync(int id);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代理商等级设置表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAgentGradeRepository : IBaseRepository<CoreCmsAgentGrade>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsAgentGrade>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsAgentGrade, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsAgentGrade, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync(CoreCmsAgentGrade entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(CoreCmsAgentGrade entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsAgentGrade> entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<AdminUiCallBack> DeleteByIdAsync(int id);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<CoreCmsAgentGrade>> GetCaChe();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
Task<List<CoreCmsAgentGrade>> UpdateCaChe();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代理商订单记录表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAgentOrderRepository : IBaseRepository<CoreCmsAgentOrder>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsAgentOrder>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsAgentOrder, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsAgentOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync(CoreCmsAgentOrder entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(CoreCmsAgentOrder entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsAgentOrder> entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代理货品池 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAgentProductsRepository : IBaseRepository<CoreCmsAgentProducts>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsAgentProducts>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsAgentProducts, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsAgentProducts, object>> orderByExpression, OrderByType orderByType,
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
62
CoreCms.Net.IRepository/Agent/ICoreCmsAgentRepository.cs
Normal file
62
CoreCms.Net.IRepository/Agent/ICoreCmsAgentRepository.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.DTO.Agent;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代理商表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsAgentRepository : IBaseRepository<CoreCmsAgent>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据条件查询订单分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="typeId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IPageList<CoreCmsAgentOrder>> QueryOrderPageAsync(int userId, int pageIndex = 1, int pageSize = 20,
|
||||||
|
int typeId = 0);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsAgent>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsAgent, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsAgent, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取代理商排行
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IPageList<AgentRankingDTO>> QueryRankingPageAsync(int pageIndex = 1, int pageSize = 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 第三方授权记录表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsApiAccessTokenRepository : IBaseRepository<CoreCmsApiAccessToken>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
46
CoreCms.Net.IRepository/Article/ICoreCmsArticleRepository.cs
Normal file
46
CoreCms.Net.IRepository/Article/ICoreCmsArticleRepository.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文章表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsArticleRepository : IBaseRepository<CoreCmsArticle>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定id 的文章详情
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">序列</param>
|
||||||
|
Task<CoreCmsArticle> ArticleDetail(int id);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IPageList<CoreCmsArticle>> QueryPageAsync(Expression<Func<CoreCmsArticle, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsArticle, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文章分类表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsArticleTypeRepository : IBaseRepository<CoreCmsArticleType>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品图片关联表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillAftersalesImagesRepository : IBaseRepository<CoreCmsBillAftersalesImages>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 售后单明细表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillAftersalesItemRepository : IBaseRepository<CoreCmsBillAftersalesItem>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 退货单表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillAftersalesRepository : IBaseRepository<CoreCmsBillAftersales>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IPageList<CoreCmsBillAftersales>> QueryPageAsync(Expression<Func<CoreCmsBillAftersales, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsBillAftersales, object>> orderByExpression, OrderByType orderByType,
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = 20);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取单个数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reshipId"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<CoreCmsBillAftersales> GetInfo(string aftersalesId, int userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 发货单详情表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillDeliveryItemRepository : IBaseRepository<CoreCmsBillDeliveryItem>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 发货单表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillDeliveryRepository : IBaseRepository<CoreCmsBillDelivery>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 发货单统计7天统计
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<StatisticsOut>> Statistics();
|
||||||
|
}
|
||||||
|
}
|
||||||
28
CoreCms.Net.IRepository/Bill/ICoreCmsBillLadingRepository.cs
Normal file
28
CoreCms.Net.IRepository/Bill/ICoreCmsBillLadingRepository.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 提货单表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillLadingRepository : IBaseRepository<CoreCmsBillLading>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 添加提货单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<WebApiCallBack> AddData(string orderId, int storeId, string name, string mobile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 支付单表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillPaymentsRepository : IBaseRepository<CoreCmsBillPayments>
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付单7天统计
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<StatisticsOut>> Statistics();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsBillPayments>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsBillPayments, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsBillPayments, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
CoreCms.Net.IRepository/Bill/ICoreCmsBillRefundRepository.cs
Normal file
40
CoreCms.Net.IRepository/Bill/ICoreCmsBillRefundRepository.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 退款单表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillRefundRepository : IBaseRepository<CoreCmsBillRefund>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsBillRefund>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsBillRefund, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsBillRefund, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 退货单明细表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillReshipItemRepository : IBaseRepository<CoreCmsBillReshipItem>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
51
CoreCms.Net.IRepository/Bill/ICoreCmsBillReshipRepository.cs
Normal file
51
CoreCms.Net.IRepository/Bill/ICoreCmsBillReshipRepository.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 退货单表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsBillReshipRepository : IBaseRepository<CoreCmsBillReship>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取单个数据带导航
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="orderByType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<CoreCmsBillReship> GetDetails(Expression<Func<CoreCmsBillReship, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsBillReship, object>> orderByExpression, OrderByType orderByType);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IPageList<CoreCmsBillReship>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsBillReship, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsBillReship, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
CoreCms.Net.IRepository/Cart/ICoreCmsCartRepository.cs
Normal file
27
CoreCms.Net.IRepository/Cart/ICoreCmsCartRepository.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 购物车表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsCartRepository : IBaseRepository<CoreCmsCart>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取购物车用户数据总数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> GetCountAsync(int userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
public interface ICodeGeneratorRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有的表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<DbTableInfo> GetDbTables();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取表下面所有的字段
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tableName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<DbColumnInfo> GetDbTablesColumns(string tableName);
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 自动生成全部代码
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="model"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
byte[] CodeGen(string tableName, string fileType);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动生成类型的所有数据库代码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tableName"></param>
|
||||||
|
/// <param name="fileType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
byte[] CodeGenByAll(string fileType);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
CoreCms.Net.IRepository/Com/ICoreCmsLabelRepository.cs
Normal file
21
CoreCms.Net.IRepository/Com/ICoreCmsLabelRepository.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 标签表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsLabelRepository : IBaseRepository<CoreCmsLabel>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
11
CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj
Normal file
11
CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* Project: CoreCms
|
||||||
|
* ProjectName: 核心内容管理系统
|
||||||
|
* Web: https://www.corecms.net
|
||||||
|
* Author: 大灰灰
|
||||||
|
* Email: jianweie@163.com
|
||||||
|
* CreateTime: 2021/1/31 21:45:10
|
||||||
|
* Description: 暂无
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分销商等级升级条件 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsDistributionConditionRepository : IBaseRepository<CoreCmsDistributionCondition>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsDistributionCondition>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsDistributionCondition, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsDistributionCondition, object>> orderByExpression, OrderByType orderByType,
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionCondition entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionCondition entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsDistributionCondition> entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<CoreCmsDistributionCondition>> GetCaChe();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
Task<List<CoreCmsDistributionCondition>> UpdateCaChe();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分销商等级设置表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsDistributionGradeRepository : IBaseRepository<CoreCmsDistributionGrade>
|
||||||
|
{
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionGrade entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionGrade entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<AdminUiCallBack> DeleteByIdAsync(int id);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<CoreCmsDistributionGrade>> GetCaChe();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新cache
|
||||||
|
/// </summary>
|
||||||
|
Task<List<CoreCmsDistributionGrade>> UpdateCaChe();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsDistributionGrade>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsDistributionGrade, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsDistributionGrade, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CoreCms.Net.Model.Entities;
|
||||||
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CoreCms.Net.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分销商订单记录表 工厂接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICoreCmsDistributionOrderRepository : IBaseRepository<CoreCmsDistributionOrder>
|
||||||
|
{
|
||||||
|
#region 重写增删改查操作===========================================================
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步插入方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionOrder entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionOrder entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写异步更新方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsDistributionOrder> entity);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写删除指定ID集合的数据(批量删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">判断集合</param>
|
||||||
|
/// <param name="orderByType">排序方式</param>
|
||||||
|
/// <param name="pageIndex">当前页面索引</param>
|
||||||
|
/// <param name="pageSize">分布大小</param>
|
||||||
|
/// <param name="orderByExpression"></param>
|
||||||
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
new Task<IPageList<CoreCmsDistributionOrder>> QueryPageAsync(
|
||||||
|
Expression<Func<CoreCmsDistributionOrder, bool>> predicate,
|
||||||
|
Expression<Func<CoreCmsDistributionOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取下级推广订单数量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentId">父类序列</param>
|
||||||
|
/// <param name="type">1获取1级,其他为2级,0为全部</param>
|
||||||
|
/// <param name="thisMonth">显示当月</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> QueryChildOrderCountAsync(int parentId, int type = 1, bool thisMonth = false);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取下级推广订单金额
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentId">父类序列</param>
|
||||||
|
/// <param name="type">1获取1级,其他为2级,0为全部</param>
|
||||||
|
/// <param name="thisMonth">显示当月</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<decimal> QueryChildOrderMoneySumAsync(int parentId, int type = 1, bool thisMonth = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user