swagger跳转
This commit is contained in:
@@ -376,6 +376,12 @@
|
|||||||
测试控制器
|
测试控制器
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</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">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.DbTest">
|
||||||
<summary>
|
<summary>
|
||||||
仓储上下文对象测试
|
仓储上下文对象测试
|
||||||
@@ -436,6 +442,24 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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">
|
<member name="T:Yi.Framework.ApiMicroservice.Controllers.UserController">
|
||||||
<summary>
|
<summary>
|
||||||
用户管理
|
用户管理
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using Yi.Framework.Repository;
|
|||||||
using Yi.Framework.WebCore;
|
using Yi.Framework.WebCore;
|
||||||
using Yi.Framework.WebCore.AttributeExtend;
|
using Yi.Framework.WebCore.AttributeExtend;
|
||||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||||
|
using Yi.Framework.WebCore.DbExtend;
|
||||||
|
|
||||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||||
{
|
{
|
||||||
@@ -39,6 +40,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
_quartzInvoker = quartzInvoker;
|
_quartzInvoker = quartzInvoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// swagger跳转
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/")]
|
||||||
|
public IActionResult Swagger()
|
||||||
|
{
|
||||||
|
return Redirect("/Swagger");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 仓储上下文对象测试
|
/// 仓储上下文对象测试
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -198,6 +210,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Success().SetData(treeData);
|
return Result.Success().SetData(treeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 授权测试
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Result AuthorizeTest()
|
public Result AuthorizeTest()
|
||||||
@@ -205,6 +221,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Success();
|
return Result.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空数据库
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Result> ClearDb()
|
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)
|
if (_status)
|
||||||
{
|
{
|
||||||
|
this.code = ResultCodeEnum.Success;
|
||||||
this.message = "操作成功";
|
this.message = "操作成功";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
this.code = code = ResultCodeEnum.NotSuccess;
|
||||||
this.message = "操作失败";
|
this.message = "操作失败";
|
||||||
}
|
}
|
||||||
this.status = _status;
|
this.status = _status;
|
||||||
|
|||||||
@@ -13,20 +13,20 @@ namespace Yi.Framework.WebCore.DbExtend
|
|||||||
{
|
{
|
||||||
public static class DbSeedExtend
|
public static class DbSeedExtend
|
||||||
{
|
{
|
||||||
public static void UseDbSeedInitService(this IApplicationBuilder app)
|
public static bool Invoer(ISqlSugarClient _Db)
|
||||||
{
|
{
|
||||||
|
bool res = false;
|
||||||
if (Appsettings.appBool("DbSeed_Enabled"))
|
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
|
||||||
{
|
{
|
||||||
|
_Db.AsTenant().BeginTran();
|
||||||
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();
|
|
||||||
if (!_Db.Queryable<UserEntity>().Any())
|
if (!_Db.Queryable<UserEntity>().Any())
|
||||||
{
|
{
|
||||||
_Db.Insertable(users).ExecuteCommand();
|
_Db.Insertable(users).ExecuteCommand();
|
||||||
@@ -54,8 +54,6 @@ namespace Yi.Framework.WebCore.DbExtend
|
|||||||
{
|
{
|
||||||
_Db.Insertable(dictinfos).ExecuteCommand();
|
_Db.Insertable(dictinfos).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!_Db.Queryable<DeptEntity>().Any())
|
if (!_Db.Queryable<DeptEntity>().Any())
|
||||||
{
|
{
|
||||||
_Db.Insertable(depts).ExecuteCommand();
|
_Db.Insertable(depts).ExecuteCommand();
|
||||||
@@ -70,8 +68,27 @@ namespace Yi.Framework.WebCore.DbExtend
|
|||||||
{
|
{
|
||||||
_Db.Insertable(SeedFactory.GetRoleMenuSeed(roles, menus)).ExecuteCommand();
|
_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