using cylsg.Core.Attributes;
|
using cylsg.Core;
|
|
namespace cylsg.Application;
|
|
/// <summary>
|
/// 系统服务接口
|
/// </summary>
|
public class SystemAppService : IDynamicApiController
|
{
|
private readonly ISystemService _systemService;
|
private ISqlSugarClient _sqlSugarClient;
|
public SystemAppService(ISystemService systemService,ISqlSugarClient sqlSugarClient)
|
{
|
_systemService = systemService;
|
_sqlSugarClient = sqlSugarClient;
|
}
|
|
|
/// <summary>
|
/// 创建系统
|
/// </summary>
|
/// <returns></returns>
|
public string codefirst()
|
{
|
|
|
try
|
{
|
//_ez.GetDb().AsTenant().ChangeDatabase(ConfigId);
|
_sqlSugarClient.DbMaintenance.CreateDatabase();
|
Type[]? types = DbCoreUntil.DbCodeFirstModes("cylsg.Model", thisAttribute: typeof(CoderFirstAttribute));
|
|
|
_sqlSugarClient.CodeFirst.SetStringDefaultLength(512).InitTables(types ?? new Type[] { });
|
|
return "创建成功";
|
}
|
catch (Exception e)
|
{
|
|
return $"创建失败,报错: {e.Message},-----详情:{e.StackTrace}";
|
|
}
|
|
}
|
}
|