Broker System for Supercredit
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

64 行
2.0KB

  1. import {HttpClient} from '@angular/common/http';
  2. import {AuthService} from './auth.service';
  3. import {Observable} from 'rxjs';
  4. import {LoanModel} from '../models/loan.model';
  5. import {Injectable} from '@angular/core';
  6. import {RewardModel} from '../models/reward.model';
  7. import {ClonerService} from './clone.service';
  8. import {PayInModel} from '../models/pay-in.model';
  9. import {PayInModelEx} from '../models/pay-in-ex.model';
  10. @Injectable()
  11. export class LoanSingleService {
  12. constructor(private http: HttpClient, private auth: AuthService, private dcs: ClonerService ){ }
  13. getLoan(loanId: string): Observable<LoanModel> {
  14. return this.http.get<LoanModel>(this.auth.getUrl('loan/' + loanId));
  15. }
  16. public updateBasicInfo(loan: LoanModel): Observable<any>{
  17. return this.http.post(this.auth.getUrl('loan/basic/' + loan.Id), loan.cloneForJson());
  18. }
  19. public photoUrl(peopleId: string): string{
  20. const url = this.auth.getUrl('avatar/') + peopleId;
  21. return 'url("' + url + '")';
  22. }
  23. public saveReward(reward: RewardModel, isNew: boolean ): Observable<RewardModel> {
  24. return this.http.post<RewardModel>(this.auth.getUrl('reward/'), reward);
  25. }
  26. public removeReward(reward: RewardModel): void {
  27. this.http.delete<RewardModel>(this.auth.getUrl('reward/' + reward.Id)).subscribe(
  28. resp => {
  29. console.log(resp);
  30. }
  31. );
  32. }
  33. public savePayIn(payIn: PayInModel, isNew: boolean): Observable<PayInModelEx> {
  34. return this.http.post<PayInModelEx>(this.auth.getUrl('payIn/'), payIn);
  35. }
  36. public removePayIn(id: number): void {
  37. this.http.delete<PayInModel>(this.auth.getUrl('payIn/' + id)).subscribe(
  38. resp => {
  39. console.log(resp);
  40. }
  41. );
  42. }
  43. // delete means more than remove, it removes relevant data too
  44. public deleteLoan(id: string): Observable<string> {
  45. return this.http.delete<string>(this.auth.getUrl('loan/' + id));
  46. }
  47. public getLoanByClient(id: string): Observable<LoanModel[]> {
  48. return this.http.get<LoanModel[]>(this.auth.getUrl('loan-by-client/' + id));
  49. }
  50. }