PerformanceItemServices.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Microsoft.AspNetCore.Components.Authorization;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Net.Http;
  6. using System.Net.Http.Json;
  7. using System.Threading.Tasks;
  8. using wispro.sp.entity;
  9. using wispro.sp.share;
  10. using wispro.sp.web.Auth;
  11. namespace wispro.sp.web.Services
  12. {
  13. public class PerformanceItemServices
  14. {
  15. private readonly HttpClient _httpClient;
  16. private readonly JwtAuthenticationStateProvider _jwt;
  17. public PerformanceItemServices(HttpClient httpClient, AuthenticationStateProvider jwt)
  18. {
  19. _httpClient = httpClient;
  20. _jwt = (JwtAuthenticationStateProvider)jwt;
  21. }
  22. public async Task<ListApiResponse<PerformanceItem>> GetItems(int _pageIndex,int _pageSize)
  23. {
  24. ListApiResponse<PerformanceItem> data = await _httpClient.GetFromJsonAsync<ListApiResponse<PerformanceItem>>($"http://localhost:39476/api/PerformanceItem/Query?pageIndex={_pageIndex}&pageSize={_pageSize}");
  25. return data;
  26. }
  27. public async Task<ApiSaveResponse> SaveFieldChange(int id,string Field,string value)
  28. {
  29. ApiSaveResponse data = await _httpClient.GetFromJsonAsync<ApiSaveResponse>($"http://localhost:39476/api/PerformanceItem/UpdateFieldValue?id={id}&field={Field}&value={value}");
  30. return data;
  31. }
  32. public async Task<ListApiResponse<PerformanceItem>> GetMyList(int userid,jxType type,int pageIndex=1,int pageSize=5)
  33. {
  34. ListApiResponse<PerformanceItem> data = await _httpClient.GetFromJsonAsync<ListApiResponse<PerformanceItem>>($"http://localhost:39476/api/PerformanceItem/GetMyList?userid={userid}&Type={Convert.ToInt32(type)}&pageIndex={pageIndex}&pageSize={pageSize}");
  35. return data;
  36. }
  37. public async Task<List<StaffStatistics>> CalMyStatistics(int year, int month, int? userid = null)
  38. {
  39. var data = await _httpClient.GetFromJsonAsync<List<StaffStatistics>>($"http://localhost:39476/api/PerformanceItem/CalMyStatistics?userid={userid}&year={year}&month={month}");
  40. return data;
  41. }
  42. }
  43. }