parent
3401856281
commit
e55edf4c63
|
|
@ -115,11 +115,11 @@
|
|||
"DockerConfig": {
|
||||
"Prot": "5192:5192",
|
||||
"AspNetCoreEnv": "",
|
||||
"LastEnvName": "29dev",
|
||||
"LastEnvName": "marking001",
|
||||
"RemoveDaysFromPublished": "10",
|
||||
"WorkDir": "",
|
||||
"Volume": "",
|
||||
"Other": "--name wgshare-api -e ASPNETCORE_ENVIRONMENT=Development -e TZ=Asia/Shanghai",
|
||||
"Other": "--name wgshare-api -e ASPNETCORE_ENVIRONMENT=Production -e TZ=Asia/Shanghai",
|
||||
"EnvPairList": [
|
||||
{
|
||||
"EnvName": "29dev",
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace WGShare.API.Controllers.Frontend
|
|||
//}
|
||||
}
|
||||
|
||||
return PagedResult<RoomOutputDTO>.Create(result, total.Value);
|
||||
return PagedResult<RoomOutputDTO>.Create(result, total.Value, dto.PageSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ namespace WGShare.API.Controllers.Frontend
|
|||
}
|
||||
|
||||
user.IsRoomManager = false;
|
||||
user.EnableCamera = false;
|
||||
user.EnableMicr = false;
|
||||
RedisHelper.Instance.HSet(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, inputDTO.RoomNum), inputDTO.UserId, user);
|
||||
|
||||
// 判断是否显示用户
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
|
|||
using WGShare.API.Controllers.Basic;
|
||||
using WGShare.API.Helpers;
|
||||
using WGShare.Domain.DTOs.Login;
|
||||
using WGShare.Domain.DTOs.MiniProgram;
|
||||
using WGShare.Domain.DTOs.User;
|
||||
using WGShare.Domain.Entities;
|
||||
using WGShare.Domain.Enums;
|
||||
|
|
@ -26,10 +27,19 @@ namespace WGShare.API.Controllers
|
|||
public class PublicController : BasicController
|
||||
{
|
||||
private readonly ISqlSugarClient _sqlSugar;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly Microsoft.Extensions.Configuration.IConfiguration _configuration;
|
||||
private readonly ILogger<PublicController> _logger;
|
||||
|
||||
public PublicController(ISqlSugarClient sqlSugar)
|
||||
public PublicController(ISqlSugarClient sqlSugar,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
Microsoft.Extensions.Configuration.IConfiguration configuration,
|
||||
ILogger<PublicController> logger)
|
||||
{
|
||||
_sqlSugar = sqlSugar;
|
||||
this._httpClientFactory = httpClientFactory;
|
||||
this._configuration = configuration;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -69,5 +79,26 @@ namespace WGShare.API.Controllers
|
|||
else
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取小程序openid
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("mini-openid"), AllowAnonymous]
|
||||
public async Task<string> GetOpenId(string js_code)
|
||||
{
|
||||
var queryString = $@"appid={_configuration["miniProgram:appId"]}&secret={_configuration["miniProgram:appSecret"]}&js_code={js_code}&grant_type=authorization_code";
|
||||
|
||||
var httpclient = _httpClientFactory.CreateClient();
|
||||
var result = await httpclient.GetFromJsonAsync<JsCode2SessionApiResult>($@"https://api.weixin.qq.com/sns/jscode2session?{queryString}");
|
||||
if (result == null || result.errorcode != 0 || string.IsNullOrWhiteSpace(result.openid))
|
||||
{
|
||||
_logger.LogError($"获取openid失败,错误码:{result?.errorcode},错误信息:{result?.errmsg}");
|
||||
|
||||
throw Oops.Oh("小程序登录失败");
|
||||
}
|
||||
|
||||
return result.openid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,6 +402,12 @@
|
|||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WGShare.API.Controllers.PublicController.GetOpenId(System.String)">
|
||||
<summary>
|
||||
获取小程序openid
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:WGShare.API.Helpers.AgoraHelper.Constant.REDIS_CHANNEL_USERCOUNT">
|
||||
<summary>
|
||||
Redis 键,hash ,每个频道用户数量
|
||||
|
|
|
|||
|
|
@ -38,5 +38,9 @@
|
|||
"Endpoint": "oss-cn-chengdu.aliyuncs.com",
|
||||
"Host": "https://wgshare.oss-cn-chengdu.aliyuncs.com/",
|
||||
"BucketName": "wgshare"
|
||||
},
|
||||
"miniProgram": {
|
||||
"appId": "wx99885b1c181cda72",
|
||||
"appSecret": "edd9cdb04c3f59fe70f2a70c396e5b0d"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WGShare.Domain.DTOs.MiniProgram
|
||||
{
|
||||
public class JsCode2SessionApiResult
|
||||
{
|
||||
public string openid { get; set; }
|
||||
public string seesionkey { get; set; }
|
||||
public string unionid { get; set; }
|
||||
public int errorcode { get; set; }
|
||||
public string errmsg { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace WGShare.Domain.GeneralModel
|
|||
public class PagedResult<TEntity>
|
||||
{
|
||||
public PagedResult() { }
|
||||
public PagedResult(IEnumerable<TEntity> list, int total)
|
||||
public PagedResult(IEnumerable<TEntity> list, int total, int pageSize = 10)
|
||||
{
|
||||
Total = total;
|
||||
Items = list;
|
||||
|
|
@ -20,9 +20,19 @@ namespace WGShare.Domain.GeneralModel
|
|||
public int Total { get; set; }
|
||||
public IEnumerable<TEntity> Items { get; private set; }
|
||||
|
||||
public static PagedResult<TEntity> Create(IEnumerable<TEntity> list, int total)
|
||||
private int pageSize = 10;
|
||||
|
||||
public int TotalPage
|
||||
{
|
||||
return new PagedResult<TEntity>(list, total);
|
||||
get
|
||||
{
|
||||
return (int)Math.Ceiling(Total / (double)pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
public static PagedResult<TEntity> Create(IEnumerable<TEntity> list, int total, int pageSize = 10)
|
||||
{
|
||||
return new PagedResult<TEntity>(list, total, pageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue