public ServiceResult InitTenantDefaultData(TenantInit tenantInit) { var result = Check(tenantInit); if (!result.Succeeded) { return(result); } // 初始化站点信息 Resolve <ITenantService>().InitSite(); if (HttpWeb.Site == null) { return(ServiceResult.Failure("站点信息初始化错误")); } //初始化默认数据 Resolve <IAdminService>().DefaultInit(tenantInit.IsTenant); // 修改管理员的账号 var user = Resolve <IAlaboUserService>().GetSingle(r => r.UserName == "admin"); if (user != null) { user.Mobile = tenantInit.Mobile; Resolve <IAlaboUserService>().Update(user); } return(ServiceResult.Success); }
public ApiResult InitTheme([FromBody] TenantInit tenantInit) { if (!this.IsFormValid()) { return(ApiResult.Failure(this.FormInvalidReason())); } var result = Resolve <ITenantCreateService>().InitTenantTheme(tenantInit); return(ToResult(result)); }
public ApiResult InitAll([FromBody] TenantInit tenantInit) { if (!this.IsFormValid()) { return(ApiResult.Failure(this.FormInvalidReason())); } tenantInit.IsTenant = false; var result = Resolve <ITenantCreateService>().InitTenantDefaultData(tenantInit); return(ToResult(result)); }
private ServiceResult Check(TenantInit tenantInit) { var tenantToken = HttpWeb.HttpContext.Request.Headers["zk-tenant"]; if (TenantContext.CurrentTenant == TenantContext.Master) { return(ServiceResult.Failure("主库不能初始化")); } if (tenantToken == "master") { return(ServiceResult.Failure("主库不能初始化")); } if (tenantToken.IsNullOrEmpty()) { return(ServiceResult.Failure("租户头不能为空")); } if (tenantInit.Mobile.IsNullOrEmpty()) { return(ServiceResult.Failure("手机号码不能为空")); } if (!RegexHelper.CheckMobile(tenantInit.Mobile)) { return(ServiceResult.Failure("手机号码格式不正确")); } if (tenantToken != tenantInit.Tenant) { return(ServiceResult.Failure("租户标识输入错误")); } var siteId = RuntimeContext.Current.WebsiteConfig.OpenApiSetting.Id; var token = Token(tenantInit.Tenant, siteId); if (token != tenantInit.Token) { return(ServiceResult.Failure("Token加密不正确")); } return(ServiceResult.Success); }
public ServiceResult DeleteTenant(TenantInit tenantInit) { var result = Check(tenantInit); if (!result.Succeeded) { return(result); } if (tenantInit.Tenant == "master") { return(ServiceResult.Failure("主库不能初始化")); } var dataBase = RuntimeContext.GetTenantMongodbDataBase(tenantInit.Tenant); // 删除数据库 _tenantCreateRepository.DeleteDatabase(dataBase); return(ServiceResult.Success); }
public ServiceResult InitTenantTheme(TenantInit tenantInit) { var result = Check(tenantInit); if (!result.Succeeded) { return(result); } //DOTO 2019年9月21日重构 // 初始化后台模板 //ClientPageInput pageInput = new ClientPageInput { // ClientType = ClientType.PcWeb, // Type = ThemeType.Admin //}; //try { // var allClientPages = Resolve<IThemePageService>().GetAllClientPages(pageInput); // allClientPages.LastUpdate = DateTime.Now.AddMinutes(10).ConvertDateTimeInt(); //} catch (Exception ex) { // return ServiceResult.Failure("后台模板初始化出错" + ex.Message); //} return(ServiceResult.Success); }