diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
index 9a2993e4..d1495d5a 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
@@ -376,6 +376,12 @@
测试控制器
+
+
+ swagger跳转
+
+
+
仓储上下文对象测试
@@ -436,6 +442,24 @@
+
+
+ 授权测试
+
+
+
+
+
+ 清空数据库
+
+
+
+
+
+ 种子数据
+
+
+
用户管理
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs
index c2f7fdf3..c2bb50e6 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs
@@ -16,6 +16,7 @@ using Yi.Framework.Repository;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.AttributeExtend;
using Yi.Framework.WebCore.AuthorizationPolicy;
+using Yi.Framework.WebCore.DbExtend;
namespace Yi.Framework.ApiMicroservice.Controllers
{
@@ -39,6 +40,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_quartzInvoker = quartzInvoker;
}
+ ///
+ /// swagger跳转
+ ///
+ ///
+ [HttpGet]
+ [Route("/")]
+ public IActionResult Swagger()
+ {
+ return Redirect("/Swagger");
+ }
+
///
/// 仓储上下文对象测试
///
@@ -198,6 +210,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return Result.Success().SetData(treeData);
}
+ ///
+ /// 授权测试
+ ///
+ ///
[Authorize]
[HttpGet]
public Result AuthorizeTest()
@@ -205,6 +221,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return Result.Success();
}
+ ///
+ /// 清空数据库
+ ///
+ ///
[HttpGet]
public async Task ClearDb()
{
@@ -224,5 +244,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
}));
}
+
+
+ ///
+ /// 种子数据
+ ///
+ ///
+ [HttpGet]
+ public Result SeedDb()
+ {
+ var rep = _iUserService._repository;
+ return Result.Success().SetStatus(DbSeedExtend.Invoer(rep._Db));
+ }
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db
index 503721e8..1b1873d2 100644
Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs
index 8551c4a0..345f657d 100644
--- a/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs
@@ -38,10 +38,12 @@ namespace Yi.Framework.Common.Models
{
if (_status)
{
+ this.code = ResultCodeEnum.Success;
this.message = "操作成功";
}
else
{
+ this.code = code = ResultCodeEnum.NotSuccess;
this.message = "操作失败";
}
this.status = _status;
diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs
index 65462da3..e8b1270d 100644
--- a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs
+++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs
@@ -13,20 +13,20 @@ namespace Yi.Framework.WebCore.DbExtend
{
public static class DbSeedExtend
{
- public static void UseDbSeedInitService(this IApplicationBuilder app)
+ public static bool Invoer(ISqlSugarClient _Db)
{
-
- if (Appsettings.appBool("DbSeed_Enabled"))
+ bool res = false;
+ var users = SeedFactory.GetUserSeed();
+ var roles = SeedFactory.GetRoleSeed();
+ var menus = SeedFactory.GetMenuSeed();
+ var dicts = SeedFactory.GetDictionarySeed();
+ var posts = SeedFactory.GetPostSeed();
+ var dictinfos = SeedFactory.GetDictionaryInfoSeed();
+ var depts = SeedFactory.GetDeptSeed();
+ try
{
-
- var _Db = app.ApplicationServices.GetService();
- var users = SeedFactory.GetUserSeed();
- var roles = SeedFactory.GetRoleSeed();
- var menus = SeedFactory.GetMenuSeed();
- var dicts= SeedFactory.GetDictionarySeed();
- var posts = SeedFactory.GetPostSeed();
- var dictinfos= SeedFactory.GetDictionaryInfoSeed();
- var depts = SeedFactory.GetDeptSeed();
+ _Db.AsTenant().BeginTran();
+
if (!_Db.Queryable().Any())
{
_Db.Insertable(users).ExecuteCommand();
@@ -54,8 +54,6 @@ namespace Yi.Framework.WebCore.DbExtend
{
_Db.Insertable(dictinfos).ExecuteCommand();
}
-
-
if (!_Db.Queryable().Any())
{
_Db.Insertable(depts).ExecuteCommand();
@@ -70,8 +68,27 @@ namespace Yi.Framework.WebCore.DbExtend
{
_Db.Insertable(SeedFactory.GetRoleMenuSeed(roles, menus)).ExecuteCommand();
}
+ _Db.AsTenant().CommitTran();
+ res = true;
+ }
+ catch (Exception ex)
+ {
+ _Db.AsTenant().RollbackTran();//数据回滚
+ Console.WriteLine(ex);
+
+ }
+ return res;
+ }
+
+ public static void UseDbSeedInitService(this IApplicationBuilder app)
+ {
+ if (Appsettings.appBool("DbSeed_Enabled"))
+ {
+
+ var _Db = app.ApplicationServices.GetService();
+ Invoer(_Db);
}
}