using Senparc.Weixin.MP.CommonAPIs; using Senparc.Weixin.MP.Containers; using System; using System.Threading.Tasks; using Znyc.Recruitment.Admin.Commons.Entitys; using Znyc.Recruitment.Admin.Commons.Services; using Znyc.Recruitment.Admin.Security.Dtos; using Znyc.Recruitment.Admin.Security.Entitys; using Znyc.Recruitment.Admin.Security.IRepositories; using Znyc.Recruitment.Admin.Security.IServices; namespace Znyc.Recruitment.Admin.Security.Services { /// /// public class WxUserRelationService : BaseService, 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; } /// /// /// /// /// public async Task 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; } } }