😎1、默认系统自带种子禁止更新 2、修复微信支付证书找不到问题 3、优化初始化表和种子流程

This commit is contained in:
zuohuaijun 2025-06-05 13:11:21 +08:00
parent e3fef395bc
commit 61e79b6a51
22 changed files with 60 additions and 23 deletions

View File

@ -20,7 +20,7 @@
"MerchantId": "1500000001", //
"MerchantV3Secret": "3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaoo", // APIv3
"MerchantCertificateSerialNumber": "66aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0", //
"MerchantCertificatePrivateKey": "\\WxPayCert\\apiclient_key.pem" // API(apiclient_key.pem)
"MerchantCertificatePrivateKey": "WxPayCert/apiclient_key.pem" // API(apiclient_key.pem)
},
//
"PayCallBack": {

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core.SeedData;
/// <summary>
/// 代码生成模板配置表 表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysCodeGenTemplateSeedData : ISqlSugarEntitySeedData<SysCodeGenTemplate>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统配置表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysConfigSeedData : ISqlSugarEntitySeedData<SysConfig>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统字典值表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysDictDataSeedData : ISqlSugarEntitySeedData<SysDictData>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统字典类型表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysDictTypeSeedData : ISqlSugarEntitySeedData<SysDictType>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统菜单表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统通知公告表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysNoticeSeedData : ISqlSugarEntitySeedData<SysNotice>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统职位表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysPosSeedData : ISqlSugarEntitySeedData<SysPos>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统角色菜单表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysRoleMenuSeedData : ISqlSugarEntitySeedData<SysRoleMenu>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统角色表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysRoleSeedData : ISqlSugarEntitySeedData<SysRole>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统租户表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysTenantSeedData : ISqlSugarEntitySeedData<SysTenant>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统用户扩展机构表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysUserExtOrgSeedData : ISqlSugarEntitySeedData<SysUserExtOrg>
{
/// <summary>

View File

@ -9,6 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 系统用户角色表种子数据
/// </summary>
[IgnoreUpdateSeed]
public class SysUserRoleSeedData : ISqlSugarEntitySeedData<SysUserRole>
{
/// <summary>

View File

@ -41,6 +41,11 @@ public class TableOutput
/// </summary>
public string TableComment { get; set; }
/// <summary>
/// 表字段个数
/// </summary>
public int ColumnCount { get; set; }
/// <summary>
/// 程序集名称
/// </summary>

View File

@ -124,18 +124,8 @@ public class SysCodeGenConfigService : IDynamicApiController, ITransient
}
}
}
//var sugarTableType = typeof(SugarTable);
//bool IsMyAttribute(Attribute[] o)
//{
// foreach (Attribute a in o)
// {
// if (a.GetType() == sugarTableType)
// return true;
// }
// return false;
//}
Type[] cosType = types.Where(u => u.IsDefined(typeof(SugarTable), false) && !u.GetCustomAttributes<IgnoreTableAttribute>().Any()).ToArray();
Type[] cosType = types.Where(u => u.IsDefined(typeof(SugarTable), false) && !u.GetCustomAttributes<IgnoreTableAttribute>().Any()).ToArray();
var entityInfos = new List<EntityInfo>();
foreach (var ct in cosType)
{

View File

@ -181,8 +181,9 @@ public class SysCodeGenService : IDynamicApiController, ITransient
var config = _dbConnectionOptions.ConnectionConfigs.FirstOrDefault(u => configId.Equals(u.ConfigId));
IEnumerable<EntityInfo> entityInfos = await _codeGenConfigService.GetEntityInfos(); // 获取所有实体定义
entityInfos = entityInfos.OrderBy(u => u.EntityName.StartsWith("Sys") ? 1 : 0).ThenBy(u => u.EntityName);
// 获取所有实体列表并按照程序集和实体名称进行排序
IEnumerable<EntityInfo> entityInfos = await _codeGenConfigService.GetEntityInfos();
entityInfos = entityInfos.OrderBy(u => u.Type.Assembly.ManifestModule.Name).ThenBy(u => u.EntityName);
var tableOutputList = new List<TableOutput>();
foreach (var item in entityInfos)
@ -205,6 +206,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
EntityName = item.EntityName,
TableName = table?.Name,
TableComment = item.TableDescription,
ColumnCount = item.Type.GetProperties().Length,
AssemblyName = item.Type.Assembly.ManifestModule.Name
});
}

View File

@ -10,6 +10,8 @@ public class DataInitItemOutput
{
public string Name { get; set; }
public int Count { get; set; }
public string AssemblyName { get; set; }
public string Description { get; set; }

View File

@ -562,8 +562,12 @@ public class SysDatabaseService : IDynamicApiController, ITransient
var outputList = new List<DataInitItemOutput>();
foreach (var seedDataType in seedDataTypes)
{
var instance = Activator.CreateInstance(seedDataType);
var hasDataMethod = seedDataType.GetMethod("HasData");
var seedData = ((IEnumerable)hasDataMethod?.Invoke(instance, null))?.Cast<object>().ToArray() ?? [];
var entityType = seedDataType.GetInterfaces().First().GetGenericArguments().First();
outputList.Add(new DataInitItemOutput() { Name = seedDataType.Name, AssemblyName = seedDataType.Assembly.ManifestModule.Name, Description = entityType.GetCustomAttribute<SugarTable>().TableDescription + "种子数据" });
outputList.Add(new DataInitItemOutput() { Name = seedDataType.Name, Count = seedData.Length, AssemblyName = seedDataType.Assembly.ManifestModule.Name, Description = entityType.GetCustomAttribute<SugarTable>().TableDescription + "种子数据" });
}
return outputList;
}

View File

@ -52,7 +52,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
/// <returns></returns>
private WechatTenpayClient CreateTenpayClient()
{
var cerFilePath = App.WebHostEnvironment.ContentRootPath + _wechatPayOptions.MerchantCertificatePrivateKey;
var cerFilePath = Path.Combine(App.WebHostEnvironment.ContentRootPath, _wechatPayOptions.MerchantCertificatePrivateKey.Replace("/", Path.DirectorySeparatorChar.ToString()));
if (!File.Exists(cerFilePath))
Log.Warning("商户证书文件不存在:" + cerFilePath);

View File

@ -26,6 +26,12 @@ export interface DataInitItemOutput {
*/
name?: string | null;
/**
* @type {number}
* @memberof DataInitItemOutput
*/
count?: number;
/**
* @type {string}
* @memberof DataInitItemOutput

View File

@ -68,6 +68,14 @@ export interface TableOutput {
*/
tableComment?: string | null;
/**
*
*
* @type {number}
* @memberof TableOutput
*/
columnCount?: number;
/**
*
*

View File

@ -9,6 +9,9 @@
初始化表结构<span v-if="state.entitySelectedRows.length > 0">({{ state.entitySelectedRows.length }})</span>
</el-button>
</template>
<template #row_columnCount="{ row }">
<el-tag type="primary"> {{ row.columnCount }} </el-tag>
</template>
</vxe-grid>
</pane>
@ -19,6 +22,9 @@
初始化种子数据<span v-if="state.seedSelectedRows.length > 0">({{ state.seedSelectedRows.length }})</span>
</el-button>
</template>
<template #row_count="{ row }">
<el-tag type="primary"> {{ row.count }} </el-tag>
</template>
</vxe-grid>
</pane>
</splitpanes>
@ -57,10 +63,11 @@ const optionsEntity = useVxeTable(
columns: [
{ type: 'checkbox', width: 40, fixed: 'left' },
{ type: 'seq', title: '序号', width: 50, fixed: 'left' },
{ field: 'entityName', title: '实体名称', showOverflow: 'tooltip', sortable: false },
{ field: 'tableName', title: '表名称', showOverflow: 'tooltip', sortable: false },
{ field: 'tableComment', title: '描述', showOverflow: 'tooltip', sortable: false },
{ field: 'assemblyName', title: '程序集', showOverflow: 'tooltip', sortable: false },
{ field: 'entityName', title: '实体名称', showOverflow: 'tooltip', align: 'left' },
{ field: 'tableName', title: '库表名称', showOverflow: 'tooltip', align: 'left' },
{ field: 'tableComment', title: '描述', showOverflow: 'tooltip', align: 'left' },
{ field: 'columnCount', title: '字段个数', showOverflow: 'tooltip', slots: { default: 'row_columnCount' } },
{ field: 'assemblyName', title: '所属程序集', showOverflow: 'tooltip', align: 'left' },
],
},
{
@ -128,9 +135,10 @@ const optionsSeed = useVxeTable(
columns: [
{ type: 'checkbox', width: 40, fixed: 'left' },
{ type: 'seq', title: '序号', width: 50, fixed: 'left' },
{ field: 'name', title: '种子名称', showOverflow: 'tooltip', sortable: false },
{ field: 'description', title: '描述', showOverflow: 'tooltip', sortable: false },
{ field: 'assemblyName', title: '程序集', showOverflow: 'tooltip', sortable: false },
{ field: 'name', title: '种子名称', showOverflow: 'tooltip', align: 'left' },
{ field: 'description', title: '描述', showOverflow: 'tooltip', align: 'left' },
{ field: 'count', title: '种子个数', showOverflow: 'tooltip', slots: { default: 'row_count' } },
{ field: 'assemblyName', title: '所属程序集', showOverflow: 'tooltip', align: 'left' },
],
},
{