DocumentFile.Service/Properties/launchSettings.json
New file @@ -0,0 +1,12 @@ { "profiles": { "DocumentFile.Service": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:52095;http://localhost:52096" } } } 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> 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> 证件正面 </summary> </member> <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.CardPositiveVersionNo"> <summary> 证件正面版本号 </summary> </member> <member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.CardPositiveSize"> <summary> 证件正面大小 </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> DocumentServiceAPI.Application/Repository/EmployeeRepository.cs
New file @@ -0,0 +1,18 @@ using 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 { } } 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"); } } 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 DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/IUserService.cs
File was renamed from DocumentServiceAPI.Application/UserAndLogin/Services/Interfaces/ILoginVerifyService.cs @@ -6,7 +6,7 @@ namespace DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces { public interface ILoginVerifyService public interface IUserService { } } 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; } } DocumentServiceAPI.Application/UserAndLogin/Services/UserService.cs
@@ -1,8 +1,12 @@ using DocumentServiceAPI.Application.UserAndLogin.Services.Interfaces; using 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); } } DocumentServiceAPI.Application/UserAndLogin/UserInfoController.cs
@@ -1,4 +1,11 @@ using System; using 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); } } } 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; } DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
New file @@ -0,0 +1,176 @@ using 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> /// 证件正面 /// </summary> public string CardPositive { get; set; } /// <summary> /// 证件正面版本号 /// </summary> public string CardPositiveVersionNo { get; set; } /// <summary> /// 证件正面大小 /// </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; } } } DocumentServiceAPI.Application/UserAndLogin/dto/Mapper.cs
@@ -1,4 +1,6 @@ using System; using 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>(); } } } DocumentServiceAPI.Core/DbContext.cs
@@ -45,7 +45,7 @@ db.CurrentConnectionConfig.ConfigureExternalServices = new ConfigureExternalServices() { //判断是否开启redis设置二级缓存方式 // DataInfoCacheService = new SqlSugarRedisCache(), DataInfoCacheService = new SqlSugarRedisCache(), //模型定义为 int?号时自动为可空 EntityService = (c, p) => { 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" /> 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> DocumentServiceAPI.Core/SqlSugarMemoryCache.cs
New file @@ -0,0 +1,282 @@ using 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; } } } DocumentServiceAPI.Core/SqlSugarRedisCache.cs
New file @@ -0,0 +1,61 @@ using 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); } } } 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> 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> DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
New file @@ -0,0 +1,17 @@ using 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 { } } DocumentServiceAPI.Model/UserInfoModel/EmployeeInfo.cs
@@ -64,7 +64,7 @@ /// <summary> /// 描述 /// </summary> public string? Description { get; set; } public string? Description { get; set; } } 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() { 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>(); } DocumentServiceAPI.Web.Entry/.config/dotnet-tools.json
New file @@ -0,0 +1,12 @@ { "version": 1, "isRoot": true, "tools": { "dotnet-ef": { "version": "7.0.9", "commands": [ "dotnet-ef" ] } } } 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> DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml
New file @@ -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> DocumentServiceAPI.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user
New file @@ -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>