|
|
@ -20,6 +20,9 @@ using Mapster;
|
|
|
|
using GDZZ.Core.Service;
|
|
|
|
using GDZZ.Core.Service;
|
|
|
|
using TencentCloud.Sms.V20210111.Models;
|
|
|
|
using TencentCloud.Sms.V20210111.Models;
|
|
|
|
using TencentCloud.Common;
|
|
|
|
using TencentCloud.Common;
|
|
|
|
|
|
|
|
using Polly;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
using System.Diagnostics.Eventing.Reader;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GDZZ.Application.Service.Auth
|
|
|
|
namespace GDZZ.Application.Service.Auth
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -493,6 +496,10 @@ namespace GDZZ.Application.Service.Auth
|
|
|
|
[HttpGet("/Mini/GetShareCode")]
|
|
|
|
[HttpGet("/Mini/GetShareCode")]
|
|
|
|
public async Task<string> GetShareCode(string scene, string page)
|
|
|
|
public async Task<string> GetShareCode(string scene, string page)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var url = await this.cacheService.GetQRCodeAsync(UserManager.UserId);
|
|
|
|
|
|
|
|
if(url != null)
|
|
|
|
|
|
|
|
return url;
|
|
|
|
var value = await cacheService.GetAccessTokenAsync();
|
|
|
|
var value = await cacheService.GetAccessTokenAsync();
|
|
|
|
if (value == null)
|
|
|
|
if (value == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -500,9 +507,23 @@ namespace GDZZ.Application.Service.Auth
|
|
|
|
await cacheService.SetAccessTokenAsync(token.Result.AccessToken);
|
|
|
|
await cacheService.SetAccessTokenAsync(token.Result.AccessToken);
|
|
|
|
value = token.Result.AccessToken;
|
|
|
|
value = token.Result.AccessToken;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var res = await this._wechatOAuth.GetShareCodeAsync(value,scene, page);
|
|
|
|
var res = await this._wechatOAuth.GetShareCodeAsync(value,scene, page);
|
|
|
|
|
|
|
|
var fileName = Path.Combine(App.WebHostEnvironment.WebRootPath+ UserManager.UserId + "_" + DateTime.Now + "png");
|
|
|
|
return Convert.ToBase64String(res);
|
|
|
|
Console.WriteLine(fileName);
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MemoryStream ms = new MemoryStream(res);
|
|
|
|
|
|
|
|
FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
|
|
|
|
|
|
|
|
ms.WriteTo(fs);
|
|
|
|
|
|
|
|
ms.Close();
|
|
|
|
|
|
|
|
fs.Close();
|
|
|
|
|
|
|
|
await this.cacheService.SetQRCodeAsync(UserManager.UserId, fileName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(e.Message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|