diff --git a/Blog.Core.Api/Blog.Core.Model.xml b/Blog.Core.Api/Blog.Core.Model.xml
index 4befdeb..3984a3c 100644
--- a/Blog.Core.Api/Blog.Core.Model.xml
+++ b/Blog.Core.Api/Blog.Core.Model.xml
@@ -861,6 +861,496 @@
修改时间
+
+
+
+
+
+
+
+ 公司ID
+
+
+
+
+ 公司名称
+
+
+
+
+ 公司IP
+
+
+
+
+ 公司备注
+
+
+
+
+ api地址
+
+
+
+
+ 是否激活
+
+
+
+
+ 创建者id
+
+
+
+
+ 创建人
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改者id
+
+
+
+
+ 修改人
+
+
+
+
+ 修改时间
+
+
+
+
+
+
+
+
+
+ 微信公众号唯一标识
+
+
+
+
+ 微信公众号名称
+
+
+
+
+ 微信账号
+
+
+
+
+ 微信名称
+
+
+
+
+ 应用ID
+
+
+
+
+ 应用秘钥
+
+
+
+
+ 公众号推送token
+
+
+
+
+ 验证秘钥(验证消息是否真实)
+
+
+
+
+ 微信公众号token过期时间
+
+
+
+
+ 备注
+
+
+
+
+ 是否激活
+
+
+
+
+ 创建者id
+
+
+
+
+ 创建人
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改者id
+
+
+
+
+ 修改人
+
+
+
+
+ 修改时间
+
+
+
+
+
+
+
+
+
+ 推送ID
+
+
+
+
+ 来自谁
+
+
+
+
+ 推送IP
+
+
+
+
+ 推送客户
+
+
+
+
+ 推送用户
+
+
+
+
+ 推送模板ID
+
+
+
+
+ 推送内容
+
+
+
+
+ 推送时间
+
+
+
+
+ 推送状态(Y/N)
+
+
+
+
+ 备注
+
+
+
+
+ 推送OpenID
+
+
+
+
+ 推送微信公众号
+
+
+
+
+ 创建者id
+
+
+
+
+ 创建人
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改者id
+
+
+
+
+ 修改人
+
+
+
+
+ 修改时间
+
+
+
+
+
+
+
+
+
+ 主键id,ticket
+
+
+
+
+ 需要绑定的公司
+
+
+
+
+ 需要绑定的员工id
+
+
+
+
+ 需要绑定的员工昵称
+
+
+
+
+ 创建时间
+
+
+
+
+ 关联的公众号
+
+
+
+
+ 是否已使用
+
+
+
+
+ 使用时间
+
+
+
+
+ 关联的微信用户id
+
+
+
+
+ 创建者id
+
+
+
+
+ 创建人
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改者id
+
+
+
+
+ 修改人
+
+
+
+
+ 修改时间
+
+
+
+
+
+
+
+
+
+ 来自哪个公众号
+
+
+
+
+ 绑定公司id
+
+
+
+
+ 绑定员工id
+
+
+
+
+ 绑定微信id
+
+
+
+
+ 绑定微信联合id
+
+
+
+
+ 绑定时间
+
+
+
+
+ 更新时间
+
+
+
+
+ 备注
+
+
+
+
+ 是否已解绑
+
+
+
+
+ 上次绑定微信id
+
+
+
+
+ 创建者id
+
+
+
+
+ 创建人
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改者id
+
+
+
+
+ 修改人
+
+
+
+
+ 修改时间
+
+
+
+
+
+
+
+
+
+ 文件ID
+
+
+
+
+ 文件名称
+
+
+
+
+ 文件大小
+
+
+
+
+ 文件类型
+
+
+
+
+ 文件拓展名
+
+
+
+
+ 文件位置
+
+
+
+
+ 文件上传时间
+
+
+
+
+ 文件备注
+
+
+
+
+ 创建者id
+
+
+
+
+ 创建人
+
+
+
+
+ 创建时间
+
+
+
+
+ 修改者id
+
+
+
+
+ 修改人
+
+
+
+
+ 修改时间
+
+
ID
@@ -997,6 +1487,33 @@
返回数据
+
+
+ 所需分页参数
+ 作者:胡丁文
+ 时间:2020-4-3 20:31:26
+
+
+
+
+ 当前页
+
+
+
+
+ 每页大小
+
+
+
+
+ 排序字段(例如:id desc,time asc)
+
+
+
+
+ 查询条件( 例如:id = 1 and name = 小明)
+
+
无权限
@@ -1730,5 +2247,681 @@
+
+
+ 微信接口消息DTO
+ 作者:胡丁文
+ 时间:2020-03-25
+
+
+
+
+ 微信公众号ID(数据库查询)
+
+
+
+
+ 错误代码
+
+
+
+
+ 错误信息
+
+
+
+
+ token
+
+
+
+
+ 过期时间(秒)
+
+
+
+
+ 用户关注数
+
+
+
+
+ 获取用户数量
+
+
+
+
+ 获取用户OpenIDs
+
+
+
+
+ 下一个关注用户
+
+
+
+
+ 微信消息模板列表
+
+
+
+
+ 微信菜单
+
+
+
+
+ 二维码票据
+
+
+
+
+ 二维码过期时间
+
+
+
+
+ 二维码地址
+
+
+
+
+ 关注状态
+
+
+
+
+ 用户微信ID
+
+
+
+
+ 昵称
+
+
+
+
+ 性别
+
+
+
+
+ 语言
+
+
+
+
+ 城市
+
+
+
+
+ 省份
+
+
+
+
+ 城市
+
+
+
+
+ 头像地址
+
+
+
+
+ 微信推送消息Dto
+ 作者:胡丁文
+ 时间:2020-4-8 09:16:16
+
+
+
+
+ 推送关键信息
+
+
+
+
+ 推送卡片消息Dto
+
+
+
+
+ 微信推送消息Dto
+ 作者:胡丁文
+ 时间:2020-11-23 16:29:05
+
+
+
+
+ 推送关键信息
+
+
+
+
+ 推送卡片消息Dto
+
+
+
+
+ 消息模板dto(如何填写数据,请参考微信模板即可)
+ 作者:胡丁文
+ 时间:2020-4-1 09:32:16
+
+
+
+
+ 消息模板
+
+
+
+
+ 标题
+
+
+
+
+ 标题颜色(颜色代码都必须为#开头的16进制代码)
+
+
+
+
+ 内容1
+
+
+
+
+ 内容1颜色
+
+
+
+
+ 内容2
+
+
+
+
+ 内容2颜色
+
+
+
+
+ 内容3
+
+
+
+
+ 内容3颜色
+
+
+
+
+ 内容4
+
+
+
+
+ 内容4颜色
+
+
+
+
+ 内容5
+
+
+
+
+ 内容5颜色
+
+
+
+
+ 备注信息
+
+
+
+
+ 备注信息颜色
+
+
+
+
+ 跳转连接
+
+
+
+
+ 获取微信菜单DTO,用于存放具体菜单内容
+
+
+
+
+ 获取微信菜单DTO
+
+
+
+
+ 按钮列表(最多三个)
+
+
+
+
+ 微信OpenID列表Dto
+
+
+
+
+ 推送详细数据
+ 作者:胡丁文
+ 时间:2020-4-8 09:16:16
+
+
+
+
+ 推送给微信所需Dto
+ 作者:胡丁文
+ 时间:2020-4-8 09:16:16
+
+
+
+
+ 推送微信用户ID
+
+
+
+
+ 推送的模板ID
+
+
+
+
+ 推送URL地址
+
+
+
+
+ 推送的数据
+
+
+
+
+ 微信keyword所需Dto
+ 作者:胡丁文
+ 时间:2020-4-8 09:18:08
+
+
+
+
+ 内容
+
+
+
+
+ 文字颜色
+
+
+
+
+ 图文链接标题
+
+
+
+
+ 图文描述
+
+
+
+
+ 访问URL
+
+
+
+
+ 图片URL
+
+
+
+
+ 图片mediaID
+
+
+
+
+ 推送模拟消息Dto
+ 作者:胡丁文
+ 时间:2020-4-24 14:52:44
+
+
+
+
+ 当前选中的微信公众号
+
+
+
+
+ 当前选中的操作集合
+
+
+
+
+ 当前选中的绑定还是订阅
+
+
+
+
+ 当前选中的微信客户
+
+
+
+
+ 当前选中的消息类型
+
+
+
+
+ 当前选中要发送的用户
+
+
+
+
+ 文本消息
+
+
+
+
+ 图片消息
+
+
+
+
+ 语音消息
+
+
+
+
+ 视频消息
+
+
+
+
+ 链接消息
+
+
+
+
+ 文字消息
+
+
+
+
+ 视频标题
+
+
+
+
+ 视频封面mediaID
+
+
+
+
+ 视频mediaID
+
+
+
+
+ 语音mediaID
+
+
+
+
+ 微信二维码预装发送信息dto
+
+
+
+
+ 微信二维码预装具体消息
+
+
+
+
+ 微信二维码预装信息DTO
+
+
+
+
+ 返回给调用者的Dto
+ 作者:胡丁文
+ 时间:2020-4-8 09:52:06
+
+
+
+
+ 微信公众号ID
+
+
+
+
+ 公司代码
+
+
+
+
+ 数据
+
+
+
+
+ 微信消息模板Dto
+
+
+
+
+ 微信推送所需信息(公司版本)
+ 作者:胡丁文
+ 时间:2020-4-8 09:04:36
+
+
+
+
+ 微信公众号ID
+
+
+
+
+ 公司代码
+
+
+
+
+ 用户id
+
+
+
+
+ 用户昵称
+
+
+
+
+ 微信推送所需信息(OpenID版本)
+ 作者:胡丁文
+ 时间:2020-11-23 16:27:29
+
+
+
+
+ 微信公众号ID
+
+
+
+
+ 微信OpenID
+
+
+
+
+ 微信验证Dto
+ 作者:胡丁文
+ 时间:2020-4-1 21:34:07
+
+
+
+
+ 微信公众号唯一标识
+
+
+
+
+ 验证成功后返回给微信的字符串
+
+
+
+
+ 签名
+
+
+
+
+ 时间戳
+
+
+
+
+ 随机数
+
+
+
+
+ 微信XmlDto
+ 作者:胡丁文
+ 时间:2020-4-3 20:31:26
+
+
+
+
+ 微信公众号唯一表示
+
+
+
+
+ 微信开发者
+
+
+
+
+ 来自谁
+
+
+
+
+ 创建时间
+
+
+
+
+ 消息类型
+
+
+
+
+ 文字内容
+
+
+
+
+ 消息ID
+
+
+
+
+ 消息事件
+
+
+
+
+ 事件key值
+
+
+
+
+ 图片地址
+
+
+
+
+ 多媒体ID
+
+
+
+
+ 格式
+
+
+
+
+ 语音失败
+
+
+
+
+ 缩略媒体ID
+
+
+
+
+ 地理位置维度
+
+
+
+
+ 地理位置经度
+
+
+
+
+ 地图缩放大小
+
+
+
+
+ 地理位置信息
+
+
+
+
+ 消息标题
+
+
+
+
+ 消息描述
+
+
+
+
+ 消息链接
+
+
+
+
+ 二维码的ticket,可用来换取二维码图片
+
+
+
+
+ 地理位置纬度
+
+
+
+
+ 地理位置经度
+
+
+
+
+ 地理位置精度
+
+
diff --git a/Blog.Core.Api/Blog.Core.xml b/Blog.Core.Api/Blog.Core.xml
index 87df176..cef46a9 100644
--- a/Blog.Core.Api/Blog.Core.xml
+++ b/Blog.Core.Api/Blog.Core.xml
@@ -823,6 +823,307 @@
通过此处的key格式为 xx:xx:x
+
+
+ WeChatCompanyController
+
+
+
+
+ 构造函数
+
+
+
+
+
+ 获取
+
+ 分页条件
+
+
+
+
+ 获取(id)
+
+ 主键ID
+
+
+
+
+ 添加
+
+
+
+
+
+ 更新
+
+
+
+
+
+ 删除
+
+
+
+
+
+ 批量删除
+
+
+
+
+
+ WeChatConfigController
+
+
+
+
+ 构造函数
+
+
+
+
+
+ 获取
+
+ 分页条件
+
+
+
+
+ 获取(id)
+
+ 主键ID
+
+
+
+
+ 添加
+
+
+
+
+
+ 更新
+
+
+
+
+
+ 删除
+
+
+
+
+
+ 批量删除
+
+
+
+
+
+ 微信公众号管理
+ 作者:胡丁文
+ 时间:2020-3-29 21:24:12
+
+
+
+
+ 构造函数
+
+
+
+
+
+
+ 更新Token
+
+
+
+
+
+
+ 刷新Token
+
+
+
+
+
+
+ 获取模板
+
+
+
+
+
+
+ 获取菜单
+
+
+
+
+
+
+ 更新菜单
+
+
+
+
+
+
+ 获取订阅用户(所有)
+
+
+
+
+
+
+ 入口
+
+
+
+
+
+
+ 获取订阅用户
+
+
+
+
+
+
+ 获取一个绑定员工公众号二维码
+
+ 消息
+
+
+
+
+ 推送卡片消息接口
+
+ 卡片消息对象
+
+
+
+
+ 推送文本消息
+
+ 消息对象
+
+
+
+
+ 通过绑定用户获取微信用户信息(一般用于初次绑定检测)
+
+ 信息
+
+
+
+
+ 用户解绑
+
+ 消息
+
+
+
+
+ WeChatPushLogController
+
+
+
+
+ 构造函数
+
+
+
+
+
+ 获取
+
+ 分页条件
+
+
+
+
+ 获取(id)
+
+ 主键ID
+
+
+
+
+ 添加
+
+
+
+
+
+ 更新
+
+
+
+
+
+ 删除
+
+
+
+
+
+ 批量删除
+
+
+
+
+
+ WeChatSubController
+
+
+
+
+ 构造函数
+
+
+
+
+
+ 获取
+
+ 分页条件
+
+
+
+
+ 获取(id)
+
+ 主键ID
+
+
+
+
+ 添加
+
+
+
+
+
+ 更新
+
+
+
+
+
+ 删除
+
+
+
+
+
+ 批量删除
+
+
+
服务管理
diff --git a/Blog.Core.Api/Controllers/PermissionController.cs b/Blog.Core.Api/Controllers/PermissionController.cs
index 10f3c20..1dbdb0a 100644
--- a/Blog.Core.Api/Controllers/PermissionController.cs
+++ b/Blog.Core.Api/Controllers/PermissionController.cs
@@ -254,9 +254,10 @@ namespace Blog.Core.Controllers
foreach (var item in assignView.pids)
{
var rmpitem = roleModulePermissions.Where(d => d.PermissionId == item);
+ var moduleid = (await _permissionServices.Query(p => p.Id == item)).FirstOrDefault()?.Mid;
if (!rmpitem.Any())
{
- var moduleid = (await _permissionServices.Query(p => p.Id == item)).FirstOrDefault()?.Mid;
+
RoleModulePermission roleModulePermission = new RoleModulePermission()
{
IsDeleted = false,
@@ -272,6 +273,17 @@ namespace Blog.Core.Controllers
data.success &= (await _roleModulePermissionServices.Add(roleModulePermission)) > 0;
}
+ else
+ {
+ foreach (var role in rmpitem)
+ {
+ if (!role.ModuleId.Equals(moduleid))
+ {
+ role.ModuleId = moduleid.Value;
+ await _roleModulePermissionServices.Update(role, new List { "ModuleId" });
+ }
+ }
+ }
}
if (data.success)
@@ -373,6 +385,7 @@ namespace Blog.Core.Controllers
if (pids.Any())
{
var rolePermissionMoudles = (await _permissionServices.Query(d => pids.Contains(d.Id))).OrderBy(c => c.OrderSort);
+ var temp = rolePermissionMoudles.ToList().Find(t => t.Id == 87);
var permissionTrees = (from child in rolePermissionMoudles
where child.IsDeleted == false
orderby child.Id
@@ -410,7 +423,6 @@ namespace Blog.Core.Controllers
};
permissionTrees = permissionTrees.OrderBy(d => d.order).ToList();
-
RecursionHelper.LoopNaviBarAppendChildren(permissionTrees, rootRoot);
data.success = true;
diff --git a/Blog.Core.Api/Controllers/WeChatCompanyController.cs b/Blog.Core.Api/Controllers/WeChatCompanyController.cs
new file mode 100644
index 0000000..50cec46
--- /dev/null
+++ b/Blog.Core.Api/Controllers/WeChatCompanyController.cs
@@ -0,0 +1,94 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Blog.Core.Common.Helper;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Blog.Core.Controllers
+{
+ ///
+ /// WeChatCompanyController
+ ///
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ [Authorize(Permissions.Name)]
+ public partial class WeChatCompanyController : Controller
+ {
+ readonly IWeChatCompanyServices _WeChatCompanyServices;
+ ///
+ /// 构造函数
+ ///
+ ///
+ public WeChatCompanyController(IWeChatCompanyServices iWeChatCompanyServices)
+ {
+ _WeChatCompanyServices = iWeChatCompanyServices;
+ }
+ ///
+ /// 获取
+ ///
+ /// 分页条件
+ ///
+ [HttpGet]
+ public async Task>> Get([FromQuery] PaginationModel pagination)
+ {
+ var data = await _WeChatCompanyServices.QueryPage(pagination);
+ return new MessageModel> { success = true, response = data};
+ }
+ ///
+ /// 获取(id)
+ ///
+ /// 主键ID
+ ///
+ [HttpGet("{id}")]
+ public async Task> Get(string id)
+ {
+ var data = await _WeChatCompanyServices.QueryById(id);
+ return new MessageModel { success = true, response = data };
+ }
+ ///
+ /// 添加
+ ///
+ ///
+ [HttpPost]
+ public async Task> Post([FromBody] WeChatCompany obj)
+ {
+ await _WeChatCompanyServices.Add(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 更新
+ ///
+ ///
+ [HttpPut]
+ public async Task> Put([FromBody] WeChatCompany obj)
+ {
+ await _WeChatCompanyServices.Update(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> Delete(string id)
+ {
+ await _WeChatCompanyServices.DeleteById(id);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 批量删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> BatchDelete(string ids)
+ {
+ var i = ids.Split(",");
+ await _WeChatCompanyServices.DeleteByIds(i);
+ return new MessageModel { success = true };
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Api/Controllers/WeChatConfigController.cs b/Blog.Core.Api/Controllers/WeChatConfigController.cs
new file mode 100644
index 0000000..e3c7707
--- /dev/null
+++ b/Blog.Core.Api/Controllers/WeChatConfigController.cs
@@ -0,0 +1,94 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Blog.Core.Common.Helper;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Blog.Core.Controllers
+{
+ ///
+ /// WeChatConfigController
+ ///
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ [Authorize(Permissions.Name)]
+ public partial class WeChatConfigController : Controller
+ {
+ readonly IWeChatConfigServices _WeChatConfigServices;
+ ///
+ /// 构造函数
+ ///
+ ///
+ public WeChatConfigController(IWeChatConfigServices iWeChatConfigServices)
+ {
+ _WeChatConfigServices = iWeChatConfigServices;
+ }
+ ///
+ /// 获取
+ ///
+ /// 分页条件
+ ///
+ [HttpGet]
+ public async Task>> Get([FromQuery] PaginationModel pagination)
+ {
+ var data = await _WeChatConfigServices.QueryPage(pagination);
+ return new MessageModel> { success = true, response = data};
+ }
+ ///
+ /// 获取(id)
+ ///
+ /// 主键ID
+ ///
+ [HttpGet("{id}")]
+ public async Task> Get(string id)
+ {
+ var data = await _WeChatConfigServices.QueryById(id);
+ return new MessageModel { success = true, response = data };
+ }
+ ///
+ /// 添加
+ ///
+ ///
+ [HttpPost]
+ public async Task> Post([FromBody] WeChatConfig obj)
+ {
+ await _WeChatConfigServices.Add(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 更新
+ ///
+ ///
+ [HttpPut]
+ public async Task> Put([FromBody] WeChatConfig obj)
+ {
+ await _WeChatConfigServices.Update(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> Delete(string id)
+ {
+ await _WeChatConfigServices.DeleteById(id);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 批量删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> BatchDelete(string ids)
+ {
+ var i = ids.Split(",");
+ await _WeChatConfigServices.DeleteByIds(i);
+ return new MessageModel { success = true };
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Api/Controllers/WeChatController.cs b/Blog.Core.Api/Controllers/WeChatController.cs
new file mode 100644
index 0000000..e8b57d2
--- /dev/null
+++ b/Blog.Core.Api/Controllers/WeChatController.cs
@@ -0,0 +1,187 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Xml;
+using Blog.Core.Common.Helper;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace Blog.Core.Controllers
+{
+ ///
+ /// 微信公众号管理
+ /// 作者:胡丁文
+ /// 时间:2020-3-29 21:24:12
+ ///
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ [Authorize(Permissions.Name)]
+ public partial class WeChatController : Controller
+ {
+ readonly IWeChatConfigServices _weChatConfigServices;
+ readonly ILogger _logger;
+ ///
+ /// 构造函数
+ ///
+ ///
+ ///
+ public WeChatController(IWeChatConfigServices weChatConfigServices, ILogger logger)
+ {
+ _weChatConfigServices = weChatConfigServices;
+ _logger = logger;
+ }
+ ///
+ /// 更新Token
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task> GetToken(string id)
+ {
+ return await _weChatConfigServices.GetToken(id);
+
+ }
+ ///
+ /// 刷新Token
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task> RefreshToken(string id)
+ {
+ return await _weChatConfigServices.RefreshToken(id);
+
+ }
+ ///
+ /// 获取模板
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task> GetTemplate(string id)
+ {
+ return await _weChatConfigServices.GetTemplate(id);
+ }
+ ///
+ /// 获取菜单
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task> GetMenu(string id)
+ {
+ return await _weChatConfigServices.GetMenu(id);
+ }
+
+ ///
+ /// 更新菜单
+ ///
+ ///
+ ///
+ [HttpPut]
+ public async Task> UpdateMenu(WeChatApiDto menu)
+ {
+ return await _weChatConfigServices.UpdateMenu(menu);
+ }
+ ///
+ /// 获取订阅用户(所有)
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task> GetSubUsers(string id)
+ {
+ return await _weChatConfigServices.GetSubUsers(id);
+ }
+ ///
+ /// 入口
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ [HttpPost]
+ [HttpGet]
+ public async Task Valid([FromQuery] WeChatValidDto validDto)
+ {
+ using (var reader = new StreamReader(Request.Body))
+ {
+ var body = await reader.ReadToEndAsync();
+ return await _weChatConfigServices.Valid(validDto, body);
+ }
+ }
+ ///
+ /// 获取订阅用户
+ ///
+ ///
+ ///
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task> GetSubUser(string id,string openid)
+ {
+ return await _weChatConfigServices.GetSubUser(id,openid);
+ }
+ ///
+ /// 获取一个绑定员工公众号二维码
+ ///
+ /// 消息
+ ///
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task> GetQRBind([FromQuery]WeChatUserInfo info)
+ {
+ return await _weChatConfigServices.GetQRBind(info);
+ }
+ ///
+ /// 推送卡片消息接口
+ ///
+ /// 卡片消息对象
+ ///
+ [HttpPost]
+ [AllowAnonymous]
+ public async Task> PushCardMsg(WeChatCardMsgDataDto msg)
+ {
+ string pushUserIP = $"{Request.HttpContext.Connection.RemoteIpAddress}:{Request.HttpContext.Connection.RemotePort}";
+ return await _weChatConfigServices.PushCardMsg(msg, pushUserIP);
+ }
+ ///
+ /// 推送文本消息
+ ///
+ /// 消息对象
+ ///
+ [HttpPost]
+ [AllowAnonymous]
+ public async Task> PushTxtMsg([FromBody] WeChatPushTestDto msg)
+ {
+ return await _weChatConfigServices.PushTxtMsg(msg);
+ }
+ ///
+ /// 通过绑定用户获取微信用户信息(一般用于初次绑定检测)
+ ///
+ /// 信息
+ ///
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task> GetBindUserInfo([FromQuery]WeChatUserInfo info)
+ {
+ return await _weChatConfigServices.GetBindUserInfo(info);
+ }
+ ///
+ /// 用户解绑
+ ///
+ /// 消息
+ ///
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task> UnBind([FromQuery]WeChatUserInfo info)
+ {
+ return await _weChatConfigServices.UnBind(info);
+ }
+ }
+}
diff --git a/Blog.Core.Api/Controllers/WeChatPushLogController.cs b/Blog.Core.Api/Controllers/WeChatPushLogController.cs
new file mode 100644
index 0000000..8b0dce8
--- /dev/null
+++ b/Blog.Core.Api/Controllers/WeChatPushLogController.cs
@@ -0,0 +1,94 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Blog.Core.Common.Helper;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Blog.Core.Controllers
+{
+ ///
+ /// WeChatPushLogController
+ ///
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ [Authorize(Permissions.Name)]
+ public partial class WeChatPushLogController : Controller
+ {
+ readonly IWeChatPushLogServices _WeChatPushLogServices;
+ ///
+ /// 构造函数
+ ///
+ ///
+ public WeChatPushLogController(IWeChatPushLogServices iWeChatPushLogServices)
+ {
+ _WeChatPushLogServices = iWeChatPushLogServices;
+ }
+ ///
+ /// 获取
+ ///
+ /// 分页条件
+ ///
+ [HttpGet]
+ public async Task>> Get([FromQuery] PaginationModel pagination)
+ {
+ var data = await _WeChatPushLogServices.QueryPage(pagination);
+ return new MessageModel> { success = true, response = data};
+ }
+ ///
+ /// 获取(id)
+ ///
+ /// 主键ID
+ ///
+ [HttpGet("{id}")]
+ public async Task> Get(string id)
+ {
+ var data = await _WeChatPushLogServices.QueryById(id);
+ return new MessageModel { success = true, response = data };
+ }
+ ///
+ /// 添加
+ ///
+ ///
+ [HttpPost]
+ public async Task> Post([FromBody] WeChatPushLog obj)
+ {
+ await _WeChatPushLogServices.Add(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 更新
+ ///
+ ///
+ [HttpPut]
+ public async Task> Put([FromBody] WeChatPushLog obj)
+ {
+ await _WeChatPushLogServices.Update(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> Delete(string id)
+ {
+ await _WeChatPushLogServices.DeleteById(id);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 批量删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> BatchDelete(string ids)
+ {
+ var i = ids.Split(",");
+ await _WeChatPushLogServices.DeleteByIds(i);
+ return new MessageModel { success = true };
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Api/Controllers/WeChatSubController.cs b/Blog.Core.Api/Controllers/WeChatSubController.cs
new file mode 100644
index 0000000..d341c85
--- /dev/null
+++ b/Blog.Core.Api/Controllers/WeChatSubController.cs
@@ -0,0 +1,94 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Blog.Core.Common.Helper;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Blog.Core.Controllers
+{
+ ///
+ /// WeChatSubController
+ ///
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ [Authorize(Permissions.Name)]
+ public partial class WeChatSubController : Controller
+ {
+ readonly IWeChatSubServices _WeChatSubServices;
+ ///
+ /// 构造函数
+ ///
+ ///
+ public WeChatSubController(IWeChatSubServices iWeChatSubServices)
+ {
+ _WeChatSubServices = iWeChatSubServices;
+ }
+ ///
+ /// 获取
+ ///
+ /// 分页条件
+ ///
+ [HttpGet]
+ public async Task>> Get([FromQuery] PaginationModel pagination)
+ {
+ var data = await _WeChatSubServices.QueryPage(pagination);
+ return new MessageModel> { success = true, response = data};
+ }
+ ///
+ /// 获取(id)
+ ///
+ /// 主键ID
+ ///
+ [HttpGet("{id}")]
+ public async Task> Get(string id)
+ {
+ var data = await _WeChatSubServices.QueryById(id);
+ return new MessageModel { success = true, response = data };
+ }
+ ///
+ /// 添加
+ ///
+ ///
+ [HttpPost]
+ public async Task> Post([FromBody] WeChatSub obj)
+ {
+ await _WeChatSubServices.Add(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 更新
+ ///
+ ///
+ [HttpPut]
+ public async Task> Put([FromBody] WeChatSub obj)
+ {
+ await _WeChatSubServices.Update(obj);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> Delete(string id)
+ {
+ await _WeChatSubServices.DeleteById(id);
+ return new MessageModel { success = true};
+ }
+ ///
+ /// 批量删除
+ ///
+ ///
+ [HttpDelete]
+ public async Task> BatchDelete(string ids)
+ {
+ var i = ids.Split(",");
+ await _WeChatSubServices.DeleteByIds(i);
+ return new MessageModel { success = true };
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Api/Properties/launchSettings.json b/Blog.Core.Api/Properties/launchSettings.json
index 9b02dcc..09b0712 100644
--- a/Blog.Core.Api/Properties/launchSettings.json
+++ b/Blog.Core.Api/Properties/launchSettings.json
@@ -13,7 +13,7 @@
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": ""
+ "ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:9291"
},
diff --git a/Blog.Core.Api/Startup.cs b/Blog.Core.Api/Startup.cs
index 599d376..12c30b1 100644
--- a/Blog.Core.Api/Startup.cs
+++ b/Blog.Core.Api/Startup.cs
@@ -107,7 +107,7 @@ namespace Blog.Core
//{
// options.JsonSerializerOptions.PropertyNamingPolicy = null;
//})
- //全局配置Json序列化处理
+ //MVC全局配置Json序列化处理
.AddNewtonsoftJson(options =>
{
//忽略循环引用
@@ -115,7 +115,7 @@ namespace Blog.Core
//不使用驼峰样式的key
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
//设置时间格式
- //options.SerializerSettings.DateFormatString = "yyyy-MM-dd";
+ options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
//忽略Model中为null的属性
//options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
//设置本地时间而非UTC时间
diff --git a/Blog.Core.Api/appsettings.Development.json b/Blog.Core.Api/appsettings.Development.json
new file mode 100644
index 0000000..077404a
--- /dev/null
+++ b/Blog.Core.Api/appsettings.Development.json
@@ -0,0 +1,3 @@
+{
+
+}
\ No newline at end of file
diff --git a/Blog.Core.Api/appsettings.json b/Blog.Core.Api/appsettings.json
index c31755d..0d69770 100644
--- a/Blog.Core.Api/appsettings.json
+++ b/Blog.Core.Api/appsettings.json
@@ -1,5 +1,5 @@
{
- "urls": "http://*:9291", //web服务端口,如果用IIS部署,把这个去掉
+ "urls": "http://*:8081", //web服务端口,如果用IIS部署,把这个去掉
"Logging": {
"LogLevel": {
"Default": "Information", //加入Default否则log4net本地写入不了日志
diff --git a/Blog.Core.Api/wwwroot/BlogCore.Data.json/Modules.tsv b/Blog.Core.Api/wwwroot/BlogCore.Data.json/Modules.tsv
index a0f2eae..9acf2b3 100644
--- a/Blog.Core.Api/wwwroot/BlogCore.Data.json/Modules.tsv
+++ b/Blog.Core.Api/wwwroot/BlogCore.Data.json/Modules.tsv
@@ -1010,5 +1010,402 @@
"ModifyBy": null,
"ModifyTime": "\/Date(1546272000000+0800)\/",
"Id": 46
+ },
+
+ {
+ "Id": "47",
+ "IsDeleted": 0,
+ "Name": "微信获取",
+ "LinkUrl": "\/api\/WeChatConfig\/get",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-22 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "48",
+ "IsDeleted": 0,
+ "Name": "微信客户批量删除",
+ "LinkUrl": "\/api\/WeChatCompany\/BatchDelete",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "49",
+ "IsDeleted": 0,
+ "Name": "微信客户删除",
+ "LinkUrl": "\/api\/WeChatCompany\/delete",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "50",
+ "IsDeleted": 0,
+ "Name": "微信客户获取",
+ "LinkUrl": "\/api\/WeChatCompany\/get",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "51",
+ "IsDeleted": 0,
+ "Name": "微信客户添加",
+ "LinkUrl": "\/api\/WeChatCompany\/post",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "52",
+ "IsDeleted": 0,
+ "Name": "微信客户更新",
+ "LinkUrl": "\/api\/WeChatCompany\/put",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "53",
+ "IsDeleted": 0,
+ "Name": "微信公众号批量删除",
+ "LinkUrl": "\/api\/WeChatConfig\/BatchDelete",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-25 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "54",
+ "IsDeleted": 0,
+ "Name": "微信公众号获取",
+ "LinkUrl": "\/api\/WeChatConfig\/get",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-22 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "55",
+ "IsDeleted": 0,
+ "Name": "获取公众号菜单设置",
+ "LinkUrl": "\/api\/WeChat\/GetMenu",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "56",
+ "IsDeleted": 0,
+ "Name": "获取订阅用户",
+ "LinkUrl": "\/api\/WeChat\/GetSubUsers",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 16:20:30",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "57",
+ "IsDeleted": 0,
+ "Name": "获取消息模板列表",
+ "LinkUrl": "\/api\/WeChat\/GetTemplate",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-08 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "58",
+ "IsDeleted": 0,
+ "Name": "微信公众号更新",
+ "LinkUrl": "\/api\/WeChatConfig\/post",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-24 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "59",
+ "IsDeleted": 0,
+ "Name": "微信公众号添加",
+ "LinkUrl": "\/api\/WeChatConfig\/put",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-24 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "60",
+ "IsDeleted": 0,
+ "Name": "刷新Token",
+ "LinkUrl": "\/api\/WeChat\/RefreshToken",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-30 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "61",
+ "IsDeleted": 0,
+ "Name": "更新微信菜单设置",
+ "LinkUrl": "\/api\/WeChat\/UpdateMenu",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "62",
+ "IsDeleted": 0,
+ "Name": "获取推送记录",
+ "LinkUrl": "\/api\/WeChatPushLog\/get",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-08 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "63",
+ "IsDeleted": 0,
+ "Name": "获取绑定用户",
+ "LinkUrl": "\/api\/WeChatSub\/get",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 16:20:47",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-23 00:00:00",
+ "ParentId": 0
+ },
+ {
+ "Id": "64",
+ "IsDeleted": 0,
+ "Name": "微信公众号删除",
+ "LinkUrl": "\/api\/WeChatConfig\/delete",
+ "Area": null,
+ "Controller": null,
+ "Action": null,
+ "Icon": null,
+ "Code": null,
+ "OrderSort": 0,
+ "Description": null,
+ "IsMenu": 0,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-24 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "ParentId": 0
}
]
diff --git a/Blog.Core.Api/wwwroot/BlogCore.Data.json/Permission.tsv b/Blog.Core.Api/wwwroot/BlogCore.Data.json/Permission.tsv
index 9054658..81984e1 100644
--- a/Blog.Core.Api/wwwroot/BlogCore.Data.json/Permission.tsv
+++ b/Blog.Core.Api/wwwroot/BlogCore.Data.json/Permission.tsv
@@ -1666,8 +1666,7 @@
"IsDeleted": 0,
"Id": 82,
"IsHide": 0
- }
- ,
+ },
{
"Code": " ",
"Name": "删除",
@@ -1751,5 +1750,599 @@
"IsDeleted": 0,
"Id": 86,
"IsHide": 1
+ },
+ {
+ "Id": 87,
+ "Code": "-",
+ "Name": "微信公众号管理",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 3,
+ "Icon": "fa-weixin",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-21 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-13 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 0,
+ "Mid": 0
+ },
+ {
+ "Id": 88,
+ "Code": "\/WeChat\/Manager",
+ "Name": "微信列表",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 1,
+ "Icon": "fa-list",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-21 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 89,
+ "Code": "\/WeChat\/Company",
+ "Name": "微信客户",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": "2",
+ "Icon": "fa-address-book",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-26 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 90,
+ "Code": "\/WeChat\/Menu",
+ "Name": "微信菜单",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 3,
+ "Icon": "fa-sliders",
+ "Description": "微信菜单设置",
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 91,
+ "Code": "\/WeChat\/Template",
+ "Name": "模板消息",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 4,
+ "Icon": "fa-comments-o",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-08 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 92,
+ "Code": "\/WeChat\/PushLog",
+ "Name": "推送记录",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 8,
+ "Icon": "fa-history",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-08 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 93,
+ "Code": "\/WeChat\/SubUser",
+ "Name": "订阅用户",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 6,
+ "Icon": "fa fa-user",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 14:09:08",
+ "ModifyId": 8,
+ "ModifyBy": "test",
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 94,
+ "Code": "\/WeChat\/BindUser",
+ "Name": "绑定用户",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 7,
+ "Icon": "fa fa-user-circle-o",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 16:12:52",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 95,
+ "Code": "\/WeChat\/SendMessage",
+ "Name": "文本消息",
+ "IsButton": 0,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 5,
+ "Icon": "fa fa-paper-plane",
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-24 09:05:50",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-30 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 87,
+ "Mid": 0
+ },
+ {
+ "Id": 96,
+ "Code": " ",
+ "Name": "查询",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": "getWeChatAccount",
+ "OrderSort": "0",
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-22 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-17 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 88,
+ "Mid": 54
+ },
+ {
+ "Id": 98,
+ "Code": " ",
+ "Name": "删除",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": "handleDel",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-22 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-17 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 88,
+ "Mid": 64
+ },
+ {
+ "Id": 99,
+ "Code": " ",
+ "Name": "新增",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": "handleAdd",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-24 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-17 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 88,
+ "Mid": 59
+ },
+ {
+ "Id": 100,
+ "Code": " ",
+ "Name": "编辑",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": "handleEdit",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-24 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-17 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 88,
+ "Mid": 58
+ },
+ {
+ "Id": 101,
+ "Code": " ",
+ "Name": "批量删除",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": "batchRemove",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-25 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-17 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 88,
+ "Mid": 53
+ },
+ {
+ "Id": 102,
+ "Code": " ",
+ "Name": "刷新Token",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": "handleRefreshWeChatToken",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-03-30 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-17 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 88,
+ "Mid": 60
+ },
+ {
+ "Id": 103,
+ "Code": " ",
+ "Name": "查询",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": null,
+ "Func": "getWeChatCompany",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 89,
+ "Mid": 50
+ },
+ {
+ "Id": 104,
+ "Code": " ",
+ "Name": "删除",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": null,
+ "Func": "handleDel",
+ "OrderSort": "0",
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 89,
+ "Mid": 49
+ },
+ {
+ "Id": 105,
+ "Code": " ",
+ "Name": "批量删除",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": null,
+ "Func": "batchRemove",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 89,
+ "Mid": 48
+ },
+ {
+ "Id": 106,
+ "Code": " ",
+ "Name": "添加",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": null,
+ "Func": "handleAdd",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 89,
+ "Mid": 51
+ },
+ {
+ "Id": 107,
+ "Code": " ",
+ "Name": "编辑",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": null,
+ "Func": "handleEdit",
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-06 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 89,
+ "Mid": 52
+ },
+ {
+ "Id": 108,
+ "Code": " ",
+ "Name": "获取菜单",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 90,
+ "Mid": 55
+ },
+ {
+ "Id": 109,
+ "Code": " ",
+ "Name": "更新菜单",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-06 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 90,
+ "Mid": 61
+ },
+ {
+ "Id": 110,
+ "Code": " ",
+ "Name": "获取消息模板",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-08 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 91,
+ "Mid": 57
+ },
+ {
+ "Id": 111,
+ "Code": " ",
+ "Name": "获取推送记录",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-08 00:00:00",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 92,
+ "Mid": 62
+ },
+ {
+ "Id": 112,
+ "Code": " ",
+ "Name": "获取订阅用户",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": null,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 16:21:53",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2020-04-23 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 93,
+ "Mid": 56
+ },
+ {
+ "Id": 113,
+ "Code": " ",
+ "Name": "获取绑定用户",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 16:22:11",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 94,
+ "Mid": 63
+ },
+ {
+ "Id": 114,
+ "Code": " ",
+ "Name": "推送文字消息",
+ "IsButton": 1,
+ "IsHide": 0,
+ "IskeepAlive": 0,
+ "Func": null,
+ "OrderSort": 0,
+ "Icon": null,
+ "Description": null,
+ "Enabled": 1,
+ "CreateId": 8,
+ "CreateBy": "test",
+ "CreateTime": "2020-04-23 16:22:11",
+ "ModifyId": null,
+ "ModifyBy": null,
+ "ModifyTime": "2021-09-29 00:00:00",
+ "IsDeleted": 0,
+ "Pid": 95,
+ "Mid": 0
}
]
diff --git a/Blog.Core.Common/Helper/DynamicLinqFactory.cs b/Blog.Core.Common/Helper/DynamicLinqFactory.cs
new file mode 100644
index 0000000..7673cc1
--- /dev/null
+++ b/Blog.Core.Common/Helper/DynamicLinqFactory.cs
@@ -0,0 +1,551 @@
+using RestSharp.Extensions;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text;
+
+namespace Blog.Core.Common.Helper
+{
+ #region 动态linq帮助类,连接符号,运算符号
+
+ ///
+ /// 动态linq工厂
+ ///
+ public static class DynamicLinqFactory
+ {
+
+ ///
+ /// 生成lambd表达式(如:CompanyID != 1 & CompanyID == 1)
+ ///
+ ///
+ ///
+ ///
+ public static Expression> CreateLambda(string propertyStr)
+ {
+ // 设置自定义lanbd
+ // 定义 lanbd 种子(p=> xxxxxx)中的 p
+ if (string.IsNullOrWhiteSpace(propertyStr))
+ return LinqHelper.True();//为空就返回空的表达式
+
+ var parameter = Expression.Parameter(typeof(TSource), "p");
+ var strArr = SpiltStrings(propertyStr);
+
+
+ // 第一个判断条件,固定一个判断条件作为最左边
+ Expression mainExpressin = ExpressionStudio(null, strArr.FirstOrDefault(x => x.LinkSymbol == LinkSymbol.Empty), parameter);
+
+ // 将需要放置在最左边的判断条件从列表中去除,因为已经合成到表达式最左边了
+ strArr.Remove(strArr.FirstOrDefault(x => x.LinkSymbol == LinkSymbol.Empty));
+
+ foreach (var x in strArr)
+ {
+ mainExpressin = ExpressionStudio(mainExpressin, x, parameter);
+ }
+
+ return mainExpressin.ToLambda>(parameter);
+ }
+
+ ///
+ /// 组合条件判断表达式
+ ///
+ /// 左边的表达式
+ ///
+ ///
+ ///
+ public static Expression ExpressionStudio(Expression left, DynamicLinqHelper DynamicLinq, ParameterExpression key)
+ {
+ Expression mainExpression = key;
+
+ var properties = DynamicLinq.Left.Split('.');
+
+ // 从1开始,是不想用自定义种子,外层种子已经定义好了
+ // 暂时也不会有多个自定义种子,先这样
+ for (var i = 0; i < properties.Length; i++)
+ {
+ mainExpression = mainExpression.Property(properties[i]);
+ }
+
+ left = left == null
+ // 如果左边表达式为空,则当前的表达式就为最左边
+ ? ChangeOperationSymbol(DynamicLinq.OperationSymbol, mainExpression, DynamicLinq.Right)
+ // 如果不为空,则将当前的表达式连接到左边
+ : ChangeLinkSymbol(DynamicLinq.LinkSymbol, left, ChangeOperationSymbol(DynamicLinq.OperationSymbol, mainExpression, DynamicLinq.Right));
+ return left;
+ }
+
+ ///
+ /// 将字符串装换成动态帮助类(内含递归)
+ ///
+ public static List SpiltStrings(string propertyStr)
+ {
+ // 定义返回用List
+ var outList = new List();
+
+ // 当最后已经没有连接运算符的时候,进入该条件
+ if (!propertyStr.Contains("&") & !propertyStr.Contains("|"))
+ {
+ // 当前的条件是不具备连接符号的
+ var lastStr = propertyStr.Trim().Split(' ');
+ outList.Add(new DynamicLinqHelper
+ {
+ LinkSymbol = LinkSymbol.Empty,
+ Left = lastStr[0],
+ Right = lastStr[2],
+ OperationSymbol = ChangeOperationSymbol(lastStr[1])
+ });
+ return outList;
+ }
+ // 判断当前 & | 哪个符号在最后一个判断逻辑内
+ var key = propertyStr.LastIndexOf('&') > propertyStr.LastIndexOf('|') ? '&' : '|';
+
+ var nowStrArr = propertyStr.Substring(propertyStr.LastIndexOf(key)).Trim().Split(' ');
+
+ outList.Add(new DynamicLinqHelper
+ {
+ LinkSymbol = ChangeLinkSymbol(nowStrArr[0]),
+ Left = nowStrArr[1],
+ OperationSymbol = ChangeOperationSymbol(nowStrArr[2]),
+ Right = nowStrArr[3]
+ });
+ // 将剩余部分继续切割
+ propertyStr = propertyStr.Substring(0, propertyStr.LastIndexOf(key)).Trim();
+ // 递归 由后彺前
+ outList.AddRange(SpiltStrings(propertyStr));
+
+ return outList;
+ }
+
+ ///
+ /// 将字符串符号转成运算枚举符号
+ ///
+ public static LinkSymbol ChangeLinkSymbol(string str)
+ {
+ // 这里判断链接符号
+ // 当链接符号为Empty,则说明当前对象为表达式的最左边
+ // 如果一个表达式出现两次链接符号为空,则说明输入的字符串格式有问题
+ switch (str)
+ {
+ case "|":
+ return LinkSymbol.OrElse;
+ case "&":
+ return LinkSymbol.AndAlso;
+ default:
+ return LinkSymbol.Empty;
+ }
+ }
+
+ ///
+ /// 将运算枚举符号转成具体使用方法
+ ///
+ public static Expression ChangeLinkSymbol(LinkSymbol Symbol, Expression left, Expression right)
+ {
+ switch (Symbol)
+ {
+ case LinkSymbol.OrElse:
+ return left.OrElse(right);
+ case LinkSymbol.AndAlso:
+ return left.AndAlso(right);
+ default:
+ return left;
+ }
+ }
+
+ ///
+ /// 将字符串符号转成运算枚举符号
+ ///
+ public static OperationSymbol ChangeOperationSymbol(string str)
+ {
+ switch (str)
+ {
+ case "<":
+ return OperationSymbol.LessThan;
+ case "<=":
+ return OperationSymbol.LessThanOrEqual;
+ case ">":
+ return OperationSymbol.GreaterThan;
+ case ">=":
+ return OperationSymbol.GreaterThanOrEqual;
+ case "==":
+ case "=":
+ return OperationSymbol.Equal;
+ case "!=":
+ return OperationSymbol.NotEqual;
+ case "contains":
+ case "like":
+ return OperationSymbol.Contains;
+ }
+ throw new Exception("OperationSymbol IS NULL");
+ }
+
+ ///
+ /// 将运算枚举符号转成具体使用方法
+ ///
+ public static Expression ChangeOperationSymbol(OperationSymbol symbol, Expression key, object right)
+ {
+ // 将右边数据类型强行转换成左边一样的类型
+ // 两者如果Type不匹配则无法接下去的运算操作,抛出异常
+ object newTypeRight;
+ if (right == null || string.IsNullOrEmpty(right.ToString()) || right.ToString() == "null")
+ newTypeRight = null;
+ else
+ newTypeRight = Convert.ChangeType(right, key.Type);
+
+ // 根据当前枚举类别判断使用那种比较方法
+ switch (symbol)
+ {
+ case OperationSymbol.Equal:
+ return key.Equal(Expression.Constant(newTypeRight));
+ case OperationSymbol.GreaterThan:
+ {
+ if (key.Type == typeof(string))
+ return key.Contains(Expression.Constant(newTypeRight)); //对string 特殊处理 由于string
+ else
+ return key.GreaterThan(Expression.Constant((newTypeRight)));
+ }
+ case OperationSymbol.GreaterThanOrEqual:
+ {
+ if (key.Type == typeof(string))
+ return key.Contains(Expression.Constant(newTypeRight, typeof(string)));
+ else
+ return key.GreaterThanOrEqual(Expression.Constant(newTypeRight));
+ }
+
+ case OperationSymbol.LessThan:
+ {
+ if (key.Type == typeof(string))
+ return key.Contains(Expression.Constant(newTypeRight, typeof(string)));
+ else
+ return key.LessThan(Expression.Constant((newTypeRight)));
+ }
+ case OperationSymbol.LessThanOrEqual:
+ {
+ if (key.Type == typeof(string))
+ return key.Contains(Expression.Constant(newTypeRight, typeof(string)));
+ else
+ return key.LessThanOrEqual(Expression.Constant((newTypeRight)));
+ }
+ case OperationSymbol.NotEqual:
+ return key.NotEqual(Expression.Constant(newTypeRight));
+ case OperationSymbol.Contains:
+ return key.Contains(Expression.Constant(newTypeRight));
+ }
+ throw new Exception("OperationSymbol IS NULL");
+ }
+ }
+
+ ///
+ /// 动态linq帮助类
+ ///
+ public class DynamicLinqHelper
+ {
+ [Display(Name = "左")]
+ public string Left { get; set; }
+ [Display(Name = "右")]
+ public string Right { get; set; }
+
+ [Display(Name = "运算符")]
+ public OperationSymbol OperationSymbol { get; set; }
+
+ [Display(Name = "连接符")]
+ public LinkSymbol LinkSymbol { get; set; }
+ }
+
+ ///
+ /// 连接符枚举(将来可能会包含 括号 )
+ ///
+ public enum LinkSymbol
+ {
+ [Display(Name = "&&")]
+ AndAlso,
+ [Display(Name = "||")]
+ OrElse,
+ [Display(Name = "空")]
+ Empty
+ }
+
+ ///
+ /// 常用比较运算符 > , >= , == , < , <= , != ,Contains
+ ///
+ public enum OperationSymbol
+ {
+ [Display(Name = "Contains")]
+ Contains,
+ [Display(Name = ">")]
+ GreaterThan,
+ [Display(Name = ">=")]
+ GreaterThanOrEqual,
+ [Display(Name = "<")]
+ LessThan,
+ [Display(Name = "<=")]
+ LessThanOrEqual,
+ [Display(Name = "==")]
+ Equal,
+ [Display(Name = "!=")]
+ NotEqual
+ }
+
+ #endregion
+
+ ///
+ /// Linq扩展
+ ///
+ public static class ExpressionExtensions
+ {
+ #region 常用扩展方法
+
+ ///
+ /// 调用内部方法
+ ///
+ public static Expression Call(this Expression instance, string methodName, params Expression[] arguments)
+ {
+ if(instance.Type == typeof(string))
+ return Expression.Call(instance, instance.Type.GetMethod(methodName,new Type[] { typeof(string)}), arguments); //修复string contains 出现的问题 Ambiguous match found.
+ else
+ return Expression.Call(instance, instance.Type.GetMethod(methodName), arguments);
+ }
+
+ ///
+ /// 获取内部成员
+ ///
+ public static Expression Property(this Expression expression, string propertyName)
+ {
+ // Todo:左边条件如果是dynamic,
+ // 则Expression.Property无法获取子内容
+ // 报错在这里,由于expression内的对象为Object,所以无法解析到
+ // var x = (expression as IQueryable).ElementType;
+ return Expression.Property(expression, propertyName);
+ }
+
+ ///
+ /// 转Lambda
+ ///
+ public static Expression ToLambda(this Expression body,
+ params ParameterExpression[] parameters)
+ {
+ return Expression.Lambda(body, parameters);
+ }
+
+ #endregion
+
+ #region 常用运算符 [ > , >= , == , < , <= , != , || , && ]
+
+ ///
+ /// &&
+ ///
+ public static Expression AndAlso(this Expression left, Expression right)
+ {
+ return Expression.AndAlso(left, right);
+ }
+
+ ///
+ /// ||
+ ///
+ public static Expression OrElse(this Expression left, Expression right)
+ {
+ return Expression.OrElse(left, right);
+ }
+
+ ///
+ /// Contains
+ ///
+ public static Expression Contains(this Expression left, Expression right)
+ {
+ return left.Call("Contains", right);
+ }
+
+ ///
+ /// >
+ ///
+ public static Expression GreaterThan(this Expression left, Expression right)
+ {
+ return Expression.GreaterThan(left, right);
+ }
+
+ ///
+ /// >=
+ ///
+ public static Expression GreaterThanOrEqual(this Expression left, Expression right)
+ {
+ return Expression.GreaterThanOrEqual(left, right);
+ }
+
+ ///
+ /// <
+ ///
+ public static Expression LessThan(this Expression left, Expression right)
+ {
+ return Expression.LessThan(left, right);
+ }
+
+ ///
+ /// <=
+ ///
+ public static Expression LessThanOrEqual(this Expression left, Expression right)
+ {
+ return Expression.LessThanOrEqual(left, right);
+ }
+
+ ///
+ /// ==
+ ///
+ public static Expression Equal(this Expression left, Expression right)
+ {
+ return Expression.Equal(left, right);
+ }
+
+ ///
+ /// !=
+ ///
+ public static Expression NotEqual(this Expression left, Expression right)
+ {
+ return Expression.NotEqual(left, right);
+ }
+
+ #endregion
+ }
+
+ ///
+ /// Queryable扩展
+ ///
+ public static class QueryableExtensions
+ {
+ #region 自定义扩展Queryable
+
+ ///
+ /// Where扩展
+ ///
+ public static IEnumerable IWhere(this IEnumerable source, string linqStr)
+ {
+ return source.Where(DynamicLinqFactory.CreateLambda(linqStr).Compile());
+ }
+
+ ///
+ /// FirstOrDefault扩展
+ ///
+ public static TSource IFirstOrDefault(this IEnumerable source, string linqStr)
+ {
+ return source.FirstOrDefault(DynamicLinqFactory.CreateLambda(linqStr).Compile());
+ }
+
+ ///
+ /// Count扩展
+ ///
+ public static Int32 ICount(this IEnumerable source, string linqStr)
+ {
+ return source.Count(DynamicLinqFactory.CreateLambda(linqStr).Compile());
+ }
+
+ ///
+ /// 自定义排序
+ ///
+ public static IOrderedQueryable ISort(this IQueryable source, string orderByProperty, bool asc)
+ {
+ string command = asc ? "OrderBy" : "OrderByDescending";
+ var type = typeof(TSource);
+ var property = type.GetProperty(orderByProperty);
+ var parameter = Expression.Parameter(type, "p");
+ var propertyAccess = Expression.MakeMemberAccess(parameter, property);
+ var orderByExpression = Expression.Lambda(propertyAccess, parameter);
+ var resultExpression = Expression.Call(typeof(Queryable), command, new Type[] { type, property.PropertyType }, source.Expression, Expression.Quote(orderByExpression));
+ return (IOrderedQueryable)source.Provider.CreateQuery(resultExpression);
+ }
+
+ ///
+ /// 自定义分页
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IQueryable IPaging(this IQueryable source, int nowPage, int pageSize)
+ {
+ return source.ISkip((nowPage - 1) * pageSize).ITake(pageSize);
+ }
+
+ ///
+ /// 自定义Skip
+ ///
+ public static IQueryable ISkip(this IQueryable source, int count)
+ {
+ return source.Provider.CreateQuery(Expression.Call(
+ // 类别
+ typeof(Queryable),
+ // 调用的方法
+ "Skip",
+ // 元素类别
+ new Type[] { source.ElementType },
+ // 调用的表达树
+ source.Expression,
+ // 参数
+ Expression.Constant(count)));
+ }
+
+ ///
+ /// 自定义Take
+ ///
+ public static IQueryable ITake(this IQueryable source, int count)
+ {
+ return source.Provider.CreateQuery(Expression.Call(
+ // 类别
+ typeof(Queryable),
+ // 调用的方法
+ "Take",
+ // 元素类别
+ new Type[] { source.ElementType },
+ // 调用的表达树
+ source.Expression,
+ // 参数
+ Expression.Constant(count)));
+ }
+
+ ///
+ /// 自定义去重复
+ ///
+ public static IEnumerable IDistinctBy(this IEnumerable source, Func keySelector)
+ {
+ var seenKeys = new HashSet();
+ return source.Where(element => seenKeys.Add(keySelector(element)));
+ }
+
+ ///
+ /// 动态赋值
+ ///
+ public static void CopyTo(this object source, T target) where T : class, new()
+ {
+ if (source == null)
+ return;
+
+ if (target == null)
+ {
+ target = new T();
+ }
+
+ foreach (var property in target.GetType().GetProperties())
+ {
+ // 这里可以判断一下当前属性值是否为空的 source.GetType().GetProperty(property.Name).GetValue(source, null)
+ target.GetType().InvokeMember(property.Name, BindingFlags.SetProperty, null, target, new object[] { source.GetType().GetProperty(property.Name).GetValue(source, null) });
+ }
+ }
+
+ ///
+ /// 移除特殊字段数据
+ ///
+ public static void RemoveSpecialPropertyValue(this object source)
+ {
+ var properties = source.GetType().GetProperties();
+ foreach (var x in properties)
+ {
+ if (x.GetAccessors().Any(y => y.IsVirtual))
+ {
+ source.GetType().GetProperty(x.Name).SetValue(source, null, null);
+ }
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Blog.Core.Common/Helper/HttpHelper.cs b/Blog.Core.Common/Helper/HttpHelper.cs
index 54d5661..ba5ef48 100644
--- a/Blog.Core.Common/Helper/HttpHelper.cs
+++ b/Blog.Core.Common/Helper/HttpHelper.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Net;
+using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
@@ -50,7 +51,7 @@ namespace Blog.Core.Common.Helper
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
- if (encoding.Length < 1)
+ if (string.IsNullOrWhiteSpace(encoding))
{
encoding = "UTF-8"; //默认编码
}
@@ -75,14 +76,16 @@ namespace Blog.Core.Common.Helper
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
- if (encoding.Length < 1)
+ if (string.IsNullOrWhiteSpace(encoding))
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = await reader.ReadToEndAsync();
return retString;
- }
+ }
+
+
}
diff --git a/Blog.Core.Common/Helper/JsonConfigUtils.cs b/Blog.Core.Common/Helper/JsonConfigUtils.cs
index b49024b..38ceb46 100644
--- a/Blog.Core.Common/Helper/JsonConfigUtils.cs
+++ b/Blog.Core.Common/Helper/JsonConfigUtils.cs
@@ -99,7 +99,7 @@ namespace Blog.Core.Common.Helper
if (value == null)
value = defaultValue;
}
- catch (Exception ex)
+ catch (Exception)
{
value = defaultValue;
}
diff --git a/Blog.Core.Common/Helper/LinqHelper.cs b/Blog.Core.Common/Helper/LinqHelper.cs
new file mode 100644
index 0000000..de47215
--- /dev/null
+++ b/Blog.Core.Common/Helper/LinqHelper.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Linq.Expressions;
+
+namespace Blog.Core.Common.Helper
+{
+ ///
+ /// Linq操作帮助类
+ ///
+ public static class LinqHelper
+ {
+ ///
+ /// 创建初始条件为True的表达式
+ ///
+ ///
+ ///
+ public static Expression> True()
+ {
+ return x => true;
+ }
+
+ ///
+ /// 创建初始条件为False的表达式
+ ///
+ ///
+ ///
+ public static Expression> False()
+ {
+ return x => false;
+ }
+ }
+}
diff --git a/Blog.Core.Common/Helper/MD5Hepler.cs b/Blog.Core.Common/Helper/MD5Hepler.cs
index 984771b..2f87cba 100644
--- a/Blog.Core.Common/Helper/MD5Hepler.cs
+++ b/Blog.Core.Common/Helper/MD5Hepler.cs
@@ -62,6 +62,37 @@ namespace Blog.Core.Common.Helper
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
return Convert.ToBase64String(s);
}
-
+ ///
+ /// Sha1加密
+ ///
+ /// 要加密的字符串
+ /// 加密后的十六进制的哈希散列(字符串)
+ public static string Sha1(string str, string format = "x2")
+ {
+ var buffer = Encoding.UTF8.GetBytes(str);
+ var data = SHA1.Create().ComputeHash(buffer);
+ var sb = new StringBuilder();
+ foreach (var t in data)
+ {
+ sb.Append(t.ToString(format));
+ }
+ return sb.ToString();
+ }
+ ///
+ /// Sha256加密
+ ///
+ /// 要加密的字符串
+ /// 加密后的十六进制的哈希散列(字符串)
+ public static string Sha256(string str, string format = "x2")
+ {
+ var buffer = Encoding.UTF8.GetBytes(str);
+ var data = SHA256.Create().ComputeHash(buffer);
+ var sb = new StringBuilder();
+ foreach (var t in data)
+ {
+ sb.Append(t.ToString(format));
+ }
+ return sb.ToString();
+ }
}
}
diff --git a/Blog.Core.Common/Helper/WeChatHelper.cs b/Blog.Core.Common/Helper/WeChatHelper.cs
new file mode 100644
index 0000000..22cdaaf
--- /dev/null
+++ b/Blog.Core.Common/Helper/WeChatHelper.cs
@@ -0,0 +1,312 @@
+using Blog.Core.Model.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Blog.Core.Common.Helper
+{
+ ///
+ /// 微信公众号帮助类
+ ///
+ public static class WeChatHelper
+ {
+ ///
+ /// 新增素材/上传多媒体文件(临时)
+ /// http://mp.weixin.qq.com/wiki/5/963fc70b80dc75483a271298a76a8d59.html
+ /// 1.上传的媒体文件限制:
+ ///图片(image) : 1MB,支持JPG格式
+ ///语音(voice):1MB,播放长度不超过60s,支持MP4格式
+ ///视频(video):10MB,支持MP4格式
+ ///缩略图(thumb):64KB,支持JPG格式
+ ///2.媒体文件在后台保存时间为3天,即3天后media_id失效
+ ///
+ ///
+ /// 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)
+ /// 文件名
+ /// 文件输入流
+ /// media_id
+ public async static Task UploadMediaTemp(string token, string type, string fileName, Stream inputStream)
+ {
+ var url = $"http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token={token}&type={type}";
+ using var client = new HttpClient();
+ using HttpContent content = new StreamContent(inputStream);
+ var httpResponse = await client.PostAsync(url, content);
+ var txt = await httpResponse.Content.ReadAsStringAsync();
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 新增素材/上传多媒体文件(永久)
+ /// http://mp.weixin.qq.com/wiki/5/963fc70b80dc75483a271298a76a8d59.html
+ /// 1.上传的媒体文件限制:
+ ///图片(image) : 1MB,支持JPG格式
+ ///语音(voice):1MB,播放长度不超过60s,支持MP4格式
+ ///视频(video):10MB,支持MP4格式
+ ///缩略图(thumb):64KB,支持JPG格式
+ ///
+ ///
+ /// 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)
+ /// 文件名
+ /// 文件输入流
+ /// media_id
+ public async static Task UploadMedia(string token, string type, string fileName, Stream inputStream)
+ {
+ var url = $"https://api.weixin.qq.com/cgi-bin/material/add_material?access_token={token}&type={type}";
+ using var client = new HttpClient();
+ using HttpContent content = new StreamContent(inputStream);
+ var httpResponse = await client.PostAsync(url, content);
+ var txt = await httpResponse.Content.ReadAsStringAsync();
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 通过绑定票据获取公众号关注二维码
+ ///
+ ///
+ ///
+ public async static Task GetQRCodePicture(string ticket)
+ {
+ string url = $"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={ticket}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 获取临时关注二维码
+ ///
+ /// The token.
+ /// The post data.
+ public async static Task GetQRCode(string token, string jsonData)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={token}";
+ var txt = await HttpHelper.PostAsync(url, jsonData);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 获取关注的公众号用户openid(获取所有OpenID)
+ ///
+ /// The token.
+ /// 是否递归获取所有用户的
+ /// List<System.String>.
+ public async static Task GetUsers(string token,bool isGetAll=false)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/user/get?access_token={token}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ if (data.data == null) data.data = new WeChatOpenIDsDto();
+ if(!string.IsNullOrEmpty(data.next_openid))
+ await GetUsers(token, data.next_openid, data.data.openid);
+ return data;
+ }
+ ///
+ /// 获取关注的公众号用户openid(递归)
+ ///
+ /// The token.
+ /// The next user.
+ /// The users.
+ public async static Task GetUsers(string token, string nextUser, List users)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/user/get?access_token={token}&next_openid={nextUser}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ if (data.data != null && data.data.openid != null)
+ users.AddRange(data.data.openid);
+ if (!string.IsNullOrEmpty(data.next_openid))
+ await GetUsers(token, data.next_openid, data.data.openid);
+ }
+ ///
+ /// 获取菜单内容(获取菜单有menu外层,提交菜单不需要menu外层)
+ ///
+ /// The token.
+ /// System.String.
+ public async static Task GetMenu(string token)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/menu/get?access_token={token}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 转换微信菜单按钮为事件的按钮
+ ///
+ public static void ConverMenuButtonForEvent(WeChatApiDto weChatApiDto)
+ {
+ foreach (var item in weChatApiDto?.menu?.button)
+ {
+ if (item.key.ObjToString().Equals("event") || item.type.ObjToString().Equals("event"))
+ {
+ var temp = item.type;
+ item.type = item.key;
+ item.key = temp;
+ }
+ if (item.sub_button != null)
+ {
+ ConverMenuButtonForEvent(item.sub_button);
+ }
+ }
+ }
+ ///
+ /// 转换微信菜单按钮为事件的按钮
+ ///
+ public static void ConverMenuButtonForEvent(WeChatMenuButtonDto[] weChatMenuButtonDto)
+ {
+ foreach (var item in weChatMenuButtonDto)
+ {
+ if (item.key.ObjToString().Equals("event") || item.type.ObjToString().Equals("event"))
+ {
+ var temp = item.type;
+ item.type = item.key;
+ item.key = temp;
+ }
+ if (item.sub_button != null)
+ {
+ ConverMenuButtonForEvent(item.sub_button);
+ }
+ }
+ }
+ ///
+ /// 设置菜单内容(设置菜单不需要menu外层)
+ ///
+ /// The token.
+ /// The json menu.
+ /// System.String.
+ public async static Task SetMenu(string token, string jsonMenu)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/menu/create?access_token={token}";
+ var txt = await HttpHelper.PostAsync(url, jsonMenu);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 删除菜单内容
+ ///
+ /// The token.
+ /// true if XXXX, false otherwise.
+ public async static Task DeleteMenu(string token)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/menu/delete?access_token={token}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 发送普通消息(群发所有人,单人发送也可以)
+ ///
+ /// The token.
+ /// The json data.
+ /// System.String.
+ public async static Task SendMsgToAll(string token, string jsonData)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token={token}";
+ var txt = await HttpHelper.PostAsync(url, jsonData);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 发送普通消息(单个人-24小时内用户跟微信公众号有互动才会推送成功)
+ ///
+ /// The token.
+ /// The json data.
+ /// System.String.
+ public async static Task SendMsg(string token, string jsonData)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={token}";
+ var txt = await HttpHelper.PostAsync(url, jsonData);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 发送卡片消息模板
+ ///
+ /// The token.
+ /// The json data.
+ /// true if XXXX, false otherwise.
+ public async static Task SendCardMsg(string token, string jsonData)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={token}";
+ var txt = await HttpHelper.PostAsync(url, jsonData);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 拉取普通access_token
+ ///
+ /// appid
+ /// appsecret
+ /// 返回token
+ public async static Task GetToken(string appid, string appsecret)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={appsecret}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 获取微信服务器IP列表
+ ///
+ /// The token.
+ /// System.String.
+ public async static Task GetWechatIP(string token)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token={token}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// openid获取微信用户信息
+ ///
+ /// The token.
+ /// The openid.
+ /// Dictionary<System.String, System.Object>.
+ public async static Task GetUserInfo(string token,string openid)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/user/info?access_token={token}&openid={openid}&lang=zh_CN";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// openid获取微信用户信息
+ ///
+ /// The openid.
+ /// The access token.
+ public async static Task GetUserInfoTwo(string token,string openid)
+ {
+ string url = $"https://api.weixin.qq.com/sns/userinfo?access_token={token}&openid={openid}&lang=zh_CN";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// code换取用户openID
+ ///
+ /// The appid.
+ /// The appsecret.
+ /// The code.
+ /// Dictionary<System.String, System.Object>.
+ public async static Task GetOpenidByCode(string appid, string appsecret, string code)
+ {
+ string url = $"https://api.weixin.qq.com/sns/oauth2/access_token?appid={appid}&secret={appsecret}&code={code}&grant_type=authorization_code";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ ///
+ /// 获取模板消息
+ ///
+ /// The token.
+ /// Dictionary<System.String, System.Object>.
+ public async static Task GetTemplate(string token)
+ {
+ string url = $"https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token={token}";
+ var txt = await HttpHelper.GetAsync(url);
+ var data = JsonHelper.ParseFormByJson(txt);
+ return data;
+ }
+ }
+}
diff --git a/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs b/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs
index 8378853..c3d15f5 100644
--- a/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs
+++ b/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs
@@ -13,7 +13,7 @@ namespace Blog.Core.Extensions
///
public static class AppConfigSetup
{
- public static void AddAppConfigSetup(this IServiceCollection services, IWebHostEnvironment env)
+ public static void AddAppConfigSetup(this IServiceCollection services, IHostEnvironment env)
{
if (services == null) throw new ArgumentNullException(nameof(services));
diff --git a/Blog.Core.IServices/BASE/IBaseServices.cs b/Blog.Core.IServices/BASE/IBaseServices.cs
index 1797786..dbc242c 100644
--- a/Blog.Core.IServices/BASE/IBaseServices.cs
+++ b/Blog.Core.IServices/BASE/IBaseServices.cs
@@ -57,6 +57,7 @@ namespace Blog.Core.IServices.BASE
Expression> joinExpression,
Expression> selectExpression,
Expression> whereLambda = null) where T : class, new();
+ Task> QueryPage(PaginationModel pagination);
}
}
diff --git a/Blog.Core.IServices/IWeChatCompanyServices.cs b/Blog.Core.IServices/IWeChatCompanyServices.cs
new file mode 100644
index 0000000..b47ac45
--- /dev/null
+++ b/Blog.Core.IServices/IWeChatCompanyServices.cs
@@ -0,0 +1,16 @@
+using Blog.Core.IServices.BASE;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using System.Threading.Tasks;
+
+namespace Blog.Core.IServices
+{
+ ///
+ /// IWeChatCompanyServices
+ ///
+ public interface IWeChatCompanyServices : IBaseServices
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.IServices/IWeChatConfigServices.cs b/Blog.Core.IServices/IWeChatConfigServices.cs
new file mode 100644
index 0000000..68f9f61
--- /dev/null
+++ b/Blog.Core.IServices/IWeChatConfigServices.cs
@@ -0,0 +1,102 @@
+using Blog.Core.IServices.BASE;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using System.Threading.Tasks;
+
+namespace Blog.Core.IServices
+{
+ ///
+ /// IWeChatConfigServices
+ ///
+ public interface IWeChatConfigServices :IBaseServices
+ {
+ ///
+ /// 获取可用的微信token
+ ///
+ ///
+ ///
+ Task> GetToken(string id);
+ ///
+ /// 刷新微信token
+ ///
+ ///
+ ///
+ Task> RefreshToken(string id);
+ ///
+ /// 获取模板信息
+ ///
+ ///
+ ///
+ Task> GetTemplate(string id);
+ ///
+ /// 获取菜单
+ ///
+ ///
+ ///
+ Task> GetMenu(string id);
+ ///
+ /// 获取订阅用户
+ ///
+ ///
+ ///
+ ///
+ Task> GetSubUser(string id,string openid);
+ ///
+ /// 获取订阅用户列表
+ ///
+ ///
+ Task> GetSubUsers(string id);
+ ///
+ /// 处理微信事件
+ ///
+ ///
+ ///
+ Task HandleWeChat(WeChatXMLDto weChat);
+ ///
+ /// 微信验证入库
+ ///
+ ///
+ ///
+ ///
+
+ Task Valid(WeChatValidDto validDto,string body);
+ ///
+ /// 获取绑定二维码
+ ///
+ ///
+ ///
+ Task> GetQRBind(WeChatUserInfo info);
+ ///
+ /// 推送卡片消息(绑定用户)
+ ///
+ ///
+ ///
+ ///
+ Task> PushCardMsg(WeChatCardMsgDataDto msg,string ip);
+ ///
+ /// 推送文本消息(绑定或订阅)
+ ///
+ ///
+ ///
+ Task> PushTxtMsg(WeChatPushTestDto msg);
+ ///
+ /// 更新菜单
+ ///
+ ///
+ ///
+ Task> UpdateMenu(WeChatApiDto menu);
+ ///
+ /// 通过绑定用户获取微信用户信息
+ ///
+ ///
+ ///
+ Task> GetBindUserInfo(WeChatUserInfo info);
+ ///
+ /// 解除绑定用户
+ ///
+ ///
+ ///
+ Task> UnBind(WeChatUserInfo info);
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.IServices/IWeChatPushLogServices.cs b/Blog.Core.IServices/IWeChatPushLogServices.cs
new file mode 100644
index 0000000..0063209
--- /dev/null
+++ b/Blog.Core.IServices/IWeChatPushLogServices.cs
@@ -0,0 +1,16 @@
+using Blog.Core.IServices.BASE;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using System.Threading.Tasks;
+
+namespace Blog.Core.IServices
+{
+ ///
+ /// IWeChatPushLogServices
+ ///
+ public interface IWeChatPushLogServices : IBaseServices
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.IServices/IWeChatSubServices.cs b/Blog.Core.IServices/IWeChatSubServices.cs
new file mode 100644
index 0000000..3ad954d
--- /dev/null
+++ b/Blog.Core.IServices/IWeChatSubServices.cs
@@ -0,0 +1,16 @@
+using Blog.Core.IServices.BASE;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using System.Threading.Tasks;
+
+namespace Blog.Core.IServices
+{
+ ///
+ /// IWeChatSubServices
+ ///
+ public interface IWeChatSubServices : IBaseServices
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Model/Models/Advertisement.cs b/Blog.Core.Model/Models/Advertisement.cs
index 568a0c1..c2babd7 100644
--- a/Blog.Core.Model/Models/Advertisement.cs
+++ b/Blog.Core.Model/Models/Advertisement.cs
@@ -9,25 +9,25 @@ namespace Blog.Core.Model.Models
///
/// 广告图片
///
- [SugarColumn(Length = 512, IsNullable = true, ColumnDataType = "nvarchar")]
+ [SugarColumn(Length = 512, IsNullable = true)]
public string ImgUrl { get; set; }
///
/// 广告标题
///
- [SugarColumn(Length = 64, IsNullable = true, ColumnDataType = "nvarchar")]
+ [SugarColumn(Length = 64, IsNullable = true)]
public string Title { get; set; }
///
/// 广告链接
///
- [SugarColumn(Length = 256, IsNullable = true, ColumnDataType = "nvarchar")]
+ [SugarColumn(Length = 256, IsNullable = true)]
public string Url { get; set; }
///
/// 备注
///
- [SugarColumn(Length = 2000, IsNullable = true, ColumnDataType = "nvarchar")]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Remark { get; set; }
///
diff --git a/Blog.Core.Model/Models/BlogArticle.cs b/Blog.Core.Model/Models/BlogArticle.cs
index 19235da..5217619 100644
--- a/Blog.Core.Model/Models/BlogArticle.cs
+++ b/Blog.Core.Model/Models/BlogArticle.cs
@@ -17,25 +17,25 @@ namespace Blog.Core.Model.Models
///
/// 创建人
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 600, IsNullable = true)]
+ [SugarColumn(Length = 600, IsNullable = true)]
public string bsubmitter { get; set; }
///
/// 标题blog
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 256, IsNullable = true)]
+ [SugarColumn(Length = 256, IsNullable = true)]
public string btitle { get; set; }
///
/// 类别
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string bcategory { get; set; }
///
/// 内容
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string bcontent { get; set; }
///
@@ -60,7 +60,7 @@ namespace Blog.Core.Model.Models
///
/// 备注
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string bRemark { get; set; }
///
diff --git a/Blog.Core.Model/Models/Guestbook.cs b/Blog.Core.Model/Models/Guestbook.cs
index ee31572..d1f671c 100644
--- a/Blog.Core.Model/Models/Guestbook.cs
+++ b/Blog.Core.Model/Models/Guestbook.cs
@@ -15,29 +15,29 @@ namespace Blog.Core.Model.Models
///
public DateTime createdate { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string username { get; set; }
/// 手机
///
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string phone { get; set; }
/// qq
///
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string QQ { get; set; }
/// 留言内容
///
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string body { get; set; }
/// ip地址
///
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string ip { get; set; }
/// 是否显示在前台,0否1是
diff --git a/Blog.Core.Model/Models/ModulePermission.cs b/Blog.Core.Model/Models/ModulePermission.cs
index 6d1a9ea..7425200 100644
--- a/Blog.Core.Model/Models/ModulePermission.cs
+++ b/Blog.Core.Model/Models/ModulePermission.cs
@@ -23,7 +23,7 @@ namespace Blog.Core.Model.Models
///
/// 创建者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string CreateBy { get; set; }
///
/// 创建时间
@@ -38,7 +38,7 @@ namespace Blog.Core.Model.Models
///
/// 修改者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string ModifyBy { get; set; }
///
///修改时间
diff --git a/Blog.Core.Model/Models/Modules.cs b/Blog.Core.Model/Models/Modules.cs
index 2ecb21f..b62c0a4 100644
--- a/Blog.Core.Model/Models/Modules.cs
+++ b/Blog.Core.Model/Models/Modules.cs
@@ -25,37 +25,37 @@ namespace Blog.Core.Model.Models
///
/// 名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string Name { get; set; }
///
/// 菜单链接地址
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string LinkUrl { get; set; }
///
/// 区域名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Area { get; set; }
///
/// 控制器名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Controller { get; set; }
///
/// Action名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Action { get; set; }
///
/// 图标
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string Icon { get; set; }
///
/// 菜单编号
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 10, IsNullable = true)]
+ [SugarColumn(Length = 10, IsNullable = true)]
public string Code { get; set; }
///
/// 排序
@@ -64,7 +64,7 @@ namespace Blog.Core.Model.Models
///
/// /描述
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string Description { get; set; }
///
/// 是否是右侧菜单
@@ -82,7 +82,7 @@ namespace Blog.Core.Model.Models
///
/// 创建者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string CreateBy { get; set; }
///
/// 创建时间
@@ -97,7 +97,7 @@ namespace Blog.Core.Model.Models
///
/// 修改者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string ModifyBy { get; set; }
///
/// 修改时间
diff --git a/Blog.Core.Model/Models/OperateLog.cs b/Blog.Core.Model/Models/OperateLog.cs
index 7f60dc3..5d9cfe1 100644
--- a/Blog.Core.Model/Models/OperateLog.cs
+++ b/Blog.Core.Model/Models/OperateLog.cs
@@ -17,27 +17,27 @@ namespace Blog.Core.Model.Models
///
/// 区域名
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Area { get; set; }
///
/// 区域控制器名
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Controller { get; set; }
///
/// Action名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Action { get; set; }
///
/// IP地址
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string IPAddress { get; set; }
///
/// 描述
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string Description { get; set; }
///
/// 登录时间
@@ -47,7 +47,7 @@ namespace Blog.Core.Model.Models
///
/// 登录名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string LoginName { get; set; }
///
/// 用户ID
diff --git a/Blog.Core.Model/Models/PasswordLib.cs b/Blog.Core.Model/Models/PasswordLib.cs
index 5164085..a5e458d 100644
--- a/Blog.Core.Model/Models/PasswordLib.cs
+++ b/Blog.Core.Model/Models/PasswordLib.cs
@@ -18,13 +18,13 @@ namespace Blog.Core.Model.Models
[SugarColumn(IsNullable = true)]
public bool? IsDeleted { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string plURL { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string plPWD { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string plAccountName { get; set; }
[SugarColumn(IsNullable = true)]
@@ -33,10 +33,10 @@ namespace Blog.Core.Model.Models
[SugarColumn(IsNullable = true)]
public int? plErrorCount { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string plHintPwd { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string plHintquestion { get; set; }
[SugarColumn(IsNullable = true)]
@@ -48,7 +48,7 @@ namespace Blog.Core.Model.Models
[SugarColumn(IsNullable = true)]
public DateTime? plLastErrTime { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string test { get; set; }
diff --git a/Blog.Core.Model/Models/Permission.cs b/Blog.Core.Model/Models/Permission.cs
index f20e503..a8240d1 100644
--- a/Blog.Core.Model/Models/Permission.cs
+++ b/Blog.Core.Model/Models/Permission.cs
@@ -18,12 +18,12 @@ namespace Blog.Core.Model.Models
///
/// 菜单执行Action名
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string Code { get; set; }
///
/// 菜单显示名(如用户页、编辑(按钮)、删除(按钮))
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string Name { get; set; }
///
/// 是否是按钮
@@ -44,7 +44,7 @@ namespace Blog.Core.Model.Models
///
/// 按钮事件
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string Func { get; set; }
///
@@ -54,12 +54,12 @@ namespace Blog.Core.Model.Models
///
/// 菜单图标
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string Icon { get; set; }
///
/// 菜单描述
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string Description { get; set; }
///
/// 激活状态
@@ -73,7 +73,7 @@ namespace Blog.Core.Model.Models
///
/// 创建者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string CreateBy { get; set; }
///
/// 创建时间
@@ -88,7 +88,7 @@ namespace Blog.Core.Model.Models
///
/// 修改者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string ModifyBy { get; set; }
///
/// 修改时间
diff --git a/Blog.Core.Model/Models/Role.cs b/Blog.Core.Model/Models/Role.cs
index 0f08cc1..0d53783 100644
--- a/Blog.Core.Model/Models/Role.cs
+++ b/Blog.Core.Model/Models/Role.cs
@@ -34,12 +34,12 @@ namespace Blog.Core.Model.Models
///
/// 角色名
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string Name { get; set; }
///
///描述
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]
+ [SugarColumn(Length = 100, IsNullable = true)]
public string Description { get; set; }
///
///排序
@@ -57,7 +57,7 @@ namespace Blog.Core.Model.Models
///
/// 创建者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string CreateBy { get; set; }
///
/// 创建时间
diff --git a/Blog.Core.Model/Models/RoleModulePermission.cs b/Blog.Core.Model/Models/RoleModulePermission.cs
index 6670559..13d82a8 100644
--- a/Blog.Core.Model/Models/RoleModulePermission.cs
+++ b/Blog.Core.Model/Models/RoleModulePermission.cs
@@ -30,7 +30,7 @@ namespace Blog.Core.Model.Models
///
/// 创建者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string CreateBy { get; set; }
///
/// 创建时间
@@ -45,7 +45,7 @@ namespace Blog.Core.Model.Models
///
/// 修改者
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string ModifyBy { get; set; }
///
/// 修改时间
diff --git a/Blog.Core.Model/Models/TasksQz.cs b/Blog.Core.Model/Models/TasksQz.cs
index 8cc53d2..5c812f7 100644
--- a/Blog.Core.Model/Models/TasksQz.cs
+++ b/Blog.Core.Model/Models/TasksQz.cs
@@ -13,32 +13,32 @@ namespace Blog.Core.Model.Models
///
/// 任务名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string Name { get; set; }
///
/// 任务分组
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string JobGroup { get; set; }
///
/// 任务运行时间表达式
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string Cron { get; set; }
///
/// 任务所在DLL对应的程序集名称
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string AssemblyName { get; set; }
///
/// 任务所在类
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string ClassName { get; set; }
///
/// 任务描述
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 1000, IsNullable = true)]
+ [SugarColumn(Length = 1000, IsNullable = true)]
public string Remark { get; set; }
///
/// 执行次数
diff --git a/Blog.Core.Model/Models/Topic.cs b/Blog.Core.Model/Models/Topic.cs
index 258d545..16bf7da 100644
--- a/Blog.Core.Model/Models/Topic.cs
+++ b/Blog.Core.Model/Models/Topic.cs
@@ -14,19 +14,19 @@ namespace Blog.Core.Model.Models
this.TopicDetail = new List();
this.tUpdatetime = DateTime.Now;
}
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tLogo { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tName { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 400, IsNullable = true)]
+ [SugarColumn(Length = 400, IsNullable = true)]
public string tDetail { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tAuthor { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tSectendDetail { get; set; }
public bool tIsDelete { get; set; }
diff --git a/Blog.Core.Model/Models/TopicDetail.cs b/Blog.Core.Model/Models/TopicDetail.cs
index 1f35278..f2f19a3 100644
--- a/Blog.Core.Model/Models/TopicDetail.cs
+++ b/Blog.Core.Model/Models/TopicDetail.cs
@@ -13,19 +13,19 @@ namespace Blog.Core.Model.Models
this.tdUpdatetime = DateTime.Now;
}
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tdLogo { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tdName { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string tdContent { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string tdDetail { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tdSectendDetail { get; set; }
public bool tdIsDelete { get; set; } = false;
@@ -36,7 +36,7 @@ namespace Blog.Core.Model.Models
public DateTime tdUpdatetime { get; set; }
public int tdTop { get; set; }
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string tdAuthor { get; set; }
diff --git a/Blog.Core.Model/Models/UserRole.cs b/Blog.Core.Model/Models/UserRole.cs
index a3bb168..996eea2 100644
--- a/Blog.Core.Model/Models/UserRole.cs
+++ b/Blog.Core.Model/Models/UserRole.cs
@@ -35,7 +35,7 @@ namespace Blog.Core.Model.Models
///
/// 创建者
///
- [SugarColumn(ColumnDataType ="nvarchar",Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string CreateBy { get; set; }
///
/// 创建时间
@@ -50,7 +50,7 @@ namespace Blog.Core.Model.Models
///
/// 修改者
///
- [SugarColumn(ColumnDataType ="nvarchar",Length = 50, IsNullable = true)]
+ [SugarColumn(Length = 50, IsNullable = true)]
public string ModifyBy { get; set; }
///
/// 修改时间
diff --git a/Blog.Core.Model/Models/WeChatCompany.cs b/Blog.Core.Model/Models/WeChatCompany.cs
new file mode 100644
index 0000000..d07d420
--- /dev/null
+++ b/Blog.Core.Model/Models/WeChatCompany.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Blog.Core.Model.Models
+{
+ ///
+ ///
+ ///
+ [SugarTable("WeChatCompany")]
+ public partial class WeChatCompany
+ {
+
+ ///
+ /// 公司ID
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 100, IsNullable = false)]
+ public string CompanyID { get; set; }
+ ///
+ /// 公司名称
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string CompanyName { get; set; }
+ ///
+ /// 公司IP
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string CompanyIP { get; set; }
+ ///
+ /// 公司备注
+ ///
+ [SugarColumn(Length = 200, IsNullable = false)]
+ public string CompanyRemark { get; set; }
+ ///
+ /// api地址
+ ///
+ [SugarColumn(Length = 200, IsNullable = false)]
+ public string CompanyAPI { get; set; }
+ ///
+ /// 是否激活
+ ///
+ public bool Enabled { get; set; }
+ ///
+ /// 创建者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CreateId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string CreateBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 修改者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ModifyId { get; set; }
+ ///
+ /// 修改人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string ModifyBy { get; set; }
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/Models/WeChatConfig.cs b/Blog.Core.Model/Models/WeChatConfig.cs
new file mode 100644
index 0000000..f0aa97c
--- /dev/null
+++ b/Blog.Core.Model/Models/WeChatConfig.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Blog.Core.Model.Models
+{
+ ///
+ ///
+ ///
+ [SugarTable("WeChatConfig")]
+ public class WeChatConfig
+ {
+
+ ///
+ /// 微信公众号唯一标识
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 100, IsNullable = false)]
+ public string publicAccount { get; set; }
+
+ ///
+ /// 微信公众号名称
+ ///
+ [SugarColumn(Length = 200, IsNullable = false)]
+ public string publicNick { get; set; }
+
+ ///
+ /// 微信账号
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string weChatAccount { get; set; }
+
+ ///
+ /// 微信名称
+ ///
+ [SugarColumn(Length = 200)]
+ public string weChatNick { get; set; }
+
+ ///
+ /// 应用ID
+ ///
+ [SugarColumn(Length = 100)]
+ public string appid { get; set; }
+
+ ///
+ /// 应用秘钥
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string appsecret { get; set; }
+
+ ///
+ /// 公众号推送token
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string token { get; set; }
+
+ ///
+ /// 验证秘钥(验证消息是否真实)
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string interactiveToken { get; set; }
+
+ ///
+ /// 微信公众号token过期时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? tokenExpiration { get; set; }
+
+ ///
+ /// 备注
+ ///
+ [SugarColumn(Length = 200,IsNullable = true)]
+ public string remark { get; set; }
+ ///
+ /// 是否激活
+ ///
+ public bool Enabled { get; set; }
+
+ ///
+ /// 创建者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CreateId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string CreateBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 修改者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ModifyId { get; set; }
+ ///
+ /// 修改人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string ModifyBy { get; set; }
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/Models/WeChatPushLog.cs b/Blog.Core.Model/Models/WeChatPushLog.cs
new file mode 100644
index 0000000..b2b6752
--- /dev/null
+++ b/Blog.Core.Model/Models/WeChatPushLog.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Blog.Core.Model.Models
+{
+ ///
+ ///
+ ///
+ [SugarTable("WeChatPushLog")]
+ public partial class WeChatPushLog
+ {
+
+ ///
+ /// 推送ID
+ ///
+ [SugarColumn(IsPrimaryKey = true,IsNullable = false)]
+ public string id { get; set; }
+ ///
+ /// 来自谁
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string PushLogFrom { get; set; }
+
+ ///
+ /// 推送IP
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string PushLogIP { get; set; }
+
+ ///
+ /// 推送客户
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string PushLogCompanyID { get; set; }
+
+ ///
+ /// 推送用户
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string PushLogToUserID { get; set; }
+
+ ///
+ /// 推送模板ID
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string PushLogTemplateID { get; set; }
+
+ ///
+ /// 推送内容
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string PushLogContent { get; set; }
+
+ ///
+ /// 推送时间
+ ///
+ [SugarColumn(IsNullable = false)]
+ public DateTime? PushLogTime { get; set; }
+
+ ///
+ /// 推送状态(Y/N)
+ ///
+ [SugarColumn(Length =1,IsNullable = false)]
+ public string PushLogStatus { get; set; }
+
+ ///
+ /// 备注
+ ///
+ [SugarColumn(Length = 200, IsNullable = false)]
+ public string PushLogRemark { get; set; }
+
+ ///
+ /// 推送OpenID
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string PushLogOpenid { get; set; }
+
+ ///
+ /// 推送微信公众号
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string PushLogPublicAccount { get; set; }
+ ///
+ /// 创建者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CreateId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string CreateBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 修改者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ModifyId { get; set; }
+ ///
+ /// 修改人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string ModifyBy { get; set; }
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/Models/WeChatQR.cs b/Blog.Core.Model/Models/WeChatQR.cs
new file mode 100644
index 0000000..6df0bcb
--- /dev/null
+++ b/Blog.Core.Model/Models/WeChatQR.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Blog.Core.Model.Models
+{
+ ///
+ ///
+ ///
+ [SugarTable("WeChatQR")]
+ public partial class WeChatQR
+ {
+
+ ///
+ /// 主键id,ticket
+ ///
+ [SugarColumn(Length = 200,IsPrimaryKey =true, IsNullable = false)]
+ public string QRticket { get; set; }
+
+ ///
+ /// 需要绑定的公司
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string QRbindCompanyID { get; set; }
+
+ ///
+ /// 需要绑定的员工id
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string QRbindJobID { get; set; }
+ ///
+ /// 需要绑定的员工昵称
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string QRbindJobNick { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime QRcrateTime { get; set; }
+
+ ///
+ /// 关联的公众号
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string QRpublicAccount { get; set; }
+
+ ///
+ /// 是否已使用
+ ///
+ public bool QRisUsed { get; set; }
+
+ ///
+ /// 使用时间
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public DateTime? QRuseTime { get; set; }
+
+ ///
+ /// 关联的微信用户id
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string QRuseOpenid { get; set; }
+ ///
+ /// 创建者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CreateId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string CreateBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 修改者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ModifyId { get; set; }
+ ///
+ /// 修改人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string ModifyBy { get; set; }
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/Models/WeChatSub.cs b/Blog.Core.Model/Models/WeChatSub.cs
new file mode 100644
index 0000000..48787a5
--- /dev/null
+++ b/Blog.Core.Model/Models/WeChatSub.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Blog.Core.Model.Models
+{
+ ///
+ ///
+ ///
+ [SugarTable("WeChatSub")]
+ public partial class WeChatSub
+ {
+ [SugarColumn(IsNullable = false,IsPrimaryKey = true)]
+ public string id { get; set; }
+ ///
+ /// 来自哪个公众号
+ ///
+ [SugarColumn(Length = 100 , IsNullable = false, IndexGroupNameList = new string[] { "index" })]
+ public string SubFromPublicAccount { get; set; }
+
+ ///
+ /// 绑定公司id
+ ///
+ [SugarColumn(Length = 100 , IsNullable = false, IndexGroupNameList = new string[] { "index" })]
+ public string CompanyID { get; set; }
+
+ ///
+ /// 绑定员工id
+ ///
+ [SugarColumn(Length = 100 , IsNullable = false, IndexGroupNameList = new string[] { "index" })]
+ public string SubJobID { get; set; }
+
+ ///
+ /// 绑定微信id
+ ///
+ [SugarColumn(Length = 100, IsNullable = false)]
+ public string SubUserOpenID { get; set; }
+
+ ///
+ /// 绑定微信联合id
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string SubUserUnionID { get; set; }
+
+ ///
+ /// 绑定时间
+ ///
+ public DateTime SubUserRegTime { get; set; }
+
+ ///
+ /// 更新时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? SubUserRefTime { get; set; }
+
+ ///
+ /// 备注
+ ///
+ [SugarColumn(Length = 200, IsNullable = true)]
+ public string SubUserRemark { get; set; }
+
+ ///
+ /// 是否已解绑
+ ///
+ public bool IsUnBind { get; set; }
+
+ ///
+ /// 上次绑定微信id
+ ///
+ [SugarColumn(Length = 100, IsNullable = true)]
+ public string LastSubUserOpenID { get; set; }
+ ///
+ /// 创建者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CreateId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string CreateBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 修改者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ModifyId { get; set; }
+ ///
+ /// 修改人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string ModifyBy { get; set; }
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/Models/WeChatUploadFile.cs b/Blog.Core.Model/Models/WeChatUploadFile.cs
new file mode 100644
index 0000000..f7b979d
--- /dev/null
+++ b/Blog.Core.Model/Models/WeChatUploadFile.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Blog.Core.Model.Models
+{
+ ///
+ ///
+ ///
+ [SugarTable("WeChatUploadFile")]
+ public partial class WeChatUploadFile
+ {
+
+ ///
+ /// 文件ID
+ ///
+ [SugarColumn(Length = 100,IsPrimaryKey = true,IsNullable =false)]
+ public string UploadFileID { get; set; }
+
+ ///
+ /// 文件名称
+ ///
+ [SugarColumn(Length = 200, IsNullable = false)]
+ public string UploadFileName { get; set; }
+
+ ///
+ /// 文件大小
+ ///
+ [SugarColumn(IsNullable = false)]
+ public int? UploadFileSize { get; set; }
+
+ ///
+ /// 文件类型
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string UploadFileContentType { get; set; }
+
+ ///
+ /// 文件拓展名
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string UploadFileExtension { get; set; }
+
+ ///
+ /// 文件位置
+ ///
+ [SugarColumn(Length = 200, IsNullable = true)]
+ public string UploadFilePosition { get; set; }
+
+ ///
+ /// 文件上传时间
+ ///
+ public DateTime? UploadFileTime { get; set; }
+
+ ///
+ /// 文件备注
+ ///
+ [SugarColumn(Length = 200, IsNullable = true)]
+ public string UploadFileRemark { get; set; }
+ ///
+ /// 创建者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CreateId { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string CreateBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 修改者id
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ModifyId { get; set; }
+ ///
+ /// 修改人
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string ModifyBy { get; set; }
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ModifyTime { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/Models/sysUserInfo.cs b/Blog.Core.Model/Models/sysUserInfo.cs
index 65b3716..6b8e74e 100644
--- a/Blog.Core.Model/Models/sysUserInfo.cs
+++ b/Blog.Core.Model/Models/sysUserInfo.cs
@@ -28,17 +28,17 @@ namespace Blog.Core.Model.Models
///
/// 登录账号
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string uLoginName { get; set; }
///
/// 登录密码
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string uLoginPWD { get; set; }
///
/// 真实姓名
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string uRealName { get; set; }
///
/// 状态
@@ -47,7 +47,7 @@ namespace Blog.Core.Model.Models
///
/// 备注
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)]
+ [SugarColumn(Length = 2000, IsNullable = true)]
public string uRemark { get; set; }
///
/// 创建时间
@@ -73,7 +73,7 @@ namespace Blog.Core.Model.Models
///
/// 登录账号
///
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string name { get; set; }
// 性别
@@ -86,7 +86,7 @@ namespace Blog.Core.Model.Models
[SugarColumn(IsNullable = true)]
public DateTime birth { get; set; } = DateTime.Now;
// 地址
- [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)]
+ [SugarColumn(Length = 200, IsNullable = true)]
public string addr { get; set; }
[SugarColumn(IsNullable = true)]
diff --git a/Blog.Core.Model/PaginationModel.cs b/Blog.Core.Model/PaginationModel.cs
new file mode 100644
index 0000000..3afee0b
--- /dev/null
+++ b/Blog.Core.Model/PaginationModel.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model
+{
+ ///
+ /// 所需分页参数
+ /// 作者:胡丁文
+ /// 时间:2020-4-3 20:31:26
+ ///
+ public class PaginationModel
+ {
+ ///
+ /// 当前页
+ ///
+ public int intPageIndex { get; set; } = 1;
+ ///
+ /// 每页大小
+ ///
+ public int intPageSize { get; set; } = 10;
+ ///
+ /// 排序字段(例如:id desc,time asc)
+ ///
+ public string strOrderByFileds { get; set; }
+ ///
+ /// 查询条件( 例如:id = 1 and name = 小明)
+ ///
+ public string conditions { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatApiDto.cs b/Blog.Core.Model/ViewModels/WeChatApiDto.cs
new file mode 100644
index 0000000..e02a55b
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatApiDto.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信接口消息DTO
+ /// 作者:胡丁文
+ /// 时间:2020-03-25
+ ///
+ public class WeChatApiDto
+ {
+ ///
+ /// 微信公众号ID(数据库查询)
+ ///
+ public string id { get; set; }
+ ///
+ /// 错误代码
+ ///
+ public int errcode { get; set; }
+ ///
+ /// 错误信息
+ ///
+ public string errmsg { get; set; }
+
+
+ ///
+ /// token
+ ///
+ public string access_token { get; set; }
+ ///
+ /// 过期时间(秒)
+ ///
+ public int expires_in { get; set; }
+
+
+ ///
+ /// 用户关注数
+ ///
+ public int total { get; set; }
+ ///
+ /// 获取用户数量
+ ///
+ public int count { get; set; }
+ ///
+ /// 获取用户OpenIDs
+ ///
+ public WeChatOpenIDsDto data { get; set; }
+ public List users { get; set; }
+ ///
+ /// 下一个关注用户
+ ///
+ public string next_openid { get; set; }
+
+ ///
+ /// 微信消息模板列表
+ ///
+
+ public WeChatTemplateList[] template_list { get; set; }
+ ///
+ /// 微信菜单
+ ///
+ public WeChatMenuDto menu { get; set; }
+
+ ///
+ /// 二维码票据
+ ///
+ public string ticket { get; set; }
+ ///
+ /// 二维码过期时间
+ ///
+ public int expire_seconds { get; set; }
+ ///
+ /// 二维码地址
+ ///
+ public string url { get; set; }
+ ///
+ /// 关注状态
+ ///
+ public string subscribe { get; set; }
+ ///
+ /// 用户微信ID
+ ///
+ public string openid { get; set; }
+ ///
+ /// 昵称
+ ///
+ public string nickname { get; set; }
+ ///
+ /// 性别
+ ///
+ public int sex { get; set; }
+ ///
+ /// 语言
+ ///
+ public string language { get; set; }
+ ///
+ /// 城市
+ ///
+ public string city { get; set; }
+ ///
+ /// 省份
+ ///
+ public string province { get; set; }
+ ///
+ /// 城市
+ ///
+ public string country { get; set; }
+ ///
+ /// 头像地址
+ ///
+ public string headimgurl { get; set; }
+
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatCardMsgDataDto.cs b/Blog.Core.Model/ViewModels/WeChatCardMsgDataDto.cs
new file mode 100644
index 0000000..2448bdd
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatCardMsgDataDto.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信推送消息Dto
+ /// 作者:胡丁文
+ /// 时间:2020-4-8 09:16:16
+ ///
+ public class WeChatCardMsgDataDto
+ {
+ ///
+ /// 推送关键信息
+ ///
+ public WeChatUserInfo info { get; set; }
+ ///
+ /// 推送卡片消息Dto
+ ///
+ public WeChatCardMsgDetailDto cardMsg { set; get; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatCardMsgDataOpenIDDto.cs b/Blog.Core.Model/ViewModels/WeChatCardMsgDataOpenIDDto.cs
new file mode 100644
index 0000000..e90e5f4
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatCardMsgDataOpenIDDto.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信推送消息Dto
+ /// 作者:胡丁文
+ /// 时间:2020-11-23 16:29:05
+ ///
+ public class WeChatCardMsgDataOpenIDDto
+ {
+ ///
+ /// 推送关键信息
+ ///
+ public WeChatUserInfoOpenID info { get; set; }
+ ///
+ /// 推送卡片消息Dto
+ ///
+ public WeChatCardMsgDetailDto cardMsg { set; get; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatCardMsgDetailDto.cs b/Blog.Core.Model/ViewModels/WeChatCardMsgDetailDto.cs
new file mode 100644
index 0000000..17db8c9
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatCardMsgDetailDto.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 消息模板dto(如何填写数据,请参考微信模板即可)
+ /// 作者:胡丁文
+ /// 时间:2020-4-1 09:32:16
+ ///
+ public class WeChatCardMsgDetailDto
+ {
+ ///
+ /// 消息模板
+ ///
+ public string template_id { get; set; }
+ ///
+ /// 标题
+ ///
+ public string first { get; set; }
+ ///
+ /// 标题颜色(颜色代码都必须为#开头的16进制代码)
+ ///
+ public string colorFirst { get; set; } = "#173177";
+ ///
+ /// 内容1
+ ///
+ public string keyword1 { get; set; }
+ ///
+ /// 内容1颜色
+ ///
+
+ public string color1 { get; set; } = "#173177";
+ ///
+ /// 内容2
+ ///
+ public string keyword2 { get; set; }
+ ///
+ /// 内容2颜色
+ ///
+ public string color2 { get; set; } = "#173177";
+ ///
+ /// 内容3
+ ///
+ public string keyword3 { get; set; }
+ ///
+ /// 内容3颜色
+ ///
+ public string color3 { get; set; } = "#173177";
+ ///
+ /// 内容4
+ ///
+ public string keyword4 { get; set; }
+ ///
+ /// 内容4颜色
+ ///
+ public string color4 { get; set; } = "#173177";
+ ///
+ /// 内容5
+ ///
+ public string keyword5 { get; set; }
+ ///
+ /// 内容5颜色
+ ///
+ public string color5 { get; set; } = "#173177";
+ ///
+ /// 备注信息
+ ///
+ public string remark { get; set; }
+ ///
+ /// 备注信息颜色
+ ///
+ public string colorRemark { get; set; } = "#173177";
+ ///
+ /// 跳转连接
+ ///
+ public string url { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatMenuButtonDto.cs b/Blog.Core.Model/ViewModels/WeChatMenuButtonDto.cs
new file mode 100644
index 0000000..df8952c
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatMenuButtonDto.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 获取微信菜单DTO,用于存放具体菜单内容
+ ///
+ public class WeChatMenuButtonDto
+ {
+ public string type { get; set; }
+ public string name { get; set; }
+ public string key { get; set; }
+ public string url { get; set; }
+ public WeChatMenuButtonDto[] sub_button { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatMenuDto.cs b/Blog.Core.Model/ViewModels/WeChatMenuDto.cs
new file mode 100644
index 0000000..3015a2a
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatMenuDto.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 获取微信菜单DTO
+ ///
+ public class WeChatMenuDto
+ {
+ ///
+ /// 按钮列表(最多三个)
+ ///
+ public WeChatMenuButtonDto[] button { get; set; }
+
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatOpenIDsDto.cs b/Blog.Core.Model/ViewModels/WeChatOpenIDsDto.cs
new file mode 100644
index 0000000..93c1349
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatOpenIDsDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信OpenID列表Dto
+ ///
+ public class WeChatOpenIDsDto
+ {
+ public List openid { get; set; } = new List();
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushCardMsgDetailDto.cs b/Blog.Core.Model/ViewModels/WeChatPushCardMsgDetailDto.cs
new file mode 100644
index 0000000..b203dac
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushCardMsgDetailDto.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 推送详细数据
+ /// 作者:胡丁文
+ /// 时间:2020-4-8 09:16:16
+ ///
+ public class WeChatPushCardMsgDetailDto
+ {
+ public WeChatPushCardMsgValueColorDto first { get; set; }
+ public WeChatPushCardMsgValueColorDto keyword1 { get; set; }
+ public WeChatPushCardMsgValueColorDto keyword2 { get; set; }
+ public WeChatPushCardMsgValueColorDto keyword3 { get; set; }
+ public WeChatPushCardMsgValueColorDto keyword4 { get; set; }
+ public WeChatPushCardMsgValueColorDto keyword5 { get; set; }
+ public WeChatPushCardMsgValueColorDto remark { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushCardMsgDto.cs b/Blog.Core.Model/ViewModels/WeChatPushCardMsgDto.cs
new file mode 100644
index 0000000..588ee09
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushCardMsgDto.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 推送给微信所需Dto
+ /// 作者:胡丁文
+ /// 时间:2020-4-8 09:16:16
+ ///
+ public class WeChatPushCardMsgDto
+ {
+ ///
+ /// 推送微信用户ID
+ ///
+ public string touser { get; set; }
+ ///
+ /// 推送的模板ID
+ ///
+ public string template_id { get; set; }
+ ///
+ /// 推送URL地址
+ ///
+ public string url { get; set; }
+ ///
+ /// 推送的数据
+ ///
+ public WeChatPushCardMsgDetailDto data { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushCardMsgValueColorDto.cs b/Blog.Core.Model/ViewModels/WeChatPushCardMsgValueColorDto.cs
new file mode 100644
index 0000000..e9548fd
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushCardMsgValueColorDto.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信keyword所需Dto
+ /// 作者:胡丁文
+ /// 时间:2020-4-8 09:18:08
+ ///
+ public class WeChatPushCardMsgValueColorDto
+ {
+ ///
+ /// 内容
+ ///
+ public string value { get; set; }
+ ///
+ /// 文字颜色
+ ///
+ public string color { get; set; } = "#173177";
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushLinkMsgContentDto.cs b/Blog.Core.Model/ViewModels/WeChatPushLinkMsgContentDto.cs
new file mode 100644
index 0000000..064eaab
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushLinkMsgContentDto.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ public class WeChatPushLinkMsgContentDto
+ {
+ ///
+ /// 图文链接标题
+ ///
+ public string title { get; set; }
+ ///
+ /// 图文描述
+ ///
+ public string description { get; set; }
+ ///
+ /// 访问URL
+ ///
+ public string viewUrl { get; set; }
+ ///
+ /// 图片URL
+ ///
+ public string pictureUrl { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushPictureContentDto.cs b/Blog.Core.Model/ViewModels/WeChatPushPictureContentDto.cs
new file mode 100644
index 0000000..3b29681
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushPictureContentDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ public class WeChatPushPictureContentDto
+ {
+ ///
+ /// 图片mediaID
+ ///
+ public string pictureMediaID { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushTestDto.cs b/Blog.Core.Model/ViewModels/WeChatPushTestDto.cs
new file mode 100644
index 0000000..a906fb8
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushTestDto.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 推送模拟消息Dto
+ /// 作者:胡丁文
+ /// 时间:2020-4-24 14:52:44
+ ///
+ public class WeChatPushTestDto
+ {
+ ///
+ /// 当前选中的微信公众号
+ ///
+ public string selectWeChat { get; set; }
+ ///
+ /// 当前选中的操作集合
+ ///
+ public string selectOperate { get; set; }
+ ///
+ /// 当前选中的绑定还是订阅
+ ///
+ public string selectBindOrSub { get; set; }
+ ///
+ /// 当前选中的微信客户
+ ///
+ public string selectCompany { get; set; }
+ ///
+ /// 当前选中的消息类型
+ ///
+ public string selectMsgType { get; set; }
+ ///
+ /// 当前选中要发送的用户
+ ///
+ public string selectUser { get; set; }
+ ///
+ /// 文本消息
+ ///
+ public WeChatPushTextContentDto textContent { get; set; }
+ ///
+ /// 图片消息
+ ///
+ public WeChatPushPictureContentDto pictureContent { get; set; }
+ ///
+ /// 语音消息
+ ///
+ public WeChatPushVoiceContentDto voiceContent { get; set; }
+ ///
+ /// 视频消息
+ ///
+ public WeChatPushVideoContentDto videoContent { get; set; }
+ ///
+ /// 链接消息
+ ///
+ public WeChatPushLinkMsgContentDto linkMsgContent { get; set; }
+
+
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushTextContentDto.cs b/Blog.Core.Model/ViewModels/WeChatPushTextContentDto.cs
new file mode 100644
index 0000000..55d6cc5
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushTextContentDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ public class WeChatPushTextContentDto
+ {
+ ///
+ /// 文字消息
+ ///
+ public string text { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushVideoContentDto.cs b/Blog.Core.Model/ViewModels/WeChatPushVideoContentDto.cs
new file mode 100644
index 0000000..a00ad6c
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushVideoContentDto.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ public class WeChatPushVideoContentDto
+ {
+ ///
+ /// 视频标题
+ ///
+ public string title { get; set; }
+ ///
+ /// 视频封面mediaID
+ ///
+ public string pictureMediaID { get; set; }
+ ///
+ /// 视频mediaID
+ ///
+ public string videoMediaID { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatPushVoiceContentDto.cs b/Blog.Core.Model/ViewModels/WeChatPushVoiceContentDto.cs
new file mode 100644
index 0000000..1a9da49
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatPushVoiceContentDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ public class WeChatPushVoiceContentDto
+ {
+ ///
+ /// 语音mediaID
+ ///
+ public string voiceMediaID { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatQRActionDto.cs b/Blog.Core.Model/ViewModels/WeChatQRActionDto.cs
new file mode 100644
index 0000000..13001b6
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatQRActionDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信二维码预装发送信息dto
+ ///
+ public class WeChatQRActionDto
+ {
+ public WeChatQRActionInfoDto scene { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatQRActionInfoDto.cs b/Blog.Core.Model/ViewModels/WeChatQRActionInfoDto.cs
new file mode 100644
index 0000000..ba38072
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatQRActionInfoDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信二维码预装具体消息
+ ///
+ public class WeChatQRActionInfoDto
+ {
+ public string scene_str { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatQRDto.cs b/Blog.Core.Model/ViewModels/WeChatQRDto.cs
new file mode 100644
index 0000000..eca876f
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatQRDto.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信二维码预装信息DTO
+ ///
+ public class WeChatQRDto
+ {
+ public int expire_seconds { get; set; }
+ public string action_name { get; set; }
+ public WeChatQRActionDto action_info { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatResponseUserInfo.cs b/Blog.Core.Model/ViewModels/WeChatResponseUserInfo.cs
new file mode 100644
index 0000000..9d28fe5
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatResponseUserInfo.cs
@@ -0,0 +1,28 @@
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 返回给调用者的Dto
+ /// 作者:胡丁文
+ /// 时间:2020-4-8 09:52:06
+ ///
+ public class WeChatResponseUserInfo
+ {
+ ///
+ /// 微信公众号ID
+ ///
+ public string id { get; set; }
+ ///
+ /// 公司代码
+ ///
+ public string companyCode { get; set; }
+ ///
+ /// 数据
+ ///
+ public WeChatApiDto usersData { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatTemplateList.cs b/Blog.Core.Model/ViewModels/WeChatTemplateList.cs
new file mode 100644
index 0000000..820266f
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatTemplateList.cs
@@ -0,0 +1,15 @@
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信消息模板Dto
+ ///
+ public class WeChatTemplateList
+ {
+ public string template_id { get; set; }
+ public string title { get; set; }
+ public string primary_industry { get; set; }
+ public string deputy_industry { get; set; }
+ public string content { get; set; }
+ public string example { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatUserInfo.cs b/Blog.Core.Model/ViewModels/WeChatUserInfo.cs
new file mode 100644
index 0000000..faf65b1
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatUserInfo.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信推送所需信息(公司版本)
+ /// 作者:胡丁文
+ /// 时间:2020-4-8 09:04:36
+ ///
+ public class WeChatUserInfo
+ {
+ ///
+ /// 微信公众号ID
+ ///
+ public string id { get; set; }
+ ///
+ /// 公司代码
+ ///
+ public string companyCode { get; set; }
+ ///
+ /// 用户id
+ ///
+ public string userID { get; set; }
+ ///
+ /// 用户昵称
+ ///
+ public string userNick { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatUserInfoOpenID.cs b/Blog.Core.Model/ViewModels/WeChatUserInfoOpenID.cs
new file mode 100644
index 0000000..ef01aad
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatUserInfoOpenID.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信推送所需信息(OpenID版本)
+ /// 作者:胡丁文
+ /// 时间:2020-11-23 16:27:29
+ ///
+ public class WeChatUserInfoOpenID
+ {
+ ///
+ /// 微信公众号ID
+ ///
+ public string id { get; set; }
+ ///
+ /// 微信OpenID
+ ///
+ public List userID { get; set; }
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatValidDto.cs b/Blog.Core.Model/ViewModels/WeChatValidDto.cs
new file mode 100644
index 0000000..c0d038d
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatValidDto.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml.Serialization;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信验证Dto
+ /// 作者:胡丁文
+ /// 时间:2020-4-1 21:34:07
+ ///
+ public class WeChatValidDto
+ {
+ ///
+ /// 微信公众号唯一标识
+ ///
+ public string publicAccount { get; set; }
+ ///
+ /// 验证成功后返回给微信的字符串
+ ///
+ public string echoStr { get; set; }
+ ///
+ /// 签名
+ ///
+ public string signature { get; set; }
+ ///
+ /// 时间戳
+ ///
+ public string timestamp { get; set; }
+ ///
+ /// 随机数
+ ///
+ public string nonce { get; set; }
+
+ }
+}
diff --git a/Blog.Core.Model/ViewModels/WeChatXMLDto.cs b/Blog.Core.Model/ViewModels/WeChatXMLDto.cs
new file mode 100644
index 0000000..e293849
--- /dev/null
+++ b/Blog.Core.Model/ViewModels/WeChatXMLDto.cs
@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace Blog.Core.Model.ViewModels
+{
+ ///
+ /// 微信XmlDto
+ /// 作者:胡丁文
+ /// 时间:2020-4-3 20:31:26
+ ///
+ [XmlRoot(ElementName ="xml")]
+ public class WeChatXMLDto
+ {
+ ///
+ /// 微信公众号唯一表示
+ ///
+ public string publicAccount { get; set; }
+ ///
+ /// 微信开发者
+ ///
+ public string ToUserName { get; set; }
+ ///
+ /// 来自谁
+ ///
+ public string FromUserName { get; set; }
+ ///
+ /// 创建时间
+ ///
+ public string CreateTime { get; set; }
+ ///
+ /// 消息类型
+ ///
+ public string MsgType { get; set; }
+ ///
+ /// 文字内容
+ ///
+ public string Content { get; set; }
+ ///
+ /// 消息ID
+ ///
+ public string MsgId { get; set; }
+ ///
+ /// 消息事件
+ ///
+ public string Event { get; set; }
+ ///
+ /// 事件key值
+ ///
+ public string EventKey { get; set; }
+ ///
+ /// 图片地址
+ ///
+ public string PicUrl { get; set; }
+ ///
+ /// 多媒体ID
+ ///
+ public string MediaId { get; set; }
+ ///
+ /// 格式
+ ///
+ public string Format { get; set; }
+ ///
+ /// 语音失败
+ ///
+ public string Recognition { get; set; }
+ ///
+ /// 缩略媒体ID
+ ///
+ public string ThumbMediaId { get; set; }
+ ///
+ /// 地理位置维度
+ ///
+ public string Location_X { get; set; }
+ ///
+ /// 地理位置经度
+ ///
+ public string Location_Y { get; set; }
+ ///
+ /// 地图缩放大小
+ ///
+ public string Scale { get; set; }
+ ///
+ /// 地理位置信息
+ ///
+ public string Label { get; set; }
+ ///
+ /// 消息标题
+ ///
+ public string Title { get; set; }
+ ///
+ /// 消息描述
+ ///
+ public string Description { get; set; }
+ ///
+ /// 消息链接
+ ///
+ public string Url { get; set; }
+ ///
+ /// 二维码的ticket,可用来换取二维码图片
+ ///
+ public string Ticket { get; set; }
+ ///
+ /// 地理位置纬度
+ ///
+ public string Latitude { get; set; }
+ ///
+ /// 地理位置经度
+ ///
+ public string Longitude { get; set; }
+ ///
+ /// 地理位置精度
+ ///
+ public string Precision { get; set; }
+ }
+}
diff --git a/Blog.Core.Serilog.Es/HttpInfo/ParamsHelper.cs b/Blog.Core.Serilog.Es/HttpInfo/ParamsHelper.cs
index 3b39c0b..fbbd9e3 100644
--- a/Blog.Core.Serilog.Es/HttpInfo/ParamsHelper.cs
+++ b/Blog.Core.Serilog.Es/HttpInfo/ParamsHelper.cs
@@ -72,7 +72,7 @@ namespace Blog.Core.Serilog.Es.HttpInfo
}
return data;
}
- catch(Exception ex)
+ catch(Exception)
{
return string.Empty;
}
diff --git a/Blog.Core.Services/BASE/BaseServices.cs b/Blog.Core.Services/BASE/BaseServices.cs
index ba55308..d110b58 100644
--- a/Blog.Core.Services/BASE/BaseServices.cs
+++ b/Blog.Core.Services/BASE/BaseServices.cs
@@ -1,4 +1,5 @@
-using Blog.Core.IRepository.Base;
+using Blog.Core.Common.Helper;
+using Blog.Core.IRepository.Base;
using Blog.Core.IServices.BASE;
using Blog.Core.Model;
using SqlSugar;
@@ -317,6 +318,11 @@ namespace Blog.Core.Services.BASE
{
return await BaseDal.QueryMuch(joinExpression, selectExpression, whereLambda);
}
+ public async Task> QueryPage(PaginationModel pagination)
+ {
+ var express = DynamicLinqFactory.CreateLambda(pagination.conditions);
+ return await QueryPage(express, pagination.intPageIndex, pagination.intPageSize, pagination.strOrderByFileds);
+ }
}
}
diff --git a/Blog.Core.Services/WeChatCompanyServices.cs b/Blog.Core.Services/WeChatCompanyServices.cs
new file mode 100644
index 0000000..c44ff0c
--- /dev/null
+++ b/Blog.Core.Services/WeChatCompanyServices.cs
@@ -0,0 +1,34 @@
+using Blog.Core.Common;
+using Blog.Core.Common.Helper;
+using Blog.Core.IRepository.Base;
+using Blog.Core.IRepository.UnitOfWork;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using Blog.Core.Services.BASE;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Blog.Core.Services
+{
+ ///
+ /// WeChatCompanyServices
+ ///
+ public class WeChatCompanyServices : BaseServices, IWeChatCompanyServices
+ {
+ readonly IBaseRepository _dal;
+ readonly IUnitOfWork _unitOfWork;
+ readonly ILogger _logger;
+ public WeChatCompanyServices(IBaseRepository dal,IUnitOfWork unitOfWork, ILogger logger)
+ {
+ this._dal = dal;
+ base.BaseDal = dal;
+ this._unitOfWork = unitOfWork;
+ this._logger = logger;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Services/WeChatConfigServices.cs b/Blog.Core.Services/WeChatConfigServices.cs
new file mode 100644
index 0000000..a268a31
--- /dev/null
+++ b/Blog.Core.Services/WeChatConfigServices.cs
@@ -0,0 +1,906 @@
+using Blog.Core.Common;
+using Blog.Core.Common.Helper;
+using Blog.Core.IRepository.Base;
+using Blog.Core.IRepository.UnitOfWork;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using Blog.Core.Services.BASE;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Blog.Core.Services
+{
+ ///
+ /// WeChatConfigServices
+ ///
+ public class WeChatConfigServices : BaseServices, IWeChatConfigServices
+ {
+ readonly IBaseRepository _dal;
+ readonly IUnitOfWork _unitOfWork;
+ readonly ILogger _logger;
+ public WeChatConfigServices(IBaseRepository dal,IUnitOfWork unitOfWork, ILogger logger)
+ {
+ this._dal = dal;
+ base.BaseDal = dal;
+ this._unitOfWork = unitOfWork;
+ this._logger = logger;
+ }
+ public async Task> GetToken(string publicAccount)
+ {
+ var config = await this.QueryById(publicAccount);
+ if (config == null) MessageModel.Success($"公众号{publicAccount}未维护至系统");//还没过期,直接返回
+ if (config.tokenExpiration > DateTime.Now)
+ {
+ //再次判断token在微信服务器是否正确
+ var wechatIP = await WeChatHelper.GetWechatIP(config.token);
+ if (wechatIP.errcode == 0)
+ MessageModel.Success("", new WeChatApiDto { access_token = config.token });//还没过期,直接返回
+ }
+ //过期了,重新获取
+ var data = await WeChatHelper.GetToken(config.appid, config.appsecret);
+ if (data.errcode.Equals(0))
+ {
+ config.token = data.access_token;
+ config.tokenExpiration = DateTime.Now.AddSeconds(data.expires_in);
+ await this.Update(config);
+ return MessageModel.Success("",data);
+ }
+ else
+ {
+ return MessageModel.Fail($"\r\n获取Token失败\r\n错误代码:{data.errcode}\r\n错误信息:{data.errmsg}");
+ }
+ }
+ public async Task> RefreshToken(string publicAccount)
+ {
+ var config = await this.QueryById(publicAccount);
+ if (config == null) MessageModel.Success($"公众号{publicAccount}未维护至系统");//还没过期,直接返回
+ //过期了,重新获取
+ var data = await WeChatHelper.GetToken(config.appid, config.appsecret);
+ if (data.errcode.Equals(0))
+ {
+ config.token = data.access_token;
+ config.tokenExpiration = DateTime.Now.AddSeconds(data.expires_in);
+ await this.Update(config);
+ return MessageModel.Success("", data);
+ }
+ else
+ {
+ return MessageModel.Fail($"\r\n获取Token失败\r\n错误代码:{data.errcode}\r\n错误信息:{data.errmsg}");
+ }
+ }
+ public async Task> GetTemplate(string id)
+ {
+ var res = await GetToken(id);
+ if (!res.success) return res;
+ var data = await WeChatHelper.GetTemplate(res.response.access_token);
+ if (data.errcode.Equals(0))
+ {
+ return MessageModel.Success("", data);
+ }
+ else
+ {
+ return MessageModel.Success($"\r\n获取模板失败\r\n错误代码:{data.errcode}\r\n错误信息:{data.errmsg}", data);
+ }
+ }
+ ///
+ /// 获取菜单
+ ///
+ ///
+ ///
+ public async Task> GetMenu(string id)
+ {
+ var res = await GetToken(id);
+ if (!res.success) return res;
+ var data = await WeChatHelper.GetMenu(res.response.access_token);
+ if (data.errcode.Equals(0))
+ {
+ return MessageModel.Success("", data);
+ }
+ else
+ {
+ return MessageModel.Success($"\r\n获取菜单失败\r\n错误代码:{data.errcode}\r\n错误信息:{data.errmsg}", data);
+ }
+ }
+ public async Task> GetSubUsers(string id)
+ {
+ var res = await GetToken(id);
+ if (!res.success) return res;
+ var data = await WeChatHelper.GetUsers(res.response.access_token);
+ if (data.errcode.Equals(0))
+ {
+ data.users = new List();
+ foreach (var openid in data.data.openid)
+ {
+ data.users.Add(await WeChatHelper.GetUserInfo(res.response.access_token, openid));
+ }
+ return MessageModel.Success("", data);
+ }
+ else
+ {
+ return MessageModel.Success($"\r\n获取订阅用户失败\r\n错误代码:{data.errcode}\r\n错误信息:{data.errmsg}", data);
+ }
+ }
+ public async Task> GetSubUser(string id,string openid)
+ {
+ var res = await GetToken(id);
+ if (!res.success) return res;
+ var data = await WeChatHelper.GetUserInfo(res.response.access_token,openid);
+ if (data.errcode.Equals(0))
+ {
+ return MessageModel.Success("", data);
+ }
+ else
+ {
+ return MessageModel.Success($"\r\n获取订阅用户失败\r\n错误代码:{data.errcode}\r\n错误信息:{data.errmsg}", data);
+ }
+ }
+ public async Task Valid(WeChatValidDto validDto,string body)
+ {
+ WeChatXMLDto weChatData = null;
+ string objReturn = null;
+ try
+ {
+ _logger.LogInformation("会话开始");
+ if (string.IsNullOrEmpty(validDto.publicAccount)) throw new Exception("没有微信公众号唯一标识id数据");
+ var config = await QueryById(validDto.publicAccount);
+ if (config == null) throw new Exception($"公众号不存在=>{validDto.publicAccount}");
+ _logger.LogInformation(JsonHelper.GetJSON(validDto));
+ var token = config.interactiveToken;//验证用的token 和access_token不一样
+ string[] arrTmp = { token, validDto.timestamp, validDto.nonce };
+ Array.Sort(arrTmp);
+ string combineString = string.Join("", arrTmp);
+ string encryption = MD5Helper.Sha1(combineString).ToLower();
+
+ _logger.LogInformation(
+ $"来自公众号:{validDto.publicAccount}\r\n" +
+ $"微信signature:{validDto.signature}\r\n" +
+ $"微信timestamp:{validDto.timestamp}\r\n" +
+ $"微信nonce:{validDto.nonce}\r\n" +
+ $"合并字符串:{combineString}\r\n" +
+ $"微信服务器signature:{validDto.signature}\r\n" +
+ $"本地服务器signature:{encryption}"
+ );
+ if (encryption == validDto.signature)
+ {
+ //判断是首次验证还是交互?
+ if (string.IsNullOrEmpty(validDto.echoStr))
+ {
+ //非首次验证
+ weChatData = XmlHelper.ParseFormByXml(body, "xml");
+ weChatData.publicAccount = validDto.publicAccount;
+ objReturn = await HandleWeChat(weChatData);
+ }
+ else
+ {
+ //首次接口地址验证
+ objReturn = validDto.echoStr;
+ }
+ }
+ else
+ {
+ objReturn = "签名验证失败";
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"会话出错(信息)=>\r\n{ex.Message}");
+ _logger.LogInformation($"会话出错(堆栈)=>\r\n{ex.StackTrace}");
+ //返回错误给用户
+ objReturn = string.Format(@$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ ");
+ }
+ finally
+ {
+ _logger.LogInformation($"微信get数据=>\r\n{JsonHelper.GetJSON(validDto)}");
+ _logger.LogInformation($"微信post数据=>\r\n{body}");
+ _logger.LogInformation($"返回微信数据=>\r\n{objReturn}");
+ _logger.LogInformation($"会话结束");
+ }
+ return objReturn;
+ }
+ public async Task> GetQRBind(WeChatUserInfo info)
+ {
+ var res = await GetToken(info?.id);
+ if (!res.success) return MessageModel.Fail(res.msg);
+ var push = new WeChatQRDto
+ {
+ expire_seconds = 604800,
+ action_name = "QR_STR_SCENE",
+ action_info = new WeChatQRActionDto
+ {
+ scene = new WeChatQRActionInfoDto
+ {
+ scene_str = $"bind_{info?.id}"
+ }
+ }
+ };
+ WeChatResponseUserInfo reData = new WeChatResponseUserInfo();
+ reData.companyCode = info.companyCode;
+ reData.id = info.id;
+ var pushJosn = JsonHelper.GetJSON(push);
+ var data = await WeChatHelper.GetQRCode(res.response.access_token, pushJosn);
+ WeChatQR weChatQR = new WeChatQR
+ {
+ QRbindCompanyID = info.companyCode,
+ QRbindJobID = info.userID,
+ QRbindJobNick = info.userNick,
+ QRcrateTime = DateTime.Now,
+ QRpublicAccount = info.id,
+ QRticket = data.ticket
+ };
+ data.id = info.userID;
+ await this._dal.Db.Insertable(weChatQR).ExecuteCommandAsync();
+ reData.usersData= data;
+ return MessageModel.Success("获取二维码成功", reData);
+ }
+ public async Task> PushCardMsg(WeChatCardMsgDataDto msg,string ip)
+ {
+ var bindUser = await _dal.Db.Queryable().Where(t => t.SubFromPublicAccount == msg.info.id && t.CompanyID == msg.info.companyCode && t.IsUnBind == false && msg.info.userID.Contains(t.SubJobID)).SingleAsync();
+ if (bindUser == null)
+ return MessageModel.Fail("用户不存在或者已经解绑!");
+ var res = await GetToken(msg?.info?.id);
+ if(!res.success)
+ return MessageModel.Fail(res.msg);
+ WeChatResponseUserInfo reData = new WeChatResponseUserInfo();
+ reData.companyCode = msg.info.companyCode;
+ reData.id = msg.info.id;
+ try
+ {
+ var pushData = new WeChatPushCardMsgDto
+ {
+ template_id = msg.cardMsg.template_id,
+ url = msg.cardMsg.url,
+ touser = bindUser.SubUserOpenID,
+ data = new WeChatPushCardMsgDetailDto
+ {
+ first = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.first,
+ color = msg.cardMsg.color1
+ },
+ keyword1 = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.keyword1,
+ color = msg.cardMsg.color1
+ },
+ keyword2 = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.keyword2,
+ color = msg.cardMsg.color2
+ },
+ keyword3 = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.keyword3,
+ color = msg.cardMsg.color3
+ },
+ keyword4 = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.keyword4,
+ color = msg.cardMsg.color4
+ },
+ keyword5 = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.keyword5,
+ color = msg.cardMsg.color5
+ },
+ remark = new WeChatPushCardMsgValueColorDto
+ {
+ value = msg.cardMsg.remark,
+ color = msg.cardMsg.colorRemark
+ }
+ }
+ };
+ var pushJson = JsonHelper.GetJSON(pushData);
+ var data = await WeChatHelper.SendCardMsg(res.response.access_token, pushJson);
+ reData.usersData = data;
+ try
+ {
+ var pushLog = new WeChatPushLog
+ {
+ PushLogCompanyID = msg.info.companyCode,
+ PushLogPublicAccount = msg.info.id,
+ PushLogContent = pushJson,
+ PushLogOpenid = bindUser.SubUserOpenID,
+ PushLogToUserID = bindUser.SubJobID,
+ PushLogStatus = data.errcode == 0 ? "Y" : "N",
+ PushLogRemark = data.errmsg,
+ PushLogTime = DateTime.Now,
+ PushLogTemplateID = msg.cardMsg.template_id,
+ PushLogIP = ip
+ };
+ await _dal.Db.Insertable(pushLog).ExecuteCommandAsync();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"记录失败\r\n{ex.Message}\r\n{ex.StackTrace}");
+ }
+ if (reData.usersData.errcode.Equals(0))
+ {
+ return MessageModel.Success("卡片消息推送成功", reData);
+ }
+ else
+ {
+ return MessageModel.Success("卡片消息推送失败", reData);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ return MessageModel.Success($"卡片消息推送错误=>{ex.Message}", reData);
+ }
+
+ }
+
+ public async Task> PushTxtMsg(WeChatPushTestDto msg) {
+ var res = await GetToken(msg.selectWeChat);
+ if (!res.success) return res;
+ var token = res.response.access_token;
+ if (msg.selectBindOrSub.Equals("sub"))
+ {
+ return await PushText(token, msg);
+ }
+ else
+ {
+ MessageModel messageModel = new MessageModel();
+ messageModel.success = true;
+ //绑定用户
+ if (msg.selectOperate.Equals("one"))
+ {
+ //发送单个
+ var usrs = _dal.Db.Queryable().Where(t => t.SubFromPublicAccount.Equals(msg.selectWeChat) && t.CompanyID.Equals(msg.selectCompany) && t.SubJobID.Equals(msg.selectUser)).ToList();
+ foreach (var item in usrs)
+ {
+ msg.selectUser = item.SubUserOpenID;
+ var info = await PushText(token, msg);
+ if (!info.success)
+ {
+ messageModel.success = false;
+ }
+ messageModel.msg += info.msg;
+ }
+ }
+ else
+ {
+ //发送所有
+ var usrs = _dal.Db.Queryable().Where(t => t.SubFromPublicAccount.Equals(msg.selectWeChat) && t.CompanyID.Equals(msg.selectCompany)).ToList();
+ foreach (var item in usrs)
+ {
+ msg.selectUser = item.SubUserOpenID;
+ var info = await PushText(token, msg);
+ if (!info.success)
+ {
+ messageModel.success = false;
+ }
+ messageModel.msg += info.msg;
+ }
+ }
+ return messageModel;
+ }
+
+ }
+ public async Task> PushText(string token,WeChatPushTestDto msg) {
+
+ object data = null; ;
+ WeChatApiDto pushres = null; ;
+ //订阅用户
+ switch (msg.selectMsgType)
+ {
+ case "text":
+ //发送文本
+ data = new
+ {
+ filter = new
+ {
+ is_to_all = msg.selectOperate.Equals("one") ? false : true,
+ tag_id = 0,
+ },
+ touser = msg.selectUser,
+ msgtype = msg.selectMsgType,
+ text = new
+ {
+ content = msg.textContent.text
+ }
+ };
+
+ if (msg.selectOperate.Equals("one"))
+ {
+ pushres = await WeChatHelper.SendMsg(token, JsonHelper.ObjToJson(data));
+ }
+ else
+ {
+ pushres = await WeChatHelper.SendMsgToAll(token, JsonHelper.ObjToJson(data));
+ }
+ break;
+ case "image":
+ //发送图片
+ data = new
+ {
+ filter = new
+ {
+ is_to_all = msg.selectOperate.Equals("one") ? false : true,
+ tag_id = 0,
+ },
+ touser = msg.selectUser,
+ msgtype = msg.selectMsgType,
+ images = new
+ {
+ media_ids = new List {
+ msg.pictureContent.pictureMediaID
+ },
+ recommend = "xxx",
+ need_open_comment = 1,
+ only_fans_can_comment = 0
+ }
+ };
+ if (msg.selectOperate.Equals("one"))
+ {
+ pushres = await WeChatHelper.SendMsg(token, JsonHelper.ObjToJson(data));
+ }
+ else
+ {
+ pushres = await WeChatHelper.SendMsgToAll(token, JsonHelper.ObjToJson(data));
+ }
+ break;
+ case "voice":
+ //发送音频
+ data = new
+ {
+ filter = new
+ {
+ is_to_all = msg.selectOperate.Equals("one") ? false : true,
+ tag_id = 0,
+ },
+ touser = msg.selectUser,
+ msgtype = msg.selectMsgType,
+ voice = new
+ {
+ media_id = msg.voiceContent.voiceMediaID
+ }
+ };
+ if (msg.selectOperate.Equals("one"))
+ {
+ pushres = await WeChatHelper.SendMsg(token, JsonHelper.ObjToJson(data));
+ }
+ else
+ {
+ pushres = await WeChatHelper.SendMsgToAll(token, JsonHelper.ObjToJson(data));
+ }
+ break;
+ case "mpvideo":
+ //发送视频
+ data = new
+ {
+ filter = new
+ {
+ is_to_all = msg.selectOperate.Equals("one") ? false : true,
+ tag_id = 0,
+ },
+ touser = msg.selectUser,
+ msgtype = msg.selectMsgType,
+ mpvideo = new
+ {
+ media_id = msg.videoContent.videoMediaID,
+ }
+ };
+ if (msg.selectOperate.Equals("one"))
+ {
+ pushres = await WeChatHelper.SendMsg(token, JsonHelper.ObjToJson(data));
+ }
+ else
+ {
+ pushres = await WeChatHelper.SendMsgToAll(token, JsonHelper.ObjToJson(data));
+ }
+ break;
+ default:
+ pushres = new WeChatApiDto() { errcode = -1, errmsg = $"未找到推送类型{msg.selectMsgType}" };
+ break;
+ }
+ if (pushres.errcode.Equals(0))
+ {
+ return MessageModel.Success("推送成功", pushres);
+
+ }
+ else
+ {
+ return MessageModel.Fail($"\r\n推送失败\r\n错误代码:{pushres.errcode}\r\n错误信息:{pushres.errmsg}", pushres);
+ }
+ }
+ public async Task> UpdateMenu(WeChatApiDto menu)
+ {
+ WeChatHelper.ConverMenuButtonForEvent(menu);
+ var res = await GetToken(menu.id);
+ if (!res.success) return res;
+ var data = await WeChatHelper.SetMenu(res.response.access_token, JsonHelper.ObjToJson(menu.menu));
+ if (data.errcode.Equals(0))
+ {
+
+ return MessageModel.Success("更新成功", data);
+ }
+ else
+ {
+ return MessageModel.Success("更新失败", data);
+ }
+ }
+ public async Task> GetBindUserInfo(WeChatUserInfo info)
+ {
+ var bindUser = await _dal.Db.Queryable().Where(t => t.SubFromPublicAccount == info.id && t.CompanyID == info.companyCode && info.userID.Equals(t.SubJobID) && t.IsUnBind == false ).FirstAsync();
+ if (bindUser == null) return MessageModel.Fail("用户不存在或者已经解绑!");
+ var res = await GetToken(info.id);
+ if(!res.success) return MessageModel.Fail(res.msg);
+ var token = res.response.access_token;
+ WeChatResponseUserInfo reData = new WeChatResponseUserInfo();
+ reData.companyCode = info.companyCode;
+ reData.id = info.id;
+ var data = await WeChatHelper.GetUserInfo(token, bindUser.SubUserOpenID);
+ reData.usersData = data;
+ if (data.errcode.Equals(0))
+ {
+ return MessageModel.Success("用户信息获取成功", reData);
+ }
+ else
+ {
+ return MessageModel.Fail("用户信息获取失败", reData);
+ }
+ }
+ public async Task> UnBind(WeChatUserInfo info)
+ {
+ var bindUser = await _dal.Db.Queryable().Where(t => t.SubFromPublicAccount == info.id && t.CompanyID == info.companyCode && info.userID.Equals(t.SubJobID) && t.IsUnBind == false ).FirstAsync();
+ if (bindUser == null) return MessageModel.Fail("用户不存在或者已经解绑!");
+ WeChatResponseUserInfo reData = new WeChatResponseUserInfo();
+ reData.companyCode = info.companyCode;
+ reData.id = info.id;
+ bindUser.IsUnBind = true;
+ bindUser.SubUserRefTime = DateTime.Now;
+ await _dal.Db.Updateable(bindUser).UpdateColumns(t=> new{ t.IsUnBind,t.SubUserRefTime}).ExecuteCommandAsync();
+ return MessageModel.Success("用户解绑成功", reData);
+ }
+
+ public async Task HandleWeChat(WeChatXMLDto weChat)
+ {
+
+ switch (weChat.MsgType)
+ {
+ case "text":
+ return await HandText(weChat);
+ case "image":
+ return await HandImage(weChat);
+ case "voice":
+ return await HandVoice(weChat);
+ case "shortvideo":
+ return await HandShortvideo(weChat);
+ case "location":
+ return await HandLocation(weChat);
+ case "link":
+ return await HandLink(weChat);
+ case "event":
+ return await HandEvent(weChat);
+ default:
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.MsgType}]]>";
+ });
+ }
+
+ }
+ ///
+ /// 处理文本
+ ///
+ ///
+ ///
+ private async Task HandText(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.Content}]]>";
+ });
+ }
+ ///
+ /// 处理图片
+ ///
+ ///
+ ///
+ private async Task HandImage(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.PicUrl}]]>";
+ });
+ }
+ ///
+ /// 处理声音
+ ///
+ ///
+ ///
+ private async Task HandVoice(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.MediaId}]]>";
+ });
+ }
+ ///
+ /// 处理小视频
+ ///
+ ///
+ ///
+ private async Task HandShortvideo(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.MediaId}]]>";
+ });
+ }
+ ///
+ /// 处理地理位置
+ ///
+ ///
+ ///
+ private async Task HandLocation(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.Label}]]>";
+ });
+ }
+ ///
+ /// 处理链接消息
+ ///
+ ///
+ ///
+ private async Task HandLink(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.Url}]]>";
+ });
+ }
+ ///
+ /// 处理事件
+ ///
+ ///
+ ///
+ private async Task HandEvent(WeChatXMLDto weChat)
+ {
+
+ switch (weChat.Event)
+ {
+ case "subscribe":
+ return await EventSubscribe(weChat);
+ case "unsubscribe":
+ return await EventUnsubscribe(weChat);
+ case "SCAN":
+ return await EventSCAN(weChat);
+ case "LOCATION":
+ return await EventLOCATION(weChat);
+ case "CLICK":
+ return await EventCLICK(weChat);
+ case "VIEW":
+ return await EventVIEW(weChat);
+ default:
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.Event}]]>";
+ });
+ }
+ }
+ ///
+ /// 关注事件
+ ///
+ ///
+ ///
+ private async Task EventSubscribe(WeChatXMLDto weChat)
+ {
+ if (weChat.EventKey != null && (weChat.EventKey.Equals("bind") || weChat.EventKey.Equals("qrscene_bind")))
+ {
+ return await QRBind(weChat);
+ }
+ else
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ key:{weChat.EventKey}=>ticket:{weChat.Ticket}]]>";
+ });
+ }
+ }
+ ///
+ /// 取消关注事件
+ ///
+ ///
+ ///
+ private async Task EventUnsubscribe(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.Event}]]>";
+ });
+ }
+ ///
+ /// 已关注扫码事件
+ ///
+ ///
+ ///
+ private async Task EventSCAN(WeChatXMLDto weChat)
+ {
+ if (weChat.EventKey != null && (weChat.EventKey.StartsWith("bind_") || weChat.EventKey.StartsWith("qrscene_bind_")))
+ {
+
+ return await QRBind(weChat);
+ }
+ else
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ key:{weChat.EventKey}=>ticket:{weChat.Ticket}]]>";
+ });
+
+ }
+
+ }
+ ///
+ /// 扫码绑定
+ ///
+ ///
+ ///
+
+ private async Task QRBind(WeChatXMLDto weChat)
+ {
+ var ticket = await _dal.Db.Queryable().InSingleAsync(weChat.Ticket);
+ if (ticket == null) throw new Exception("ticket未找到");
+ if (ticket.QRisUsed) throw new Exception("ticket已被使用");
+ if (!ticket.QRpublicAccount.Equals(weChat.publicAccount)) throw new Exception($"公众号错误 need:{ticket.QRpublicAccount} but:{weChat.publicAccount}");
+
+ var bindUser = await _dal.Db.Queryable().Where(t => t.SubFromPublicAccount == ticket.QRpublicAccount && t.CompanyID == ticket.QRbindCompanyID && t.SubJobID == ticket.QRbindJobID).SingleAsync();
+ bool isNewBind;
+ if (bindUser == null )
+ {
+ isNewBind = true;
+ bindUser = new WeChatSub
+ {
+ SubFromPublicAccount = ticket.QRpublicAccount,
+ CompanyID = ticket.QRbindCompanyID,
+ SubJobID = ticket.QRbindJobID,
+ SubUserOpenID = weChat.FromUserName,
+ SubUserRegTime = DateTime.Now,
+ };
+ }
+ else
+ {
+ isNewBind = false;
+ //订阅过的就更新
+ if (bindUser.SubUserOpenID != weChat.FromUserName)
+ {
+ //记录上一次的订阅此工号的微信号
+ bindUser.LastSubUserOpenID = bindUser.SubUserOpenID;
+ }
+ bindUser.SubUserOpenID = weChat.FromUserName;
+ bindUser.SubUserRefTime = DateTime.Now;
+ bindUser.IsUnBind = false;
+ }
+ ticket.QRisUsed = true;
+ ticket.QRuseTime = DateTime.Now;
+ ticket.QRuseOpenid = weChat.FromUserName;
+
+ try
+ {
+ _unitOfWork.BeginTran();
+ await _dal.Db.Updateable(ticket).ExecuteCommandAsync();
+ if (isNewBind)
+ await _dal.Db.Insertable(bindUser).ExecuteCommandAsync();
+ else
+ await _dal.Db.Updateable(bindUser).ExecuteCommandAsync();
+ _unitOfWork.CommitTran();
+ }
+ catch
+ {
+ _unitOfWork.RollbackTran();
+ throw;
+ }
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ ";
+ }
+ ///
+ /// 上报位置地理事件
+ ///
+ ///
+ ///
+ private async Task EventLOCATION(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ 维度:{weChat.Latitude}经度:{weChat.Longitude}位置精度:{weChat.Precision}]]>";
+ });
+ }
+ ///
+ /// 点击菜单按钮事件
+ ///
+ ///
+ ///
+ private async Task EventCLICK(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.EventKey}]]>";
+ });
+ }
+ ///
+ /// 点击菜单网址事件
+ ///
+ ///
+ ///
+ private async Task EventVIEW(WeChatXMLDto weChat)
+ {
+ return await Task.Run(() =>
+ {
+ return @$"
+
+ {DateTime.Now.Ticks.ToString()}
+
+ {weChat.EventKey}]]>";
+ });
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Services/WeChatPushLogServices.cs b/Blog.Core.Services/WeChatPushLogServices.cs
new file mode 100644
index 0000000..8ca342f
--- /dev/null
+++ b/Blog.Core.Services/WeChatPushLogServices.cs
@@ -0,0 +1,34 @@
+using Blog.Core.Common;
+using Blog.Core.Common.Helper;
+using Blog.Core.IRepository.Base;
+using Blog.Core.IRepository.UnitOfWork;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using Blog.Core.Services.BASE;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Blog.Core.Services
+{
+ ///
+ /// WeChatPushLogServices
+ ///
+ public class WeChatPushLogServices : BaseServices, IWeChatPushLogServices
+ {
+ readonly IBaseRepository _dal;
+ readonly IUnitOfWork _unitOfWork;
+ readonly ILogger _logger;
+ public WeChatPushLogServices(IBaseRepository dal,IUnitOfWork unitOfWork, ILogger logger)
+ {
+ this._dal = dal;
+ base.BaseDal = dal;
+ this._unitOfWork = unitOfWork;
+ this._logger = logger;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Blog.Core.Services/WeChatSubServices.cs b/Blog.Core.Services/WeChatSubServices.cs
new file mode 100644
index 0000000..dfd9840
--- /dev/null
+++ b/Blog.Core.Services/WeChatSubServices.cs
@@ -0,0 +1,34 @@
+using Blog.Core.Common;
+using Blog.Core.Common.Helper;
+using Blog.Core.IRepository.Base;
+using Blog.Core.IRepository.UnitOfWork;
+using Blog.Core.IServices;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using Blog.Core.Services.BASE;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Blog.Core.Services
+{
+ ///
+ /// WeChatSubServices
+ ///
+ public class WeChatSubServices : BaseServices, IWeChatSubServices
+ {
+ readonly IBaseRepository _dal;
+ readonly IUnitOfWork _unitOfWork;
+ readonly ILogger _logger;
+ public WeChatSubServices(IBaseRepository dal,IUnitOfWork unitOfWork, ILogger logger)
+ {
+ this._dal = dal;
+ base.BaseDal = dal;
+ this._unitOfWork = unitOfWork;
+ this._logger = logger;
+ }
+
+ }
+}
\ No newline at end of file