94 lines
2.7 KiB
C#
94 lines
2.7 KiB
C#
![]() |
using Microsoft.AspNetCore.Authorization;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using YD_XinWei.Commons;
|
|||
|
using YD_XinWei.Commons.Exceptions;
|
|||
|
using TGJ.NetworkFreight.SeckillAggregateServices.Pos.UserService;
|
|||
|
using YD_XinWei.Api.Utilities;
|
|||
|
using YD_XinWei.Api.WeChat.Lib;
|
|||
|
using YD_XinWei.Api.Services.Interface;
|
|||
|
using YD_XinWei.Api.WeChat;
|
|||
|
|
|||
|
namespace YD_XinWei.Api.Controllers
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// <20>û<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
[ApiController]
|
|||
|
[ApiExplorerSettings(GroupName = "v1")]
|
|||
|
[Route("[controller]")]
|
|||
|
public class UserController : ControllerBase
|
|||
|
{
|
|||
|
private readonly IUserService _userService;
|
|||
|
public UserController(IUserService userService)
|
|||
|
{
|
|||
|
_userService = userService;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<C8A1><CEA2><EFBFBD><EFBFBD>Ϣ
|
|||
|
/// </summary>
|
|||
|
/// <param name="wXLoginPo"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost("WXUserInfo")]
|
|||
|
public WechatUserInfo GetWXUserInfo(WXLoginPo wXLoginPo)
|
|||
|
{
|
|||
|
var wli = new WechatLoginInfo();
|
|||
|
wli.code = wXLoginPo.code;
|
|||
|
wli.encryptedData = wXLoginPo.encryptedData;
|
|||
|
wli.iv = wXLoginPo.iv;
|
|||
|
wli.rawData = wXLoginPo.rawData;
|
|||
|
wli.signature = wXLoginPo.signature;
|
|||
|
|
|||
|
wli.appid = AppSettings.WeChat.Appid;
|
|||
|
wli.secret = AppSettings.WeChat.Appid;
|
|||
|
|
|||
|
|
|||
|
WechatUserInfo wechatResult = new WeChatAppDecrypt().Decrypt(wli);
|
|||
|
|
|||
|
if (wechatResult == null || string.IsNullOrWhiteSpace(wechatResult.openId))
|
|||
|
{
|
|||
|
throw new BizException("<22>û<EFBFBD><C3BB><EFBFBD>Ϣ<EFBFBD><CFA2>ȡʧ<C8A1><CAA7>");
|
|||
|
}
|
|||
|
|
|||
|
return wechatResult;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(Login))]
|
|||
|
[AllowAnonymous]
|
|||
|
public async Task<IActionResult> Login([FromBody] LoginInfo paramDto)
|
|||
|
{
|
|||
|
var res = await _userService.Login(paramDto);
|
|||
|
return Ok(res);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <><CEA2><EFBFBD>û<EFBFBD><C3BB><EFBFBD>¼
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost("WxLogin")]
|
|||
|
[AllowAnonymous]
|
|||
|
public async Task<IActionResult> WxLogin(WXLoginPo loginPo)
|
|||
|
{
|
|||
|
//var id = UserLoginContext.Current.UserId;
|
|||
|
var res = await _userService.WxLogin(loginPo);
|
|||
|
return Ok(res);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="relevanceId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet("RelatedAccounts")]
|
|||
|
public async Task<List<RelatedAccountsDto>> RelatedAccounts(Guid relevanceId)
|
|||
|
{
|
|||
|
var res = await _userService.RelatedAccounts(relevanceId);
|
|||
|
return res;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|