swagger跳转
This commit is contained in:
@@ -376,6 +376,12 @@
|
||||
测试控制器
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.Swagger">
|
||||
<summary>
|
||||
swagger跳转
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.DbTest">
|
||||
<summary>
|
||||
仓储上下文对象测试
|
||||
@@ -436,6 +442,24 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.AuthorizeTest">
|
||||
<summary>
|
||||
授权测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.ClearDb">
|
||||
<summary>
|
||||
清空数据库
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.SeedDb">
|
||||
<summary>
|
||||
种子数据
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.UserController">
|
||||
<summary>
|
||||
用户管理
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// swagger跳转
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("/")]
|
||||
public IActionResult Swagger()
|
||||
{
|
||||
return Redirect("/Swagger");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仓储上下文对象测试
|
||||
/// </summary>
|
||||
@@ -198,6 +210,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
return Result.Success().SetData(treeData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 授权测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
public Result AuthorizeTest()
|
||||
@@ -205,6 +221,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空数据库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> ClearDb()
|
||||
{
|
||||
@@ -224,5 +244,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 种子数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result SeedDb()
|
||||
{
|
||||
var rep = _iUserService._repository;
|
||||
return Result.Success().SetStatus(DbSeedExtend.Invoer(rep._Db));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -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;
|
||||
|
||||
@@ -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<ISqlSugarClient>();
|
||||
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<UserEntity>().Any())
|
||||
{
|
||||
_Db.Insertable(users).ExecuteCommand();
|
||||
@@ -54,8 +54,6 @@ namespace Yi.Framework.WebCore.DbExtend
|
||||
{
|
||||
_Db.Insertable(dictinfos).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
if (!_Db.Queryable<DeptEntity>().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<ISqlSugarClient>();
|
||||
Invoer(_Db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user