87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
|
|
export interface PagedResult<T> {
|
|
page: number;
|
|
pageSize: number;
|
|
total: number;
|
|
items: T[];
|
|
}
|
|
|
|
export interface MobileLineList {
|
|
id: string;
|
|
item: number;
|
|
conta: string | null;
|
|
linha: string | null;
|
|
chip: string | null;
|
|
cliente: string | null;
|
|
usuario: string | null;
|
|
planoContrato: string | null;
|
|
status: string | null;
|
|
skil: string | null;
|
|
modalidade: string | null;
|
|
vencConta: string | null;
|
|
}
|
|
|
|
export interface MobileLineDetail extends MobileLineList {
|
|
franquiaVivo?: number | null;
|
|
valorPlanoVivo?: number | null;
|
|
gestaoVozDados?: number | null;
|
|
skeelo?: number | null;
|
|
vivoNewsPlus?: number | null;
|
|
vivoTravelMundo?: number | null;
|
|
vivoGestaoDispositivo?: number | null;
|
|
valorContratoVivo?: number | null;
|
|
|
|
franquiaLine?: number | null;
|
|
franquiaGestao?: number | null;
|
|
locacaoAp?: number | null;
|
|
valorContratoLine?: number | null;
|
|
|
|
desconto?: number | null;
|
|
lucro?: number | null;
|
|
|
|
dataBloqueio?: string | null;
|
|
cedente?: string | null;
|
|
solicitante?: string | null;
|
|
dataEntregaOpera?: string | null;
|
|
dataEntregaCliente?: string | null;
|
|
}
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class LinesService {
|
|
// ajuste aqui conforme sua API (mesmo host do auth)
|
|
private baseUrl = 'http://localhost:5000/api/lines';
|
|
|
|
constructor(private http: HttpClient) {}
|
|
|
|
getLines(page: number, pageSize: number, search: string): Observable<PagedResult<MobileLineList>> {
|
|
let params = new HttpParams()
|
|
.set('page', page)
|
|
.set('pageSize', pageSize);
|
|
|
|
if (search?.trim()) params = params.set('search', search.trim());
|
|
|
|
return this.http.get<PagedResult<MobileLineList>>(this.baseUrl, { params });
|
|
}
|
|
|
|
getById(id: string): Observable<MobileLineDetail> {
|
|
return this.http.get<MobileLineDetail>(`${this.baseUrl}/${id}`);
|
|
}
|
|
|
|
update(id: string, payload: any): Observable<void> {
|
|
return this.http.put<void>(`${this.baseUrl}/${id}`, payload);
|
|
}
|
|
|
|
delete(id: string): Observable<void> {
|
|
return this.http.delete<void>(`${this.baseUrl}/${id}`);
|
|
}
|
|
|
|
importExcel(file: File): Observable<{ imported: number }> {
|
|
const form = new FormData();
|
|
form.append('file', file);
|
|
return this.http.post<{ imported: number }>(`${this.baseUrl}/import-excel`, form);
|
|
}
|
|
}
|