From 3f4013e9283d1fe29ef40cc8b4d7ee7a590a1590 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期二, 17 十月 2023 09:26:40 +0800
Subject: [PATCH] 最新代码
---
DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs | 88 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 73 insertions(+), 15 deletions(-)
diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
index 728bcd2..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>
/// 鍛樺伐璇︽儏
@@ -120,21 +129,21 @@
}
).WithCache( 10).ToListAsync();
+ //涓嶅啀閫夋嫨绉熸埛
+ //var ten = await _db.Queryable<TenantInfo>().Where(x => x.IsEn == true && x.IsDel != true && x.ItCode == ItCode)
+ // .Select(x => new TenderVM
+ // {
- var ten = await _db.Queryable<TenantInfo>().Where(x => x.IsEn == true && x.IsDel != true && x.ItCode == ItCode)
- .Select(x => new TenderVM
- {
+ // Description = x.Description,
+ // ItCode = ItCode,
+ // Name = x.Name,
+ // TenderId = x.Id,
+ // IsTender = true
- Description = x.Description,
- ItCode = ItCode,
- Name = x.Name,
- TenderId = x.Id,
- IsTender = true
-
- }
- ).WithCache(10).ToListAsync() ;
- ten.AddRange(tentlist);
- return ten;
+ // }
+ // ).WithCache(10).ToListAsync() ;
+ //ten.AddRange(tentlist);
+ return tentlist;
}
@@ -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