Files
zsxt_nbzs_h5/Api/Ewide.Core/OAuth/UserInfoModel.cs

63 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Ewide.Core.OAuth
{
/// <summary>
/// 微信用户参数
/// </summary>
public class UserInfoModel
{
[JsonPropertyName("nickname")]
public string Name { get; set; }
[JsonPropertyName("headimgurl")]
public string Avatar { get; set; }
[JsonPropertyName("language")]
public string Language { get; set; }
[JsonPropertyName("openid")]
public string Openid { get; set; }
[JsonPropertyName("sex")]
public int Sex { get; set; }
[JsonPropertyName("province")]
public string Province { get; set; }
[JsonPropertyName("city")]
public string City { get; set; }
[JsonPropertyName("country")]
public string Country { get; set; }
/// <summary>
/// 用户特权信息json 数组如微信沃卡用户为chinaunicom
/// </summary>
[JsonPropertyName("privilege")]
public List<string> Privilege { get; set; }
[JsonPropertyName("unionid")]
public string UnionId { get; set; }
[JsonPropertyName("errmsg")]
public string ErrorMessage { get; set; }
}
public static class UserInfoModelExtensions
{
/// <summary>
/// 获取的用户是否包含错误
/// </summary>
/// <param name="userInfoModel"></param>
/// <returns></returns>
public static bool HasError(this UserInfoModel userInfoModel)
{
return userInfoModel == null ||
string.IsNullOrEmpty(userInfoModel.Name) ||
!string.IsNullOrEmpty(userInfoModel.ErrorMessage);
}
}
}