From b4f4b640ac62bf583e25512656ac92bb09872b8a Mon Sep 17 00:00:00 2001 From: liaoxujun@qq.com <liaoxujun@qq.com> Date: 星期五, 04 八月 2023 09:38:10 +0800 Subject: [PATCH] 增加用户详情, --- DocumentServiceAPI.Web.Entry/DocumentServiceAPI.Web.Entry.csproj.user | 1 DocumentServiceAPI.Enum/BaseModel.cs | 4 DocumentServiceAPI.Model/JwtInfo.cs | 4 DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user | 11 DocumentServiceAPI.Application/UserAndLogin/ViewMode/Login.cs | 2 DocumentServiceAPI.Application/Repository/EmployeeRepository.cs | 18 DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs | 2 DocumentServiceAPI.Core/DocumentServiceAPI.Core.xml | 112 +++++ DocumentServiceAPI.Core/SqlSugarMemoryCache.cs | 282 ++++++++++++ DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj | 4 DocumentServiceAPI.Model/Permissions/TenantPermissions.cs | 17 DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml | 194 ++++++++ DocumentServiceAPI.Application/UserAndLogin/UserInfoController.cs | 56 ++ DocumentServiceAPI.Model/UserInfoModel/EmployeeInfo.cs | 2 DocumentServiceAPI.Application/System/Services/OrganizationService.cs | 6 DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs | 176 ++++++++ DocumentServiceAPI.Utility/UtilityFun.cs | 4 DocumentServiceAPI.Application/UserAndLogin/LogInController.cs | 19 DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj | 1 DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml | 17 DocumentServiceAPI.Application/UserAndLogin/dto/Mapper.cs | 8 DocumentFile.Service/Properties/launchSettings.json | 12 DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/IUserService.cs | 2 DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs | 232 ++++++++++ DocumentServiceAPI.Core/DbContext.cs | 2 DocumentServiceAPI.Web.Entry/.config/dotnet-tools.json | 12 DocumentServiceAPI.Web.Core/Startup.cs | 7 DocumentServiceAPI.Core/SqlSugarRedisCache.cs | 61 ++ 28 files changed, 1,225 insertions(+), 43 deletions(-) diff --git a/DocumentFile.Service/Properties/launchSettings.json b/DocumentFile.Service/Properties/launchSettings.json new file mode 100644 index 0000000..63b94f2 --- /dev/null +++ b/DocumentFile.Service/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "DocumentFile.Service": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:52095;http://localhost:52096" + } + } +} \ No newline at end of file diff --git a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj index 1ec5c17..a44c6d5 100644 --- a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj +++ b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.csproj @@ -32,4 +32,8 @@ <Folder Include="GlobalServices\" /> </ItemGroup> + <ItemGroup> + <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" /> + </ItemGroup> + </Project> diff --git a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml index e696fce..29ebda8 100644 --- a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml +++ b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml @@ -4,6 +4,11 @@ <name>DocumentServiceAPI.Application</name> </assembly> <members> + <member name="T:DocumentServiceAPI.Application.Repository.EmployeeRepository"> + <summary> + 鍛樺伐璇诲彇 + </summary> + </member> <member name="T:DocumentServiceAPI.Application.System.Services.OrganizationService"> <summary> 鎶曟爣鍗曚綅鎿嶄綔绫� @@ -84,7 +89,7 @@ 鑾峰彇Jwt鐩稿叧淇℃伅 </summary> </member> - <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.UserService.GetUserUnitInfo(System.Int32)"> + <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.UserService.GetUserUnitList(System.Int32)"> <summary> 鑾峰彇鍗曚綅鍒楄〃 </summary> @@ -106,6 +111,23 @@ <param name="PsW">瀵嗙爜</param> <returns></returns> </member> + <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.UserService.GetUserInfo(System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32})"> + <summary> + 鑾峰彇鐢ㄦ埛璇︽儏锛屽寘鎷憳宸ヤ俊鎭紝绉熸埛淇℃伅锛屽崟浣嶄俊鎭� + </summary> + <param name="TenantID"> 绉熸埛ID</param> + <param name="EmployeeID">鍛樺伐ID </param> + <param name="UnitID">鍗曚綅ID</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.UserService.postEmployeeList(DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeePageSearch)"> + <summary> + 鑾峰彇鍛樺伐鍒楄〃 + </summary> + <param name="_businessService"></param> + <param name="page"></param> + <returns></returns> + </member> <member name="T:DocumentServiceAPI.Application.UserAndLogin.UserInfoController"> <summary> 鐧诲綍鎺у埗鍣� @@ -113,8 +135,29 @@ </member> <member name="M:DocumentServiceAPI.Application.UserAndLogin.UserInfoController.GetUserInfo"> <summary> - + 鑾峰彇鐢ㄦ埛璇︽儏 </summary> + </member> + <member name="M:DocumentServiceAPI.Application.UserAndLogin.UserInfoController.postEmployeeList(DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeePageSearch)"> + <summary> + 鑾峰彇鍛樺伐鍒楄〃 + </summary> + <param name="page"></param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Application.UserAndLogin.UserInfoController.CreateEmployee(DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM)"> + <summary> + 鍒涘缓鏂板憳宸� + </summary> + <param name="Parma"></param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Application.UserAndLogin.UserInfoController.UpDataEmployee(DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM)"> + <summary> + 鏇存柊鍛樺伐淇℃伅 + </summary> + <param name="Parma"></param> + <returns></returns> </member> <member name="T:DocumentServiceAPI.Application.UserAndLogin.ViewMode.LoginPsWordIN"> <summary> @@ -251,10 +294,155 @@ 鍏徃鍒楄〃 </summary> </member> - <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.RetLoginVM.Tenders"> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.RetLoginVM.Tenants"> <summary> 绉熸埛鍒楄〃 </summary> </member> + <member name="T:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeePageSearch"> + <summary> + 鍛樺伐鎼滅储 鍙傛暟 + </summary> + </member> + <member name="T:DocumentServiceAPI.Application.UserAndLogin.ViewMode.UnitInfoVM"> + <summary> + 鍗曚綅璇︽儏 + </summary> + </member> + <member name="T:DocumentServiceAPI.Application.UserAndLogin.ViewMode.TenderInfoVM"> + <summary> + 绉熸埛璇︽儏 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.TenderInfoVM.Id"> + <summary> + ID + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.TenderInfoVM.ItCode"> + <summary> + 绉熸埛鍚� + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.TenderInfoVM.Name"> + <summary> + 鍚嶇О + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.TenderInfoVM.Description"> + <summary> + 鎻忚堪 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.TenderInfoVM.ReMark"> + <summary> + 鏍囨敞 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.EmployeeId"> + <summary> + 鍛樺伐ID + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.EmployeeName"> + <summary> + 鍛樺伐鍚嶇О + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.Job"> + <summary> + 宸ヤ綔鑱屼綅 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.Phone"> + <summary> + 鐢佃瘽 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.IsWork"> + <summary> + 鏄惁鍦ㄥ伐浣� + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.LeaveTime"> + <summary> + 绂诲紑鏃堕棿 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.CardPositive"> + <summary> + 璇佷欢姝i潰 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.CardPositiveVersionNo"> + <summary> + 璇佷欢姝i潰鐗堟湰鍙� + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.CardPositiveSize"> + <summary> + 璇佷欢姝i潰澶у皬 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.LastUpdateTime"> + <summary> + 鏈�鍚庢洿鏂版椂闂� + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.LastUpdateName"> + <summary> + 鏈�鍚庢洿鏂颁汉 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserName"> + <summary> + 鐢ㄦ埛鍚� + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserPassWord"> + <summary> + 鐢ㄦ埛瀵嗙爜 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.LoginTime"> + <summary> + 鐧诲綍鏃堕棿 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.IsLogin"> + <summary> + 鏄惁鐧诲綍 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.AdviseFlag"> + <summary> + 寤鸿鏍囧織 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserId"> + <summary> + 鐢ㄦ埛ID + </summary> + </member> + <member name="T:DocumentServiceAPI.Application.UserAndLogin.ViewMode.RetUserInfo"> + <summary> + 鐢ㄦ埛璇︽儏 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.RetUserInfo.UnitInfo"> + <summary> + 鍗曚綅淇℃伅 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.RetUserInfo.TenderInfo"> + <summary> + 绉熸埛淇℃伅 + </summary> + </member> + <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.RetUserInfo.EmployeeInfo"> + <summary> + 鍛樺伐淇℃伅 + </summary> + </member> </members> </doc> diff --git a/DocumentServiceAPI.Application/Repository/EmployeeRepository.cs b/DocumentServiceAPI.Application/Repository/EmployeeRepository.cs new file mode 100644 index 0000000..14eda72 --- /dev/null +++ b/DocumentServiceAPI.Application/Repository/EmployeeRepository.cs @@ -0,0 +1,18 @@ +锘縰sing DocumentServiceAPI.Core; +using DocumentServiceAPI.Model.cyDocumentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceAPI.Application.Repository +{ + /// <summary> + /// 鍛樺伐璇诲彇 + /// </summary> + public class EmployeeRepository:BaseRepository<Document_EmployeeInfo>, ITransient + { + + } +} diff --git a/DocumentServiceAPI.Application/System/Services/OrganizationService.cs b/DocumentServiceAPI.Application/System/Services/OrganizationService.cs index 79bb66b..4613025 100644 --- a/DocumentServiceAPI.Application/System/Services/OrganizationService.cs +++ b/DocumentServiceAPI.Application/System/Services/OrganizationService.cs @@ -9,11 +9,7 @@ public class OrganizationService : BaseRepository<Document_TenderUnit>, ITransient { - public OrganizationService(ISqlSugarClient sql) { - base.Context = sql; - base.Context.AsTenant().ChangeDatabase("default"); - - } + } diff --git a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs index ddcbf1f..af4662b 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs @@ -3,6 +3,7 @@ using DocumentServiceAPI.Utility; using Furion.DynamicApiController; using Furion.JsonSerialization; +using Swashbuckle.AspNetCore.Annotations; using System; using System.Collections.Generic; using System.Linq; @@ -16,6 +17,7 @@ /// </summary> [ApiDescriptionSettings("LogInAndUser")] [DynamicApiController] + public class LogInController { private TokenService _tokenService; @@ -29,6 +31,8 @@ /// </summary> /// <returns>鐧诲綍淇℃伅</returns> [HttpPost("LogoIn")] + + public async Task<RetLoginVM> LogoIn (LoginPsWordIN Parma) { bool needtoken=false; @@ -46,9 +50,13 @@ if(!needtoken) throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); + + Parma.TenantId = Tender[0].TenderId; + Parma.employeeID = Tender[0].EmployeeID; if (Parma.UnitID == null) { - var Units = await _userService.GetUserUnitInfo(Parma.TenantId ?? 0); + + List<UnitVM> Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0); if (Units.Count == 0) { //娌℃湁鍏徃 @@ -70,7 +78,7 @@ }; } } - Parma.TenantId = Tender[0].TenderId; + break; default: @@ -78,7 +86,7 @@ return new RetLoginVM { NeedNext = true, - Tenders = Tender, + Tenants = Tender, }; @@ -93,7 +101,7 @@ else if(Parma.UnitID==null) { - var Units = await _userService.GetUserUnitInfo(Parma.TenantId??0); + var Units = await _userService.GetUserUnitList(Parma.TenantId??0); if(Units.Count==0) { //娌℃湁鍏徃 @@ -118,6 +126,7 @@ if(needtoken|| Parma.UnitID!=null) { + TenderVM Tender = (await _userService.GetUserTenderList(Parma.ITCode)).Where(x=>x.TenderId==Parma.TenantId&&x.EmployeeID==Parma.employeeID).SingleOrDefault(); if(Tender==null) { @@ -131,7 +140,7 @@ { EID = Tender.EmployeeID, LogInSource = Parma.Form, - TID = Tender.TenderId, + TEID = Tender.TenderId, UID = Parma.UnitID, }); return new RetLoginVM diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/ILoginVerifyService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/IUserService.cs similarity index 83% rename from DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/ILoginVerifyService.cs rename to DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/IUserService.cs index da67b06..6ef0df2 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/ILoginVerifyService.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/IUserService.cs @@ -6,7 +6,7 @@ namespace DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces { - public interface ILoginVerifyService + public interface IUserService { } } diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs index f7e4355..8988879 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs @@ -88,7 +88,7 @@ /// <returns></returns> private string getTokenKey(JwtInfo jwt) { - string TokenKey = TokenKeys + jwt.EID?.ToString() + jwt.UID?.ToString() + jwt.TID?.ToString(); + string TokenKey = TokenKeys + jwt.EID?.ToString() + jwt.UID?.ToString() + jwt.TEID?.ToString(); return TokenKey; } } diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs index 565e374..6c0236b 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs @@ -1,8 +1,12 @@ -锘縰sing DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces; +锘縰sing DocumentServiceAPI.Application.Repository; +using DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces; using DocumentServiceAPI.Application.UserAndLogin.ViewMode; using DocumentServiceAPI.Model; using DocumentServiceAPI.Model.cyDocumentModel; using DocumentServiceAPI.Model.UserInfoModel; +using DocumentServiceAPI.Utility; +using Furion.Logging.Extensions; +using MapsterMapper; using SqlSugar.Extensions; using System; using System.Collections.Generic; @@ -13,15 +17,20 @@ namespace DocumentServiceAPI.Application.UserAndLogin.Services { + /// <summary> /// 鐧诲綍楠岃瘉鏈嶅姟 /// </summary> - public class UserService : ILoginVerifyService, IScoped + public class UserService : IUserService, IScoped { private ISqlSugarClient _db { get; set; } - public UserService(ISqlSugarClient db) + private EmployeeRepository _employeeRepository{ get; set; } + private IMapper _mapper { get; set; } + public UserService(ISqlSugarClient db, EmployeeRepository employeeRepository, IMapper mapper) { _db = db; + _employeeRepository= employeeRepository; + _mapper = mapper; } /// <summary> /// 鍛樺伐璇︽儏 @@ -55,16 +64,17 @@ jwtInfo.LogInSource = (LogInFrom)(App.User?.FindFirstValue("loginfrom")?.ObjToInt() ?? 0); jwtInfo.EID = App.User?.FindFirstValue("eid")?.ObjToInt(); jwtInfo.UID = App.User?.FindFirstValue("uid")?.ObjToInt(); - jwtInfo.TID = App.User?.FindFirstValue("tid")?.ObjToInt(); + jwtInfo.TEID = App.User?.FindFirstValue("teid")?.ObjToInt(); var guid = App.User?.FindFirstValue("jid"); - jwtInfo.JID = string.IsNullOrEmpty(guid) ? new Guid(guid) : null; + jwtInfo.JID = string.IsNullOrEmpty(guid) ? null: new Guid(guid); return jwtInfo; } + /// <summary> /// 鑾峰彇鍗曚綅鍒楄〃 /// </summary> /// <returns></returns> - public async Task<List<UnitVM>> GetUserUnitInfo(int tid ) + public async Task<List<UnitVM>> GetUserUnitList(int tid ) { var list = await _db.Queryable<DocumentServiceAPI.Model.cyDocumentModel.Document_TenderUnit>() @@ -75,7 +85,7 @@ UnitName = tu.UnitName, Remark = tu.Remark, UnitLogo = tu.UnitLogo, - }) + }).WithCache(10) .ToListAsync(); return list; } @@ -109,7 +119,7 @@ TenderId = ti.Id } - ).ToListAsync(); + ).WithCache( 10).ToListAsync(); var ten = await _db.Queryable<TenantInfo>().Where(x => x.IsEn == true && x.IsDel != true && x.ItCode == ItCode) .Select(x => new TenderVM @@ -122,7 +132,7 @@ IsTender = true } - ).ToListAsync() ; + ).WithCache(10).ToListAsync() ; ten.AddRange(tentlist); return ten; @@ -166,7 +176,209 @@ } - + /// <summary> + /// 鑾峰彇鐢ㄦ埛璇︽儏锛屽寘鎷憳宸ヤ俊鎭紝绉熸埛淇℃伅锛屽崟浣嶄俊鎭� + /// </summary> + /// <param name="TenantID"> 绉熸埛ID</param> + /// <param name="EmployeeID">鍛樺伐ID </param> + /// <param name="UnitID">鍗曚綅ID</param> + /// <returns></returns> + public async Task<RetUserInfo> GetUserInfo(int? TenantID,int? EmployeeID,int? UnitID) + { + TenderInfoVM Tenant = null; + EmployeeInfoVM Employee = null; + if (TenantID != null) + Tenant = await _db.Queryable<TenantInfo>().Where(x => x.Id == TenantID) + .Select(x => new TenderInfoVM + { + Description = x.Description, + Id = x.Id, + ItCode = x.ItCode, + Name = x.Name, + ReMark = x.ReMark, + }).WithCache(20).FirstAsync(); + if (EmployeeID != null) + Employee = await _db.Queryable<Document_EmployeeInfo>().Where(x => x.EmployeeId == EmployeeID) + .Select(x => new EmployeeInfoVM + { AdviseFlag = x.AdviseFlag, + CardPositive = x.CardPositive, + CardPositiveSize = x.CardPositiveSize, + CardPositiveVersionNo = x.CardPositiveVersionNo, + EmployeeId = x.EmployeeId, + EmployeeName = x.EmployeeName, + Job = x.Job, + LastUpdateName = x.LastUpdateName, + UserName = x.UserName, + + + + }).WithCache(20).FirstAsync(); + UnitInfoVM Unit = null; + if (UnitID != null) + Unit = await _db.Queryable<Model.cyDocumentModel.Document_TenderUnit>().Where(x => x.UnitId == UnitID) + .Select(x => new UnitInfoVM + { + FirmQualificationLevel = x.FirmQualificationLevel, + Fax = x.Fax, + CorporaterTechnicalPost= x.CorporaterTechnicalPost, + LastUpdateName= x.LastUpdateName, + Address = x.Address, + AdviseFlag = x.AdviseFlag, BankNum = x.BankNum, + BusinessContent = x.BusinessContent, + BusinessLicense = x.BusinessLicense, + CardPositive= x.CardPositive, + CardPositiveSize= x.CardPositiveSize, + CardPositiveVersionNo= x.CardPositiveVersionNo, + ContactPerson= x.ContactPerson, + ContactPhone= x.ContactPhone, + CorporatePhone= x.CorporatePhone, + Corporater= x.Corporater, + CorporaterPost= x.CorporaterPost, + CreatTime= x.CreatTime, + Mechanicer= x.Mechanicer, + MiddleStaff= x.MiddleStaff, + OpenBank= x.OpenBank, + OrgStructure= x.OrgStructure, + PrimaryStaff= x.PrimaryStaff, + ProjectManager= x.ProjectManager, + RegMoney= x.RegMoney, + Remark= x.Remark, + UnitId= x.UnitId, + TechnicalLeader= x.TechnicalLeader, + SeniorStaff= x.SeniorStaff, + StaffCount= x.StaffCount, + TechnicalPhone= x.TechnicalPhone, + TechnicalPost= x.TechnicalPost, + UnitLogo= x.UnitLogo, + UnitLogoSize= x.UnitLogoSize, + UnitLogoVersionNo= x.UnitLogoVersionNo, + UnitName= x.UnitName, + UnitType= x.UnitType, + WebUrl= x.WebUrl, + ZipCode= x.ZipCode, + + + + + }).WithCache(20).FirstAsync(); + + + return new RetUserInfo + { + EmployeeInfo = Employee, + TenderInfo = Tenant, + UnitInfo = Unit + }; + } + + /// <summary> + /// 鑾峰彇鍛樺伐鍒楄〃 + /// </summary> + /// <param name="_businessService"></param> + /// <param name="page"></param> + /// <returns></returns> + public async Task<PageResult<EmployeeInfoVM>> postEmployeeList( EmployeePageSearch page) + { + var a = GetJwtInfo(); + if(a.EID!=null) + throw Oops.Oh($"娌℃湁鏉冮檺"); + SqlSugar.PageModel pg = new SqlSugar.PageModel(); + pg.PageSize = page.PageSize; + pg.PageIndex = page.PageIndex; + RefAsync<int> total = 0; + PageResult<EmployeeInfoVM> result = new PageResult<EmployeeInfoVM>(); + result.Items = await _db.Queryable<EmployeeAtTenant, Document_EmployeeInfo>((et, ei) => + new JoinQueryInfos(JoinType.Left, et.EmployeeID==ei.EmployeeId + )).Where((ei,et)=>ei.TenantID==a.TEID) + .Select((ei,et)=>new EmployeeInfoVM + { + EmployeeId = et.EmployeeId, + AdviseFlag=et.AdviseFlag, + CardPositive=et.CardPositive, + CardPositiveSize=et.CardPositiveSize, + CardPositiveVersionNo=et.CardPositiveVersionNo, + EmployeeName=et.EmployeeName, + IsWork=et.IsWork, + Job=et.Job, + LeaveTime=et.LeaveTime, + Phone=et.Phone, + UserId=et.UserId, + UserName=et.UserName, + + + + + + }).MergeTable().OrderBy(x=>x.EmployeeId).ToPageListAsync(page.PageIndex,page.PageSize, total); + + result.TotalCount = pg.TotalCount; + return result; + } + + + + + public async Task<bool > UpEmployee(EmployeeInfoVM vm) + { + + var jwtinfo = GetJwtInfo(); + + if (jwtinfo.EID != null) + throw Oops.Oh($"娌℃湁鏉冮檺"); + var info = await GetUserInfo(jwtinfo.TEID, null, null); + Document_EmployeeInfo a = _mapper.Map<Document_EmployeeInfo>(vm); + + a.LastUpdateName = info.EmployeeInfo.UserName; + a.LastUpdateTime = DateTime.Now; + + return await _employeeRepository.UpdateAsync(a); + + } + + public async Task<bool> InEmployee(EmployeeInfoVM vm) + { + var jwtinfo = GetJwtInfo(); + if (jwtinfo.EID != null) + throw Oops.Oh($"娌℃湁鏉冮檺"); + Document_EmployeeInfo a = _mapper.Map<Document_EmployeeInfo>(vm); + + var info = await GetUserInfo(jwtinfo.TEID, null, null); + EmployeeAtTenant elt = new EmployeeAtTenant + { + CreatBy = info.TenderInfo.ItCode, + CreatTime = DateTime.Now, + TenantID = info.TenderInfo.Id, + + + + }; + try + { + await _employeeRepository.AsTenant().BeginTranAsync(); + var jwtId= await _employeeRepository.InsertReturnIdentityAsync(a); + elt.EmployeeID = jwtId; + await _db.Insertable(elt).ExecuteCommandAsync(); + + await _employeeRepository.AsTenant().CommitTranAsync(); + + } + catch (Exception e) + { + + await _employeeRepository.AsTenant().RollbackTranAsync(); + //鍐欐棩蹇� + $" 鎻掑叆鏂板憳宸ュけ璐ワ紝 閿欒娑堟伅锛歿e.Message} \r\n 鍫嗘爤閿欒锛歿e.StackTrace}" .LogInformation(); + throw Oops.Oh("鏂板澶辫触"); + } + + return await _employeeRepository.InsertAsync(a); + + + + + + } + } diff --git a/DocumentServiceAPI.Application/UserAndLogin/UserInfoController.cs b/DocumentServiceAPI.Application/UserAndLogin/UserInfoController.cs index 0629ec4..9713ce3 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/UserInfoController.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/UserInfoController.cs @@ -1,4 +1,11 @@ -锘縰sing System; +锘縰sing DocumentServiceAPI.Application.Repository; +using DocumentServiceAPI.Application.UserAndLogin.Services; +using DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces; +using DocumentServiceAPI.Application.UserAndLogin.ViewMode; +using DocumentServiceAPI.Model.cyDocumentModel; +using DocumentServiceAPI.Utility; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,14 +19,51 @@ /// </summary> [ApiDescriptionSettings("LogInAndUser")] [DynamicApiController] + [Authorize] public class UserInfoController { - /// <summary> - /// - /// </summary> - public void GetUserInfo() - { + private readonly UserService _userService; + public UserInfoController(UserService userService) { + _userService = userService; + } + /// <summary> + /// 鑾峰彇鐢ㄦ埛璇︽儏 + /// </summary> + public async Task< RetUserInfo> GetUserInfo() + { + var jwt=_userService.GetJwtInfo(); + return await _userService.GetUserInfo(jwt.TEID, jwt.EID, jwt.UID); + } + /// <summary> + /// 鑾峰彇鍛樺伐鍒楄〃 + /// </summary> + /// <param name="page"></param> + /// <returns></returns> + public async Task<PageResult<EmployeeInfoVM>> postEmployeeList( EmployeePageSearch page) + { + return await _userService.postEmployeeList(page); + } + + /// <summary> + /// 鍒涘缓鏂板憳宸� + /// </summary> + /// <param name="Parma"></param> + /// <returns></returns> + public async Task<bool> CreateEmployee(EmployeeInfoVM Parma) + { + return await _userService.InEmployee(Parma); + } + + + /// <summary> + /// 鏇存柊鍛樺伐淇℃伅 + /// </summary> + /// <param name="Parma"></param> + /// <returns></returns> + public async Task<bool> UpDataEmployee(EmployeeInfoVM Parma) + { + return await _userService.UpEmployee(Parma); } } } diff --git a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/Login.cs b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/Login.cs index cf1f8e8..2a04bae 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/Login.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/Login.cs @@ -160,7 +160,7 @@ /// 绉熸埛鍒楄〃 /// </summary> #nullable enable - public List<TenderVM>? Tenders { get; set; } + public List<TenderVM>? Tenants { get; set; } #nullable enable public string? Token { get; set; } diff --git a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs new file mode 100644 index 0000000..7494f98 --- /dev/null +++ b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs @@ -0,0 +1,176 @@ +锘縰sing DocumentServiceAPI.Model.cyDocumentModel; +using DocumentServiceAPI.Utility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceAPI.Application.UserAndLogin.ViewMode +{ + + /// <summary> + /// 鍛樺伐鎼滅储 鍙傛暟 + /// </summary> + public class EmployeePageSearch : PageBaseSearch + { + + } + + + /// <summary> + /// 鍗曚綅璇︽儏 + /// </summary> + public class UnitInfoVM: Document_TenderUnit + { + } + /// <summary> + /// 绉熸埛璇︽儏 + /// </summary> + public class TenderInfoVM + { + /// <summary> + /// ID + /// </summary> + [Display(Name = "ID ")] + [SugarColumn(ColumnDescription = "ID ", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// <summary> + /// 绉熸埛鍚� + /// </summary> + [Display(Name = "绉熸埛鍚� ")] + [SugarColumn(ColumnDescription = "绉熸埛鍚� ", Length = 20)] + public string ItCode { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + [Display(Name = "鍚嶇О ")] + [SugarColumn(ColumnDescription = "鍚嶇О ", Length = 200)] + public string? Name { get; set; } + + /// <summary> + /// 鎻忚堪 + /// </summary> + [Display(Name = "鎻忚堪 ")] + [SugarColumn(ColumnDescription = "鎻忚堪 ")] + public string? Description { get; set; } + /// <summary> + /// 鏍囨敞 + /// </summary> + [Display(Name = "鏍囨敞")] + [SugarColumn(ColumnDescription = "鏍囨敞")] + public string? ReMark { get; set; } + ///// <summary> + ///// 鏁版嵁搴撻摼鎺ュ瓧绗︿覆 澶囩敤 + ///// </summary> + //[Display(Name = "鏁版嵁搴撻摼鎺ュ瓧绗︿覆")] + //[SugarColumn(ColumnDescription = "鏁版嵁搴撻摼鎺ュ瓧绗︿覆")] + //public string? ConnectionString { get; set; } + + ///// <summary> + ///// 鏁版嵁搴撶被鍨� 澶囩敤 + ///// </summary> + //[Display(Name = "鏁版嵁搴撶被鍨�")] + //[SugarColumn(ColumnDescription = "鏁版嵁搴撶被鍨�")] + //public string? DbType { get; set; } + + ///// <summary> + ///// 瀵嗙爜 + ///// </summary> + //[SugarColumn(Length = 30)] + //public string? PsW { get; set; } + } + + public class EmployeeInfoVM /*:Document_EmployeeInfo*/ + { + /// <summary> + /// 鍛樺伐ID + /// </summary> + public int? EmployeeId { get; set; } + /// <summary> + /// 鍛樺伐鍚嶇О + /// </summary> + public string EmployeeName { get; set; } + /// <summary> + /// 宸ヤ綔鑱屼綅 + /// </summary> + public string Job { get; set; } + /// <summary> + /// 鐢佃瘽 + /// </summary> + public string Phone { get; set; } + /// <summary> + /// 鏄惁鍦ㄥ伐浣� + /// </summary> + public int? IsWork { get; set; } + /// <summary> + /// 绂诲紑鏃堕棿 + /// </summary> + public DateTime? LeaveTime { get; set; } + /// <summary> + /// 璇佷欢姝i潰 + /// </summary> + public string CardPositive { get; set; } + /// <summary> + /// 璇佷欢姝i潰鐗堟湰鍙� + /// </summary> + public string CardPositiveVersionNo { get; set; } + /// <summary> + /// 璇佷欢姝i潰澶у皬 + /// </summary> + public int? CardPositiveSize { get; set; } + /// <summary> + /// 鏈�鍚庢洿鏂版椂闂� + /// </summary> + public DateTime? LastUpdateTime { get; set; } + /// <summary> + /// 鏈�鍚庢洿鏂颁汉 + /// </summary> + public string LastUpdateName { get; set; } + /// <summary> + /// 鐢ㄦ埛鍚� + /// </summary> + public string UserName { get; set; } + /// <summary> + /// 鐢ㄦ埛瀵嗙爜 + /// </summary> + public string UserPassWord { get; set; } + /// <summary> + /// 鐧诲綍鏃堕棿 + /// </summary> + public DateTime? LoginTime { get; set; } + /// <summary> + /// 鏄惁鐧诲綍 + /// </summary> + public bool? IsLogin { get; set; } + /// <summary> + /// 寤鸿鏍囧織 + /// </summary> + public int? AdviseFlag { get; set; } + /// <summary> + /// 鐢ㄦ埛ID + /// </summary> + public int? UserId { get; set; } + } + /// <summary> + /// 鐢ㄦ埛璇︽儏 + /// </summary> + public class RetUserInfo + { + /// <summary> + /// 鍗曚綅淇℃伅 + /// </summary> + public UnitInfoVM UnitInfo { get; set; } + /// <summary> + /// 绉熸埛淇℃伅 + /// </summary> + public TenderInfoVM TenderInfo{ get; set; } + /// <summary> + /// 鍛樺伐淇℃伅 + /// </summary> + public EmployeeInfoVM EmployeeInfo { get; set; } + + } +} diff --git a/DocumentServiceAPI.Application/UserAndLogin/dto/Mapper.cs b/DocumentServiceAPI.Application/UserAndLogin/dto/Mapper.cs index f3c23d7..081eba5 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/dto/Mapper.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/dto/Mapper.cs @@ -1,4 +1,6 @@ -锘縰sing System; +锘縰sing DocumentServiceAPI.Application.UserAndLogin.ViewMode; +using DocumentServiceAPI.Model.cyDocumentModel; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,7 +12,9 @@ { public void Register(TypeAdapterConfig config) { - + config.ForType<Document_EmployeeInfo, EmployeeInfoVM>(); + + } } } diff --git a/DocumentServiceAPI.Core/DbContext.cs b/DocumentServiceAPI.Core/DbContext.cs index 069d96f..3dd2e23 100644 --- a/DocumentServiceAPI.Core/DbContext.cs +++ b/DocumentServiceAPI.Core/DbContext.cs @@ -45,7 +45,7 @@ db.CurrentConnectionConfig.ConfigureExternalServices = new ConfigureExternalServices() { //鍒ゆ柇鏄惁寮�鍚痳edis璁剧疆浜岀骇缂撳瓨鏂瑰紡 - // DataInfoCacheService = new SqlSugarRedisCache(), + DataInfoCacheService = new SqlSugarRedisCache(), //妯″瀷瀹氫箟涓� int?鍙锋椂鑷姩涓哄彲绌� EntityService = (c, p) => { diff --git a/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj b/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj index f061aea..bde0efd 100644 --- a/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj +++ b/DocumentServiceAPI.Core/DocumentServiceAPI.Core.csproj @@ -14,6 +14,7 @@ </ItemGroup> <ItemGroup> + <PackageReference Include="CSRedisCore" Version="3.8.670" /> <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.38" /> <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.38" /> <PackageReference Include="Furion.Pure" Version="4.8.8.38" /> diff --git a/DocumentServiceAPI.Core/DocumentServiceAPI.Core.xml b/DocumentServiceAPI.Core/DocumentServiceAPI.Core.xml index 161906c..f7acc16 100644 --- a/DocumentServiceAPI.Core/DocumentServiceAPI.Core.xml +++ b/DocumentServiceAPI.Core/DocumentServiceAPI.Core.xml @@ -23,5 +23,117 @@ <param name="ConfigId">閰嶇疆搴撳悕</param> <param name="ModeProjectName"></param> </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Exists(System.String)"> + <summary> + 楠岃瘉缂撳瓨椤规槸鍚﹀瓨鍦� + </summary> + <param name="key">缂撳瓨Key</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Set(System.String,System.Object,System.TimeSpan,System.TimeSpan)"> + <summary> + 娣诲姞缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <param name="value">缂撳瓨Value</param> + <param name="expiresSliding">婊戝姩杩囨湡鏃堕暱锛堝鏋滃湪杩囨湡鏃堕棿鍐呮湁鎿嶄綔锛屽垯浠ュ綋鍓嶆椂闂寸偣寤堕暱杩囨湡鏃堕棿锛�</param> + <param name="expiressAbsoulte">缁濆杩囨湡鏃堕暱</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Set(System.String,System.Object,System.TimeSpan,System.Boolean)"> + <summary> + 娣诲姞缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <param name="value">缂撳瓨Value</param> + <param name="expiresIn">缂撳瓨鏃堕暱</param> + <param name="isSliding">鏄惁婊戝姩杩囨湡锛堝鏋滃湪杩囨湡鏃堕棿鍐呮湁鎿嶄綔锛屽垯浠ュ綋鍓嶆椂闂寸偣寤堕暱杩囨湡鏃堕棿锛�</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Set(System.String,System.Object)"> + <summary> + 娣诲姞缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <param name="value">缂撳瓨Value</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Set(System.String,System.Object,System.TimeSpan)"> + <summary> + 娣诲姞缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <param name="value">缂撳瓨Value</param> + <param name="ts"></param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Set(System.String,System.Object,System.Int32)"> + <summary> + 娣诲姞缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <param name="value">缂撳瓨Value</param> + <param name="ts"></param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Remove(System.String)"> + <summary> + 鍒犻櫎缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.RemoveAll(System.Collections.Generic.IEnumerable{System.String})"> + <summary> + 鎵归噺鍒犻櫎缂撳瓨 + </summary> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Get``1(System.String)"> + <summary> + 鑾峰彇缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.Get(System.String)"> + <summary> + 鑾峰彇缂撳瓨 + </summary> + <param name="key">缂撳瓨Key</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.GetAll(System.Collections.Generic.IEnumerable{System.String})"> + <summary> + 鑾峰彇缂撳瓨闆嗗悎 + </summary> + <param name="keys">缂撳瓨Key闆嗗悎</param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.RemoveCacheAll"> + <summary> + 鍒犻櫎鎵�鏈夌紦瀛� + </summary> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.RemoveCacheRegex(System.String)"> + <summary> + 鍒犻櫎鍖归厤鍒扮殑缂撳瓨 + </summary> + <param name="pattern"></param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.SearchCacheRegex(System.String)"> + <summary> + 鎼滅储 鍖归厤鍒扮殑缂撳瓨 + </summary> + <param name="pattern"></param> + <returns></returns> + </member> + <member name="M:DocumentServiceAPI.Core.MemoryCacheHelper.GetCacheKeys"> + <summary> + 鑾峰彇鎵�鏈夌紦瀛橀敭 + </summary> + <returns></returns> + </member> </members> </doc> diff --git a/DocumentServiceAPI.Core/SqlSugarMemoryCache.cs b/DocumentServiceAPI.Core/SqlSugarMemoryCache.cs new file mode 100644 index 0000000..522a1cc --- /dev/null +++ b/DocumentServiceAPI.Core/SqlSugarMemoryCache.cs @@ -0,0 +1,282 @@ +锘縰sing Microsoft.Extensions.Caching.Memory; +using SqlSugar; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace DocumentServiceAPI.Core +{ + public class SqlSugarMemoryCache : ICacheService + { + MemoryCacheHelper cache = new MemoryCacheHelper(); + public void Add<V>(string key, V value) + { + cache.Set(key, value); + } + + public void Add<V>(string key, V value, int cacheDurationInSeconds) + { + cache.Set(key, value, cacheDurationInSeconds); + } + + public bool ContainsKey<V>(string key) + { + return cache.Exists(key); + } + + public V Get<V>(string key) + { + return cache.Get<V>(key); + } + + public IEnumerable<string> GetAllKey<V>() + { + return cache.GetCacheKeys(); + } + + public V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue) + { + if (cache.Exists(cacheKey)) + { + return cache.Get<V>(cacheKey); + } + else + { + var result = create(); + cache.Set(cacheKey, result, cacheDurationInSeconds); + return result; + } + } + + public void Remove<V>(string key) + { + cache.Remove(key); + } + } + public class MemoryCacheHelper + { + private static readonly Microsoft.Extensions.Caching.Memory.MemoryCache Cache = new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptions()); + + /// <summary> + /// 楠岃瘉缂撳瓨椤规槸鍚﹀瓨鍦� + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <returns></returns> + public bool Exists(string key) + { + if (key == null) + throw new ArgumentNullException(nameof(key)); + return Cache.TryGetValue(key, out _); + } + + /// <summary> + /// 娣诲姞缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <param name="value">缂撳瓨Value</param> + /// <param name="expiresSliding">婊戝姩杩囨湡鏃堕暱锛堝鏋滃湪杩囨湡鏃堕棿鍐呮湁鎿嶄綔锛屽垯浠ュ綋鍓嶆椂闂寸偣寤堕暱杩囨湡鏃堕棿锛�</param> + /// <param name="expiressAbsoulte">缁濆杩囨湡鏃堕暱</param> + /// <returns></returns> + public bool Set(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte) + { + if (key == null) + throw new ArgumentNullException(nameof(key)); + if (value == null) + throw new ArgumentNullException(nameof(value)); + + Cache.Set(key, value, + new MemoryCacheEntryOptions().SetSlidingExpiration(expiresSliding) + .SetAbsoluteExpiration(expiressAbsoulte)); + return Exists(key); + } + + /// <summary> + /// 娣诲姞缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <param name="value">缂撳瓨Value</param> + /// <param name="expiresIn">缂撳瓨鏃堕暱</param> + /// <param name="isSliding">鏄惁婊戝姩杩囨湡锛堝鏋滃湪杩囨湡鏃堕棿鍐呮湁鎿嶄綔锛屽垯浠ュ綋鍓嶆椂闂寸偣寤堕暱杩囨湡鏃堕棿锛�</param> + /// <returns></returns> + public bool Set(string key, object value, TimeSpan expiresIn, bool isSliding = false) + { + if (key == null) + throw new ArgumentNullException(nameof(key)); + if (value == null) + throw new ArgumentNullException(nameof(value)); + + Cache.Set(key, value, + isSliding + ? new MemoryCacheEntryOptions().SetSlidingExpiration(expiresIn) + : new MemoryCacheEntryOptions().SetAbsoluteExpiration(expiresIn)); + + return Exists(key); + } + + /// <summary> + /// 娣诲姞缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <param name="value">缂撳瓨Value</param> + /// <returns></returns> + public void Set(string key, object value) + { + Set(key, value, TimeSpan.FromDays(1)); + } + + /// <summary> + /// 娣诲姞缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <param name="value">缂撳瓨Value</param> + /// <param name="ts"></param> + /// <returns></returns> + public void Set(string key, object value, TimeSpan ts) + { + Set(key, value, ts, false); + } + + /// <summary> + /// 娣诲姞缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <param name="value">缂撳瓨Value</param> + /// <param name="ts"></param> + /// <returns></returns> + public void Set(string key, object value, int seconds) + { + var ts = TimeSpan.FromSeconds(seconds); + Set(key, value, ts, false); + } + + /// <summary> + /// 鍒犻櫎缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <returns></returns> + public void Remove(string key) + { + if (key == null) + throw new ArgumentNullException(nameof(key)); + Cache.Remove(key); + } + + /// <summary> + /// 鎵归噺鍒犻櫎缂撳瓨 + /// </summary> + /// <returns></returns> + public void RemoveAll(IEnumerable<string> keys) + { + if (keys == null) + throw new ArgumentNullException(nameof(keys)); + + keys.ToList().ForEach(item => Cache.Remove(item)); + } + + + #region 鑾峰彇缂撳瓨 + + /// <summary> + /// 鑾峰彇缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <returns></returns> + public T Get<T>(string key) + { + if (key == null) + throw new ArgumentNullException(nameof(key)); + + return Cache.Get<T>(key); + } + + /// <summary> + /// 鑾峰彇缂撳瓨 + /// </summary> + /// <param name="key">缂撳瓨Key</param> + /// <returns></returns> + public object Get(string key) + { + if (key == null) + throw new ArgumentNullException(nameof(key)); + + return Cache.Get(key); + } + + /// <summary> + /// 鑾峰彇缂撳瓨闆嗗悎 + /// </summary> + /// <param name="keys">缂撳瓨Key闆嗗悎</param> + /// <returns></returns> + public IDictionary<string, object> GetAll(IEnumerable<string> keys) + { + if (keys == null) + throw new ArgumentNullException(nameof(keys)); + + var dict = new Dictionary<string, object>(); + keys.ToList().ForEach(item => dict.Add(item, Cache.Get(item))); + return dict; + } + #endregion + + /// <summary> + /// 鍒犻櫎鎵�鏈夌紦瀛� + /// </summary> + public void RemoveCacheAll() + { + var l = GetCacheKeys(); + foreach (var s in l) + { + Remove(s); + } + } + + /// <summary> + /// 鍒犻櫎鍖归厤鍒扮殑缂撳瓨 + /// </summary> + /// <param name="pattern"></param> + /// <returns></returns> + public void RemoveCacheRegex(string pattern) + { + IList<string> l = SearchCacheRegex(pattern); + foreach (var s in l) + { + Remove(s); + } + } + + /// <summary> + /// 鎼滅储 鍖归厤鍒扮殑缂撳瓨 + /// </summary> + /// <param name="pattern"></param> + /// <returns></returns> + public IList<string> SearchCacheRegex(string pattern) + { + var cacheKeys = GetCacheKeys(); + var l = cacheKeys.Where(k => Regex.IsMatch(k, pattern)).ToList(); + return l.AsReadOnly(); + } + + /// <summary> + /// 鑾峰彇鎵�鏈夌紦瀛橀敭 + /// </summary> + /// <returns></returns> + public List<string> GetCacheKeys() + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; + var entries = Cache.GetType().GetField("_entries", flags).GetValue(Cache); + var cacheItems = entries as IDictionary; + var keys = new List<string>(); + if (cacheItems == null) return keys; + foreach (DictionaryEntry cacheItem in cacheItems) + { + keys.Add(cacheItem.Key.ToString()); + } + return keys; + } + } +} diff --git a/DocumentServiceAPI.Core/SqlSugarRedisCache.cs b/DocumentServiceAPI.Core/SqlSugarRedisCache.cs new file mode 100644 index 0000000..c0bb167 --- /dev/null +++ b/DocumentServiceAPI.Core/SqlSugarRedisCache.cs @@ -0,0 +1,61 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceAPI.Core +{ + public class SqlSugarRedisCache : ICacheService + { + + public SqlSugarRedisCache() + { + } + + public void Add<TV>(string key, TV value) + { + RedisHelper.Set(key, value); + } + + public void Add<TV>(string key, TV value, int cacheDurationInSeconds) + { + RedisHelper.Set(key, value, cacheDurationInSeconds); + } + + public bool ContainsKey<TV>(string key) + { + return RedisHelper.Exists(key); + } + + public TV Get<TV>(string key) + { + return RedisHelper.Get<TV>(key); + } + + public IEnumerable<string> GetAllKey<TV>() + { + return RedisHelper.Keys("SqlSugarDataCache.*"); + } + + public TV GetOrCreate<TV>(string cacheKey, Func<TV> create, int cacheDurationInSeconds = int.MaxValue) + { + if (this.ContainsKey<TV>(cacheKey)) + { + return this.Get<TV>(cacheKey); + } + else + { + var result = create(); + this.Add(cacheKey, result, cacheDurationInSeconds); + return result; + } + } + + public void Remove<TV>(string key) + { + RedisHelper.DelAsync(key); + } + } +} diff --git a/DocumentServiceAPI.Enum/BaseModel.cs b/DocumentServiceAPI.Enum/BaseModel.cs index bd114fc..c77a211 100644 --- a/DocumentServiceAPI.Enum/BaseModel.cs +++ b/DocumentServiceAPI.Enum/BaseModel.cs @@ -21,7 +21,7 @@ /// </summary> [Display(Name = "鍒涘缓浜� ")] [SugarColumn(ColumnDescription = "鍒涘缓浜� ")] - public DateTime? CreatBy { get; set; } + public string? CreatBy { get; set; } /// <summary> /// 淇敼鏃堕棿 /// </summary> @@ -33,7 +33,7 @@ /// </summary> [Display(Name = "淇敼浜� ")] [SugarColumn(ColumnDescription = "淇敼浜� ")] - public DateTime? UpdataBy { get; set; } + public string? UpdataBy { get; set; } /// <summary> diff --git a/DocumentServiceAPI.Model/JwtInfo.cs b/DocumentServiceAPI.Model/JwtInfo.cs index 39d2cd5..0820cd0 100644 --- a/DocumentServiceAPI.Model/JwtInfo.cs +++ b/DocumentServiceAPI.Model/JwtInfo.cs @@ -14,14 +14,14 @@ public class JwtInfo { /// <summary> - /// 鍛樺伐ITCODE + /// 鍛樺伐ID /// </summary> public int? EID { get; set; } /// <summary> /// 绉熸埛ID /// </summary> - public int ?TID { get; set; } + public int? TEID { get; set; } /// <summary> diff --git a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs new file mode 100644 index 0000000..bdb4a9c --- /dev/null +++ b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs @@ -0,0 +1,17 @@ +锘縰sing DocumentServiceAPI.Enum; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceAPI.Model.Permissions +{ + /// <summary> + /// 绉熸埛鏉冮檺 + /// </summary> + public class TenantPermissions + { + + } +} diff --git a/DocumentServiceAPI.Model/UserInfoModel/EmployeeInfo.cs b/DocumentServiceAPI.Model/UserInfoModel/EmployeeInfo.cs index 072ca13..a33ac8b 100644 --- a/DocumentServiceAPI.Model/UserInfoModel/EmployeeInfo.cs +++ b/DocumentServiceAPI.Model/UserInfoModel/EmployeeInfo.cs @@ -64,7 +64,7 @@ /// <summary> /// 鎻忚堪 /// </summary> - public string? Description { get; set; } + public string? Description { get; set; } } diff --git a/DocumentServiceAPI.Utility/UtilityFun.cs b/DocumentServiceAPI.Utility/UtilityFun.cs index 7ca5140..6a3d402 100644 --- a/DocumentServiceAPI.Utility/UtilityFun.cs +++ b/DocumentServiceAPI.Utility/UtilityFun.cs @@ -11,12 +11,12 @@ public class UtilityFun { + + private static List<Assembly>? _allAssemblies = null; /// <summary> /// 鑾峰彇鎵�鏈夌▼搴忕洰褰曚笅鍜屽父鐢ㄧ殑绋嬪簭闆� 鍖呮嫭涓�浜涚郴缁熷紩鐢ㄧ▼搴忛泦 /// </summary> /// <returns> 褰撳墠宸ョ▼涓嬬殑绋嬪簭闆�</returns> - private static List<Assembly>? _allAssemblies = null; - public static List<Assembly> GetAllAssembly() { diff --git a/DocumentServiceAPI.Web.Core/Startup.cs b/DocumentServiceAPI.Web.Core/Startup.cs index 984c08d..126af8e 100644 --- a/DocumentServiceAPI.Web.Core/Startup.cs +++ b/DocumentServiceAPI.Web.Core/Startup.cs @@ -5,7 +5,9 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using System.Text.Encodings.Web; using System.Text.Json.Serialization; +using System.Text.Unicode; namespace DocumentServiceAPI.Web.Core; @@ -19,7 +21,10 @@ services.AddCorsAccessor(); services.AddControllers().AddJsonOptions(options => - options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter())); ; + { + options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); + // options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(); + }); ; services.AddInjectWithUnifyResult<DSRESTFulResultProvider>(); } diff --git a/DocumentServiceAPI.Web.Entry/.config/dotnet-tools.json b/DocumentServiceAPI.Web.Entry/.config/dotnet-tools.json new file mode 100644 index 0000000..2be6730 --- /dev/null +++ b/DocumentServiceAPI.Web.Entry/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "7.0.9", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/DocumentServiceAPI.Web.Entry/DocumentServiceAPI.Web.Entry.csproj.user b/DocumentServiceAPI.Web.Entry/DocumentServiceAPI.Web.Entry.csproj.user index 8e1e47d..d5c942b 100644 --- a/DocumentServiceAPI.Web.Entry/DocumentServiceAPI.Web.Entry.csproj.user +++ b/DocumentServiceAPI.Web.Entry/DocumentServiceAPI.Web.Entry.csproj.user @@ -5,5 +5,6 @@ </PropertyGroup> <PropertyGroup> <ActiveDebugProfile>DocumentServiceAPI.Web.Entry</ActiveDebugProfile> + <NameOfLastUsedPublishProfile>E:\workdir\鏍囦功杞欢\ApiService\DocumentServiceAPI\DocumentServiceAPI.Web.Entry\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile> </PropertyGroup> </Project> \ No newline at end of file diff --git a/DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml b/DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..3bcc5df --- /dev/null +++ b/DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,17 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<!-- +https://go.microsoft.com/fwlink/?LinkID=208121. +--> +<Project> + <PropertyGroup> + <DeleteExistingFiles>false</DeleteExistingFiles> + <ExcludeApp_Data>false</ExcludeApp_Data> + <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish> + <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> + <LastUsedPlatform>Any CPU</LastUsedPlatform> + <PublishProvider>FileSystem</PublishProvider> + <PublishUrl>D:\DocServiceAPI</PublishUrl> + <WebPublishMethod>FileSystem</WebPublishMethod> + <_TargetId>Folder</_TargetId> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user b/DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..81242db --- /dev/null +++ b/DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,11 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<!-- +https://go.microsoft.com/fwlink/?LinkID=208121. +--> +<Project> + <PropertyGroup> + <_PublishTargetUrl>D:\DocServiceAPI</_PublishTargetUrl> + <History>True|2023-08-03T03:23:49.7155745Z;True|2023-08-03T10:57:12.3860490+08:00;True|2023-08-02T17:29:04.8984231+08:00;True|2023-08-02T14:24:54.6607875+08:00;True|2023-08-02T13:12:00.3228236+08:00;</History> + <LastFailureDetails /> + </PropertyGroup> +</Project> \ No newline at end of file -- Gitblit v1.9.1