From c11cc1d4c09041dce1d0f8e62a6f98d1b9f56268 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 10 May 2025 23:16:07 +0800 Subject: [PATCH] add email template. add update password controller. adjustment project structure layer. change datetime to dateonly. --- .../EnergyManagementService.cs | 4 +- .../Business/Room/RoomService.cs | 23 ++-- .../Employee/EmployeeService.cs | 126 +++++++++++------- .../Employee/IEmployeeService.cs | 7 + .../Dto/ReadEnergyManagementInputDto.cs | 4 +- .../Room/Dto/Room/ReadRoomInputDto.cs | 2 +- .../Room/Dto/Room/UpdateRoomInputDto.cs | 4 +- .../Dto/Employee/ReadEmployeeInputDto.cs | 1 + .../Dto/Employee/ReadEmployeeOutputDto.cs | 1 + .../Dto/Employee/UpdateEmployeeInputDto.cs | 1 + .../Department/CreateDepartmentInputDto.cs | 2 +- .../Dto/Department/ReadDepartmentInputDto.cs | 2 +- .../Dto/Department/ReadDepartmentOutputDto.cs | 2 +- .../Department/UpdateDepartmentInputDto.cs | 2 +- .../Business/Asset/Asset.cs | 2 +- .../EnergyManagement/EnergyManagement.cs | 4 +- .../Business/Reser/Reser.cs | 4 +- .../Business/Room/Room.cs | 4 +- .../Employee/Employee.cs | 6 + .../Employee/EmployeeRewardPunishment.cs | 2 +- .../SystemManagement/Department.cs | 2 +- .../EOM.TSHotelManagement.Common.Util.csproj | 8 +- .../Templates/EmailTemplate.cs | 63 +++++++++ .../{ => Config}/JwtConfig.cs | 0 .../{Interfaces => Config}/LskyConfig.cs | 0 .../{ => Config}/MailConfig.cs | 2 +- .../Config/Template.cs | 14 ++ EOM.TSHotelManagement.Shared/EnumHelper.cs | 19 +++ .../Interfaces/IJwtConfigFactory.cs | 3 +- .../Interfaces/ILskyConfigFactory.cs | 3 +- .../Interfaces/IMailConfigFactory.cs | 3 +- .../Employee/EmployeeController.cs | 10 ++ 32 files changed, 244 insertions(+), 86 deletions(-) create mode 100644 EOM.TSHotelManagement.Common.Util/Templates/EmailTemplate.cs rename EOM.TSHotelManagement.Shared/{ => Config}/JwtConfig.cs (100%) rename EOM.TSHotelManagement.Shared/{Interfaces => Config}/LskyConfig.cs (100%) rename EOM.TSHotelManagement.Shared/{ => Config}/MailConfig.cs (94%) create mode 100644 EOM.TSHotelManagement.Shared/Config/Template.cs diff --git a/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs index 675de59..fcbdf45 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 e58c0f3..69879b1 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 b97e954..d00621c 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 f819c25..c2fef9c 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 1d5bf92..65936ec 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 d5a5277..ee08f8e 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 add4dc2..df0b206 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 ea5a02f..b91870d 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 2a2ddd0..adbb6d1 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 c8d9b90..e70734d 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 d7137b4..398f0f3 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 165bc30..35598d6 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 a46119c..ac030be 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 599c29a..1b951fa 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 317618b..baa8b57 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 b82c250..0b1c87a 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 e192d1d..f2c7b02 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 ea5783a..227c7b1 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 53a5a2e..44d88ef 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 cb94fd4..9d957df 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 044321d..0c0e635 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 d969c08..02bfc85 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 0000000..da0ee3e --- /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 290e38c..aa60aee 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 0000000..e49907d --- /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 453693c..b5828a4 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 7d6399b..04fa3ea 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 eeb55e8..6c8cccb 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 c78f76d..a84c005 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 87fc04b..06ccdda 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); + } /// /// 重置员工账号密码 /// -- Gitee