|
|
|
@ -6,6 +6,7 @@ import { Login } from '../models/login'; |
|
|
|
import { User } from '../models/user'; |
|
|
|
import 'rxjs/add/operator/map'; |
|
|
|
import { Observable } from 'rxjs'; |
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
|
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
@ -16,7 +17,7 @@ export class UserService { |
|
|
|
|
|
|
|
// private _url : string = "http://localhost:9000";
|
|
|
|
|
|
|
|
constructor(private _http : Http) { } |
|
|
|
constructor(private _http : HttpClient) { } |
|
|
|
|
|
|
|
// public showAllUsers() : Observable<User[]> {
|
|
|
|
// return this._http.get<User[]>(this._url + "/showAllUsers");
|
|
|
|
@ -30,33 +31,33 @@ constructor(private _http : Http) { } |
|
|
|
// this._http.post(this._url+"/addUser/", user);
|
|
|
|
currentUser:User |
|
|
|
private _url:string ="http://localhost:8008/user/" |
|
|
|
showAllUsers() : Observable<User[]> { |
|
|
|
return this._http.get(this._url+"showAllUsers").map((res : Response) => res.json()); |
|
|
|
} |
|
|
|
showAllUsers() { |
|
|
|
return this._http.get<User[]>(this._url+"showAllUsers")} |
|
|
|
// .map((res : Response) => res.json());}
|
|
|
|
|
|
|
|
addUser(user: User) : Observable<any> { |
|
|
|
return this._http.post(this._url+"addUser/",user).map((res: Response)=> null).pipe(); |
|
|
|
} |
|
|
|
addUser(user: User) { |
|
|
|
return this._http.post<any>(this._url+"addUser/",user)} |
|
|
|
// .map((res: Response)=> null).pipe();}
|
|
|
|
// loginUser (user:User):Observable<any>{
|
|
|
|
// return this._http.post("http://localhost:8006/user/login/",user).map((res: Response)=>null);
|
|
|
|
// }
|
|
|
|
searchUser(userid : number) : Observable<User> { |
|
|
|
return this._http.get(this._url+"findUserById/" +userid).map((res : Response) => res.json()); |
|
|
|
} |
|
|
|
updateUser(user : User) : Observable<any> { |
|
|
|
return this._http.put(this._url+"update/",user).map((res: Response)=> null); |
|
|
|
} |
|
|
|
searchUser(userid : number) { |
|
|
|
return this._http.get<User>(this._url+"findUserById/" +userid)} |
|
|
|
// .map((res : Response) => res.json());}
|
|
|
|
updateUser(user : User) { |
|
|
|
return this._http.put<any>(this._url+"update/",user)} |
|
|
|
// .map((res: Response)=> null);}
|
|
|
|
// findUserByUsername(name : string) : Observable<User> {
|
|
|
|
// return this._http.get("http://localhost:8006/user/findUserByName/"+name).map((res : Response) => res.json());
|
|
|
|
// }
|
|
|
|
|
|
|
|
public loginUser(user : Login) : Observable<string> { |
|
|
|
return this._http.post(this._url+"login/",user).map((res: Response)=>null); |
|
|
|
} |
|
|
|
public loginUser(user : Login) { |
|
|
|
return this._http.post<string>(this._url+"login/",user)} |
|
|
|
// .map((res: Response)=>null);}
|
|
|
|
|
|
|
|
public findUserByUsername(name : string) : Observable<User> { |
|
|
|
return this._http.get(this._url+"findUserByName/"+name).map((res : Response) => res.json()); |
|
|
|
} |
|
|
|
public findUserByUsername(name : string) { |
|
|
|
return this._http.get<User>(this._url+"findUserByName/"+name)} |
|
|
|
//.map((res : Response) => res.json());}
|
|
|
|
|
|
|
|
|
|
|
|
// private _url : String = "http://localhost:8001/user";
|
|
|
|
|