SysAdminController.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // /*
  2. // * 后台管理员
  3. // */
  4. // using System;
  5. // using System.Web;
  6. // using System.Collections.Generic;
  7. // using Microsoft.AspNetCore.Mvc;
  8. // using Microsoft.AspNetCore.Http;
  9. // using MySystem.Models.Bs;
  10. // using Library;
  11. // using LitJson;
  12. // using Microsoft.AspNetCore.Authorization;
  13. // using MySystem.Service.Bs;
  14. // namespace MySystem.Areas.Api.Controllers.v1
  15. // {
  16. // [Area("Api")]
  17. // [Route("Api/v1/[controller]/[action]")]
  18. // public class SysAdminController : BaseController
  19. // {
  20. // public SysAdminController(IHttpContextAccessor accessor) : base(accessor)
  21. // {
  22. // }
  23. // #region 登录
  24. // public JsonResult Login(string value)
  25. // {
  26. // value = PublicFunction.DesDecrypt(value);
  27. // JsonData jsonObj = JsonMapper.ToObject(value);
  28. // string userName = jsonObj["userName"].ToString(); //账号
  29. // string pwd = jsonObj["pwd"].ToString(); //密码
  30. // SysAdminNew sys = SysAdminNewService.Query(userName, function.MD5_32(pwd));
  31. // if(sys.Id == 0)
  32. // {
  33. // return Json(new AppResultJson() { Status = "-1", Info = "账号或密码不正确" });
  34. // }
  35. // int RoleId = int.Parse(function.CheckInt(sys.Role));
  36. // SysAdminRoleNew Role = SysAdminRoleNewService.Query(RoleId);
  37. // string RightInfo = function.CheckNull(Role.RightInfo);
  38. // Dictionary<string, object> obj = new Dictionary<string, object>(); //返回字段
  39. // obj.Add("rightList", new AdminRightList().GetRight(sys.Role, RightInfo)); //权限列表
  40. // obj.Add("apiToken", PublicFunction.AppToken(sys.AdminName)); //后台所有接口API所需的token
  41. // obj.Add("apiTokenExpiredDate", DateTime.Now.AddDays(10).ToString("yyyy-MM-dd HH:mm:ss"));
  42. // string token = dbconn.Encrypt3DES(sys.Id.ToString() + "-" + function.ConvertDateTimeInt(DateTime.Now));
  43. // RefreshTokens check = RefreshTokensService.Query(sys.Id);
  44. // if(check.UserId == 0)
  45. // {
  46. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  47. // Fields.Add("UserId", sys.Id);
  48. // Fields.Add("ExpiredDate", DateTime.Now.AddDays(10));
  49. // Fields.Add("RefreshToken", token);
  50. // RefreshTokensService.Add(Fields);
  51. // }
  52. // else
  53. // {
  54. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  55. // Fields.Add("ExpiredDate", DateTime.Now.AddDays(10));
  56. // Fields.Add("RefreshToken", token);
  57. // RefreshTokensService.Edit(Fields, sys.Id);
  58. // }
  59. // List<string> roles = new List<string>();
  60. // roles.Add(sys.Role);
  61. // obj.Add("roles", roles);
  62. // obj.Add("realName", sys.RealName);
  63. // obj.Add("refreshToken", token); //主token,用于刷新apiToken
  64. // AppConfig.LoginSession.sysId = sys.Id;
  65. // AppConfig.LoginSession.sysAdminName = sys.AdminName;
  66. // AppConfig.LoginSession.sysRealName = sys.RealName;
  67. // return Json(new AppResultJson() { Status = "1", Info = "", Data = obj });
  68. // }
  69. // #endregion
  70. // #region 刷新token
  71. // public JsonResult RefreshToken(string value)
  72. // {
  73. // value = PublicFunction.DesDecrypt(value);
  74. // JsonData jsonObj = JsonMapper.ToObject(value);
  75. // string refreshToken = jsonObj["refreshToken"].ToString(); //账号
  76. // Dictionary<string, object> obj = new Dictionary<string, object>(); //返回字段
  77. // string[] data = dbconn.Decrypt3DES(refreshToken).Split('-');
  78. // int Id = int.Parse(data[0]);
  79. // SysAdminNew sys = SysAdminNewService.Query(Id);
  80. // if(sys.Id == 0)
  81. // {
  82. // return Json(new AppResultJson() { Status = "-1", Info = "刷新失败" });
  83. // }
  84. // obj.Add("apiToken", PublicFunction.AppToken(sys.AdminName)); //后台所有接口API所需的token
  85. // obj.Add("apiTokenExpiredDate", DateTime.Now.AddDays(10));
  86. // string token = dbconn.Encrypt3DES(sys.Id.ToString() + "-" + function.ConvertDateTimeInt(DateTime.Now));
  87. // RefreshTokensNew check = RefreshTokensNewService.Query(sys.Id);
  88. // if(check.UserId == 0)
  89. // {
  90. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  91. // Fields.Add("UserId", sys.Id);
  92. // Fields.Add("ExpiredDate", DateTime.Now.AddDays(10));
  93. // Fields.Add("RefreshToken", token);
  94. // RefreshTokensNewService.Add(Fields);
  95. // }
  96. // else
  97. // {
  98. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  99. // Fields.Add("ExpiredDate", DateTime.Now.AddDays(10));
  100. // Fields.Add("RefreshToken", token);
  101. // RefreshTokensNewService.Edit(Fields, sys.Id);
  102. // }
  103. // obj.Add("refreshToken", token); //主token,用于刷新apiToken
  104. // return Json(new AppResultJson() { Status = "1", Info = "", Data = obj });
  105. // }
  106. // #endregion
  107. // }
  108. // }