From 6d9a0ede045129f6c57e51a7a3ff241e82ad3a71 Mon Sep 17 00:00:00 2001
From: hudingwen <765472804@qq.com>
Date: Tue, 2 Aug 2022 21:53:16 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4dal=E5=86=97=E4=BD=99?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81,=E7=A7=91=E5=AD=A6=E4=B8=8A=E7=BD=91?=
=?UTF-8?q?=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Blog.Core.Api/Blog.Core.Model.xml | 137 +++
Blog.Core.Api/Blog.Core.xml | 158 +++
Blog.Core.Api/Controllers/TrojanController.cs | 455 +++++++
Blog.Core.Api/appsettings.json | 11 +-
.../Extensions/Extention.Expression.cs | 387 ++++++
Blog.Core.Common/Helper/ShaHelper.cs | 1096 +++++++++++++++++
.../AutofacModuleRegister.cs | 3 +
Blog.Core.IServices/ITrojanUsersServices.cs | 14 +
Blog.Core.Model/Models/TrojanCusServers.cs | 25 +
Blog.Core.Model/Models/TrojanDetails.cs | 62 +
Blog.Core.Model/Models/TrojanServers.cs | 30 +
Blog.Core.Model/Models/TrojanUrlServers.cs | 25 +
Blog.Core.Model/Models/TrojanUsers.cs | 38 +
.../ViewModels/TrojanLimitFlowDto.cs | 23 +
Blog.Core.Model/ViewModels/TrojanServerDto.cs | 14 +
.../ViewModels/TrojanServerSpliceDto.cs | 28 +
.../ViewModels/TrojanUseDetailDto.cs | 35 +
Blog.Core.Services/AccessTrendLogServices.cs | 6 -
Blog.Core.Services/AdvertisementServices.cs | 7 -
Blog.Core.Services/BASE/BaseServices.cs | 4 +
Blog.Core.Services/BlogArticleServices.cs | 1 -
Blog.Core.Services/DepartmentServices.cs | 7 +-
Blog.Core.Services/GuestbookServices.cs | 19 +-
.../IDS4Db/ApplicationUserServices.cs | 7 -
Blog.Core.Services/ModuleServices.cs | 7 -
Blog.Core.Services/OperateLogServices.cs | 6 -
Blog.Core.Services/PasswordLibServices.cs | 6 -
Blog.Core.Services/PayServices.cs | 5 +-
Blog.Core.Services/PermissionServices.cs | 7 -
.../RoleModulePermissionServices.cs | 3 +-
Blog.Core.Services/RoleServices.cs | 7 -
Blog.Core.Services/TasksQzServices.cs | 6 -
Blog.Core.Services/TopicDetailServices.cs | 7 -
Blog.Core.Services/TopicServices.cs | 8 -
Blog.Core.Services/TrojanUsersServices.cs | 18 +
Blog.Core.Services/UserRoleServices.cs | 7 -
Blog.Core.Services/WeChatCompanyServices.cs | 5 +-
Blog.Core.Services/WeChatConfigServices.cs | 31 +-
Blog.Core.Services/WeChatPushLogServices.cs | 12 +-
Blog.Core.Services/WeChatSubServices.cs | 10 -
Blog.Core.Services/sysUserInfoServices.cs | 6 +-
41 files changed, 2588 insertions(+), 155 deletions(-)
create mode 100644 Blog.Core.Api/Controllers/TrojanController.cs
create mode 100644 Blog.Core.Common/Extensions/Extention.Expression.cs
create mode 100644 Blog.Core.Common/Helper/ShaHelper.cs
create mode 100644 Blog.Core.IServices/ITrojanUsersServices.cs
create mode 100644 Blog.Core.Model/Models/TrojanCusServers.cs
create mode 100644 Blog.Core.Model/Models/TrojanDetails.cs
create mode 100644 Blog.Core.Model/Models/TrojanServers.cs
create mode 100644 Blog.Core.Model/Models/TrojanUrlServers.cs
create mode 100644 Blog.Core.Model/Models/TrojanUsers.cs
create mode 100644 Blog.Core.Model/ViewModels/TrojanLimitFlowDto.cs
create mode 100644 Blog.Core.Model/ViewModels/TrojanServerDto.cs
create mode 100644 Blog.Core.Model/ViewModels/TrojanServerSpliceDto.cs
create mode 100644 Blog.Core.Model/ViewModels/TrojanUseDetailDto.cs
create mode 100644 Blog.Core.Services/TrojanUsersServices.cs
diff --git a/Blog.Core.Api/Blog.Core.Model.xml b/Blog.Core.Api/Blog.Core.Model.xml
index 8437e22..e75b50d 100644
--- a/Blog.Core.Api/Blog.Core.Model.xml
+++ b/Blog.Core.Api/Blog.Core.Model.xml
@@ -922,6 +922,76 @@
Tibug 博文
+
+
+ users自定义服务器
+
+
+
+
+ 用户流量每月汇总表
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Trojan服务器
+
+
+
+
+ users自定义URL服务器
+
+
+
+
+ Trojan用户
+
+
+
+
+ 历史流量记录
+
+
用户跟角色关联表
@@ -2347,6 +2417,73 @@
+
+
+ 限制流量dto
+ 作者:胡丁文
+ 时间:2020-4-27 16:57:07
+
+
+
+
+ 用户
+
+
+
+
+ 流量(-1为无限,单位为最小单位byte)
+
+
+
+
+ Trojan服务器拼接服务器和订阅地址
+
+
+
+
+ 普通订阅连接
+
+
+
+
+ clash订阅连接
+
+
+
+
+ 备用clash订阅连接
+
+
+
+
+ Trojan用户流量统计分组
+
+
+
+
+ 用户ID
+
+
+
+
+ 月度
+
+
+
+
+ 上传流量
+
+
+
+
+ 下载流量
+
+
+
+
+ 下载流量
+
+
微信接口消息DTO
diff --git a/Blog.Core.Api/Blog.Core.xml b/Blog.Core.Api/Blog.Core.xml
index f5df626..e26c917 100644
--- a/Blog.Core.Api/Blog.Core.xml
+++ b/Blog.Core.Api/Blog.Core.xml
@@ -639,6 +639,164 @@
+
+
+ 获取Trojan用户
+
+
+
+
+
+
+ 获取Trojan用户
+
+
+
+
+
+
+ 获取Trojan用户-下拉列表用
+
+
+
+
+
+ 添加Trojan用户
+
+
+
+
+
+
+ 更新Trojan用户
+
+
+
+
+
+
+ 删除用户
+
+
+
+
+
+
+ 重置流量
+
+
+
+
+
+
+ 限制流量
+
+
+
+
+
+
+ 重置链接密码
+
+
+
+
+
+
+ 获取Trojan服务器
+
+
+
+
+
+ 获取拼接后的Trojan服务器
+
+ passwordshow
+
+
+
+
+ 删除Trojan服务器
+
+
+
+
+
+
+ 更新Trojan服务器
+
+
+
+
+
+
+ 添加Trojan服务器
+
+
+
+
+
+
+ 获取Cus服务器
+
+
+
+
+
+ 删除Cus服务器
+
+
+
+
+
+
+ 更新Cus服务器
+
+
+
+
+
+
+ 添加Cus服务器
+
+
+
+
+
+
+ 获取Url服务器
+
+
+
+
+
+ 删除Url服务器
+
+
+
+
+
+
+ 更新Url服务器
+
+
+
+
+
+
+ 添加Url服务器
+
+
+
+
+
+
+ 获取订阅数据
+
+ 链接密码
+ 是否使用base64加密
+
+
用户管理
diff --git a/Blog.Core.Api/Controllers/TrojanController.cs b/Blog.Core.Api/Controllers/TrojanController.cs
new file mode 100644
index 0000000..5d800cb
--- /dev/null
+++ b/Blog.Core.Api/Controllers/TrojanController.cs
@@ -0,0 +1,455 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Blog.Core.Common;
+using Blog.Core.Common.Extensions;
+using Blog.Core.Common.Helper;
+using Blog.Core.Common.HttpContextUser;
+using Blog.Core.IServices;
+using Blog.Core.IServices.BASE;
+using Blog.Core.Model;
+using Blog.Core.Model.Models;
+using Blog.Core.Model.ViewModels;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Blog.Core.Controllers
+{
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ [Authorize(Permissions.Name)]
+ public class TrojanController : ControllerBase
+ {
+ private ITrojanUsersServices _trojanUsersServices;
+ public IBaseServices _baseServicesServers;
+ public IBaseServices _baseServicesDetails;
+ public IBaseServices _baseServicesCusServers;
+ public IBaseServices _baseServicesUrlServers;
+ private IUser _user;
+ public TrojanController(ITrojanUsersServices trojanUsersServices,IUser user
+ , IBaseServices baseServicesServers
+ , IBaseServices baseServicesDetails
+ , IBaseServices baseServicesCusServers
+ , IBaseServices baseServicesUrlServers)
+ {
+ _baseServicesDetails = baseServicesDetails;
+ _baseServicesServers = baseServicesServers;
+ _trojanUsersServices = trojanUsersServices;
+ _baseServicesCusServers = baseServicesCusServers;
+ _baseServicesUrlServers = baseServicesUrlServers;
+ _user = user;
+ }
+ ///
+ /// 获取Trojan用户
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task>> GetUser([FromQuery]PaginationModel pagination)
+ {
+ return await GetAllUser(pagination);
+ }
+ ///
+ /// 获取Trojan用户
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task>> GetAllUser([FromQuery]PaginationModel pagination)
+ {
+ var data = await _trojanUsersServices.QueryPage(pagination);
+ if (data.data.Count > 0)
+ {
+ var ids = data.data.Select(t => t.id).ToList();
+ var where = LinqHelper.True();
+ where = where.And(t => ids.Contains(t.userId)).And(t => t.calDate < DateTime.Now).And(t => t.calDate > DateTime.Now.AddMonths(-12));
+ var userDetails = await _baseServicesDetails.Query(where);
+ foreach (var trojanUser in data.data)
+ {
+
+ var ls = from t in userDetails
+ where t.userId == trojanUser.id
+ group t by new { moth = t.calDate.ToString("yyyy-MM"), id = t.userId } into g
+ orderby g.Key.moth descending
+ select new TrojanUseDetailDto { userId = g.Key.id, moth = g.Key.moth, up = g.Sum(t => Convert.ToDecimal(t.upload)), down = g.Sum(t => Convert.ToDecimal(t.download)) };
+ var lsData = ls.ToList();
+ trojanUser.useList = lsData;
+ }
+ }
+ return MessageModel>.Success("获取成功", data);
+ }
+
+ ///
+ /// 获取Trojan用户-下拉列表用
+ ///
+ ///
+ [HttpGet]
+ public async Task> GetAllTrojanUser()
+ {
+ var data = await _trojanUsersServices.QueryTable("select id,username from users");
+ return MessageModel.Success("获取成功", data);
+ }
+ ///
+ /// 添加Trojan用户
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> AddUser([FromBody]TrojanUsers user)
+ {
+ var find = await _trojanUsersServices.Query(t => t.username == user.username);
+ if(find!=null && find.Count>0) return MessageModel
public class DepartmentServices : BaseServices, IDepartmentServices
{
- private readonly IBaseRepository _dal;
- public DepartmentServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
+
}
}
\ No newline at end of file
diff --git a/Blog.Core.Services/GuestbookServices.cs b/Blog.Core.Services/GuestbookServices.cs
index 8da0e7f..f759a54 100644
--- a/Blog.Core.Services/GuestbookServices.cs
+++ b/Blog.Core.Services/GuestbookServices.cs
@@ -12,13 +12,10 @@ namespace Blog.Core.Services
{
public class GuestbookServices : BaseServices, IGuestbookServices
{
- private readonly IBaseRepository _dal;
private readonly IUnitOfWork _unitOfWork;
private readonly IBaseRepository _passwordLibRepository;
- public GuestbookServices(IUnitOfWork unitOfWork, IBaseRepository dal, IBaseRepository passwordLibRepository)
+ public GuestbookServices(IUnitOfWork unitOfWork, IBaseRepository passwordLibRepository)
{
- this._dal = dal;
- base.BaseDal = dal;
_unitOfWork = unitOfWork;
_passwordLibRepository = passwordLibRepository;
}
@@ -47,7 +44,7 @@ namespace Blog.Core.Services
//......
Console.WriteLine($"");
- var guestbooks = await _dal.Query();
+ var guestbooks = await BaseDal.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
int ex = 0;
@@ -55,7 +52,7 @@ namespace Blog.Core.Services
int throwEx = 1 / ex;
Console.WriteLine($"insert a data into the table Guestbook now.");
- var insertGuestbook = await _dal.Add(new Guestbook()
+ var insertGuestbook = await BaseDal.Add(new Guestbook()
{
username = "bbb",
blogId = 1,
@@ -63,7 +60,7 @@ namespace Blog.Core.Services
isshow = true
});
- guestbooks = await _dal.Query();
+ guestbooks = await BaseDal.Query();
Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}");
@@ -81,7 +78,7 @@ namespace Blog.Core.Services
var passwords = await _passwordLibRepository.Query();
Console.WriteLine($"third time : the count of passwords is :{passwords.Count}");
- var guestbooks = await _dal.Query();
+ var guestbooks = await BaseDal.Query();
Console.WriteLine($"third time : the count of guestbooks is :{guestbooks.Count}");
return new MessageModel()
@@ -114,7 +111,7 @@ namespace Blog.Core.Services
//......
Console.WriteLine($"");
- var guestbooks = await _dal.Query();
+ var guestbooks = await BaseDal.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
int ex = 0;
@@ -122,7 +119,7 @@ namespace Blog.Core.Services
int throwEx = 1 / ex;
Console.WriteLine($"insert a data into the table Guestbook now.");
- var insertGuestbook = await _dal.Add(new Guestbook()
+ var insertGuestbook = await BaseDal.Add(new Guestbook()
{
username = "bbb",
blogId = 1,
@@ -130,7 +127,7 @@ namespace Blog.Core.Services
isshow = true
});
- guestbooks = await _dal.Query();
+ guestbooks = await BaseDal.Query();
Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}");
return true;
diff --git a/Blog.Core.Services/IDS4Db/ApplicationUserServices.cs b/Blog.Core.Services/IDS4Db/ApplicationUserServices.cs
index 6e39c4a..1cda7d3 100644
--- a/Blog.Core.Services/IDS4Db/ApplicationUserServices.cs
+++ b/Blog.Core.Services/IDS4Db/ApplicationUserServices.cs
@@ -7,12 +7,5 @@ namespace Blog.Core.IServices
public class ApplicationUserServices : BaseServices, IApplicationUserServices
{
- IBaseRepository _dal;
- public ApplicationUserServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
-
}
}
\ No newline at end of file
diff --git a/Blog.Core.Services/ModuleServices.cs b/Blog.Core.Services/ModuleServices.cs
index a27c2ba..c27a63e 100644
--- a/Blog.Core.Services/ModuleServices.cs
+++ b/Blog.Core.Services/ModuleServices.cs
@@ -11,12 +11,5 @@ namespace Blog.Core.Services
public class ModuleServices : BaseServices, IModuleServices
{
- IBaseRepository _dal;
- public ModuleServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
-
}
}
diff --git a/Blog.Core.Services/OperateLogServices.cs b/Blog.Core.Services/OperateLogServices.cs
index 8715b0d..6527ba9 100644
--- a/Blog.Core.Services/OperateLogServices.cs
+++ b/Blog.Core.Services/OperateLogServices.cs
@@ -7,12 +7,6 @@ namespace Blog.Core.Services
{
public partial class OperateLogServices : BaseServices, IOperateLogServices
{
- IBaseRepository _dal;
- public OperateLogServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
}
}
diff --git a/Blog.Core.Services/PasswordLibServices.cs b/Blog.Core.Services/PasswordLibServices.cs
index 8aad027..2d2cdb6 100644
--- a/Blog.Core.Services/PasswordLibServices.cs
+++ b/Blog.Core.Services/PasswordLibServices.cs
@@ -7,12 +7,6 @@ namespace Blog.Core.Services
{
public partial class PasswordLibServices : BaseServices, IPasswordLibServices
{
- IBaseRepository _dal;
- public PasswordLibServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
}
}
diff --git a/Blog.Core.Services/PayServices.cs b/Blog.Core.Services/PayServices.cs
index 2a4c42c..b257d08 100644
--- a/Blog.Core.Services/PayServices.cs
+++ b/Blog.Core.Services/PayServices.cs
@@ -20,13 +20,10 @@ namespace Blog.Core.Services
{
public partial class PayServices : BaseServices>, IPayServices
{
- IBaseRepository> _dal;
IHttpContextAccessor _httpContextAccessor;
ILogger _logger;
- public PayServices(IBaseRepository> dal, ILogger logger, IHttpContextAccessor httpContextAccessor)
+ public PayServices(ILogger logger, IHttpContextAccessor httpContextAccessor)
{
- this._dal = dal;
- base.BaseDal = dal;
_logger = logger;
_httpContextAccessor = httpContextAccessor;
}
diff --git a/Blog.Core.Services/PermissionServices.cs b/Blog.Core.Services/PermissionServices.cs
index 2282a38..6c64954 100644
--- a/Blog.Core.Services/PermissionServices.cs
+++ b/Blog.Core.Services/PermissionServices.cs
@@ -11,12 +11,5 @@ namespace Blog.Core.Services
public class PermissionServices : BaseServices, IPermissionServices
{
- IBaseRepository _dal;
- public PermissionServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
-
}
}
diff --git a/Blog.Core.Services/RoleModulePermissionServices.cs b/Blog.Core.Services/RoleModulePermissionServices.cs
index 04c9b0f..c0248e1 100644
--- a/Blog.Core.Services/RoleModulePermissionServices.cs
+++ b/Blog.Core.Services/RoleModulePermissionServices.cs
@@ -21,14 +21,13 @@ namespace Blog.Core.Services
// 将多个仓储接口注入
public RoleModulePermissionServices(
- IRoleModulePermissionRepository dal,
+ IRoleModulePermissionRepository dal,
IBaseRepository moduleRepository,
IBaseRepository roleRepository)
{
this._dal = dal;
this._moduleRepository = moduleRepository;
this._roleRepository = roleRepository;
- base.BaseDal = dal;
}
///
diff --git a/Blog.Core.Services/RoleServices.cs b/Blog.Core.Services/RoleServices.cs
index 93b0c80..50861f7 100644
--- a/Blog.Core.Services/RoleServices.cs
+++ b/Blog.Core.Services/RoleServices.cs
@@ -13,13 +13,6 @@ namespace Blog.Core.Services
///
public class RoleServices : BaseServices, IRoleServices
{
-
- IBaseRepository _dal;
- public RoleServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
///
///
///
diff --git a/Blog.Core.Services/TasksQzServices.cs b/Blog.Core.Services/TasksQzServices.cs
index 14c515e..68560a2 100644
--- a/Blog.Core.Services/TasksQzServices.cs
+++ b/Blog.Core.Services/TasksQzServices.cs
@@ -7,12 +7,6 @@ namespace Blog.Core.Services
{
public partial class TasksQzServices : BaseServices, ITasksQzServices
{
- IBaseRepository _dal;
- public TasksQzServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
}
}
diff --git a/Blog.Core.Services/TopicDetailServices.cs b/Blog.Core.Services/TopicDetailServices.cs
index 6f8667c..49fb534 100644
--- a/Blog.Core.Services/TopicDetailServices.cs
+++ b/Blog.Core.Services/TopicDetailServices.cs
@@ -10,13 +10,6 @@ namespace Blog.Core.Services
{
public class TopicDetailServices : BaseServices, ITopicDetailServices
{
- IBaseRepository _dal;
- public TopicDetailServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
-
///
/// 获取开Bug数据(缓存)
///
diff --git a/Blog.Core.Services/TopicServices.cs b/Blog.Core.Services/TopicServices.cs
index 697c946..7d1b3f0 100644
--- a/Blog.Core.Services/TopicServices.cs
+++ b/Blog.Core.Services/TopicServices.cs
@@ -10,14 +10,6 @@ namespace Blog.Core.Services
{
public class TopicServices: BaseServices, ITopicServices
{
-
- IBaseRepository _dal;
- public TopicServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
-
///
/// 获取开Bug专题分类(缓存)
///
diff --git a/Blog.Core.Services/TrojanUsersServices.cs b/Blog.Core.Services/TrojanUsersServices.cs
new file mode 100644
index 0000000..f42f51d
--- /dev/null
+++ b/Blog.Core.Services/TrojanUsersServices.cs
@@ -0,0 +1,18 @@
+using Blog.Core.Common;
+using Blog.Core.IRepository.Base;
+using Blog.Core.IServices;
+using Blog.Core.Model.Models;
+using Blog.Core.Services.BASE;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Blog.Core.Services
+{
+ ///
+ /// TrojanUsersServices
+ ///
+ public class TrojanUsersServices : BaseServices, ITrojanUsersServices
+ {
+
+ }
+}
diff --git a/Blog.Core.Services/UserRoleServices.cs b/Blog.Core.Services/UserRoleServices.cs
index df73d2b..38f524d 100644
--- a/Blog.Core.Services/UserRoleServices.cs
+++ b/Blog.Core.Services/UserRoleServices.cs
@@ -13,13 +13,6 @@ namespace Blog.Core.Services
///
public class UserRoleServices : BaseServices, IUserRoleServices
{
-
- IBaseRepository _dal;
- public UserRoleServices(IBaseRepository dal)
- {
- this._dal = dal;
- base.BaseDal = dal;
- }
///
///
///
diff --git a/Blog.Core.Services/WeChatCompanyServices.cs b/Blog.Core.Services/WeChatCompanyServices.cs
index c44ff0c..864c408 100644
--- a/Blog.Core.Services/WeChatCompanyServices.cs
+++ b/Blog.Core.Services/WeChatCompanyServices.cs
@@ -19,13 +19,10 @@ namespace Blog.Core.Services
///
public class WeChatCompanyServices : BaseServices, IWeChatCompanyServices
{
- readonly IBaseRepository _dal;
readonly IUnitOfWork _unitOfWork;
readonly ILogger _logger;
- public WeChatCompanyServices(IBaseRepository dal,IUnitOfWork unitOfWork, ILogger logger)
+ public WeChatCompanyServices(IUnitOfWork unitOfWork, ILogger logger)
{
- this._dal = dal;
- base.BaseDal = dal;
this._unitOfWork = unitOfWork;
this._logger = logger;
}
diff --git a/Blog.Core.Services/WeChatConfigServices.cs b/Blog.Core.Services/WeChatConfigServices.cs
index a268a31..612a15d 100644
--- a/Blog.Core.Services/WeChatConfigServices.cs
+++ b/Blog.Core.Services/WeChatConfigServices.cs
@@ -19,13 +19,10 @@ namespace Blog.Core.Services
///
public class WeChatConfigServices : BaseServices, IWeChatConfigServices
{
- readonly IBaseRepository _dal;
readonly IUnitOfWork _unitOfWork;
readonly ILogger _logger;
- public WeChatConfigServices(IBaseRepository dal,IUnitOfWork unitOfWork, ILogger logger)
+ public WeChatConfigServices(IUnitOfWork unitOfWork, ILogger logger)
{
- this._dal = dal;
- base.BaseDal = dal;
this._unitOfWork = unitOfWork;
this._logger = logger;
}
@@ -237,13 +234,13 @@ namespace Blog.Core.Services
QRticket = data.ticket
};
data.id = info.userID;
- await this._dal.Db.Insertable(weChatQR).ExecuteCommandAsync();
+ await this.BaseDal.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();
+ var bindUser = await BaseDal.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);
@@ -316,7 +313,7 @@ namespace Blog.Core.Services
PushLogTemplateID = msg.cardMsg.template_id,
PushLogIP = ip
};
- await _dal.Db.Insertable(pushLog).ExecuteCommandAsync();
+ await BaseDal.Db.Insertable(pushLog).ExecuteCommandAsync();
}
catch (Exception ex)
{
@@ -355,7 +352,7 @@ namespace Blog.Core.Services
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();
+ var usrs = BaseDal.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;
@@ -370,7 +367,7 @@ namespace Blog.Core.Services
else
{
//发送所有
- var usrs = _dal.Db.Queryable().Where(t => t.SubFromPublicAccount.Equals(msg.selectWeChat) && t.CompanyID.Equals(msg.selectCompany)).ToList();
+ var usrs = BaseDal.Db.Queryable().Where(t => t.SubFromPublicAccount.Equals(msg.selectWeChat) && t.CompanyID.Equals(msg.selectCompany)).ToList();
foreach (var item in usrs)
{
msg.selectUser = item.SubUserOpenID;
@@ -531,7 +528,7 @@ namespace Blog.Core.Services
}
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();
+ var bindUser = await BaseDal.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);
@@ -552,14 +549,14 @@ namespace Blog.Core.Services
}
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();
+ var bindUser = await BaseDal.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();
+ await BaseDal.Db.Updateable(bindUser).UpdateColumns(t=> new{ t.IsUnBind,t.SubUserRefTime}).ExecuteCommandAsync();
return MessageModel.Success("用户解绑成功", reData);
}
@@ -796,12 +793,12 @@ namespace Blog.Core.Services
private async Task QRBind(WeChatXMLDto weChat)
{
- var ticket = await _dal.Db.Queryable().InSingleAsync(weChat.Ticket);
+ var ticket = await BaseDal.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();
+ var bindUser = await BaseDal.Db.Queryable().Where(t => t.SubFromPublicAccount == ticket.QRpublicAccount && t.CompanyID == ticket.QRbindCompanyID && t.SubJobID == ticket.QRbindJobID).SingleAsync();
bool isNewBind;
if (bindUser == null )
{
@@ -835,11 +832,11 @@ namespace Blog.Core.Services
try
{
_unitOfWork.BeginTran();
- await _dal.Db.Updateable(ticket).ExecuteCommandAsync();
+ await BaseDal.Db.Updateable(ticket).ExecuteCommandAsync();
if (isNewBind)
- await _dal.Db.Insertable(bindUser).ExecuteCommandAsync();
+ await BaseDal.Db.Insertable(bindUser).ExecuteCommandAsync();
else
- await _dal.Db.Updateable(bindUser).ExecuteCommandAsync();
+ await BaseDal.Db.Updateable(bindUser).ExecuteCommandAsync();
_unitOfWork.CommitTran();
}
catch
diff --git a/Blog.Core.Services/WeChatPushLogServices.cs b/Blog.Core.Services/WeChatPushLogServices.cs
index 8ca342f..3e1ca52 100644
--- a/Blog.Core.Services/WeChatPushLogServices.cs
+++ b/Blog.Core.Services/WeChatPushLogServices.cs
@@ -19,16 +19,6 @@ namespace Blog.Core.Services
///
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
index dfd9840..2b0d7ed 100644
--- a/Blog.Core.Services/WeChatSubServices.cs
+++ b/Blog.Core.Services/WeChatSubServices.cs
@@ -19,16 +19,6 @@ namespace Blog.Core.Services
///
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
diff --git a/Blog.Core.Services/sysUserInfoServices.cs b/Blog.Core.Services/sysUserInfoServices.cs
index f536cf7..282ae73 100644
--- a/Blog.Core.Services/sysUserInfoServices.cs
+++ b/Blog.Core.Services/sysUserInfoServices.cs
@@ -12,16 +12,12 @@ namespace Blog.Core.FrameWork.Services
///
public class SysUserInfoServices : BaseServices, ISysUserInfoServices
{
-
- private readonly IBaseRepository _dal;
private readonly IBaseRepository _userRoleRepository;
private readonly IBaseRepository _roleRepository;
- public SysUserInfoServices(IBaseRepository dal, IBaseRepository userRoleRepository, IBaseRepository roleRepository)
+ public SysUserInfoServices(IBaseRepository userRoleRepository, IBaseRepository roleRepository)
{
- this._dal = dal;
_userRoleRepository = userRoleRepository;
_roleRepository = roleRepository;
- base.BaseDal = dal;
}
///
///