TestController.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Business.Core.Utilities;
  2. using Business.Test;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Threading.Tasks;
  8. namespace Business.Controllers
  9. {
  10. [Area("business")]
  11. [Route("api/business/test")]
  12. public class TestController: BusinessController
  13. {
  14. private readonly ITestAppService _testAppService;
  15. public TestController(ITestAppService testAppService)
  16. {
  17. _testAppService = testAppService;
  18. }
  19. [HttpGet]
  20. public async Task<string> GetAsync(string str)
  21. {
  22. return await _testAppService.TestApi(str);
  23. }
  24. [HttpGet]
  25. [Route("classes")]
  26. public List<string> GetClasses()
  27. {
  28. var theList = Assembly.GetExecutingAssembly().GetTypes()
  29. .Where(t => t.Namespace == "Business.Models.Test")
  30. .ToList();
  31. foreach (var the in theList)
  32. {
  33. var type = the.GetProperties();
  34. }
  35. return null;
  36. }
  37. [HttpGet]
  38. [Route("user-count")]
  39. public Task<long> GetUserCount()
  40. {
  41. NLogHelper.Default.WriteLog("TestController", "默认logger","");
  42. new NLogHelper("TestController").WriteLog("TestController", "自定义logger","");
  43. return _testAppService.GetUserCount();
  44. }
  45. //[HttpGet]
  46. //[Route("menu-tree")]
  47. //public Task<dynamic> GetMenuTree()
  48. //{
  49. // return _testAppService.GetMenuTree();
  50. //}
  51. }
  52. }