HomeController.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Attribute;
  2. using Base;
  3. using Common;
  4. using Dto;
  5. using Enums;
  6. using Filters;
  7. using Infrastructure;
  8. using Infrastructure.Model;
  9. using Mapster;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Middleware;
  12. using Model;
  13. using Model.Base;
  14. using Services;
  15. using Util;
  16. namespace Controllers
  17. {
  18. /// <summary>
  19. /// 主界面Controller
  20. /// </summary>
  21. [Route("/")]
  22. public class HomeController : BaseController
  23. {
  24. private readonly ISysPermissionService permissionService;
  25. public HomeController(ISysPermissionService permissionService)
  26. {
  27. this.permissionService = permissionService;
  28. }
  29. [HttpPost("testlogin")]
  30. public IActionResult Login([FromBody] LoginDto parm)
  31. {
  32. TokenModel loginUser = new(new TokenModel()
  33. {
  34. username = parm.AdminName,
  35. userId = 1
  36. }, new List<Roles>());
  37. List<string> permissions = permissionService.List();
  38. CacheService.SetUserPerms(GlobalConstant.UserPermKEY + "1", permissions);
  39. return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser)));
  40. }
  41. [HttpGet(template: "test")]
  42. public IActionResult Test([FromQuery] LoginDto parm)
  43. {
  44. TokenModel loginUser = new(new TokenModel()
  45. {
  46. username = parm.AdminName,
  47. userId = 1
  48. }, new List<Roles>());
  49. List<string> permissions = permissionService.List();
  50. CacheService.SetUserPerms(GlobalConstant.UserPermKEY + "1", permissions);
  51. return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser)));
  52. }
  53. // [HttpGet(template: "test1")]
  54. // public IActionResult Test1()
  55. // {
  56. // List<TestVo> list = new List<TestVo>();
  57. // list.Add(new TestVo());
  58. // list.Add(new TestVo(){
  59. // Subs = new TestSubVo()
  60. // });
  61. // return SUCCESS(list);
  62. // }
  63. }
  64. }