BaseController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Web;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.AspNetCore.Http;
  10. using Microsoft.Extensions.Logging;
  11. using Microsoft.Extensions.Options;
  12. using Library;
  13. using MySystem.Models;
  14. namespace MySystem.Areas.Api.Controllers
  15. {
  16. public class BaseController : Controller
  17. {
  18. public IHttpContextAccessor _accessor;
  19. public BaseController(IHttpContextAccessor accessor)
  20. {
  21. _accessor = accessor;
  22. }
  23. public Models.Main.WebCMSEntities maindb = new Models.Main.WebCMSEntities();
  24. public Models.Main1.WebCMSEntities main1db = new Models.Main1.WebCMSEntities();
  25. public Models.KxsMainModels.WebCMSEntities kxsdb = new Models.KxsMainModels.WebCMSEntities();
  26. public static string ApiKey = "G6H7@J8%";
  27. public static string Host = Library.ConfigurationManager.AppSettings["Host"].ToString();
  28. public static string SourceHost = Library.ConfigurationManager.AppSettings["SourceHost"].ToString();
  29. public static string SpHost = Library.ConfigurationManager.AppSettings["SpHost"].ToString();
  30. public static string OssHost = Library.ConfigurationManager.AppSettings["OssHost"].ToString();
  31. public string OssKey = Library.ConfigurationManager.AppSettings["OSSKey"].ToString();
  32. public string OssSecret = Library.ConfigurationManager.AppSettings["OSSSecret"].ToString();
  33. public string OssEndpoint = Library.ConfigurationManager.AppSettings["OSSEndpoint"].ToString();
  34. public static string Database = Library.ConfigurationManager.AppSettings["Database"].ToString();
  35. public static string defaultImage = Library.ConfigurationManager.AppSettings["Host"].ToString() + "/skin/app/default/static/images/header.png";
  36. //jwt参数
  37. public string JwtSecret = Library.ConfigurationManager.AppSettings["JwtSecret"].ToString();
  38. public string JwtIss = Library.ConfigurationManager.AppSettings["JwtIss"].ToString();
  39. public string JwtAud = Library.ConfigurationManager.AppSettings["JwtAud"].ToString();
  40. #region 接口通用DES解密
  41. public string DesDecrypt(string content)
  42. {
  43. content = HttpUtility.UrlDecode(content);
  44. return dbconn.DesDecrypt(content, "*ga34|^7");
  45. }
  46. #endregion
  47. #region 默认图片
  48. public static string DefaultPic(string picpath)
  49. {
  50. if (!string.IsNullOrEmpty(picpath))
  51. {
  52. if (picpath.StartsWith("http"))
  53. {
  54. return picpath;
  55. }
  56. if (picpath.Contains("/v2/") || picpath.Contains("/upload/"))
  57. {
  58. return OssHost + picpath;
  59. }
  60. return SourceHost + picpath;
  61. }
  62. return OssHost + "/default.png";
  63. }
  64. #endregion
  65. }
  66. }