lqq il y a 8 ans
Parent
commit
8f295c440c

+ 3 - 8
Winsoft.GOV.XF.WebApi.WXCore/Controllers/BundleController.cs

@@ -93,15 +93,10 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Controllers
             BundleAccessToken a = JsonConvert.DeserializeObject<BundleAccessToken>(data);
             if (a == null)
                 return BadRequest("非法请求");
-            if (a.Expire != -1)
-            {
-                a.Expire = DateTime.Now.AddDays(1).ToTimeStamp();
-                string multimediaURL = string.Format("{0}://{1}/multimedia?bundleId={2}&data={3}",
-                    Request.Scheme,
-                    Request.Host.Value, b.Id, JsonConvert.SerializeObject(a).AESEncrypt(b.Key));
+            string multimediaURL = _bundlesService.GenerateShareURL(b, a);
+            if (!String.IsNullOrEmpty(multimediaURL))
                 return Ok(multimediaURL);
-            }
-            return BadRequest("已过期");
+            return BadRequest("无权限发布");
         }
 
         [HttpGet("getShareInfo/{id}/{ciphertext}")]

+ 5 - 9
Winsoft.GOV.XF.WebApi.WXCore/Services/BundlesService.cs

@@ -86,21 +86,17 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
             return multimediaURL;
         }
 
-        public string GenerateShareURL(Bundle b, string ciphertext)
+        public string GenerateShareURL(Bundle b, BundleAccessToken a)
         {
-            string data = ciphertext.AESDecrypt(b.Key);
-            BundleAccessToken a = JsonConvert.DeserializeObject<BundleAccessToken>(data);
-            if (a == null)
-                return 
             if (a.Expire != -1)
             {
                 a.Expire = DateTime.Now.AddDays(1).ToTimeStamp();
                 string multimediaURL = string.Format("{0}://{1}/multimedia?bundleId={2}&data={3}",
-                    Request.Scheme,
-                    Request.Host.Value, b.Id, JsonConvert.SerializeObject(a).AESEncrypt(b.Key));
-                return Ok(multimediaURL);
+                    _httpContext.Request.Scheme,
+                    _httpContext.Request.Host.Value, b.Id, JsonConvert.SerializeObject(a).AESEncrypt(b.Key));
+                return multimediaURL;
             }
-            return BadRequest("已过期");
+            return String.Empty;
         }
     }
 }

+ 6 - 2
Winsoft.GOV.XF.WebApi.WXCore/Services/XFApiService.cs

@@ -17,7 +17,8 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
     {
         public delegate void OnFails(string message);
         BundlesService _bundlesService;
-        public XFApiService(BundlesService bundlesService, ILoggerFactory loggerFactory):base(context, loggerFactory)
+
+        public XFApiService(BundlesService bundlesService, XFDbContext context, ILoggerFactory loggerFactory):base(context, loggerFactory)
         {
             _bundlesService = bundlesService;
         }
@@ -29,9 +30,12 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
         /// <returns></returns>
         public async Task<bool> PostLetter(Bundle b, OnFails onFails)
         {
+            string d = b.Describe;
+            if (b.Assets.Count() > 0)
+                d += "(此信件内容含有其他多媒体信息,详细请复制网址到浏览器打开:" + _bundlesService.GenerateBaseURL(b) + ")";
             string s = "advice={0};type={1};name={2};phone={3};is_public={4};content={5};title={6};county_id={7};unit_id={8};sswz=8;ly=2; user_id={9}";
             s = String.Format(s, b.Advice, b.Type.ToString(), b.Name, b.Mobile, b.IsPublic.ToString(), b.Describe, b.Title, b.County_id, b.Unit_id, b.OpenID);
-            return s;
+            
 
             XFApiResult rObj = await HttpPostAsync<XFApiResult>("http://118.178.118.50/test1/letter/submitLetter;", b.ToString(), onFails);