You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.1 KiB
53 lines
2.1 KiB
using Senparc.Weixin.MP.CommonAPIs;
|
|
using Senparc.Weixin.MP.Containers;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Znyc.Cloudcar.Admin.Commons.Entitys;
|
|
using Znyc.Cloudcar.Admin.Commons.Services;
|
|
using Znyc.Cloudcar.Admin.Security.Dtos;
|
|
using Znyc.Cloudcar.Admin.Security.Entitys;
|
|
using Znyc.Cloudcar.Admin.Security.IRepositories;
|
|
using Znyc.Cloudcar.Admin.Security.IServices;
|
|
|
|
namespace Znyc.Cloudcar.Admin.Security.Services
|
|
{
|
|
/// <summary>
|
|
/// </summary>
|
|
public class WxUserRelationService : BaseService<WxUserRelationEntity, WxUserRelationOutputDto, long>, IWxUserRelationService
|
|
{
|
|
private readonly ICertificationRepository _certificationRepository;
|
|
private readonly ILoginLogsRepository _loginLogsRepository;
|
|
private readonly IWxUserRelationRepository _repository;
|
|
|
|
public WxUserRelationService(IWxUserRelationRepository repository,
|
|
ILoginLogsRepository loginLogsRepository,
|
|
ICertificationRepository certificationRepository) : base(repository)
|
|
{
|
|
_repository = repository;
|
|
_certificationRepository = certificationRepository;
|
|
_loginLogsRepository = loginLogsRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="wxOpenId"></param>
|
|
/// <returns></returns>
|
|
public async Task<CommonResult> UpdateAsync(string wxOpenId)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
await AccessTokenContainer.RegisterAsync("wx07c574aca93ae8d9", "f212eda7f2db58eb0a72c539ba2a6f38");
|
|
var wxUser = CommonApi.GetUserInfo("wx07c574aca93ae8d9", wxOpenId);
|
|
string where = string.Format("unionId='{0}'", wxUser.unionid);
|
|
var wxUserRelation = await GetWhereAsync(where);
|
|
if (wxUserRelation != null)
|
|
{
|
|
wxUserRelation.WxOfficialOpenId = wxOpenId;
|
|
wxUserRelation.ModifiedTime = DateTime.Now;
|
|
await _repository.UpdateAsync(wxUserRelation, wxUserRelation.Id);
|
|
}
|
|
result.Success = true;
|
|
return result;
|
|
}
|
|
}
|
|
}
|