Explorar el Código

🍖增加生成种子的提示

KaneLeung hace 1 año
padre
commit
21a3f2f6a8

+ 6 - 0
Admin.NET/Admin.NET.Core/Enum/ErrorCodeEnum.cs

@@ -655,6 +655,12 @@ public enum ErrorCodeEnum
     [ErrorCodeItemMetadata("不允许添加相同字段名")]
     db1002,
 
+    /// <summary>
+    /// 实体文件不存在或匹配不到,如果是刚刚生成的实体,请重启服务后再试
+    /// </summary>
+    [ErrorCodeItemMetadata("实体文件不存在或匹配不到,如果是刚刚生成的实体,请重启服务后再试")]
+    db1003,
+
     /// <summary>
     /// 父节点不存在
     /// </summary>

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs

@@ -316,7 +316,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient
     /// <param name="input"></param>
     [ApiDescriptionSettings(Name = "CreateSeedData"), HttpPost]
     [DisplayName("创建种子数据")]
-    public async void CreateSeedData(CreateSeedDataInput input)
+    public async Task CreateSeedData(CreateSeedDataInput input)
     {
         var config = App.GetOptions<DbConnectionOptions>().ConnectionConfigs.FirstOrDefault(u => u.ConfigId.ToString() == input.ConfigId);
         input.Position = string.IsNullOrWhiteSpace(input.Position) ? "Admin.NET.Core" : input.Position;
@@ -333,7 +333,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient
             entityType = item.Type;
             break;
         }
-        if (entityType == null) return;
+        if (entityType == null) throw Oops.Oh(ErrorCodeEnum.db1003);
 
         input.EntityName = entityType.Name;
         input.SeedDataName = entityType.Name + "SeedData";

+ 5 - 1
Web/src/views/system/database/index.vue

@@ -22,7 +22,11 @@
 					<el-button-group style="padding-left: 10px">
 						<el-button icon="ele-Plus" @click="openAddColumn"> 增加列 </el-button>
 						<el-button icon="ele-Plus" @click="openGenDialog"> 生成实体 </el-button>
-						<el-button icon="ele-Plus" @click="openGenSeedDataDialog"> 生成种子 </el-button>
+						<el-popover placement="bottom" title="温馨提示" :width="200" trigger="hover" content="如果是刚刚生成的实体,请重启服务后再生成种子">
+							<template #reference>
+								<el-button icon="ele-Plus" @click="openGenSeedDataDialog"> 生成种子 </el-button>
+							</template>
+						</el-popover>
 					</el-button-group>
 				</el-form-item>
 			</el-form>