diff --git a/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs index 675de59aaab2b5edb2aa502f5c78a0ec6e30b699..fcbdf459233127a48c73930a8ed0d5387ae12b4c 100644 --- a/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs +++ b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs @@ -63,12 +63,12 @@ namespace EOM.TSHotelManagement.Application where = where.And(a => a.RoomNumber.Equals(readEnergyManagementInputDto.RoomNo)); } - if (!readEnergyManagementInputDto.UseDate.IsNullOrEmpty()) + if (!readEnergyManagementInputDto.UseDate.HasValue) { where = where.And(a => a.StartDate >= readEnergyManagementInputDto.UseDate.Value); } - if (!readEnergyManagementInputDto.EndDate.IsNullOrEmpty()) + if (!readEnergyManagementInputDto.EndDate.HasValue) { where = where.And(a => a.EndDate >= readEnergyManagementInputDto.EndDate.Value); } diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs index e58c0f3088e8842f7a606f392cd3ef6c322fcbc2..69879b124bab8c5a2185b43c125d9dabb593a692 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs @@ -308,8 +308,13 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto DayByRoomNo(ReadRoomInputDto roomInputDto) { - var days = Math.Abs(((TimeSpan)(roomRepository.GetSingle(a => a.RoomNumber == roomInputDto.RoomNumber).LastCheckInTime - DateTime.Now)).Days); - return new SingleOutputDto { Source = new ReadRoomOutputDto { StayDays = days } }; + var room = roomRepository.GetSingle(a => a.RoomNumber == roomInputDto.RoomNumber); + if (room?.LastCheckInTime != null) + { + var days = Math.Abs((room.LastCheckInTime.Value.ToDateTime(TimeOnly.MinValue) - DateTime.Now).Days); + return new SingleOutputDto { Source = new ReadRoomOutputDto { StayDays = days } }; + } + return new SingleOutputDto { Source = new ReadRoomOutputDto { StayDays = 0 } }; } /// @@ -590,15 +595,15 @@ namespace EOM.TSHotelManagement.Application { var originalRoom = roomRepository.GetSingle(a => a.RoomNumber == transferRoomDto.OriginalRoomNumber); var targetRoom = roomRepository.GetSingle(a => a.RoomNumber == transferRoomDto.TargetRoomNumber); - var stayDays = Math.Abs(((TimeSpan)(originalRoom.LastCheckInTime - DateTime.Now)).Days); + var stayDays = originalRoom.LastCheckInTime.HasValue + ? Math.Abs((originalRoom.LastCheckInTime.Value.ToDateTime(TimeOnly.MinValue) - DateTime.Now).Days) + : 0; var originalRoomBill = originalRoom.RoomRent * stayDays; //更新原房间状态 roomRepository.Update(a => new Room { - CustomerNumber = null, - LastCheckInTime = null, - LastCheckOutTime = DateTime.Now, + LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now), RoomStateId = (int)RoomState.Dirty, DataChgDate = transferRoomDto.DataChgDate, DataChgUsr = transferRoomDto.DataChgUsr @@ -676,7 +681,7 @@ namespace EOM.TSHotelManagement.Application { CustomerNumber = null, LastCheckInTime = null, - LastCheckOutTime = DateTime.Now, + LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now), RoomStateId = (int)RoomState.Dirty, DataChgDate = checkoutRoomDto.DataChgDate, DataChgUsr = checkoutRoomDto.DataChgUsr @@ -686,8 +691,8 @@ namespace EOM.TSHotelManagement.Application var energy = new EnergyManagement { InformationId = uniqueCode.GetNewId("EM-"), - StartDate = (DateTime)room.LastCheckInTime, - EndDate = (DateTime)checkoutRoomDto.DataChgDate, + StartDate = (DateOnly)room.LastCheckInTime, + EndDate = DateOnly.FromDateTime((DateTime)checkoutRoomDto.DataChgDate), WaterUsage = checkoutRoomDto.WaterUsage, PowerUsage = checkoutRoomDto.ElectricityUsage, Recorder = checkoutRoomDto.DataChgUsr, diff --git a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs index b97e9544acff89cc018a9dd385340c719c3cc066..d00621ce5d950765585bbc85cf82f6cded0e3a88 100644 --- a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs +++ b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs @@ -218,18 +218,9 @@ namespace EOM.TSHotelManagement.Application workerRepository.Insert(EntityMapper.Map(createEmployeeInputDto)); - var Subject = LocalizationHelper.GetLocalizedString("New Registration Notification", "​新注册通知"); - var Body = $@"

{LocalizationHelper.GetLocalizedString("Dear User,", "尊敬的用户:")}

-

{LocalizationHelper.GetLocalizedString( - $"You have successfully registered to the system on {DateTime.Now:yyyy/MM/dd}. Your account credentials are as follows:​", - $"您已于{DateTime.Now:yyyy/MM/dd}新注册系统成功,账号密码如下:")} -

-

{newPassword}

-

{LocalizationHelper.GetLocalizedString( - "Please keep your password secure and change it after login.", - "请妥善保管密码,并在成功登录后修改为你能记住的密码!")}

"; - - mailHelper.SendMail(new List { createEmployeeInputDto.EmailAddress }, Subject, Body, new List { createEmployeeInputDto.EmailAddress }); + var emailTemplate = EmailTemplate.GetNewRegistrationTemplate(newPassword); + + mailHelper.SendMail(new List { createEmployeeInputDto.EmailAddress }, emailTemplate.Subject, emailTemplate.Body, new List { createEmployeeInputDto.EmailAddress }); } catch (Exception ex) @@ -327,7 +318,7 @@ namespace EOM.TSHotelManagement.Application var passport = passportTypes.SingleOrDefault(a => a.PassportId == source.IdCardType); source.IdCardTypeName = passport.IsNullOrEmpty() ? "" : passport.PassportName; //面貌 - source.PoliticalAffiliationName = GetDescriptionByName(source.PoliticalAffiliation); + source.PoliticalAffiliationName = new EnumHelper().GetDescriptionByName(source.PoliticalAffiliation); }); var listSource = EntityMapper.MapList(employees); @@ -390,7 +381,7 @@ namespace EOM.TSHotelManagement.Application var passport = passportTypeRepository.GetSingle(a => a.PassportId == w.IdCardType); w.IdCardTypeName = passport.IsNullOrEmpty() ? "" : passport.PassportName; //面貌 - w.PoliticalAffiliationName = GetDescriptionByName(w.PoliticalAffiliation); + w.PoliticalAffiliationName = new EnumHelper().GetDescriptionByName(w.PoliticalAffiliation); var source = EntityMapper.Map(w); @@ -419,11 +410,11 @@ namespace EOM.TSHotelManagement.Application Description = helper.GetEnumDescription(e) }) .ToList(); - w = workerRepository.GetSingle(a => a.EmployeeId == readEmployeeInputDto.EmployeeId); + w = workerRepository.GetSingle(a => a.EmployeeId == readEmployeeInputDto.EmployeeId || a.EmailAddress == readEmployeeInputDto.EmailAddress); if (w == null) { w = null; - return new SingleOutputDto { Source = null }; + return new SingleOutputDto { Source = null,Message = LocalizationHelper.GetLocalizedString("Employee does not exist or entered incorrectly", "员工不存在或输入有误") }; } var dbPwd = dataProtector.Unprotect(w.Password); @@ -480,6 +471,71 @@ namespace EOM.TSHotelManagement.Application return new BaseOutputDto(); } + /// + /// 修改员工账号密码 + /// + /// + /// + public BaseOutputDto UpdateEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto) + { + try + { + var employee = workerRepository.GetSingle(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); + + if (employee.IsNullOrEmpty()) + { + return new BaseOutputDto() + { + Message = LocalizationHelper.GetLocalizedString("This employee does not exists", "员工不存在"), + StatusCode = StatusCodeConstants.InternalServerError + }; + } + + var currentPassword = dataProtector.Unprotect(employee.Password); + + if (!updateEmployeeInputDto.OldPassword.Equals(currentPassword)) + { + return new BaseOutputDto() + { + Message = LocalizationHelper.GetLocalizedString("The old password is incorrect", "旧密码不正确"), + StatusCode = StatusCodeConstants.InternalServerError + }; + } + + if (updateEmployeeInputDto.Password.Equals(currentPassword)) + { + return new BaseOutputDto() + { + Message = LocalizationHelper.GetLocalizedString("The new password cannot be the same as the old password", "新密码不能与旧密码相同"), + StatusCode = StatusCodeConstants.InternalServerError + }; + } + + var newPwd = updateEmployeeInputDto.Password; + string encrypted = dataProtector.Protect(newPwd); + + if (!employee.EmailAddress.IsNullOrEmpty()) + { + var mailTemplate = EmailTemplate.GetUpdatePasswordTemplate(newPwd); + mailHelper.SendMail(new List { employee.EmailAddress }, mailTemplate.Subject, mailTemplate.Body, new List { employee.EmailAddress }); + } + + workerRepository.Update(a => new Employee() + { + Password = encrypted, + IsInitialize = 1, + DataChgUsr = updateEmployeeInputDto.DataChgUsr, + DataChgDate = updateEmployeeInputDto.DataChgDate + }, a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); + } + catch (Exception ex) + { + return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + } + + return new BaseOutputDto(); + } + /// /// 重置员工账号密码 /// @@ -504,22 +560,14 @@ namespace EOM.TSHotelManagement.Application }; } - var Subject = LocalizationHelper.GetLocalizedString("Reset Password Notice", "重置密码通知"); - var Body = $@"

{LocalizationHelper.GetLocalizedString("Dear User,", "尊敬的用户:")}

-

{LocalizationHelper.GetLocalizedString( - $"Your password was reset at {DateTime.Now:yyyy/MM/dd}. New password:", - $"系统已于{DateTime.Now:yyyy/MM/dd}为你重置密码成功,新密码如下:")} -

-

{newPwd}

-

{LocalizationHelper.GetLocalizedString( - "Please keep your password secure and change it after login.", - "请妥善保管密码,并在成功登录后修改为你能记住的密码!")}

"; - - mailHelper.SendMail(new List { employeeMailAddress }, Subject, Body, new List { employeeMailAddress }); + var mailTemplate = EmailTemplate.GetResetPasswordTemplate(newPwd); + + mailHelper.SendMail(new List { employeeMailAddress }, mailTemplate.Subject, mailTemplate.Body, new List { employeeMailAddress }); workerRepository.Update(a => new Employee() { Password = encrypted, - DataChgUsr = updateEmployeeInputDto.DataChgUsr + DataChgUsr = updateEmployeeInputDto.DataChgUsr, + DataChgDate = updateEmployeeInputDto.DataChgDate }, a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); } catch (Exception ex) @@ -529,25 +577,5 @@ namespace EOM.TSHotelManagement.Application return new BaseOutputDto(); } - - public static string GetDescriptionByName(string enumName) - { - Type enumType = typeof(PoliticalAffiliation); - - if (!Enum.IsDefined(enumType, enumName)) - { - return null; - } - - FieldInfo field = enumType.GetField(enumName); - DescriptionAttribute attribute = field? - .GetCustomAttributes(typeof(DescriptionAttribute), false) - .SingleOrDefault() as DescriptionAttribute; - - string description = attribute?.Description ?? enumName; - - return description; - } - } } diff --git a/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs b/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs index f819c2555678c6756154e55cc054c4ac70d54c4d..c2fef9cdae5a2166dc2dbfa8b44bba5c1cd6b6c0 100644 --- a/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs +++ b/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs @@ -93,6 +93,13 @@ namespace EOM.TSHotelManagement.Application /// BaseOutputDto UpdEmployeePwdByWorkNo(UpdateEmployeeInputDto updateEmployeeInputDto); + /// + /// 修改员工账号密码 + /// + /// + /// + BaseOutputDto UpdateEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto); + /// /// 重置员工账号密码 /// diff --git a/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementInputDto.cs index 1d5bf92fa32e5df1c01e8ee40ee9bb2244e7ddf1..65936ec9e32920168a8f3e9b84d35857918f2e44 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementInputDto.cs @@ -5,8 +5,8 @@ namespace EOM.TSHotelManagement.Common.Contract public int Id { get; set; } public string InformationId { get; set; } public string RoomNo { get; set; } - public DateTime? UseDate { get; set; } - public DateTime? EndDate { get; set; } + public DateOnly? UseDate { get; set; } + public DateOnly? EndDate { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomInputDto.cs index d5a5277f4619d19f631a6e5b39302ad10b6cca50..ee08f8eea511a08b5ed70cdd7bc591508c4388ba 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomInputDto.cs @@ -5,7 +5,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string RoomNumber { get; set; } public int RoomStateId { get; set; } public string RoomTypeName { get; set; } - public DateTime LastCheckInTime { get; set; } + public DateOnly LastCheckInTime { get; set; } public string CustomerNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/UpdateRoomInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/UpdateRoomInputDto.cs index add4dc25e072f35ab027e3b80465f7d05bf17cea..df0b206d64eea36092b3585a9db350052fa9b1db 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/UpdateRoomInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/UpdateRoomInputDto.cs @@ -5,8 +5,8 @@ namespace EOM.TSHotelManagement.Common.Contract public string RoomNumber { get; set; } public int RoomTypeId { get; set; } public string CustomerNumber { get; set; } - public DateTime? LastCheckInTime { get; set; } - public DateTime? LastCheckOutTime { get; set; } + public DateOnly? LastCheckInTime { get; set; } + public DateOnly? LastCheckOutTime { get; set; } public int RoomStateId { get; set; } public decimal RoomRent { get; set; } public decimal RoomDeposit { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeInputDto.cs index ea5a02fd4d6dcd24f39b143ecf14eb3d3e8e6d7d..b91870d7b071c18737d4592883ada57a04078ff0 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeInputDto.cs @@ -15,6 +15,7 @@ namespace EOM.TSHotelManagement.Common.Contract public DateOnly HireDate { get; set; } public string PoliticalAffiliation { get; set; } public string EducationLevel { get; set; } + public string EmailAddress { get; set; } public string Password { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs index 2a2ddd0dea85fbc959ea6f8c9a4f8f87b66d1472..adbb6d1037f0546b1bbe043cc3a94719a43e6bc2 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs @@ -26,6 +26,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string EducationLevel { get; set; } public string EducationLevelName { get; set; } public int IsEnable { get; set; } + public int IsInitialize { get; set; } public string Password { get; set; } public string EmailAddress { get; set; } public string PhotoUrl { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/UpdateEmployeeInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/UpdateEmployeeInputDto.cs index c8d9b905a231688fb80496c147dfeca68bc1169d..e70734d301c8b64a11dff624c2ee8fc593fb6b04 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/UpdateEmployeeInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/UpdateEmployeeInputDto.cs @@ -16,6 +16,7 @@ namespace EOM.TSHotelManagement.Common.Contract public DateTime HireDate { get; set; } public string PoliticalAffiliation { get; set; } public string EducationLevel { get; set; } + public string OldPassword { get; set; } public string Password { get; set; } public int IsEnable { get; set; } public string EmailAddress { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/CreateDepartmentInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/CreateDepartmentInputDto.cs index d7137b4dd6db268b889debf2e186054cfabfaf1d..398f0f3f00467d39598b33799e7a0346439d13e6 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/CreateDepartmentInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/CreateDepartmentInputDto.cs @@ -6,7 +6,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string DepartmentNumber { get; set; } public string DepartmentName { get; set; } public string DepartmentDescription { get; set; } - public DateTime DepartmentCreationDate { get; set; } + public DateOnly DepartmentCreationDate { get; set; } public string DepartmentLeader { get; set; } public string LeaderName { get; set; } public string ParentDepartmentNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentInputDto.cs index 165bc30ef9aab06533810a9c402371011b70028c..35598d63610b9df2c93e4bbba4d5fe0600bf91f5 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentInputDto.cs @@ -6,7 +6,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string DepartmentNumber { get; set; } public string DepartmentName { get; set; } public string DepartmentDescription { get; set; } - public DateTime DepartmentCreationDate { get; set; } + public DateOnly DepartmentCreationDate { get; set; } public string DepartmentLeader { get; set; } public string LeaderName { get; set; } public string ParentDepartmentNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs index a46119c2c02c19a86fa9674ea69f61bf759aee06..ac030be055dbf6b4f3158444800908fedf080790 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs @@ -6,7 +6,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string DepartmentNumber { get; set; } public string DepartmentName { get; set; } public string DepartmentDescription { get; set; } - public DateTime DepartmentCreationDate { get; set; } + public DateOnly DepartmentCreationDate { get; set; } public string DepartmentLeader { get; set; } public string LeaderName { get; set; } public string ParentDepartmentNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs index 599c29a841d29cf1d361868ce5fc09a910483bd4..1b951faac1b4d0f6fcdee741abd8395673d12663 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs @@ -6,7 +6,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string DepartmentNumber { get; set; } public string DepartmentName { get; set; } public string DepartmentDescription { get; set; } - public DateTime DepartmentCreationDate { get; set; } + public DateOnly DepartmentCreationDate { get; set; } public string DepartmentLeader { get; set; } public string LeaderName { get; set; } public string ParentDepartmentNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Core/Business/Asset/Asset.cs b/EOM.TSHotelManagement.Common.Core/Business/Asset/Asset.cs index 317618b6fbd18bd0ecd6bb7b5fb221a3fe2383ea..baa8b571427608ad2f8a2f11f2c25a2756ec4ea9 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/Asset/Asset.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/Asset/Asset.cs @@ -85,7 +85,7 @@ namespace EOM.TSHotelManagement.Common.Core ///
[SqlSugar.SugarColumn(ColumnName = "acquisition_date", IsNullable = false, ColumnDescription = "入库时间 (购置日期) (Acquisition Date)")] [NeedValid] - public DateTime AcquisitionDate { get; set; } + public DateOnly AcquisitionDate { get; set; } /// /// 资产来源 (Asset Source) diff --git a/EOM.TSHotelManagement.Common.Core/Business/EnergyManagement/EnergyManagement.cs b/EOM.TSHotelManagement.Common.Core/Business/EnergyManagement/EnergyManagement.cs index b82c2502eccbed86fed9ff1e50065f54097477f8..0b1c87a6eeb1d5053792ba7990e10c83d4e700f6 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/EnergyManagement/EnergyManagement.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/EnergyManagement/EnergyManagement.cs @@ -55,13 +55,13 @@ namespace EOM.TSHotelManagement.Common.Core /// 开始使用时间 (Start Date) /// [SqlSugar.SugarColumn(ColumnName = "use_date", IsNullable = false, ColumnDescription = "开始使用时间 (Start Date)")] - public DateTime StartDate { get; set; } + public DateOnly StartDate { get; set; } /// /// 结束使用时间 (End Date) /// [SqlSugar.SugarColumn(ColumnName = "end_date", IsNullable = false, ColumnDescription = "结束使用时间 (End Date)")] - public DateTime EndDate { get; set; } + public DateOnly EndDate { get; set; } /// /// 水费 (Water Usage) diff --git a/EOM.TSHotelManagement.Common.Core/Business/Reser/Reser.cs b/EOM.TSHotelManagement.Common.Core/Business/Reser/Reser.cs index e192d1d49fc84378da1864230da69f28276ee8c7..f2c7b02dfe3229551e25b05afbdb3c13a62d3114 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/Reser/Reser.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/Reser/Reser.cs @@ -104,7 +104,7 @@ namespace EOM.TSHotelManagement.Common.Core ColumnDescription = "入住日期(格式:yyyy-MM-dd) (Check-In Date)", IsNullable = false )] - public DateTime ReservationStartDate { get; set; } + public DateOnly ReservationStartDate { get; set; } /// /// 预约结束日期 (Reservation End Date) @@ -114,7 +114,7 @@ namespace EOM.TSHotelManagement.Common.Core ColumnDescription = "离店日期(格式:yyyy-MM-dd) (Check-Out Date)", IsNullable = false )] - public DateTime ReservationEndDate { get; set; } + public DateOnly ReservationEndDate { get; set; } /// /// 预约状态 (Reservation Status) diff --git a/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs b/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs index ea5783a803b663fc214cda24427869bbf85d656b..227c7b1bc4dfbbcb3ff201d385bf7ac6c31e24ff 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs @@ -89,7 +89,7 @@ namespace EOM.TSHotelManagement.Common.Core ColumnDescription = "最后一次入住时间 (Last Check-In Time)", IsNullable = true )] - public DateTime? LastCheckInTime { get; set; } + public DateOnly? LastCheckInTime { get; set; } /// /// 最后一次退房时间 (Last Check-Out Time) @@ -99,7 +99,7 @@ namespace EOM.TSHotelManagement.Common.Core ColumnDescription = "最后一次退房时间 (Last Check-Out Time)", IsNullable = true )] - public DateTime? LastCheckOutTime { get; set; } + public DateOnly? LastCheckOutTime { get; set; } /// /// 房间状态ID (Room State ID) diff --git a/EOM.TSHotelManagement.Common.Core/Employee/Employee.cs b/EOM.TSHotelManagement.Common.Core/Employee/Employee.cs index 53a5a2e644b9437d3fe3354fc90a72ae7461daed..44d88efe4ac0622a538bcd3acc02bfd04e5f17bb 100644 --- a/EOM.TSHotelManagement.Common.Core/Employee/Employee.cs +++ b/EOM.TSHotelManagement.Common.Core/Employee/Employee.cs @@ -177,6 +177,12 @@ namespace EOM.TSHotelManagement.Common.Core [SugarColumn(ColumnName = "enable_mk", IsNullable = false, ColumnDescription = "禁用标记")] public int IsEnable { get; set; } = 1; + /// + /// 初始化标记 + /// + [SugarColumn(ColumnName = "initialize_mk", IsNullable = false, ColumnDescription = "初始化标记")] + public int IsInitialize { get; set; } + /// /// 邮箱地址 /// diff --git a/EOM.TSHotelManagement.Common.Core/Employee/EmployeeRewardPunishment.cs b/EOM.TSHotelManagement.Common.Core/Employee/EmployeeRewardPunishment.cs index cb94fd448d3827999160b0d75fdefea188ce110f..9d957df30dcaa92d368e212fd06911ac31fb9b19 100644 --- a/EOM.TSHotelManagement.Common.Core/Employee/EmployeeRewardPunishment.cs +++ b/EOM.TSHotelManagement.Common.Core/Employee/EmployeeRewardPunishment.cs @@ -78,7 +78,7 @@ namespace EOM.TSHotelManagement.Common.Core /// 奖惩时间 (Reward/Punishment Time) /// [SugarColumn(ColumnName = "reward_punishment_time", IsNullable = false, ColumnDescription = "奖惩时间 (Reward/Punishment Time)")] - public DateTime RewardPunishmentTime { get; set; } + public DateOnly RewardPunishmentTime { get; set; } /// /// 类型名称 (Type Name) diff --git a/EOM.TSHotelManagement.Common.Core/SystemManagement/Department.cs b/EOM.TSHotelManagement.Common.Core/SystemManagement/Department.cs index 044321d9e6f91ec3f32d8bc16c346aedce7a1b5b..0c0e6351947da075fce072d9d98eb93c24c7aab8 100644 --- a/EOM.TSHotelManagement.Common.Core/SystemManagement/Department.cs +++ b/EOM.TSHotelManagement.Common.Core/SystemManagement/Department.cs @@ -61,7 +61,7 @@ namespace EOM.TSHotelManagement.Common.Core /// 创建时间(部门) (Department Creation Date) /// [SugarColumn(ColumnName = "dept_date", IsNullable = true, ColumnDescription = "创建时间(部门) (Department Creation Date)")] - public DateTime DepartmentCreationDate { get; set; } + public DateOnly DepartmentCreationDate { get; set; } /// /// 部门主管 (Department Leader) diff --git a/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj b/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj index d969c084f65b4ebf89e51a42de618975fc79f97f..02bfc85980ab2d8eb1050d4f8873922e975cbcc1 100644 --- a/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj +++ b/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj @@ -4,14 +4,14 @@ net8.0 - - - - + + + + diff --git a/EOM.TSHotelManagement.Common.Util/Templates/EmailTemplate.cs b/EOM.TSHotelManagement.Common.Util/Templates/EmailTemplate.cs new file mode 100644 index 0000000000000000000000000000000000000000..da0ee3ea9660795395eb838a01b2ca9579a19c1c --- /dev/null +++ b/EOM.TSHotelManagement.Common.Util/Templates/EmailTemplate.cs @@ -0,0 +1,63 @@ +using EOM.TSHotelManagement.Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EOM.TSHotelManagement.Common.Util +{ + public static class EmailTemplate + { + public static Template GetResetPasswordTemplate(string newPwd) + { + return new Template + { + Subject = LocalizationHelper.GetLocalizedString("Reset Password Notice", "重置密码通知"), + Body = $@"
{LocalizationHelper.GetLocalizedString("Dear User,", "尊敬的用户:")}
+

{LocalizationHelper.GetLocalizedString( + $"Your password was reset at {DateTime.Now:yyyy/MM/dd HH:mm}. New password:", + $"您的密码已在{DateTime.Now:yyyy/MM/dd HH:mm}重置。新密码如下:")} +

+

{newPwd}

+

{LocalizationHelper.GetLocalizedString( + "Please keep your password secure and change it after login.", + "请妥善保管密码,并在成功登录后修改为你能记住的密码!")}

" + }; + } + + public static Template GetNewRegistrationTemplate(string newPassword) + { + return new Template + { + Subject = LocalizationHelper.GetLocalizedString("New Registration Notification", "​新注册通知"), + Body = $@"

{LocalizationHelper.GetLocalizedString("Dear User,", "尊敬的用户:")}

+

{LocalizationHelper.GetLocalizedString( + $"You have successfully registered to the system on {DateTime.Now:yyyy/MM/dd}. Your account credentials are as follows:​", + $"您已于{DateTime.Now:yyyy/MM/dd}新注册系统成功,账号密码如下:")} +

+

{newPassword}

+

{LocalizationHelper.GetLocalizedString( + "Please keep your password secure and change it after login.", + "请妥善保管密码,并在成功登录后修改为你能记住的密码!")}

" + }; + } + + public static Template GetUpdatePasswordTemplate(string newPassword) + { + return new Template + { + Subject = LocalizationHelper.GetLocalizedString("Update Password Notification", "更新密码通知"), + Body = $@"

{LocalizationHelper.GetLocalizedString("Dear User,", "尊敬的用户:")}

+

{LocalizationHelper.GetLocalizedString( + $"Your password was updated at {DateTime.Now:yyyy/MM/dd}. New password:", + $"您的密码已在{DateTime.Now:yyyy/MM/dd}更新。新密码如下:")} +

+

{newPassword}

+

{LocalizationHelper.GetLocalizedString( + "Please keep your password secure and change it after login.", + "请妥善保管密码!")}

" + }; + } + } +} diff --git a/EOM.TSHotelManagement.Shared/JwtConfig.cs b/EOM.TSHotelManagement.Shared/Config/JwtConfig.cs similarity index 100% rename from EOM.TSHotelManagement.Shared/JwtConfig.cs rename to EOM.TSHotelManagement.Shared/Config/JwtConfig.cs diff --git a/EOM.TSHotelManagement.Shared/Interfaces/LskyConfig.cs b/EOM.TSHotelManagement.Shared/Config/LskyConfig.cs similarity index 100% rename from EOM.TSHotelManagement.Shared/Interfaces/LskyConfig.cs rename to EOM.TSHotelManagement.Shared/Config/LskyConfig.cs diff --git a/EOM.TSHotelManagement.Shared/MailConfig.cs b/EOM.TSHotelManagement.Shared/Config/MailConfig.cs similarity index 94% rename from EOM.TSHotelManagement.Shared/MailConfig.cs rename to EOM.TSHotelManagement.Shared/Config/MailConfig.cs index 290e38c05f8fc99fa8f20fdd14c984241ac27c35..aa60aee24b52b1539866802bf3367a822aa7c7dc 100644 --- a/EOM.TSHotelManagement.Shared/MailConfig.cs +++ b/EOM.TSHotelManagement.Shared/Config/MailConfig.cs @@ -1,4 +1,4 @@ -namespace EOM.TSHotelManagement.Shared +namespace EOM.TSHotelManagement { public class MailConfig { diff --git a/EOM.TSHotelManagement.Shared/Config/Template.cs b/EOM.TSHotelManagement.Shared/Config/Template.cs new file mode 100644 index 0000000000000000000000000000000000000000..e49907dc4158d93ce999e9922b10e151f4ace44e --- /dev/null +++ b/EOM.TSHotelManagement.Shared/Config/Template.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EOM.TSHotelManagement.Shared +{ + public class Template + { + public string Subject { get; set; } + public string Body { get; set; } + } +} diff --git a/EOM.TSHotelManagement.Shared/EnumHelper.cs b/EOM.TSHotelManagement.Shared/EnumHelper.cs index 453693cb9e7d4dd8998c7da154f2ffe372f697f4..b5828a45bd014b762ce2505049a1ce2ade542aec 100644 --- a/EOM.TSHotelManagement.Shared/EnumHelper.cs +++ b/EOM.TSHotelManagement.Shared/EnumHelper.cs @@ -29,5 +29,24 @@ namespace EOM.TSHotelManagement.Shared throw new ArgumentNullException(nameof(value)); return Convert.ToInt32(value); } + + public string GetDescriptionByName(string enumName) where TEnum : Enum + { + Type enumType = typeof(TEnum); + + if (!Enum.IsDefined(enumType, enumName)) + { + return null; + } + + FieldInfo field = enumType.GetField(enumName); + DescriptionAttribute attribute = field? + .GetCustomAttributes(typeof(DescriptionAttribute), false) + .SingleOrDefault() as DescriptionAttribute; + + string description = attribute?.Description ?? enumName; + + return description; + } } } diff --git a/EOM.TSHotelManagement.Shared/Interfaces/IJwtConfigFactory.cs b/EOM.TSHotelManagement.Shared/Interfaces/IJwtConfigFactory.cs index 7d6399b4d7acf68ce81815eee4adc99f7aa05ea9..04fa3eaa5cc976a2b2d5a81b53b71d18a778cd3d 100644 --- a/EOM.TSHotelManagement.Shared/Interfaces/IJwtConfigFactory.cs +++ b/EOM.TSHotelManagement.Shared/Interfaces/IJwtConfigFactory.cs @@ -1,4 +1,5 @@ -namespace EOM.TSHotelManagement.Shared + +namespace EOM.TSHotelManagement.Shared { public interface IJwtConfigFactory { diff --git a/EOM.TSHotelManagement.Shared/Interfaces/ILskyConfigFactory.cs b/EOM.TSHotelManagement.Shared/Interfaces/ILskyConfigFactory.cs index eeb55e8c68680cb6f80b8d4252a21f32d52a660e..6c8cccb4095907c9ba1feee8e5789df5afd9029b 100644 --- a/EOM.TSHotelManagement.Shared/Interfaces/ILskyConfigFactory.cs +++ b/EOM.TSHotelManagement.Shared/Interfaces/ILskyConfigFactory.cs @@ -1,4 +1,5 @@ -namespace EOM.TSHotelManagement.Shared + +namespace EOM.TSHotelManagement.Shared { public interface ILskyConfigFactory { diff --git a/EOM.TSHotelManagement.Shared/Interfaces/IMailConfigFactory.cs b/EOM.TSHotelManagement.Shared/Interfaces/IMailConfigFactory.cs index c78f76d9994c5139e9dddffed5bc9b222abf3abb..a84c00582af48d66864caea89de8720872d462e1 100644 --- a/EOM.TSHotelManagement.Shared/Interfaces/IMailConfigFactory.cs +++ b/EOM.TSHotelManagement.Shared/Interfaces/IMailConfigFactory.cs @@ -1,4 +1,5 @@ -namespace EOM.TSHotelManagement.Shared + +namespace EOM.TSHotelManagement.Shared { public interface IMailConfigFactory { diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs index 87fc04be51726077d24b80a9c4b1e6d14339a80a..06ccdda036511d30e83b34017fbe4d901b6a027e 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs @@ -117,6 +117,16 @@ namespace EOM.TSHotelManagement.WebApi.Controllers return workerService.UpdEmployeePwdByWorkNo(worker); } + /// + /// 修改员工账号密码 + /// + /// + /// + [HttpPost] + public BaseOutputDto UpdateEmployeeAccountPassword([FromBody]UpdateEmployeeInputDto updateEmployeeInputDto) + { + return workerService.UpdateEmployeeAccountPassword(updateEmployeeInputDto); + } /// /// 重置员工账号密码 ///