api url is added

This commit is contained in:
병준 박 2019-08-17 21:54:21 +09:00
parent cd76913035
commit 94efeb43fd
5 changed files with 30 additions and 36 deletions

View File

@ -3,15 +3,13 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { UserModule } from './pages/users/user/user.module'; import { UserModule } from './pages/users/user/user.module';
import { AppService } from './service/app.service'; import { AppService } from './service/app.service';
import { API_BASE_URL } from 'src/shared/common/type/injection-token.type';
export function initApp(appService: AppService) { export function initApp(appService: AppService) {
return () => appService.initApp(); return () => appService.initApp();
} }
@NgModule({ @NgModule({
imports: [ imports: [UserModule.forRoot()],
UserModule.forRoot(),
],
exports: [], exports: [],
providers: [ providers: [
AppService, AppService,
@ -24,6 +22,11 @@ export function initApp(appService: AppService) {
deps: [AppService], deps: [AppService],
multi: true multi: true
}, },
{
provide: API_BASE_URL,
useValue: 'http://localhost:8088/api',
multi: true
},
// { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true }, // { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true },
{ provide: 'virtualScroller.scrollThrottlingTime', useValue: 0 }, { provide: 'virtualScroller.scrollThrottlingTime', useValue: 0 },
{ provide: 'virtualScroller.scrollDebounceTime', useValue: 0 }, { provide: 'virtualScroller.scrollDebounceTime', useValue: 0 },
@ -34,4 +37,4 @@ export function initApp(appService: AppService) {
{ provide: 'virtualScroller.resizeBypassRefreshThreshold', useValue: 5 } { provide: 'virtualScroller.resizeBypassRefreshThreshold', useValue: 5 }
] ]
}) })
export class AppProviderModule { } export class AppProviderModule {}

View File

@ -2,8 +2,6 @@ import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { COMPONENTS } from './component';
import { AccountsService } from './service/accounts.service';
import { AccountsStoreModule } from './accounts-store.module'; import { AccountsStoreModule } from './accounts-store.module';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
@ -14,7 +12,14 @@ import { MatInputModule } from '@angular/material/input';
import { FuseSharedModule } from 'src/@fuse/shared.module'; import { FuseSharedModule } from 'src/@fuse/shared.module';
import { AccountsRoutingPageModule } from './accounts-routing.page.module'; import { AccountsRoutingPageModule } from './accounts-routing.page.module';
// import { SharedModule } from '../../../common/shared/shared.module'; import { COMPONENTS } from './component';
import { SERVICES } from './service';
@NgModule({
imports: [AccountsStoreModule],
exports: []
})
export class AccountsRootModule {}
@NgModule({ @NgModule({
imports: [ imports: [
@ -31,32 +36,15 @@ import { AccountsRoutingPageModule } from './accounts-routing.page.module';
FuseSharedModule FuseSharedModule
// SharedModule, // SharedModule,
],
declarations: [
...COMPONENTS,
],
exports: [
...COMPONENTS,
], ],
declarations: [...COMPONENTS],
exports: [...COMPONENTS]
}) })
export class AccountsModule { export class AccountsModule {
public static forRoot(): ModuleWithProviders<AccountsRootModule> { public static forRoot(): ModuleWithProviders<AccountsRootModule> {
return { return {
ngModule: AccountsRootModule, ngModule: AccountsRootModule,
providers: [ providers: [...SERVICES]
AccountsService,
],
}; };
} }
} }
@NgModule({
imports: [
AccountsStoreModule,
],
exports: [
]
})
export class AccountsRootModule {
}

View File

@ -1,4 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@ -7,14 +7,15 @@ import { map } from 'rxjs/operators';
import { CookieService } from 'ngx-cookie-service'; import { CookieService } from 'ngx-cookie-service';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { User } from '../../../../shared/user/model/user.model'; import { User } from '../../../../shared/user/model/user.model';
import { API_BASE_URL } from 'src/shared/common/type/injection-token.type';
@Injectable() @Injectable()
export class AccountsService { export class AccountsService {
public constructor( public constructor(
private httpClient: HttpClient, private httpClient: HttpClient,
private cookieService: CookieService, private cookieService: CookieService,
) { @Inject(API_BASE_URL) private apiBaseUrl: string
} ) {}
// public authenticate(oauthType: string, params?: Map<string, string>) { // public authenticate(oauthType: string, params?: Map<string, string>) {
// const query = this.getQueryParams(params); // const query = this.getQueryParams(params);
@ -40,7 +41,6 @@ export class AccountsService {
let query = ''; let query = '';
if (!params || 0 === params.size) { if (!params || 0 === params.size) {
model
return query; return query;
} }
@ -60,9 +60,6 @@ export class AccountsService {
password password
}; };
return this.httpClient.post<User>( return this.httpClient.post<User>(`${this.apiBaseUrl}/auth/signin`, model);
`${this.apiEntryPoint}/auth/signin`,
model
);
} }
} }

View File

@ -0,0 +1,3 @@
import { AccountsService } from './accounts.service';
export const SERVICES = [AccountsService];

View File

@ -0,0 +1,3 @@
import { InjectionToken } from '@angular/core';
export const API_BASE_URL = new InjectionToken<string>('API_BASE_URL');