HomeController.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using Common.Http;
  8. using Common.Model;
  9. using JCSoft.WX.Framework.Api;
  10. using LigerRM.Common;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.AspNetCore.Mvc;
  13. using Microsoft.Extensions.Caching.Memory;
  14. using Microsoft.Extensions.Primitives;
  15. using ZcPeng.PublicLibrary;
  16. namespace SupplierWeb.Controllers
  17. {
  18. [Route("api/home")]
  19. [ApiController]
  20. public class HomeController : BaseController
  21. {
  22. public HomeController(IMemoryCache cache, IApiClient client) : base(cache, client)
  23. {
  24. }
  25. [HttpGet]
  26. public JsonResult Index()
  27. {
  28. var sql = $" select count(case when u.state=1 then 1 end) fill, count(case when u.state=0 then 1 end) unfill, count(case when u.state=2 then 1 end) lessthan, count(case when u.state = 3 then 1 end) genpro, count(case when u.state = 4 then 1 end) genord from sup_pushfeedback u ";
  29. var dt = new DataTable();
  30. var param = new List<SqlParameter>();
  31. DataAccess.GetValues(sql, ref dt, param.ToArray(), out _);
  32. IList<Temp> result = new List<Temp>();
  33. if (dt != null && dt.Rows.Count > 0)
  34. {
  35. result = ModelConvertHelper<Temp>.ConvertToModel(dt);
  36. }
  37. //string staffId = "";
  38. //HttpRequest request = MyHttpContext.Current.Request;
  39. //StringValues oo;
  40. //request.Headers.TryGetValue("Sso-Token", out oo);
  41. //if (oo.Count > 0 && oo.ToArray()[0] != "")
  42. //{
  43. // staffId = oo.ToArray()[0];
  44. //}
  45. Object token = "";
  46. //MyHttpContext.Cache.TryGetValue(staffId, out token);
  47. // token = CookieHelper.GetCookie("token");
  48. return new JsonResult(new
  49. {
  50. data = result,
  51. test = token
  52. });
  53. }
  54. public class Temp
  55. {
  56. public int fill { get; set; }
  57. public int unfill { get; set; }
  58. public int lessthan { get; set; }
  59. public int genpro { get; set; }
  60. public int genord { get; set; }
  61. }
  62. }
  63. }