From 6b24ae48c664c25676672ece72d134474c6af817 Mon Sep 17 00:00:00 2001
From: liaoxujun@qq.com <liaoxujun@qq.com>
Date: 星期二, 12 九月 2023 15:00:23 +0800
Subject: [PATCH] 消息发送
---
DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs | 62 ++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
index 0d9c2d1..be334f5 100644
--- a/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
+++ b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
@@ -3,7 +3,9 @@
using DocumentServiceAPI.Application.UserAndLogin.ViewMode;
using DocumentServiceAPI.Model;
using DocumentServiceAPI.Model.cyDocumentModel;
+using DocumentServiceAPI.Model.Permissions;
using DocumentServiceAPI.Model.UserInfoModel;
+using DocumentServiceAPI.Services.IService;
using DocumentServiceAPI.Utility;
using Furion.Logging.Extensions;
using MapsterMapper;
@@ -23,14 +25,21 @@
/// </summary>
public class UserService : IUserService, IScoped
{
+ /// <summary>
+ /// TenantPermissions鍦≧edis涓殑閿��
+ /// </summary>
+ public const string TenantPermissions_RedisKey = "TenantPermissionsKen:";
private ISqlSugarClient _db { get; set; }
private EmployeeRepository _employeeRepository{ get; set; }
private IMapper _mapper { get; set; }
- public UserService(ISqlSugarClient db, EmployeeRepository employeeRepository, IMapper mapper)
+ private IRedisCacheService _cacheService { get; set; }
+
+ public UserService(ISqlSugarClient db, EmployeeRepository employeeRepository, IMapper mapper , IRedisCacheService cacheService)
{
_db = db;
- _employeeRepository= employeeRepository;
+ _employeeRepository = employeeRepository;
_mapper = mapper;
+ _cacheService = cacheService;
}
/// <summary>
/// 鍛樺伐璇︽儏
@@ -379,6 +388,55 @@
}
+ /// <summary>
+ /// 绉熸埛鏄惁宸茬粡瓒呮椂杩囨湡
+ /// </summary>
+ /// <param name="TenderID">绉熸埛ID</param>
+ /// <returns> true 浠h〃娌℃湁瓒呮椂鏈夋潈闄愪娇鐢紝false 浠h〃娌℃湁鏉冮檺浣跨敤浜�</returns>
+ public async Task<bool> TenderHasPermissions( int TenderID)
+ {
+ var Key = TenantPermissions_RedisKey + TenderID.ToString();
+ var tp= _cacheService.Get<TenantPermissions>(TenantPermissions_RedisKey+ TenderID.ToString());
+ if(tp == null )
+ {
+ tp= await _db.Queryable<TenantPermissions>().Where(x=>x.TenantId == TenderID).FirstAsync();
+ if (tp != null)
+ _cacheService.Add<TenantPermissions>(Key, tp, 300);
+ else
+ return false;
+ }
+ if (tp.OverTime > DateTime.Now)
+ return true;
+ return false;
+
+ }
+ /// <summary>
+ /// 绉熸埛鏄惁宸茬粡瓒呮椂杩囨湡 鏍规嵁token涓寘鍚殑TID 璇嗗埆鏄惁鏈夋潈闄�
+ /// </summary>
+ /// <returns> true 浠h〃娌℃湁瓒呮椂鏈夋潈闄愪娇鐢紝false 浠h〃娌℃湁鏉冮檺浣跨敤浜�</returns>
+ public async Task<bool> TenderHasPermissions()
+ {
+ var jwtinfo= GetJwtInfo();
+ if(jwtinfo != null&&jwtinfo.TEID!=null )
+ {
+ var Key = TenantPermissions_RedisKey + jwtinfo.TEID.ToString();
+ var tp = _cacheService.Get<TenantPermissions>(TenantPermissions_RedisKey + jwtinfo.TEID.ToString());
+ if (tp == null)
+ {
+ tp = await _db.Queryable<TenantPermissions>().Where(x => x.TenantId == jwtinfo.TEID).FirstAsync();
+ if (tp == null)
+ _cacheService.Add<TenantPermissions>(Key, tp, 300);
+ else
+ return false;
+ }
+
+ if (tp.OverTime > DateTime.Now)
+ return true;
+ return false;
+ }
+ return false;
+ }
+
}
--
Gitblit v1.9.1