【新增】增加MySql.Data组件,防止出现Nlog新版mysql不写入的问题。

【优化】优化本地上传写入文件夹缺少反斜杠的问题。
【修复】修复appsetting.json微信公众号配置项命名错误的问题。
【新增】定时任务增加微信公众号获取JS-Token并且全局缓存功能。
【新增】增加微信公众号获取JS-SDK使用权限签名算法。
【新增】新增微信公众号【微信被动回复消息】功能,用于关于公众号提醒,微信聊天被动关键词回复等。
【新增】新增微信公众号【微信菜单管理】功能,用于管理公众号底部三列五横的链接。
【新增】新增微信公众号【消息推送】接口及业务处理。用于接收从微信公众号推送的事件交互。
【新增】新增微信公众号【授权鉴权跳转】功能,用于验证是否为微信公众号访问,及获取openid等信息。
【新增】新增微信公众号用户accressToekn存储机制。
【新增】新增微信公众号发送模板消息方法。
【新增】数据库新增【WeChatMessageResponse】【WeChatUserAccessToken】两个表,【CoreCmsUserWeChatInfo】增加【isSubscribe】是否关注字段。
【新增】商品品牌管理品牌logo增加原图上传 
【新增】商品分类管理分类图片增加原图上传
【新增】新增最新后台左侧管理菜单目录脚本,完整数据库脚本备份新增最新商品商品示例。
This commit is contained in:
大灰灰
2022-12-30 02:32:10 +08:00
parent 4430e6f4e0
commit 7d49668037
52 changed files with 7302 additions and 21 deletions

View File

@@ -0,0 +1,215 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2022/12/14 0:36:13
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Caching.Manual;
using CoreCms.Net.Configuration;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.Model.ViewModels.UI;
using SqlSugar;
namespace CoreCms.Net.Repository
{
/// <summary>
/// 微信自动回复消息表 接口实现
/// </summary>
public class WeChatMessageResponseRepository : BaseRepository<WeChatMessageResponse>, IWeChatMessageResponseRepository
{
private readonly IUnitOfWork _unitOfWork;
public WeChatMessageResponseRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
_unitOfWork = unitOfWork;
}
#region ==========================================================
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public async Task<AdminUiCallBack> InsertAsync(WeChatMessageResponse entity)
{
var jm = new AdminUiCallBack();
entity.createTime = DateTime.Now;
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
if (bl && entity.category == (int)GlobalEnumVars.WeChatRequestRuleEnum.Default && entity.isDefault == true)
{
await DbClient.Updateable<WeChatMessageResponse>(p => new WeChatMessageResponse() { isDefault = false })
.Where(p => p.isDefault == true && p.category == (int)GlobalEnumVars.WeChatRequestRuleEnum.Default)
.ExecuteCommandAsync();
}
return jm;
}
/// <summary>
/// 重写异步更新方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> UpdateAsync(WeChatMessageResponse entity)
{
var jm = new AdminUiCallBack();
var oldModel = await DbClient.Queryable<WeChatMessageResponse>().In(entity.id).SingleAsync();
if (oldModel == null)
{
jm.msg = "不存在此信息";
return jm;
}
//事物处理过程开始
//oldModel.id = entity.id;
oldModel.messageRule = entity.messageRule;
oldModel.category = entity.category;
oldModel.matchKey = entity.matchKey;
oldModel.textContent = entity.textContent;
oldModel.imgTextContext = entity.imgTextContext;
oldModel.imgTextUrl = entity.imgTextUrl;
oldModel.imgTextLink = entity.imgTextLink;
oldModel.meidaUrl = entity.meidaUrl;
oldModel.meidaLink = entity.meidaLink;
oldModel.enable = entity.enable;
oldModel.isDefault = entity.isDefault;
oldModel.remark = entity.remark;
oldModel.sort = entity.sort;
oldModel.createTime = entity.createTime;
//事物处理过程结束
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
if (bl && entity.category == (int)GlobalEnumVars.WeChatRequestRuleEnum.Default && entity.isDefault == true)
{
await DbClient.Updateable<WeChatMessageResponse>(p => new WeChatMessageResponse() { isDefault = false })
.Where(p => p.isDefault == true && p.category == (int)GlobalEnumVars.WeChatRequestRuleEnum.Default)
.ExecuteCommandAsync();
}
return jm;
}
/// <summary>
/// 重写删除指定ID的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
{
var jm = new AdminUiCallBack();
var bl = await DbClient.Deleteable<WeChatMessageResponse>(id).ExecuteCommandHasChangeAsync();
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
return jm;
}
#endregion
#region ==========================================================
/// <summary>
/// 获取缓存的所有数据
/// </summary>
/// <returns></returns>
public async Task<List<WeChatMessageResponse>> GetCaChe()
{
var list = await DbClient.Queryable<WeChatMessageResponse>().With(SqlWith.NoLock).WithCache().ToListAsync();
return list;
}
#endregion
#region
/// <summary>
/// 重写根据条件查询分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public async Task<IPageList<WeChatMessageResponse>> QueryPageAsync(Expression<Func<WeChatMessageResponse, bool>> predicate,
Expression<Func<WeChatMessageResponse, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false)
{
RefAsync<int> totalCount = 0;
List<WeChatMessageResponse> page;
if (blUseNoLock)
{
page = await DbClient.Queryable<WeChatMessageResponse>()
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
.WhereIF(predicate != null, predicate).Select(p => new WeChatMessageResponse
{
id = p.id,
messageRule = p.messageRule,
category = p.category,
matchKey = p.matchKey,
textContent = p.textContent,
imgTextContext = p.imgTextContext,
imgTextUrl = p.imgTextUrl,
imgTextLink = p.imgTextLink,
meidaUrl = p.meidaUrl,
meidaLink = p.meidaLink,
enable = p.enable,
isDefault = p.isDefault,
remark = p.remark,
sort = p.sort,
createTime = p.createTime
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
}
else
{
page = await DbClient.Queryable<WeChatMessageResponse>()
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
.WhereIF(predicate != null, predicate).Select(p => new WeChatMessageResponse
{
id = p.id,
messageRule = p.messageRule,
category = p.category,
matchKey = p.matchKey,
textContent = p.textContent,
imgTextContext = p.imgTextContext,
imgTextUrl = p.imgTextUrl,
imgTextLink = p.imgTextLink,
meidaUrl = p.meidaUrl,
meidaLink = p.meidaLink,
enable = p.enable,
isDefault = p.isDefault,
remark = p.remark,
sort = p.sort,
createTime = p.createTime
}).ToPageListAsync(pageIndex, pageSize, totalCount);
}
var list = new PageList<WeChatMessageResponse>(page, pageIndex, pageSize, totalCount);
return list;
}
#endregion
}
}

View File

@@ -0,0 +1,211 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2022/12/14 21:20:57
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Caching.Manual;
using CoreCms.Net.Configuration;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.Model.ViewModels.UI;
using SqlSugar;
namespace CoreCms.Net.Repository
{
/// <summary>
/// 微信用户交互授权 接口实现
/// </summary>
public class WeChatUserAccessTokenRepository : BaseRepository<WeChatUserAccessToken>, IWeChatUserAccessTokenRepository
{
private readonly IUnitOfWork _unitOfWork;
public WeChatUserAccessTokenRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
_unitOfWork = unitOfWork;
}
#region ==========================================================
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public async Task<AdminUiCallBack> InsertAsync(WeChatUserAccessToken entity)
{
var jm = new AdminUiCallBack();
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
return jm;
}
/// <summary>
/// 重写异步更新方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> UpdateAsync(WeChatUserAccessToken entity)
{
var jm = new AdminUiCallBack();
var oldModel = await DbClient.Queryable<WeChatUserAccessToken>().In(entity.id).SingleAsync();
if (oldModel == null)
{
jm.msg = "不存在此信息";
return jm;
}
//事物处理过程开始
oldModel.id = entity.id;
oldModel.access_token = entity.access_token;
oldModel.expires_in = entity.expires_in;
oldModel.refresh_token = entity.refresh_token;
oldModel.openid = entity.openid;
oldModel.scope = entity.scope;
oldModel.is_snapshotuser = entity.is_snapshotuser;
oldModel.unionid = entity.unionid;
//事物处理过程结束
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
return jm;
}
/// <summary>
/// 重写异步更新方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> UpdateAsync(List<WeChatUserAccessToken> entity)
{
var jm = new AdminUiCallBack();
var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync();
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
return jm;
}
/// <summary>
/// 重写删除指定ID的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
{
var jm = new AdminUiCallBack();
var bl = await DbClient.Deleteable<WeChatUserAccessToken>(id).ExecuteCommandHasChangeAsync();
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
return jm;
}
/// <summary>
/// 重写删除指定ID集合的数据(批量删除)
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
{
var jm = new AdminUiCallBack();
var bl = await DbClient.Deleteable<WeChatUserAccessToken>().In(ids).ExecuteCommandHasChangeAsync();
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
return jm;
}
#endregion
#region ==========================================================
/// <summary>
/// 获取缓存的所有数据
/// </summary>
/// <returns></returns>
public async Task<List<WeChatUserAccessToken>> GetCaChe()
{
var list = await DbClient.Queryable<WeChatUserAccessToken>().With(SqlWith.NoLock).WithCache().ToListAsync();
return list;
}
#endregion
#region
/// <summary>
/// 重写根据条件查询分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public async Task<IPageList<WeChatUserAccessToken>> QueryPageAsync(Expression<Func<WeChatUserAccessToken, bool>> predicate,
Expression<Func<WeChatUserAccessToken, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false)
{
RefAsync<int> totalCount = 0;
List<WeChatUserAccessToken> page;
if (blUseNoLock)
{
page = await DbClient.Queryable<WeChatUserAccessToken>()
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
.WhereIF(predicate != null, predicate).Select(p => new WeChatUserAccessToken
{
id = p.id,
access_token = p.access_token,
expires_in = p.expires_in,
refresh_token = p.refresh_token,
openid = p.openid,
scope = p.scope,
is_snapshotuser = p.is_snapshotuser,
unionid = p.unionid,
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
}
else
{
page = await DbClient.Queryable<WeChatUserAccessToken>()
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
.WhereIF(predicate != null, predicate).Select(p => new WeChatUserAccessToken
{
id = p.id,
access_token = p.access_token,
expires_in = p.expires_in,
refresh_token = p.refresh_token,
openid = p.openid,
scope = p.scope,
is_snapshotuser = p.is_snapshotuser,
unionid = p.unionid,
}).ToPageListAsync(pageIndex, pageSize, totalCount);
}
var list = new PageList<WeChatUserAccessToken>(page, pageIndex, pageSize, totalCount);
return list;
}
#endregion
}
}