feat(core): create multi-tenancy.service

pull/4956/head
mehmet-erim 5 years ago
parent d0b1ce8076
commit 5d7c4e7507

@ -6,6 +6,7 @@ export * from './dom-insertion.service';
export * from './lazy-load.service';
export * from './list.service';
export * from './localization.service';
export * from './multi-tenancy.service';
export * from './profile-state.service';
export * from './profile.service';
export * from './rest.service';

@ -0,0 +1,45 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { SetTenant } from '../actions/session.actions';
import { ABP } from '../models/common';
import { FindTenantResultDto } from '../models/find-tenant-result-dto';
import { RestService } from './rest.service';
@Injectable({ providedIn: 'root' })
export class MultiTenancyService {
private _domainTenant: ABP.BasicItem = null;
set domainTenant(value: ABP.BasicItem) {
this._domainTenant = value;
this.store.dispatch(new SetTenant(value));
}
get domainTenant() {
return this._domainTenant;
}
isTenantBoxVisible = true;
apiName = 'abp';
constructor(private restService: RestService, private store: Store) {}
findTenantByName(name: string, headers: ABP.Dictionary<string>): Observable<FindTenantResultDto> {
return this.restService.request(
{
url: `/api/abp/multi-tenancy/tenants/by-name/${name}`,
method: 'GET',
headers,
},
{ apiName: this.apiName },
);
}
findTenantById(id: string, headers: ABP.Dictionary<string>): Observable<FindTenantResultDto> {
return this.restService.request(
{ url: `/api/abp/multi-tenancy/tenants/by-id/${id}`, method: 'GET', headers },
{ apiName: this.apiName },
);
}
}
Loading…
Cancel
Save