using cylsg.Core.Attributes; using cylsg.Core; namespace cylsg.Application; /// /// 系统服务接口 /// public class SystemAppService : IDynamicApiController { private readonly ISystemService _systemService; private ISqlSugarClient _sqlSugarClient; public SystemAppService(ISystemService systemService,ISqlSugarClient sqlSugarClient) { _systemService = systemService; _sqlSugarClient = sqlSugarClient; } /// /// 创建系统 /// /// 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}"; } } }