SystemSetController.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using System.Web;
  9. using MySystem.BsModels;
  10. using LitJson;
  11. using Library;
  12. using Microsoft.IdentityModel.Tokens;
  13. using System.Text;
  14. using System.Security.Claims;
  15. using System.IdentityModel.Tokens.Jwt;
  16. namespace MySystem.Areas.Api.Controllers
  17. {
  18. [Area("Api")]
  19. [Route("Api/[controller]/[action]")]
  20. public class SystemSetController : Admin.Controllers.BaseController
  21. {
  22. public SystemSetController(IHttpContextAccessor accessor, ILogger<Admin.Controllers.BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  23. {
  24. }
  25. #region APP启动初始数据
  26. public JsonResult Detail(string value)
  27. {
  28. value = HttpUtility.UrlDecode(value);
  29. function.WriteLog(DateTime.Now.ToString() + ":APP启动初始数据:" + Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() + "APP接口IP监控");
  30. JsonData data = JsonMapper.ToObject(value);
  31. string apptype = data["apptype"].ToString();
  32. string version = data["version"].ToString();
  33. string CheckSignResult = CheckSign(value, new string[] { });
  34. if (CheckSignResult != "1")
  35. {
  36. return Json(new AppResultJson() { Status = "-1", Info = CheckSignResult });
  37. }
  38. else
  39. {
  40. return DetailDo(value);
  41. }
  42. }
  43. public JsonResult DetailDo(string value)
  44. {
  45. JsonData data = JsonMapper.ToObject(value);
  46. string Kind = data["Kind"].ToString();
  47. string apptype = data["apptype"].ToString();
  48. string version = data["version"].ToString();
  49. Dictionary<string, object> Obj = new Dictionary<string, object>();
  50. List<Dictionary<string, object>> PageSDK = new List<Dictionary<string, object>>();
  51. SystemSet set = RedisDbconn.Instance.Get<SystemSet>("SystemSet");
  52. List<FileUpdateInfo> files = MysqlDbconn.Instance.GetFileList(Kind).OrderBy(m => m.Path).OrderBy(m => m.FileName).ToList();
  53. foreach (FileUpdateInfo subfile in files)
  54. {
  55. string Tag = function.MD5_16(subfile.Id.ToString());
  56. string Url = subfile.Path;
  57. string FileName = subfile.FileName;
  58. int ver = subfile.VersionNum;
  59. Dictionary<string, object> row = new Dictionary<string, object>();
  60. row.Add("Url", Url);
  61. row.Add("DownloadUrl", "skin/app/" + Kind + "/" + Url);
  62. row.Add("FileName", FileName);
  63. row.Add("Version", ver);
  64. row.Add("Tag", Tag);
  65. PageSDK.Add(row);
  66. }
  67. List<Dictionary<string, string>> AfterStartPhotos = new List<Dictionary<string, string>>();
  68. string StartAdPhoto = "static/images/startadphoto.png";
  69. if (!string.IsNullOrEmpty(set.StartAdPhoto))
  70. {
  71. StartAdPhoto = set.StartAdPhoto;
  72. StartAdPhoto = StartAdPhoto.Substring(StartAdPhoto.IndexOf("static"));
  73. }
  74. string StartAdUrl = "";
  75. Dictionary<string, string> after = new Dictionary<string, string>();
  76. after.Add("Url", "");
  77. after.Add("Photo", "static/images/afterstartphoto1.png");
  78. AfterStartPhotos.Add(after);
  79. after = new Dictionary<string, string>();
  80. after.Add("Url", "");
  81. after.Add("Photo", "static/images/afterstartphoto2.png");
  82. AfterStartPhotos.Add(after);
  83. after = new Dictionary<string, string>();
  84. after.Add("Url", "");
  85. after.Add("Photo", "static/images/afterstartphoto3.png");
  86. AfterStartPhotos.Add(after);
  87. Obj.Add("PageSDK", PageSDK); //页面所需资源引用
  88. List<Dictionary<string, string>> HtmlVersion = new List<Dictionary<string, string>>();
  89. List<PageUpdateInfo> pages = MysqlDbconn.Instance.GetPageList(Kind).ToList();
  90. foreach (PageUpdateInfo page in pages)
  91. {
  92. Dictionary<string, string> item = new Dictionary<string, string>();
  93. string DataId = function.MD5_16(page.ModulePath);
  94. item.Add("Id", page.Id.ToString());
  95. item.Add("DataId", DataId);
  96. item.Add("ModuleVersion", page.ModuleVersion.ToString());
  97. item.Add("FileName", page.ModulePath);
  98. HtmlVersion.Add(item);
  99. }
  100. Obj.Add("HtmlVersion", HtmlVersion);
  101. Obj.Add("IsPageSDKZip", "0");
  102. Obj.Add("PageSDKZip", "/Areas/Admin/Assets/TemplateFile/Areas.zip");
  103. Obj.Add("StartAdPhoto", string.IsNullOrEmpty(set.StartAdPhoto) ? "" : StartAdPhoto);
  104. Obj.Add("StartAdUrl", StartAdUrl);
  105. Obj.Add("AfterStartPhotos", AfterStartPhotos);
  106. Obj.Add("IsLeftSide", "0"); //是否侧滑
  107. Obj.Add("LeftSideUrl", "http://www.baidu.com/"); //侧滑页面地址
  108. if (apptype == "ios")
  109. {
  110. Obj.Add("AppClose", "0");
  111. int check = MysqlDbconn.Instance.GetAppVersionList(Kind).Count(m => m.TerminalKind == "ios");
  112. if (check > 0)
  113. {
  114. AppVersion ver = MysqlDbconn.Instance.GetAppVersionList(Kind).Where(m => m.TerminalKind == "ios").OrderByDescending(m => m.Id).FirstOrDefault();
  115. if (ver.Status == 1 && versionToNumber(version) < versionToNumber(ver.VersionNum))
  116. {
  117. Obj.Add("AppStatus", "1");
  118. Obj.Add("AppTitle", ver.Title);
  119. Obj.Add("AppInfo", ver.Info);
  120. Obj.Add("AppBtn1", ver.ConfirmText);
  121. Obj.Add("AppBtn2", ver.CancelText);
  122. Obj.Add("AppBtn1Url", ver.DownloadUrl);
  123. }
  124. else
  125. {
  126. Obj.Add("AppStatus", "0");
  127. }
  128. }
  129. else
  130. {
  131. Obj.Add("AppStatus", "0");
  132. }
  133. }
  134. else
  135. {
  136. int check = MysqlDbconn.Instance.GetAppVersionList(Kind).Count(m => m.TerminalKind == "android");
  137. if (check > 0)
  138. {
  139. AppVersion ver = MysqlDbconn.Instance.GetAppVersionList(Kind).Where(m => m.TerminalKind == "android").OrderByDescending(m => m.Id).FirstOrDefault();
  140. if (ver.Status == 1 && versionToNumber(version) < versionToNumber(ver.VersionNum))
  141. {
  142. Obj.Add("AppStatus", "1");
  143. Obj.Add("AppTitle", ver.Title);
  144. Obj.Add("AppInfo", ver.Info);
  145. Obj.Add("AppBtn1", ver.ConfirmText);
  146. Obj.Add("AppBtn2", ver.CancelText);
  147. Obj.Add("AppBtn1Url", ver.DownloadUrl);
  148. }
  149. else
  150. {
  151. Obj.Add("AppStatus", "0");
  152. }
  153. }
  154. else
  155. {
  156. Obj.Add("AppStatus", "0");
  157. }
  158. }
  159. Obj.Add("ConnectErrUrl", ""); //网络错误页面
  160. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  161. }
  162. #endregion
  163. #region APP启动初始数据2
  164. public JsonResult Detail2(string value)
  165. {
  166. value = HttpUtility.UrlDecode(value);
  167. function.WriteLog(DateTime.Now.ToString() + ":APP启动初始数据:" + Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() + "APP接口IP监控");
  168. JsonData data = JsonMapper.ToObject(value);
  169. string apptype = data["apptype"].ToString();
  170. string version = data["version"].ToString();
  171. string CheckSignResult = CheckSign(value, new string[] { });
  172. if (CheckSignResult != "1")
  173. {
  174. return Json(new AppResultJson() { Status = "-1", Info = CheckSignResult });
  175. }
  176. else
  177. {
  178. return Detail2Do(value);
  179. }
  180. }
  181. public JsonResult Detail2Do(string value)
  182. {
  183. JsonData data = JsonMapper.ToObject(value);
  184. string Kind = data["Kind"].ToString();
  185. string apptype = data["apptype"].ToString();
  186. string version = data["version"].ToString();
  187. Dictionary<string, object> Obj = new Dictionary<string, object>();
  188. List<Dictionary<string, object>> PageSDK = new List<Dictionary<string, object>>();
  189. SystemSet set = RedisDbconn.Instance.Get<SystemSet>("SystemSet");
  190. List<FileUpdateInfo> files = MysqlDbconn.Instance.GetFileList(Kind).OrderBy(m => m.Path).OrderBy(m => m.FileName).ToList();
  191. foreach (FileUpdateInfo subfile in files)
  192. {
  193. string Tag = function.MD5_16(subfile.Id.ToString());
  194. string Url = subfile.Path;
  195. string FileName = subfile.FileName;
  196. int ver = subfile.VersionNum;
  197. Dictionary<string, object> row = new Dictionary<string, object>();
  198. row.Add("Url", Url);
  199. row.Add("DownloadUrl", OssHost + "skin/app/" + Kind + "/" + Url);
  200. row.Add("FileName", FileName);
  201. row.Add("Version", ver);
  202. row.Add("Tag", Tag);
  203. PageSDK.Add(row);
  204. }
  205. List<Dictionary<string, string>> AfterStartPhotos = new List<Dictionary<string, string>>();
  206. string StartAdPhoto = "static/images/startadphoto.png";
  207. if (!string.IsNullOrEmpty(set.StartAdPhoto))
  208. {
  209. StartAdPhoto = set.StartAdPhoto;
  210. StartAdPhoto = StartAdPhoto.Substring(StartAdPhoto.IndexOf("static"));
  211. }
  212. string StartAdUrl = "";
  213. Dictionary<string, string> after = new Dictionary<string, string>();
  214. after.Add("Url", "");
  215. after.Add("Photo", "static/images/afterstartphoto1.png");
  216. AfterStartPhotos.Add(after);
  217. after = new Dictionary<string, string>();
  218. after.Add("Url", "");
  219. after.Add("Photo", "static/images/afterstartphoto2.png");
  220. AfterStartPhotos.Add(after);
  221. after = new Dictionary<string, string>();
  222. after.Add("Url", "");
  223. after.Add("Photo", "static/images/afterstartphoto3.png");
  224. AfterStartPhotos.Add(after);
  225. Obj.Add("PageSDK", PageSDK); //页面所需资源引用
  226. List<Dictionary<string, string>> HtmlVersion = new List<Dictionary<string, string>>();
  227. List<PageUpdateInfo> pages = MysqlDbconn.Instance.GetPageList(Kind).ToList();
  228. foreach (PageUpdateInfo page in pages)
  229. {
  230. Dictionary<string, string> item = new Dictionary<string, string>();
  231. string DataId = function.MD5_16(page.ModulePath);
  232. item.Add("Id", page.Id.ToString());
  233. item.Add("DataId", DataId);
  234. item.Add("ModuleVersion", page.ModuleVersion.ToString());
  235. item.Add("FileName", page.ModulePath);
  236. HtmlVersion.Add(item);
  237. }
  238. Obj.Add("HtmlVersion", HtmlVersion);
  239. Obj.Add("IsPageSDKZip", "0");
  240. Obj.Add("PageSDKZip", "/Areas/Admin/Assets/TemplateFile/Areas.zip");
  241. Obj.Add("StartAdPhoto", string.IsNullOrEmpty(set.StartAdPhoto) ? "" : StartAdPhoto);
  242. Obj.Add("StartAdUrl", StartAdUrl);
  243. Obj.Add("AfterStartPhotos", AfterStartPhotos);
  244. Obj.Add("IsLeftSide", "0"); //是否侧滑
  245. Obj.Add("LeftSideUrl", "http://www.baidu.com/"); //侧滑页面地址
  246. if (apptype == "ios")
  247. {
  248. Obj.Add("AppClose", "0");
  249. int check = MysqlDbconn.Instance.GetAppVersionList(Kind).Count(m => m.TerminalKind == "ios");
  250. if (check > 0)
  251. {
  252. AppVersion ver = MysqlDbconn.Instance.GetAppVersionList(Kind).Where(m => m.TerminalKind == "ios").OrderByDescending(m => m.Id).FirstOrDefault();
  253. if (ver.Status == 1 && versionToNumber(version) < versionToNumber(ver.VersionNum))
  254. {
  255. Obj.Add("AppStatus", "1");
  256. Obj.Add("AppTitle", ver.Title);
  257. Obj.Add("AppInfo", ver.Info);
  258. Obj.Add("AppBtn1", ver.ConfirmText);
  259. Obj.Add("AppBtn2", ver.CancelText);
  260. Obj.Add("AppBtn1Url", ver.DownloadUrl);
  261. }
  262. else
  263. {
  264. Obj.Add("AppStatus", "0");
  265. }
  266. }
  267. else
  268. {
  269. Obj.Add("AppStatus", "0");
  270. }
  271. }
  272. else
  273. {
  274. int check = MysqlDbconn.Instance.GetAppVersionList(Kind).Count(m => m.TerminalKind == "android");
  275. if (check > 0)
  276. {
  277. AppVersion ver = MysqlDbconn.Instance.GetAppVersionList(Kind).Where(m => m.TerminalKind == "android").OrderByDescending(m => m.Id).FirstOrDefault();
  278. if (ver.Status == 1 && versionToNumber(version) < versionToNumber(ver.VersionNum))
  279. {
  280. Obj.Add("AppStatus", "1");
  281. Obj.Add("AppTitle", ver.Title);
  282. Obj.Add("AppInfo", ver.Info);
  283. Obj.Add("AppBtn1", ver.ConfirmText);
  284. Obj.Add("AppBtn2", ver.CancelText);
  285. Obj.Add("AppBtn1Url", ver.DownloadUrl);
  286. }
  287. else
  288. {
  289. Obj.Add("AppStatus", "0");
  290. }
  291. }
  292. else
  293. {
  294. Obj.Add("AppStatus", "0");
  295. }
  296. }
  297. Obj.Add("ConnectErrUrl", ""); //网络错误页面
  298. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  299. }
  300. #endregion
  301. #region 附加方法
  302. List<string> SystemFilesV2;
  303. private void GetSystemFilesV2(string Kind = "default")
  304. {
  305. SystemFilesV2 = new List<string>();
  306. string dataFilePath = function.getPath("/wwwroot/skin/app/" + Kind + "/");
  307. System.IO.FileSystemInfo info = new System.IO.DirectoryInfo(dataFilePath);
  308. scanV2(info);
  309. }
  310. private void scanV2(System.IO.FileSystemInfo info)
  311. {
  312. if (!info.Exists) return;
  313. System.IO.DirectoryInfo dir = info as System.IO.DirectoryInfo;
  314. //不是目录
  315. if (dir == null) return;
  316. System.IO.FileSystemInfo[] files = dir.GetFileSystemInfos();
  317. for (int i = 0; i < files.Length; i++)
  318. {
  319. System.IO.FileInfo file = files[i] as System.IO.FileInfo;
  320. //是文件
  321. if (file != null)
  322. {
  323. string filename = file.FullName.Replace("\\", "/");
  324. SystemFilesV2.Add(filename.Substring(filename.LastIndexOf("/")));
  325. }
  326. else scanV2(files[i]);
  327. }
  328. }
  329. private int versionToNumber(string version)
  330. {
  331. string[] versionlist = version.Split('.');
  332. string left = versionlist[0];
  333. string mid = versionlist[1];
  334. if (mid.Length == 1) mid = "00" + mid;
  335. if (mid.Length == 2) mid = "0" + mid;
  336. string right = versionlist[2];
  337. if (right.Length == 1) right = "00" + right;
  338. if (right.Length == 2) right = "0" + right;
  339. string result = left + mid + right;
  340. return int.Parse(result);
  341. }
  342. #endregion
  343. #region 生成APP配置文件
  344. public string makeAppInitData(string version, string apptype, string Kind = "default")
  345. {
  346. string url = Host + "Api/APPSetInfo/List?value={\"Kind\":\"" + Kind + "\",\"PageSize\":\"10\",\"PageNum\":\"1\",\"version\":\"" + version + "\",\"apptype\":\"" + apptype + "\"}";
  347. string AppInfoList = function.GetWebRequest(url);
  348. string SystemSet = function.GetWebRequest(Host + "Api/SystemSet/DetailDo?value={\"Kind\":\"" + Kind + "\",\"version\":\"" + version + "\",\"apptype\":\"" + apptype + "\"}");
  349. string GotoPages = "{";
  350. string PageInfoList = "{";
  351. string LibFile = "{";
  352. List<PageUpdateInfo> newpages = MysqlDbconn.Instance.GetPageList(Kind).OrderBy(m => m.Id).ToList();
  353. foreach (PageUpdateInfo page in newpages)
  354. {
  355. string FileName = page.ModulePath.Split('.')[0];
  356. PageInfoList += "\"page" + FileName + "\":" + function.GetWebRequest(Host + "Api/PageUpdateInfo/CheckDo?value={\"Kind\":\"" + Kind + "\",\"Url\":\"" + FileName + "\",\"version\":\"" + version + "\",\"apptype\":\"" + apptype + "\"}&ismakefile=0") + ",";
  357. GotoPages += "\"page" + FileName + "\":\"" + function.CheckNull(page.GotoPages).Trim(',') + "\",";
  358. string PagePath = "template/app/" + Kind + "/" + page.ModulePath;
  359. string pageContent = PublicFunction.GetNetFileContent(OssHost + PagePath);
  360. pageContent = dbconn.Encrypt3DES(pageContent, "*ga34|^7");
  361. LibFile += "\"page" + FileName + "\":\"" + pageContent + "\",";
  362. }
  363. PageInfoList = PageInfoList.TrimEnd(',');
  364. PageInfoList += "}";
  365. GotoPages = GotoPages.TrimEnd(',');
  366. GotoPages += "}";
  367. LibFile = LibFile.TrimEnd(',');
  368. LibFile += "}";
  369. return AppInfoList + "#cut#" + SystemSet + "#cut#" + PageInfoList + "#cut#" + GotoPages + "#cut#" + dbconn.Encrypt3DES(LibFile, "*ga34|^7");
  370. }
  371. #endregion
  372. #region 验证获取jwt的token
  373. public JsonResult AppCheck(string value)
  374. {
  375. value = HttpUtility.UrlDecode(value);
  376. JsonData data = JsonMapper.ToObject(value);
  377. string CheckSignResult = CheckSign(value, new string[] { "uuid", "salt" });
  378. if (CheckSignResult != "1")
  379. {
  380. return Json(new AppResultJson() { Status = "-1", Info = CheckSignResult });
  381. }
  382. else
  383. {
  384. string uuid = data["uuid"].ToString();
  385. string salt = data["salt"].ToString();
  386. string u = function.MD5_16(uuid + salt);
  387. Dictionary<string, object> Obj = new Dictionary<string, object>();
  388. //生成jwt令牌
  389. Obj.Add("Token", AppToken(u));
  390. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  391. }
  392. }
  393. public JsonResult AppCheckTest(string value)
  394. {
  395. value = DesDecrypt(value);
  396. JsonData data = JsonMapper.ToObject(value);
  397. string uuid = data["uuid"].ToString();
  398. string salt = data["salt"].ToString();
  399. string u = function.MD5_16(uuid + salt);
  400. Dictionary<string, object> Obj = new Dictionary<string, object>();
  401. //生成jwt令牌
  402. Obj.Add("Token", AppToken(u));
  403. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  404. }
  405. public string AppToken(string u)
  406. {
  407. string test = function.get_Random(10);
  408. var securityKey = new SigningCredentials(new SymmetricSecurityKey(Encoding.ASCII.GetBytes(JwtSecret)), SecurityAlgorithms.HmacSha256);
  409. var claims = new Claim[] {
  410. new Claim(JwtRegisteredClaimNames.Iss,JwtIss),
  411. new Claim(JwtRegisteredClaimNames.Aud,test),
  412. new Claim("Guid", Guid.NewGuid().ToString("D")),
  413. new Claim(ClaimTypes.Role,"system"),
  414. new Claim(ClaimTypes.Role,"admin"),
  415. };
  416. SecurityToken securityToken = new JwtSecurityToken(
  417. signingCredentials: securityKey,
  418. expires: DateTime.Now.AddDays(1),//过期时间
  419. claims: claims,
  420. audience: test,
  421. issuer: u
  422. );
  423. RedisDbconn.Instance.Set("utoken:" + u, test);
  424. //生成jwt令牌
  425. return new JwtSecurityTokenHandler().WriteToken(securityToken);
  426. }
  427. #endregion
  428. #region app公用包授权
  429. public JsonResult Auth(string value)
  430. {
  431. value = HttpUtility.UrlDecode(value);
  432. JsonData data = JsonMapper.ToObject(value);
  433. string CheckSignResult = CheckSign(value, new string[] { "appkey" });
  434. if (CheckSignResult != "1")
  435. {
  436. return Json(new AppResultJson() { Status = "-1", Info = CheckSignResult });
  437. }
  438. else
  439. {
  440. string appkey = data["appkey"].ToString();
  441. Dictionary<string, object> Obj = new Dictionary<string, object>();
  442. if (appkey == "kJweFaqV0Wid7Am0")
  443. {
  444. string IsCopyCheck = "2";
  445. string salt = "BG35JK46";
  446. string deskey = "*ga34|^7";
  447. string SignKey = function.MD532(appkey);
  448. string Sign = function.MD532(IsCopyCheck + salt + deskey + SignKey);
  449. Obj.Add("SignKey", SignKey);
  450. Obj.Add("Sign", Sign);
  451. }
  452. else
  453. {
  454. Obj.Add("SignKey", "");
  455. Obj.Add("Sign", "");
  456. }
  457. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  458. }
  459. }
  460. #endregion
  461. // #region ios配置文件
  462. // [Route("/apple-app-site-association")]
  463. // public Dictionary<string, object> iosSetting()
  464. // {
  465. // Dictionary<string, object> result = new Dictionary<string, object>();
  466. // Dictionary<string, object> webcredentials = new Dictionary<string, object>();
  467. // List<string> apps = new List<string>();
  468. // apps.Add("TKFY2BZ6Z7.com.cyb888.cyb");
  469. // webcredentials.Add("apps", apps);
  470. // result.Add("webcredentials", webcredentials);
  471. // Dictionary<string, object> applinks = new Dictionary<string, object>();
  472. // applinks.Add("apps", new List<string>());
  473. // List<Dictionary<string, object>> details = new List<Dictionary<string, object>>();
  474. // Dictionary<string, object> detail = new Dictionary<string, object>();
  475. // detail.Add("appID", "TKFY2BZ6Z7.com.cyb888.cyb");
  476. // detail.Add("paths", "/ios/*");
  477. // details.Add(detail);
  478. // applinks.Add("details", details);
  479. // result.Add("applinks", applinks);
  480. // return result;
  481. // }
  482. // #endregion
  483. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  484. /// <summary>
  485. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  486. /// </summary>
  487. /// <param name="value">请求的参数(json字符串)</param>
  488. /// <param name="signField">要签名的字段</param>
  489. /// <returns></returns>
  490. private string CheckSign(string value, string[] signField)
  491. {
  492. JsonData json = JsonMapper.ToObject(value);
  493. Dictionary<string, string> dic = new Dictionary<string, string>();
  494. for (int i = 0; i < signField.Length; i++)
  495. {
  496. dic.Add(signField[i], json[signField[i]].ToString());
  497. }
  498. string sign = json["sign"].ToString(); //客户端签名字符串
  499. return new Sign().sign(dic, sign);
  500. }
  501. #endregion
  502. }
  503. }