From dead8cfc93d0c8b6efaf6e84164e0a62c62a4e57 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Thu, 12 Dec 2024 17:08:10 +0800 Subject: [PATCH] feat: Add WeChat User Dto --- .../Users/Models/WeChatUser.cs | 55 +++++++++++++ .../Collections/WeChatUserDocument.cs | 78 +++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 src/Infrastructure/BotSharp.Abstraction/Users/Models/WeChatUser.cs create mode 100644 src/Plugins/BotSharp.Plugin.MongoStorage/Collections/WeChatUserDocument.cs diff --git a/src/Infrastructure/BotSharp.Abstraction/Users/Models/WeChatUser.cs b/src/Infrastructure/BotSharp.Abstraction/Users/Models/WeChatUser.cs new file mode 100644 index 00000000..511ef236 --- /dev/null +++ b/src/Infrastructure/BotSharp.Abstraction/Users/Models/WeChatUser.cs @@ -0,0 +1,55 @@ +namespace BotSharp.Abstraction.Users.Models; + +public class WeChatUser +{ + public string Id { get; set; } = string.Empty; + + /// + /// User unique identifier (unique under the current application) + /// + public string OpenId { get; set; } = string.Empty; + + public string SessionKey { get; set; } = string.Empty; + + /// + /// User unique identifier (cross application unique, requiring open platform binding) + /// + public string UnionId { get; set; } = string.Empty; + + /// + /// User's gender: 1- Male, 2- Female, 0- Unknown + /// + public int Sex { get; set; } + + /// + /// The province where the user's personal information is filled in + /// + public string Province { get; set; } = string.Empty; + + public string City { get; set; } = string.Empty; + + public string NickName { get; set; } = string.Empty; + + /// + /// User avatar URL (46/64/96/132/0 pixels) + /// + public string Headimgurl { get; set; } = string.Empty; + + public string PhoneNumber { get; set; } = string.Empty; + + /// + /// The country where the user is located, such as China CN + /// + public string Country { get; set; } = "CN"; + + /// + /// User privilege information (such as WeChat membership, etc.) + /// + public string[] Privilege { get; set; } = Array.Empty(); + + //public string AppId { get; set; } = string.Empty; + + public DateTime? UpdatedAt { get; set; } + + public DateTime CreatedAt { get; set; } +} diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/WeChatUserDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/WeChatUserDocument.cs new file mode 100644 index 00000000..6898cb9c --- /dev/null +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/WeChatUserDocument.cs @@ -0,0 +1,78 @@ +using BotSharp.Abstraction.Users.Models; + +namespace BotSharp.Plugin.MongoStorage.Collections; + +public class WeChatUserDocument : MongoBase +{ + public string Id { get; set; } = string.Empty; + + /// + /// User unique identifier (unique under the current application) + /// + public string OpenId { get; set; } = string.Empty; + + public string SessionKey { get; set; } = string.Empty; + + /// + /// User unique identifier (cross application unique, requiring open platform binding) + /// + public string UnionId { get; set; } = string.Empty; + + /// + /// User's gender: 1- Male, 2- Female, 0- Unknown + /// + public int Sex { get; set; } + + /// + /// The province where the user's personal information is filled in + /// + public string Province { get; set; } = string.Empty; + + public string City { get; set; } = string.Empty; + + public string NickName { get; set; } = string.Empty; + + /// + /// User avatar URL (46/64/96/132/0 pixels) + /// + public string Headimgurl { get; set; } = string.Empty; + + public string PhoneNumber { get; set; } = string.Empty; + + /// + /// The country where the user is located, such as China CN + /// + public string Country { get; set; } = "CN"; + + /// + /// User privilege information (such as WeChat membership, etc.) + /// + public string[] Privilege { get; set; } = Array.Empty(); + + //public string AppId { get; set; } = string.Empty; + + public DateTime? UpdatedAt { get; set; } + + public DateTime CreatedAt { get; set; } + + public WeChatUser ToWeChatUser() + { + return new WeChatUser + { + Id = Id, + OpenId = OpenId, + SessionKey = SessionKey, + UnionId = UnionId, + Sex = Sex, + Province = Province, + City = City, + NickName = NickName, + Headimgurl = Headimgurl, + PhoneNumber = PhoneNumber, + Country = Country, + Privilege = Privilege, + CreatedAt = CreatedAt, + UpdatedAt = UpdatedAt + }; + } +}